aa_splitcon(3)

πŸ’– NAME πŸ’–

okay so this is the aa_splitcon(3) page from AppArmor β€” yes, the manual page, bestie. aa_splitcon does exactly one iconic thing: it splits the confinement context into a label and mode. that's the whole gig. πŸ’…

✨ SYNOPSIS ✨

#include <sys/apparmor.h>

char *aa_splitcon(char *con, char **mode);

Link with -lapparmor when compiling. yes, literally that flag 🫢

πŸ¦‹ DESCRIPTION πŸ¦‹

aa_splitcon() splits a confinement context into separate label and mode strings. The @con string gets modified so that the label portion is NUL terminated. The enforcement mode is also NUL terminated, and the parenthesis surrounding the mode are removed. If @mode is non-NULL, then on success it will point to the first character in the enforcement mode string. slay. ✨

Also, highkey important kernel detail: the Linux kernel's /proc/<PID>/attr/current interface appends a trailing newline character to AppArmor contexts that are read from that file. If @con contains a single trailing newline character, aa_splitcon() strips it prior to all other processing. one newline, bestie, not a whole collection πŸ‘€

🌸 RETURN VALUE 🌸

Returns a pointer to the first character in the label string. NULL is returned on error. no cap. πŸ’–

πŸŽ€ EXAMPLE πŸŽ€

Here's the exact vibe check from the page:

        Context                        Label               Mode
        -----------------------------  ------------------  -------
        unconfined                     unconfined          NULL
        unconfined\n                   unconfined          NULL
        /bin/ping (enforce)            /bin/ping           enforce
        /bin/ping (enforce)\n          /bin/ping           enforce
        /usr/sbin/rsyslogd (complain)  /usr/sbin/rsyslogd  complain

πŸ’€ BUGS πŸ’€

None known. If you find any, please report them at https://gitlab.com/apparmor/apparmor/-/issues. fr fr, that's the place. πŸ™ˆ

🌈 SEE ALSO 🌈

Go peek at aa_getcon(2) and https://wiki.apparmor.net. iykyk πŸ¦‹


okay bye bestie β€” this page was brought to you by AppArmor 4.1.8, dated 2026-10-18. mwah πŸ’‹

πŸ“¦ where this page comes from
  • arch rolling: apparmor 4.1.8-2 Β· GPL-2.0-only AND LGPL-2.0-only AND LGPL-2.1-only
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms