| 1 |
<!DOCTYPE html> |
| 2 |
<html><head> |
| 3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| 4 |
<title>test.apparmor</title> |
| 5 |
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (AppArmor Security Profile) - Theme (Breeze Dark)"/> |
| 6 |
</head><body style="background-color:#232629;color:#cfcfc2"><pre> |
| 7 |
<span style="color:#7a7c7d;"># </span><span style="color:#3f8058;">kate:</span><span style="color:#7a7c7d;"> </span><span style="color:#7f8c8d;">syntax</span><span style="color:#f44f4f;"> AppArmor Security Profile</span><span style="color:#7f8c8d;">;</span><span style="color:#7a7c7d;"> </span><span style="color:#7f8c8d;">replace-tabs</span><span style="color:#7a7c7d;"> </span><span style="color:#27ae60;">off</span><span style="color:#7f8c8d;">;</span> |
| 8 |
|
| 9 |
<span style="color:#7a7c7d;">#</span> |
| 10 |
<span style="color:#7a7c7d;"># Sample AppArmor Profile.</span> |
| 11 |
<span style="color:#7a7c7d;"># License: Public Domain</span> |
| 12 |
<span style="color:#7a7c7d;">#</span> |
| 13 |
<span style="color:#7a7c7d;"># </span><span style="color:#81ca2d;background-color:#4d1f24;font-weight:bold;">NOTE</span><span style="color:#7a7c7d;">: This profile is not fully functional, since</span> |
| 14 |
<span style="color:#7a7c7d;"># it is designed to test the syntax highlighting</span> |
| 15 |
<span style="color:#7a7c7d;"># for the KDE's KSyntaxHighlighting framework.</span> |
| 16 |
<span style="color:#7a7c7d;">#</span> |
| 17 |
|
| 18 |
<span style="color:#27ae60;">include </span><span style="color:#27ae60;"><tunables/global></span> |
| 19 |
|
| 20 |
<span style="color:#7a7c7d;"># Variable assignment</span> |
| 21 |
<span style="color:#f67400;">@{FOO_LIB}</span><span style="color:#3f8058;">=</span>/usr/lib<span style="color:#da4453;">{</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">32</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">64}</span>/foo |
| 22 |
<span style="color:#f67400;">@{USER_DIR}</span> |
| 23 |
<span style="color:#3f8058;">=</span> <span style="color:#f67400;">@{HOME}</span>/Public <span style="color:#f67400;">@{HOME}</span>/Desktop <span style="color:#da4453;text-decoration:underline;">#</span>No-Comment |
| 24 |
<span style="color:#f67400;">@{USER_DIR}</span><span style="color:#3f8058;"> +=</span> <span style="color:#f67400;">@{HOME}</span>/Hello <span style="color:#3daee9;">\</span> |
| 25 |
deny owner <span style="color:#da4453;text-decoration:underline;">#</span>No-comment aa#aa |
| 26 |
<span style="color:#f67400;">${BOOL}</span> <span style="color:#3f8058;">=</span> <span style="color:#2980b9;">true</span> |
| 27 |
|
| 28 |
<span style="color:#7a7c7d;"># Alias</span> |
| 29 |
<span style="color:#27aeae;font-weight:bold;">alias</span> /usr/ <span style="color:#da4453;font-weight:bold;">-></span> /mnt/usr/, |
| 30 |
|
| 31 |
<span style="color:#7a7c7d;"># ABI feature</span> |
| 32 |
<span style="color:#27aeae;font-weight:bold;">abi</span> <span style="color:#27ae60;"><abi/3.0></span>, |
| 33 |
<span style="color:#27aeae;font-weight:bold;">abi</span> <span style="color:#27ae60;"><"includes/abi/4.19"></span>, |
| 34 |
<span style="color:#27aeae;font-weight:bold;">abi</span> <span style="color:#27ae60;">"simple_tests/includes/abi/4.19"</span>, |
| 35 |
<span style="color:#27aeae;font-weight:bold;">abi</span> <span style="color:#27ae60;">simple_tests/includes/abi/4.19</span>, |
| 36 |
|
| 37 |
<span style="color:#7a7c7d;"># Profile for /usr/bin/foo</span> |
| 38 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> <span style="color:#8e44ad;">foo</span> /usr/bin/foo <span style="color:#27ae60;">flags</span><span style="color:#3f8058;">=</span>(<span style="color:#da4453;">attach_disconnected</span> <span style="color:#da4453;">enforce</span>) <span style="color:#27ae60;">xattrs</span><span style="color:#3f8058;">=</span>(<span style="color:#2980b9;">myvalue</span><span style="color:#3f8058;">=</span>foo <span style="color:#2980b9;">user.bar</span><span style="color:#3f8058;">=</span><span style="color:#3daee9;">*</span> <span style="color:#2980b9;">user.foo</span><span style="color:#3f8058;">=</span><span style="color:#f44f4f;">"bar"</span> ) <span style="color:#3f8058;">{</span> |
| 39 |
<span style="color:#27ae60;">#include </span><span style="color:#27ae60;"><abstractions/ubuntu-helpers></span> |
| 40 |
<span style="color:#27ae60;">#include</span><span style="color:#27ae60;"><abstractions/wayland></span> |
| 41 |
<span style="color:#27ae60;">#include</span><span style="color:#27ae60;">"/etc/apparmor.d/abstractions/ubuntu-konsole"</span> |
| 42 |
<span style="color:#27ae60;"> include </span><span style="color:#27ae60;">"/etc/apparmor.d/abstractions/openssl"</span> |
| 43 |
|
| 44 |
<span style="color:#27ae60;"> include if exists </span><span style="color:#27ae60;"><path with spaces></span> |
| 45 |
<span style="color:#27ae60;"> include </span><span style="color:#27ae60;"><include_tests/includes_okay_helper.include></span> <span style="color:#27ae60;">#include </span><span style="color:#27ae60;"><includes/base></span> |
| 46 |
/some/file<span style="font-weight:bold;"> mr</span>, <span style="color:#27ae60;">#include </span><span style="color:#27ae60;"><includes/base></span> /bin/true<span style="font-weight:bold;"> Px</span>, |
| 47 |
|
| 48 |
<span style="color:#7a7c7d;"># File rules</span> |
| 49 |
/<span style="color:#da4453;">{</span><span style="color:#7f8c8d;">,</span><span style="color:#3daee9;">**</span><span style="color:#da4453;">/}</span><span style="font-weight:bold;"> r</span>, |
| 50 |
<span style="color:#27aeae;font-weight:bold;">owner</span> /<span style="color:#da4453;">{home</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">media</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">mnt</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">srv</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">net}</span>/<span style="color:#3daee9;">**</span><span style="font-weight:bold;"> r</span>, |
| 51 |
<span style="color:#27aeae;font-weight:bold;">owner</span> <span style="color:#f67400;">@{USER_DIR}</span>/<span style="color:#3daee9;">**</span><span style="font-weight:bold;"> rw</span>, |
| 52 |
<span style="font-weight:bold;">audit</span> <span style="color:#da4453;font-weight:bold;">deny</span> <span style="color:#27aeae;font-weight:bold;">owner</span> /<span style="color:#3daee9;">**</span>/<span style="color:#3daee9;">*</span><span style="font-weight:bold;"> mx</span>, |
| 53 |
/<span style="color:#3daee9;">**</span>.<span style="color:#da4453;">[tT][xX][tT]</span><span style="font-weight:bold;"> r</span>, <span style="color:#7a7c7d;"># txt</span> |
| 54 |
|
| 55 |
<span style="color:#27aeae;font-weight:bold;">owner</span> <span style="color:#27aeae;font-weight:bold;">file</span> <span style="color:#f67400;">@{HOME}</span>/.local/share/foo/<span style="color:#da4453;">{</span><span style="color:#7f8c8d;">,</span><span style="color:#3daee9;">**</span><span style="color:#da4453;">}</span><span style="font-weight:bold;"> rwkl</span>, |
| 56 |
<span style="color:#27aeae;font-weight:bold;">owner</span> <span style="color:#f67400;">@{HOME}</span>/.config/<span style="color:#3daee9;">*</span>.<span style="color:#da4453;">[a-zA-Z0-9]</span><span style="color:#3daee9;">*</span> <span style="font-weight:bold;"> rwk</span>, |
| 57 |
|
| 58 |
<span style="color:#f44f4f;">"/usr/share/</span><span style="color:#3daee9;">**</span><span style="color:#f44f4f;">"</span><span style="font-weight:bold;"> r</span>, |
| 59 |
<span style="color:#f44f4f;">"/var/lib/flatpak/exports/share/</span><span style="color:#3daee9;">**</span><span style="color:#f44f4f;">"</span><span style="font-weight:bold;"> r</span>, |
| 60 |
<span style="color:#f44f4f;">"/var/lib/</span><span style="color:#da4453;">{spaces in</span> |
| 61 |
<span style="color:#da4453;"> string</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">hello}</span><span style="color:#f44f4f;">/a</span><span style="color:#da4453;">[</span><span style="color:#7f8c8d;">^</span><span style="color:#da4453;"> a]</span><span style="color:#f44f4f;">a/</span><span style="color:#3daee9;">**</span><span style="color:#f44f4f;">"</span><span style="font-weight:bold;"> r</span>, |
| 62 |
|
| 63 |
<span style="color:#da4453;font-weight:bold;">allow</span> <span style="color:#27aeae;font-weight:bold;">file</span> /etc/nsswitch.conf <span style="font-weight:bold;"> r</span>, |
| 64 |
<span style="color:#da4453;font-weight:bold;">allow</span> /etc/fstab <span style="font-weight:bold;"> r</span>, |
| 65 |
<span style="color:#da4453;font-weight:bold;">deny</span> /etc/xdg/<span style="color:#da4453;">{autostart</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">systemd}</span>/<span style="color:#3daee9;">**</span> <span style="font-weight:bold;"> r</span>, |
| 66 |
<span style="color:#da4453;font-weight:bold;">deny</span> /boot/<span style="color:#3daee9;">**</span> <span style="font-weight:bold;"> rwlkmx</span>, |
| 67 |
|
| 68 |
<span style="color:#27aeae;font-weight:bold;">owner</span> <span style="color:#f67400;">@{PROC}</span>/<span style="color:#f67400;">@{pid}</span>/<span style="color:#da4453;">{cmdline</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">mountinfo</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">mounts</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">stat</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">status</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">vmstat}</span><span style="font-weight:bold;"> r</span>, |
| 69 |
/sys/devices/<span style="color:#3daee9;">**</span>/uevent<span style="font-weight:bold;"> r</span>, |
| 70 |
<span style="color:#f67400;">@{FOO_LIB}</span>/<span style="color:#da4453;">{</span><span style="color:#f67400;">@{multiarch}</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">64}</span>/<span style="color:#3daee9;">**</span><span style="font-weight:bold;"> mr</span>, |
| 71 |
|
| 72 |
/usr/bin/foo <span style="font-weight:bold;"> ixr</span>, |
| 73 |
/usr/bin/dolphin <span style="font-weight:bold;"> pUx</span>, |
| 74 |
/usr/bin/<span style="color:#3daee9;">*</span> <span style="font-weight:bold;"> Pixr</span>, |
| 75 |
/usr/bin/khelpcenter<span style="font-weight:bold;"> Cx</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">sanitized_helper</span>, |
| 76 |
/usr/bin/helloworld <span style="font-weight:bold;"> cxr</span> <span style="color:#da4453;font-weight:bold;">-></span> |
| 77 |
<span style="color:#8e44ad;font-style:italic;">hello_world</span>, |
| 78 |
/bin/<span style="color:#3daee9;">**</span><span style="font-weight:bold;"> px</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">profile</span>, |
| 79 |
|
| 80 |
<span style="color:#7a7c7d;"># Dbus rules</span> |
| 81 |
<span style="color:#27aeae;font-weight:bold;">dbus</span> (<span style="font-weight:bold;">send</span>) <span style="color:#da4453;text-decoration:underline;">#</span>No-Comment |
| 82 |
<span style="color:#27ae60;">bus</span><span style="color:#3f8058;">=</span><span style="font-style:italic;">system</span> |
| 83 |
<span style="color:#27ae60;">path</span><span style="color:#3f8058;">=</span>/org/freedesktop/NetworkManager |
| 84 |
<span style="color:#27ae60;">interface</span><span style="color:#3f8058;">=</span>org.freedesktop.DBus.Introspectable |
| 85 |
<span style="color:#27ae60;">peer</span><span style="color:#3f8058;">=</span>(<span style="color:#2980b9;">name</span><span style="color:#3f8058;">=</span>org.freedesktop.NetworkManager <span style="color:#2980b9;">label</span><span style="color:#3f8058;">=</span><span style="font-style:italic;">unconfined</span>), |
| 86 |
<span style="color:#27aeae;font-weight:bold;">dbus</span> (<span style="font-weight:bold;">send</span> <span style="font-weight:bold;">receive</span>) |
| 87 |
<span style="color:#27ae60;">bus</span><span style="color:#3f8058;">=</span><span style="font-style:italic;">system</span> |
| 88 |
<span style="color:#27ae60;">path</span><span style="color:#3f8058;">=</span>/org/freedesktop/NetworkManager |
| 89 |
<span style="color:#27ae60;">interface</span><span style="color:#3f8058;">=</span>org.freedesktop.NetworkManager |
| 90 |
<span style="color:#27ae60;">member</span><span style="color:#3f8058;">=</span><span style="color:#da4453;">{Introspect</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">state}</span> |
| 91 |
<span style="color:#27ae60;">peer</span><span style="color:#3f8058;">=</span>(<span style="color:#2980b9;">name</span><span style="color:#3f8058;">=</span><span style="color:#da4453;">(org.freedesktop.NetworkManager</span><span style="color:#7f8c8d;">|</span><span style="color:#da4453;">org.freedesktop.DBus)</span>), |
| 92 |
<span style="color:#27aeae;font-weight:bold;">dbus</span> (<span style="font-weight:bold;">send</span>) |
| 93 |
<span style="color:#27ae60;">bus</span><span style="color:#3f8058;">=</span><span style="font-style:italic;">session</span> |
| 94 |
<span style="color:#27ae60;">path</span><span style="color:#3f8058;">=</span>/org/gnome/GConf/Database/<span style="color:#3daee9;">*</span> |
| 95 |
<span style="color:#27ae60;">member</span><span style="color:#3f8058;">=</span><span style="color:#da4453;">{AddMatch</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">AddNotify</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">AllEntries</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">LookupExtended</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">RemoveNotify}</span>, |
| 96 |
<span style="color:#27aeae;font-weight:bold;">dbus</span> (<span style="font-weight:bold;">bind</span>) |
| 97 |
<span style="color:#27ae60;">bus</span><span style="color:#3f8058;">=</span><span style="font-style:italic;">system</span> |
| 98 |
<span style="color:#27ae60;">name</span><span style="color:#3f8058;">=</span>org.bluez, |
| 99 |
|
| 100 |
<span style="color:#7a7c7d;"># Signal rules</span> |
| 101 |
<span style="color:#27aeae;font-weight:bold;">signal</span> (<span style="font-weight:bold;">send</span>) <span style="color:#27ae60;">set</span><span style="color:#3f8058;">=</span>(<span style="color:#da4453;">term</span>) <span style="color:#27ae60;">peer</span><span style="color:#3f8058;">=</span><span style="color:#f44f4f;">"/usr/lib/hello/world</span><span style="color:#3f8058;font-weight:bold;">//</span><span style="color:#3f8058;"> foo helper</span><span style="color:#f44f4f;">"</span>, |
| 102 |
<span style="color:#27aeae;font-weight:bold;">signal</span> (<span style="font-weight:bold;">send</span>, <span style="font-weight:bold;">receive</span>) <span style="color:#27ae60;">set</span><span style="color:#3f8058;">=</span>(<span style="color:#da4453;">int</span> <span style="color:#da4453;">exists</span> <span style="color:#da4453;">rtmin+8</span>) <span style="color:#27ae60;">peer</span><span style="color:#3f8058;">=</span>/usr/lib/hello/world<span style="color:#3f8058;font-weight:bold;">//</span><span style="color:#3f8058;">foo-helper</span>, |
| 103 |
|
| 104 |
<span style="color:#7a7c7d;"># Child profile</span> |
| 105 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> <span style="color:#8e44ad;">hello_world</span> <span style="color:#3f8058;">{</span> |
| 106 |
<span style="color:#7a7c7d;"># File rules (three different ways)</span> |
| 107 |
<span style="color:#27aeae;font-weight:bold;">file</span> /usr/lib<span style="color:#da4453;">{</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">32</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">64}</span>/helloworld/<span style="color:#3daee9;">**</span>.so<span style="font-weight:bold;"> mr</span>, |
| 108 |
/usr/lib<span style="color:#da4453;">{</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">32</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">64}</span>/helloworld/<span style="color:#3daee9;">**</span><span style="font-weight:bold;"> r</span>, |
| 109 |
<span style="font-weight:bold;"> rk</span> /usr/lib<span style="color:#da4453;">{</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">32</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">64}</span>/helloworld/hello,file, |
| 110 |
|
| 111 |
<span style="color:#7a7c7d;"># Link rules (two ways)</span> |
| 112 |
<span style="font-weight:bold;"> l</span> /foo1 <span style="color:#da4453;font-weight:bold;">-></span> /bar, |
| 113 |
<span style="color:#27aeae;font-weight:bold;">link</span> /foo2 <span style="color:#da4453;font-weight:bold;">-></span> bar, |
| 114 |
<span style="color:#27aeae;font-weight:bold;">link</span> <span style="color:#27aeae;">subset</span> /link<span style="color:#3daee9;">*</span> <span style="color:#da4453;font-weight:bold;">-></span> /<span style="color:#3daee9;">**</span>, |
| 115 |
|
| 116 |
<span style="color:#7a7c7d;"># Network rules</span> |
| 117 |
<span style="color:#27aeae;font-weight:bold;">network</span> <span style="color:#27aeae;">inet6</span> <span style="color:#27aeae;">tcp</span>, |
| 118 |
<span style="color:#27aeae;font-weight:bold;">network</span> <span style="color:#27aeae;">netlink</span> <span style="color:#27aeae;">dgram</span>, |
| 119 |
<span style="color:#27aeae;font-weight:bold;">network</span> <span style="color:#27aeae;">bluetooth</span>, |
| 120 |
<span style="color:#27aeae;font-weight:bold;">network</span> <span style="font-style:italic;">unspec</span> <span style="color:#27aeae;">dgram</span>, |
| 121 |
|
| 122 |
<span style="color:#7a7c7d;"># Capability rules</span> |
| 123 |
<span style="color:#27aeae;font-weight:bold;">capability</span> <span style="color:#27aeae;">dac_override</span>, |
| 124 |
<span style="color:#27aeae;font-weight:bold;">capability</span> <span style="color:#27aeae;">sys_admin</span>, |
| 125 |
<span style="color:#27aeae;font-weight:bold;">capability</span> <span style="color:#27aeae;">sys_chroot</span>, |
| 126 |
|
| 127 |
<span style="color:#7a7c7d;"># Mount rules</span> |
| 128 |
<span style="color:#27aeae;font-weight:bold;">mount</span> <span style="color:#27ae60;">options</span><span style="color:#3f8058;">=</span>(<span style="font-weight:bold;">rw</span> <span style="font-weight:bold;">bind</span> <span style="font-weight:bold;">remount</span> <span style="font-weight:bold;">nodev</span> <span style="font-weight:bold;">noexec</span>) <span style="color:#27ae60;">vfstype</span><span style="color:#3f8058;">=</span><span style="color:#da4453;">ecryptfs</span> /home/<span style="color:#3daee9;">*</span>/.helloworld/ <span style="color:#da4453;font-weight:bold;">-></span> /home/<span style="color:#3daee9;">*</span>/helloworld/, |
| 129 |
<span style="color:#27aeae;font-weight:bold;">mount</span> <span style="color:#27ae60;">options</span> <span style="color:#da4453;font-weight:bold;">in</span> (<span style="font-weight:bold;">rw</span>, <span style="font-weight:bold;">bind</span>) / <span style="color:#da4453;font-weight:bold;">-></span> /run/hellowordd/<span style="color:#3daee9;">*</span>.mnt, |
| 130 |
<span style="color:#27aeae;font-weight:bold;">mount</span> <span style="color:#27ae60;">options</span><span style="color:#3f8058;">=</span><span style="font-weight:bold;">read-only</span> <span style="color:#27ae60;">fstype</span><span style="color:#3f8058;">=</span><span style="color:#da4453;">btrfs</span> /dev/sd<span style="color:#da4453;">[a-z][1-9]</span><span style="color:#3daee9;">*</span> <span style="color:#da4453;font-weight:bold;">-></span> /media/<span style="color:#3daee9;">*</span>/<span style="color:#3daee9;">*</span>, |
| 131 |
<span style="color:#27aeae;font-weight:bold;">umount</span> /home/<span style="color:#3daee9;">*</span>/helloworld/, |
| 132 |
|
| 133 |
<span style="color:#7a7c7d;"># Pivot Root rules</span> |
| 134 |
<span style="color:#27aeae;font-weight:bold;">pivot_root</span> <span style="color:#27ae60;">oldroot</span><span style="color:#3f8058;">=</span>/mnt/root/old/ /mnt/root/, |
| 135 |
<span style="color:#27aeae;font-weight:bold;">pivot_root</span> /mnt/root/, |
| 136 |
|
| 137 |
<span style="color:#7a7c7d;"># Ptrace rules</span> |
| 138 |
<span style="color:#27aeae;font-weight:bold;">ptrace</span> (<span style="font-weight:bold;">trace</span>) <span style="color:#27ae60;">peer</span><span style="color:#3f8058;">=</span><span style="font-style:italic;">unconfined</span>, |
| 139 |
<span style="color:#27aeae;font-weight:bold;">ptrace</span> (<span style="font-weight:bold;">read</span>, <span style="font-weight:bold;">trace</span>, <span style="font-weight:bold;">tracedby</span>) <span style="color:#27ae60;">peer</span><span style="color:#3f8058;">=</span>/usr/lib/hello/helloword, |
| 140 |
|
| 141 |
<span style="color:#7a7c7d;"># Unix rules</span> |
| 142 |
<span style="color:#27aeae;font-weight:bold;">unix</span> (<span style="font-weight:bold;">connect</span> <span style="font-weight:bold;">receive</span> <span style="font-weight:bold;">send</span>) <span style="color:#27ae60;">type</span><span style="color:#3f8058;">=</span>(<span style="color:#27aeae;">stream</span>) <span style="color:#27ae60;">peer</span><span style="color:#3f8058;">=</span>(<span style="color:#2980b9;">addr</span><span style="color:#3f8058;">=</span>@/tmp/ibus/dbus-<span style="color:#3daee9;">*</span>,<span style="color:#2980b9;">label</span><span style="color:#3f8058;">=</span><span style="font-style:italic;">unconfined</span>), |
| 143 |
<span style="color:#27aeae;font-weight:bold;">unix</span> (<span style="font-weight:bold;">send</span>,<span style="font-weight:bold;">receive</span>) <span style="color:#27ae60;">type</span><span style="color:#3f8058;">=</span>(<span style="color:#27aeae;">stream</span>) <span style="color:#27ae60;">protocol</span><span style="color:#3f8058;">=</span>0 <span style="color:#27ae60;">peer</span><span style="color:#3f8058;">=</span>(<span style="color:#2980b9;">addr</span><span style="color:#3f8058;">=</span><span style="font-style:italic;">none</span>), |
| 144 |
<span style="color:#27aeae;font-weight:bold;">unix</span> <span style="color:#27ae60;">peer</span><span style="color:#3f8058;">=</span>(<span style="color:#2980b9;">label</span><span style="color:#3f8058;">=</span><span style="color:#f67400;">@{profile_name}</span>,<span style="color:#2980b9;">addr</span><span style="color:#3f8058;">=</span>@helloworld), |
| 145 |
|
| 146 |
<span style="color:#7a7c7d;"># Rlimit rule</span> |
| 147 |
<span style="color:#27aeae;font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">rlimit</span> <span style="color:#27aeae;">data</span> <span style="color:#da4453;font-weight:bold;"><=</span> <span style="color:#f67400;">100</span><span style="color:#f67400;font-weight:bold;">M</span>, |
| 148 |
<span style="color:#27aeae;font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">rlimit</span> <span style="color:#27aeae;">nproc</span> <span style="color:#da4453;font-weight:bold;"><=</span> <span style="color:#f67400;">10</span>, |
| 149 |
<span style="color:#27aeae;font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">rlimit</span> <span style="color:#27aeae;">memlock</span> <span style="color:#da4453;font-weight:bold;"><=</span> <span style="color:#f67400;">2</span><span style="color:#f67400;font-weight:bold;">GB</span>, |
| 150 |
<span style="color:#27aeae;font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">rlimit</span> <span style="color:#27aeae;">rss</span> <span style="color:#da4453;font-weight:bold;"><=</span> <span style="color:#f67400;">infinity</span>, |
| 151 |
<span style="color:#27aeae;font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">rlimit</span> <span style="color:#27aeae;">nice</span> <span style="color:#da4453;font-weight:bold;"><=</span> <span style="color:#f67400;">-12</span>, |
| 152 |
|
| 153 |
<span style="color:#7a7c7d;"># Change Profile rules</span> |
| 154 |
<span style="color:#27aeae;font-weight:bold;">change_profile</span> <span style="color:#27aeae;">unsafe</span> /<span style="color:#3daee9;">**</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">[^u/]</span><span style="color:#3daee9;font-style:italic;">**</span>, |
| 155 |
<span style="color:#27aeae;font-weight:bold;">change_profile</span> <span style="color:#27aeae;">unsafe</span> /<span style="color:#3daee9;">**</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">{u,un,unc,unco,uncon,unconf,unconfi,unconfin,unconfine}</span>, |
| 156 |
<span style="color:#27aeae;font-weight:bold;">change_profile</span> /bin/bash <span style="color:#da4453;font-weight:bold;">-></span> |
| 157 |
<span style="color:#8e44ad;font-style:italic;">new_profile</span><span style="color:#3f8058;font-weight:bold;font-style:italic;">//</span><span style="color:#8e44ad;font-style:italic;">hat</span>, |
| 158 |
<span style="color:#3f8058;">}</span> |
| 159 |
|
| 160 |
<span style="color:#7a7c7d;"># Hat</span> |
| 161 |
<span style="color:#8e44ad;font-weight:bold;"> ^</span><span style="color:#8e44ad;">foo-helper</span><span style="color:#3daee9;">\/</span> <span style="color:#3f8058;">{</span> |
| 162 |
<span style="color:#27aeae;font-weight:bold;">network</span> <span style="color:#27aeae;">unix</span> <span style="color:#27aeae;">stream</span>, |
| 163 |
<span style="color:#27aeae;font-weight:bold;">unix</span> <span style="color:#27aeae;">stream</span>, |
| 164 |
|
| 165 |
/usr/hi<span style="color:#3daee9;">\"</span>esc<span style="color:#3daee9;">\x23</span>esc<span style="color:#3daee9;">\032</span>es<span style="color:#3daee9;">\47</span>7esc<span style="color:#3daee9;">\*</span>es<span style="color:#3daee9;">\{</span>esc<span style="color:#3daee9;">\ </span>rw<span style="font-weight:bold;"> r</span>, <span style="color:#7a7c7d;"># Escape expressions</span> |
| 166 |
|
| 167 |
<span style="color:#7a7c7d;"># Text after a variable is highlighted as path</span> |
| 168 |
<span style="color:#27aeae;font-weight:bold;">file</span> /my/path<span style="font-weight:bold;"> r</span>, |
| 169 |
<span style="color:#f67400;">@{FOO_LIB}</span>file<span style="font-weight:bold;"> r</span>, |
| 170 |
<span style="color:#f67400;">@{FOO_LIB}</span>#my/path<span style="font-weight:bold;"> r</span>, <span style="color:#7a7c7d;">#Comment</span> |
| 171 |
<span style="color:#f67400;">@{FOO_LIB}</span>ñ<span style="color:#3daee9;">*</span><span style="font-weight:bold;"> r</span>, |
| 172 |
<span style="color:#27aeae;font-weight:bold;">unix</span> (/path<span style="color:#3daee9;">\t</span><span style="color:#da4453;">{aa}</span><span style="color:#3daee9;">*</span>,*a <span style="color:#f67400;">@{var}</span><span style="color:#3daee9;">*</span>path,* <span style="color:#f67400;">@{var}</span>,*), |
| 173 |
<span style="color:#3f8058;">}</span> |
| 174 |
<span style="color:#3f8058;">}</span> |
| 175 |
|
| 176 |
<span style="color:#7a7c7d;"># Syntax Error</span> |
| 177 |
/usr/bin/error (<span style="color:#da4453;">complain</span>, <span style="color:#da4453;">audit</span>) <span style="color:#3f8058;">{</span> |
| 178 |
<span style="color:#27aeae;font-weight:bold;">file</span> <span style="color:#da4453;text-decoration:underline;">#include</span> /hello<span style="font-weight:bold;"> r</span>, |
| 179 |
|
| 180 |
<span style="color:#7a7c7d;"># Error: Variable open or with characters not allowed</span> |
| 181 |
<span style="color:#da4453;text-decoration:underline;">@</span><span style="color:#3f8058;">{</span>var |
| 182 |
<span style="color:#da4453;text-decoration:underline;">@</span><span style="color:#3f8058;">{</span>sdf&s<span style="color:#3f8058;">}</span> |
| 183 |
|
| 184 |
<span style="color:#7a7c7d;"># Error: Open brackets</span> |
| 185 |
/<span style="color:#da4453;">{hello{ab</span><span style="color:#7f8c8d;">,</span><span style="color:#da4453;">cd}worl</span><span style="color:#da4453;text-decoration:underline;">d</span> <span style="font-weight:bold;"> kr</span>, |
| 186 |
/<span style="color:#da4453;">{abc{ab</span><span style="color:#da4453;text-decoration:underline;">c</span><span style="font-weight:bold;"> kr</span>, |
| 187 |
/<span style="color:#da4453;">[ab</span><span style="color:#da4453;text-decoration:underline;">c</span> <span style="font-weight:bold;"> kr</span>, |
| 188 |
/<span style="color:#da4453;">(ab</span><span style="color:#da4453;text-decoration:underline;">c</span><span style="font-weight:bold;"> kr</span>, |
| 189 |
|
| 190 |
<span style="color:#7a7c7d;"># Error: Empty brackets</span> |
| 191 |
/hello<span style="color:#da4453;text-decoration:underline;">[]</span>hello<span style="color:#da4453;text-decoration:underline;">{}</span>hello<span style="color:#da4453;text-decoration:underline;">()</span>he <span style="font-weight:bold;"> kr</span>, |
| 192 |
|
| 193 |
<span style="color:#7a7c7d;"># Comments not allowed</span> |
| 194 |
<span style="color:#27aeae;font-weight:bold;">dbus</span> (<span style="font-weight:bold;">send</span>) <span style="color:#da4453;text-decoration:underline;">#</span>No comment |
| 195 |
<span style="color:#27ae60;">path</span><span style="color:#3f8058;">=</span>/org/hello |
| 196 |
<span style="color:#da4453;text-decoration:underline;">#</span><span style="color:#7a7c7d;">No comment</span> |
| 197 |
<span style="color:#27ae60;">interface</span><span style="color:#3f8058;">=</span>org.hello <span style="color:#da4453;text-decoration:underline;">#</span>No comment |
| 198 |
<span style="color:#27ae60;">peer</span><span style="color:#3f8058;">=</span>(<span style="color:#2980b9;">name</span><span style="color:#3f8058;">=</span>org.hello <span style="color:#da4453;text-decoration:underline;">#</span>No comment |
| 199 |
<span style="color:#2980b9;">label</span><span style="color:#3f8058;">=</span><span style="font-style:italic;">unconfined</span>), <span style="color:#7a7c7d;">#Comment</span> |
| 200 |
|
| 201 |
<span style="color:#7a7c7d;"># Don't allow assignment of variables within profiles</span> |
| 202 |
<span style="color:#f67400;">@{VARIABLE}</span> <span style="color:#da4453;text-decoration:underline;">=</span> val1 val2 val3 <span style="color:#7a7c7d;"># Comment</span> |
| 203 |
|
| 204 |
<span style="color:#7a7c7d;"># Alias rules not allowed within profiles</span> |
| 205 |
<span style="color:#da4453;text-decoration:underline;">alias</span> /run/ <span style="color:#da4453;font-weight:bold;">-></span> /mnt/run/, |
| 206 |
|
| 207 |
<span style="color:#7a7c7d;"># Error: Open rule</span> |
| 208 |
/home/<span style="color:#3daee9;">*</span>/file<span style="font-weight:bold;"> rw</span> |
| 209 |
<span style="color:#27aeae;font-weight:bold;text-decoration:underline;">capability</span> <span style="color:#27aeae;">dac_override</span> |
| 210 |
<span style="color:#da4453;font-weight:bold;text-decoration:underline;">deny</span> <span style="color:#27aeae;font-weight:bold;">file</span> /etc/fstab<span style="font-weight:bold;"> w</span> |
| 211 |
<span style="font-weight:bold;text-decoration:underline;">audit</span> <span style="color:#27aeae;font-weight:bold;">network</span> <span style="color:#27aeae;">ieee802154</span>, |
| 212 |
|
| 213 |
<span style="color:#27aeae;font-weight:bold;">dbus</span> (<span style="font-weight:bold;">receive</span> |
| 214 |
<span style="color:#27aeae;font-weight:bold;text-decoration:underline;">unix</span> <span style="color:#27aeae;">stream</span>, |
| 215 |
<span style="color:#27aeae;font-weight:bold;">unix</span> <span style="color:#27aeae;">stream</span>, |
| 216 |
<span style="color:#3f8058;">}</span> |
| 217 |
|
| 218 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> <span style="color:#8e44ad;">other_tests</span> <span style="color:#3f8058;">{</span> |
| 219 |
<span style="color:#7a7c7d;"># set rlimit</span> |
| 220 |
<span style="color:#27aeae;font-weight:bold;">set</span> <span style="color:#27aeae;font-weight:bold;">rlimit</span> <span style="color:#27aeae;">nice</span> <span style="color:#da4453;font-weight:bold;"><=</span> <span style="color:#f67400;">3</span>, |
| 221 |
<span style="color:#27aeae;font-weight:bold;text-decoration:underline;">rlimit</span> <span style="color:#27aeae;">nice</span> <span style="color:#da4453;font-weight:bold;"><=</span> <span style="color:#f67400;">3</span>, <span style="color:#7a7c7d;"># Without "set"</span> |
| 222 |
<span style="color:#27aeae;font-weight:bold;">set</span> <span style="color:#7a7c7d;">#comment</span> |
| 223 |
<span style="color:#27aeae;font-weight:bold;">rlimit</span> |
| 224 |
<span style="color:#27aeae;">nice</span> <span style="color:#da4453;font-weight:bold;"><=</span> <span style="color:#f67400;">3</span>, |
| 225 |
|
| 226 |
<span style="color:#7a7c7d;"># "remount" keyword</span> |
| 227 |
<span style="color:#27aeae;font-weight:bold;">mount</span> <span style="font-weight:bold;">remount</span> |
| 228 |
<span style="font-weight:bold;">remount</span>, |
| 229 |
<span style="color:#27aeae;font-weight:bold;">remount</span> <span style="font-weight:bold;">remount</span> |
| 230 |
<span style="font-weight:bold;">remount</span>, |
| 231 |
<span style="color:#27aeae;font-weight:bold;">dbus</span> remount |
| 232 |
<span style="color:#27aeae;font-weight:bold;text-decoration:underline;">remount</span>, |
| 233 |
<span style="color:#27aeae;font-weight:bold;">unix</span> remount |
| 234 |
<span style="color:#27aeae;font-weight:bold;text-decoration:underline;">remount</span>, |
| 235 |
<span style="color:#7a7c7d;"># "unix" keyword</span> |
| 236 |
<span style="color:#27aeae;font-weight:bold;">network</span> <span style="color:#27aeae;">unix</span> |
| 237 |
<span style="color:#27aeae;">unix</span>, |
| 238 |
<span style="color:#27aeae;font-weight:bold;">ptrace</span> unix |
| 239 |
<span style="color:#27aeae;font-weight:bold;text-decoration:underline;">unix</span>, |
| 240 |
<span style="color:#27aeae;font-weight:bold;">unix</span> unix |
| 241 |
<span style="color:#27aeae;font-weight:bold;text-decoration:underline;">unix</span>, |
| 242 |
|
| 243 |
<span style="color:#7a7c7d;"># Transition rules</span> |
| 244 |
/usr/bin/foo<span style="font-weight:bold;"> cx</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">hello</span><span style="color:#3daee9;font-style:italic;">*</span>, <span style="color:#7a7c7d;"># profile name</span> |
| 245 |
/usr/bin/foo<span style="font-weight:bold;"> Cx</span> <span style="color:#da4453;font-weight:bold;">-></span> path/, <span style="color:#7a7c7d;"># path</span> |
| 246 |
/usr/bin/foo<span style="font-weight:bold;"> cx</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">ab[ad/]hello</span>, <span style="color:#7a7c7d;"># profile name</span> |
| 247 |
/usr/bin/foo<span style="font-weight:bold;"> Cx</span> <span style="color:#da4453;font-weight:bold;">-></span> ab<span style="color:#da4453;">[cd/]</span>a<span style="color:#da4453;">[ad/]</span>hello/path, <span style="color:#7a7c7d;"># path</span> |
| 248 |
/usr/bin/foo<span style="font-weight:bold;"> Cx</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">ab[hello/path</span>, <span style="color:#7a7c7d;"># profile name</span> |
| 249 |
|
| 250 |
/usr/bin/foo<span style="font-weight:bold;"> cx</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">"hello</span><span style="color:#3daee9;font-style:italic;">*</span><span style="color:#8e44ad;font-style:italic;">"</span>, <span style="color:#7a7c7d;"># profile name</span> |
| 251 |
/usr/bin/foo<span style="font-weight:bold;"> Cx</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#f44f4f;">"path/"</span>, <span style="color:#7a7c7d;"># path</span> |
| 252 |
/usr/bin/foo<span style="font-weight:bold;"> cx</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">"ab[ad/]hello"</span>, <span style="color:#7a7c7d;"># profile name</span> |
| 253 |
/usr/bin/foo<span style="font-weight:bold;"> Cx</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#f44f4f;">"ab</span><span style="color:#da4453;">[cd/]</span><span style="color:#f44f4f;">a</span><span style="color:#da4453;">[ad/]</span><span style="color:#f44f4f;">hello/path"</span>, <span style="color:#7a7c7d;"># path</span> |
| 254 |
/usr/bin/foo<span style="font-weight:bold;"> Cx</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">"ab[hello/path"</span>, <span style="color:#7a7c7d;"># profile name</span> |
| 255 |
|
| 256 |
/usr/bin/foo<span style="font-weight:bold;"> cx</span> <span style="color:#da4453;font-weight:bold;">-></span> holas//hello/sa, <span style="color:#7a7c7d;"># path</span> |
| 257 |
/usr/bin/foo<span style="font-weight:bold;"> cx</span> <span style="color:#da4453;font-weight:bold;">-></span> df///dd<span style="color:#3f8058;font-weight:bold;">//</span><span style="color:#3f8058;">hat</span>, <span style="color:#7a7c7d;"># path + hat</span> |
| 258 |
/usr/bin/foo<span style="font-weight:bold;"> cx</span> <span style="color:#da4453;font-weight:bold;">-></span> <span style="color:#8e44ad;font-style:italic;">holas,#sd</span><span style="color:#3daee9;font-style:italic;">\323</span><span style="color:#8e44ad;font-style:italic;">fsdf</span>, <span style="color:#7a7c7d;"># profile name</span> |
| 259 |
|
| 260 |
<span style="color:#7a7c7d;"># Access modes</span> |
| 261 |
/hello/lib/foo rwklms, <span style="color:#7a7c7d;"># s invalid</span> |
| 262 |
/hello/lib/foo rwmaix, <span style="color:#7a7c7d;"># w & a incompatible</span> |
| 263 |
/hello/lib/foo kalmw, |
| 264 |
/hello/lib/foo wa, |
| 265 |
<span style="color:#7a7c7d;"># OK</span> |
| 266 |
/hello/lib/foo<span style="font-weight:bold;"> rrwrwwrwrw</span>, |
| 267 |
/hello/lib/foo<span style="font-weight:bold;"> ixixix</span>, |
| 268 |
<span style="color:#7a7c7d;"># Incompatible exec permissions</span> |
| 269 |
ixixux, uxuxUxux, ixixixPixix, ixixpx uxuxuxPuxux, UxUxcUxUx, |
| 270 |
pixpixcixix, cxcxcxix, pixpixpux pixpixix xxix xxpux ixixx puxpuxx, |
| 271 |
Cuxcux Pixpix, puxpUx puxPUx xxpix xxcx, |
| 272 |
<span style="color:#7a7c7d;"># Test valid permissions</span> |
| 273 |
<span style="font-weight:bold;"> r w a k l m l x ix ux Ux px Px cx Cx</span> , |
| 274 |
<span style="font-weight:bold;"> pix Pix cix Cix pux Pux cux Cux pUx PUx cUx CUx</span>, |
| 275 |
<span style="font-weight:bold;"> rwklmx raklmx</span>, |
| 276 |
<span style="font-weight:bold;"> r rw rwk rwkl rwklm</span>, |
| 277 |
<span style="font-weight:bold;"> rwlmix rwlmUx rwlmPx rwlmcx rwlmPUx</span>, |
| 278 |
<span style="font-weight:bold;"> rwixixixkl rwUxUxUxkl rwuxuxuxk rwpxpxpxk rwPxPxkl rwcxcxlm rwCxCxk</span>, |
| 279 |
<span style="font-weight:bold;"> rwpixpixk rwPixPixkl wrpuxpuxk rwpUxpUxk rwcixcixcixml rwCixCixk rwCuxCuxk rwCUxCUxl</span>, |
| 280 |
|
| 281 |
<span style="color:#7a7c7d;"># Profile name</span> |
| 282 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> <span style="color:#8e44ad;">holas</span> <span style="color:#3f8058;">{</span> ... <span style="color:#3f8058;">}</span> |
| 283 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> <span style="color:#3f8058;">{</span> ... <span style="color:#3f8058;">}</span> |
| 284 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> /path <span style="color:#3f8058;">{</span> ... <span style="color:#3f8058;">}</span> |
| 285 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> holas/abc <span style="color:#3f8058;">{</span> ... <span style="color:#3f8058;">}</span> |
| 286 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> <span style="color:#8e44ad;">holas</span><span style="color:#3daee9;">\/</span><span style="color:#8e44ad;">abc</span> <span style="color:#3f8058;">{</span> ... <span style="color:#3f8058;">}</span> |
| 287 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> |
| 288 |
<span style="color:#8e44ad;">#holas</span> <span style="color:#3f8058;">{</span> ... <span style="color:#3f8058;">}</span> |
| 289 |
|
| 290 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> <span style="color:#8e44ad;">flags</span><span style="color:#8e44ad;text-decoration:underline;">=</span><span style="color:#da4453;text-decoration:underline;">(complain)#asd</span> <span style="color:#3f8058;">{</span> ... <span style="color:#3f8058;">}</span> |
| 291 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> <span style="color:#8e44ad;">flags</span> <span style="color:#27ae60;">flags</span><span style="color:#3f8058;">=</span>(<span style="color:#da4453;">complain</span>) <span style="color:#3f8058;">{</span> ... <span style="color:#3f8058;">}</span> |
| 292 |
<span style="color:#8e44ad;font-weight:bold;">profile</span> <span style="color:#8e44ad;">flag</span><span style="color:#8e44ad;text-decoration:underline;">s</span><span style="color:#da4453;text-decoration:underline;">(complain)</span> <span style="color:#3f8058;">{</span> ... <span style="color:#3f8058;">}</span> |
| 293 |
<span style="color:#3f8058;">}</span> |
| 294 |
</pre></body></html> |