aa_splitcon(3)

aa_splitcon3

Split the confinement context into a label and mode

Usage

#include <sys/apparmor.h>

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

Link with -lapparmor when compiling.

Overview

The aa_splitcon() function splits a confinement context into separate label and mode strings. The @con string is 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, it will point to the first character in the enforcement mode string on success.

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, it will be stripped by aa_splitcon() prior to all other processing.

Return value

Returns a pointer to the first character in the label string. NULL is returned on error.

Examples

 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

Releases

6 releases since Debian 9 (Stretch); the text changed 5 times.

  1. 9
  2. 10
  3. 11
  4. 12
  5. 13
  6. Arch

Bugs

None known. If you find any, please report them at <https://gitlab.com/apparmor/apparmor/-/issues>.

From apparmor 4.1.8-2 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.