Rules: Owner Conditional Rules
The le rules can be extended so that they can be conditional upon the the user being the owner of the le. by
prepending the keyword owner to the rule. Owner conditional rules accumulate just as regular le rules and are
considered a subset of regular le rules. If a regular le rule
overlaps with an owner conditional le rule, the resultant
permissions will be that of the regular le rule.
Rules: Dening Execute Permissions
For executables that may be called from the conned programs, the prole creating tools ask you for an appropriate
mode, which is also reected directly in the prole itself:
DescriptionFileOption
Stay in the same (parent's) prole.
ix
Inherit
Requires that a separate prole
exists for the executed program.
px
Prole
Use Px to make use of environment scrubbing.
Requires that a local prole exists
for the executed program. Use Cx
cx
Local prole
to make use of environment
scrubbing.
Executes the program without a
prole. Avoid running programs
ux
Unconstrained
in unconstrained or unconned
mode for security reasons. Use Ux
to make use of environment
scrubbing.
allow PROT_EXEC with mmap(2)
calls
m
Allow Executable Mapping
WARNING: Running in ux Mode
Avoid running programs in ux mode as much as
possible. A program running in ux mode is not only
totally unprotected by AppArmor, but child processes inherit certain environment variables from the
parent that might inuence the child's execution
behavior and create possible security risks.
For more information about the different le execute
modes, refer to the apparmor.d(5) man page. For more
information about setgid and setuid environment scrubbing,
refer to the ld.so(8) man page.
Rules: Paths and Globbing
AppArmor supports explicit handling of directories. Use a
trailing / for any directory path that needs to be explicitly
distinguished:
/some/random/example/* r
Allow read access to les in the /some/random/
example directory.
/some/random/example/ r
Allow read access to the directory only.
/some/**/ r
Give read access to any directories below /some.
/some/random/example/** r
Give read access to les and directories under /some/
random/example.
/some/random/example/**[^/] r
Give read access to les under /some/random/
example. Explicitly exclude directories ([^/]).
To spare users from specifying similar paths all over again,
AppArmor supports basic globbing:
DescriptionGlob
Substitutes for any number of characters, except /.
*
Substitutes for any number of characters, including /.
**
Substitutes for any single character, except /.
?
Substitutes for the single character a, b,
or c.
[ abc ]
Substitutes for the single character a, b,
or c.
[ a-c ]
Expand to one rule to match ab and
another to match cd.
{ ab,cd }
Substitutes for any character except a.[ ^a ]
Rules: Auditing rules
AppArmor provides the ability to audit given rules so that
when they are matched an audit message will appear in the
audit log. To enable audit messages for a given rule the
audit keyword is prepended to the rule:
audit /etc/foo/* rw,
Rules: Setting Capabilities
Normally AppArmor only restricts existing native Linux
controls and does not grant additional privileges. The only
exception from this strict rule is the set capability rule. For
security reasons, set capability rules will not be inherited,
so once a program leaves the prole, it looses the elevated
privilege. Setting a capability also implicitly adds a capability
rule allowing that capability. Since this rules allows to give
processes root privileges it should be used with extreme
caution and only in exceptional cases.
set capabilty cap_chown,
4