Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /tags/htdocs/index.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (hide annotations) (download) (as text)
Sun Apr 8 06:04:53 2012 UTC (12 years ago) by kumaneko
File MIME type: text/html
File size: 133703 byte(s)


1 kumaneko 10 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2     <html lang="en-US">
3     <head>
4     <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5 kumaneko 15 <meta http-equiv="content-style-type" content="text/css">
6     <link rel="stylesheet" href="media/caitsith.css" media="all" type="text/css">
7 kumaneko 10 <title>CaitSith Documentation</title>
8     </head>
9     <body>
10    
11     <h1>CaitSith -- A simplified access restriction module for system protection.</h1>
12    
13     <p>CaitSith is an access restriction module for Linux systems. This module gives you ability to restrict access (e.g. opening files, executing programs) at the kernel level. This module is designed for ease of use.</p>
14    
15     <p>Below is documentation and policy syntax but is under construction. Sorry.</p>
16    
17     <hr>
18    
19     <h1><a href="#how_to_use">How to use</a></h1>
20    
21 kumaneko 15 <p><a href="#difference_with_tomoyo">1. Difference with TOMOYO (for existing TOMOYO users)</a></p>
22    
23 kumaneko 10 <ul>
24 kumaneko 15 <li><a href="#1.1">1.1. About pathnames and management programs</a></li>
25     <li><a href="#1.2">1.2. About policy syntax</a></li>
26 kumaneko 10 </ul>
27    
28 kumaneko 15 <p><a href="#how_to_install">2. How to install</a></p>
29    
30     <ul>
31     <li><a href="#2.1">2.1. Install dependencies</a></li>
32     <li><a href="#2.2">2.2. Download and patch the kernel</a></li>
33     <li><a href="#2.3">2.3. Configure the kernel</a></li>
34     <li><a href="#2.4">2.4. Compile and install the kernel</a></li>
35     <li><a href="#2.5">2.5. Install the userspace tools</a></li>
36     <li><a href="#2.6">2.6. Initializing configuration</a></li>
37     <li><a href="#2.7">2.7. Configuring your bootloader</a></li>
38     <li><a href="#2.8">2.8. Rebooting your system</a></li>
39     <li><a href="#2.9">2.9. How can I disable/uninstall CaitSith?</a></li>
40     </ul>
41    
42     <p><a href="#how_to_develop_policy">3. How to develop policy</a></p>
43    
44 kumaneko 16 <ul>
45     <li><a href="#3.1">3.1. Policy file structure</a></li>
46     <li><a href="#3.2">3.2. Updating policy configuration</a></li>
47     <li><a href="#3.3">3.3. Example of simple access restriction rule</a></li>
48     </ul>
49    
50 kumaneko 10 <h1><a href="#policy_specification">Policy Specification</a></h1>
51    
52     <ul>
53     <li><a href="#available_parameters">1. About parameters which can be handled via policy</a></li>
54     <li><a href="#string_expression">1.1. String parameters representation rule</a></li>
55     <li><a href="#numeric_expression">1.2. Numeric parameters representation rule</a></li>
56     <li><a href="#ipaddress_expression">1.3. IP address parameters representation rule</a></li>
57     <li><a href="#conditions">2. About conditional expressions</a></li>
58     <li><a href="#string_comparison">2.1. Conditional expressions which handle string parameters</a></li>
59     <li><a href="#integer_comparison">2.2. Conditional expressions which handle numeric parameters</a></li>
60     <li><a href="#ipaddr_comparison">2.3. Conditional expressions which handle IP address parameters</a></li>
61     <li><a href="#task_attributes_comparison">2.4. Conditional expressions which handle current thread's attributes</a></li>
62     <li><a href="#argv_comparison">2.5. Conditional expressions which handle command line arguments</a></li>
63     <li><a href="#envp_comparison">2.6. Conditional expressions which handle environment variable arguments</a></li>
64     <li><a href="#dac_permission_comparison">2.7. Conditional expressions which handle file's DAC permissions</a></li>
65     <li><a href="#file_type_comparison">2.8. Conditional expressions which handle file's type</a></li>
66     <li><a href="#file_attributes_comparison">2.9. Conditional expressions which handle file's attributes</a></li>
67     <li><a href="#syntax_list">3. List of syntaxes sorted by operations</a></li>
68     <li><a href="#policy_syntaxes">4. Policy syntaxes</a></li>
69     <li><a href="#policy_structure_definition">4.1. Definition</a></li>
70     <li><a href="#policy_examples">4.2. Examples</a></li>
71     </ul>
72    
73     <hr>
74    
75     <h1><a name="how_to_use">How to use</a></h1>
76    
77     <h2><a name="difference_with_tomoyo">1. Difference with TOMOYO (for existing TOMOYO users)</a></h2>
78    
79 kumaneko 15 <p>CaitSith was derived from TOMOYO Linux, but usage of CaitSith would be too different to imagine that CaitSith was derived from TOMOYO Linux. If you are already using TOMOYO Linux, please read the difference described below.</p>
80 kumaneko 10
81 kumaneko 15 <h3><a name="1.1">1.1. About pathnames and management programs</a></h3>
82 kumaneko 10
83     <p>/proc/ccs/domain_policy /proc/ccs/exception_policy /proc/ccs/profile /proc/ccs/manager /proc/ccs/stat has been aggregated into /proc/caitsith/policy</p>
84    
85     <p>/etc/ccs/policy/current/domain_policy.conf /etc/ccs/policy/current/exception_policy.conf /etc/ccs/policy/current/profile.conf /etc/ccs/policy/current/manager.conf /etc/ccs/policy/current/stat.conf has been aggregated into /etc/caitsith/policy/current</p>
86    
87     <p>Built-in policy files which are located in security/ccsecurity/policy/domain_policy.conf security/ccsecurity/policy/exception_policy.conf security/ccsecurity/policy/profile.conf security/ccsecurity/policy/manager.conf security/ccsecurity/policy/stat.conf under kernel source directory have been aggregated into security/caitsith/policy/policy.conf</p>
88    
89     <p>Only /sbin/caitsith-init /usr/sbin/caitsith-auditd /usr/sbin/caitsith-loadpolicy /usr/sbin/caitsith-notifyd /usr/sbin/caitsith-pstree /usr/sbin/caitsith-queryd /usr/sbin/caitsith-savepolicy /usr/lib/caitsith/audit-exec-param /usr/lib/caitsith/caitsith-agent /usr/lib/caitsith/init_policy are provided for managing policy. (In other words, programs such as /usr/sbin/ccs-editpolicy and /usr/sbin/ccs-setprofile have been removed.)</p>
90    
91     <p>Command line arguments for specifying type of policy to load/save has been removed from /usr/sbin/caitsith-loadpolicy and /usr/sbin/caitsith-savepolicy</p>
92    
93     <p>Command line arguments for specifying profile type has been removed from /usr/lib/caitsith/init_policy</p>
94    
95 kumaneko 15 <h3><a name="1.2">1.2. About policy syntax</a></h3>
96 kumaneko 10
97     <p>Policy syntax has been drastically changed. TOMOYO Linux used process's domainname as a key for grouping permissions to do some operations. In other words, TOMOYO Linux's policy is collection of "which domain can do ..." rules. On the other hand, this version uses operation as a key for checking permission. In other words, this version's policy is collection of "which operation can be done by ..." rules. This change is intended for allowing users to protect resources using blacklisting approach. In this version, process's domainname is nothing but one of optional parameters that can be used for controlling whether to grant or deny specific operations. Users can write rules without managing domainnames unless needed.</p>
98    
99     <p>Process's domainname representation has changed from space delimited multiple words (e.g. "&lt;kernel&gt; /sbin/init /etc/rc.d/rc.sysinit") to a single word (e.g. "/sbin/init").</p>
100    
101     <p>Domain transitions no longer happen unless explicitly specified by policy.</p>
102    
103     <p>Distinction of disabled/learning/permissive/enforcing mode has been removed.</p>
104    
105     <p>"path_group" keyword has been renamed to "string_group", and "address_group" keyword has been renamed to "ip_group".</p>
106    
107     <p>Representation of \ character has been changed from \\ to \134.</p>
108    
109     <p>Distinction between directory's pathname and non-directory's pathname has been removed by removing / character from directory's pathname.</p>
110    
111     <p>A new wildcard /\(dir\)/ has been introduced for helping converting from (e.g.) "/tmp/\{\*\}/" to "/tmp/\(\*\)/\*", for directory's pathname (except the root directory itself) no longer ends with / character which previously matched /\{\*\}/ wildcard.</p>
112    
113     <p>Category keywords (i.e. "file", "network", "ipc", "misc", "capability", "task") have been removed because access control levels which was specified using profile has been removed. Some of operation keywords have been renamed (e.g. "network inet stream connect" became "inet_stream_connect", "misc env" became "environ").</p>
114    
115     <p>"task auto_execute_handler" keyword has been renamed to "handler=" argument of "execute" keyword. This is intended for using execute handler for preprocessing purpose when executing specific programs rather than when executing from specific domains. "task denied_execute_handler" keyword has been removed.</p>
116    
117     <p>Domain argument has been removed from permission to send signals (i.e. "signal" directive), for kill() system call accepts negative number for specifying multiple processes. It is impossible to selectively deny sending signals because it is not permitted to sleep while sending signals.</p>
118    
119     <p>Restriction granularity for ptrace operation has changed from boolean (i.e. "capability SYS_PTRACE") to command number + domainname.</p>
120    
121     <p>Restriction granularity for environment variables has changed from name only to both name and values.</p>
122    
123     <p>Several variables for referencing file's attributes have been added.</p>
124    
125     <p>Local port reserve functionality (i.e. "deny_autobind" keyword) has been removed.</p>
126    
127     <h2><a name="how_to_install">2. How to install</a></h2>
128    
129 kumaneko 15 <p>Since CaitSith is a kernel component, you will have to compile your own kernel.</p>
130 kumaneko 10
131 kumaneko 15 <h3><a name="2.1">2.1. Install dependencies</a></h3>
132 kumaneko 10
133 kumaneko 15 <p>These packages are required for compiling the kernel and the userspace tools:</p>
134 kumaneko 10
135 kumaneko 15 <ul>
136     <li><strong>wget</strong>: to download sources</li>
137     <li><strong>patch</strong>: to patch the kernel</li>
138     <li><strong>gcc</strong>: to build the kernel and tools</li>
139     <li><strong>make</strong>: to build the kernel and tools</li>
140     <li><strong>ncurses-devel</strong> or <strong>libncurses-dev</strong>: to build the tools</li>
141     </ul>
142    
143     <p>These can be installed with the following commands:</p>
144    
145     <p><strong>RedHat distributions</strong></p>
146     <pre class="command">
147     # yum -y install wget patch gcc make ncurses-devel
148     </pre>
149     <p><strong>Debian distributions</strong></p>
150     <pre class="command">
151     # apt-get -y install wget patch gcc make libncurses-dev
152     </pre>
153     <p><strong>SUSE distributions</strong></p>
154     <pre class="command">
155     # yast -i wget patch gcc make ncurses-devel
156     </pre>
157    
158     <h3><a name="2.2">2.2. Download and patch the kernel</a></h3>
159    
160     <p>Download the kernel source from <a href="http://www.kernel.org/pub/linux/kernel/v2.6/">linux-2.6</a> or <a href="http://www.kernel.org/pub/linux/kernel/v3.0/">linux-3</a>.<br>
161     Linux kernel 2.6.27 and later are supported from the linux-2.6 tree.<br>
162     Linux kernel 3.0 and later are supported from the linux-3 tree.</p>
163    
164     <p>Extract the kernel source and go to the extracted directory.<br>
165     In the operations below, "$VERSION.$PATCHLEVEL.diff" should for example be replaced with "3.3.diff" if using Linux kernel 3.3.1 :</p>
166    
167     <pre class="command">
168     $ wget -O caitsith-patch-0.1-20120401.tar.gz 'http://sourceforge.jp/frs/redir.php?m=jaist&amp;f=/caitsith/55464/caitsith-patch-0.1-20120401.tar.gz'
169     $ wget -O caitsith-patch-0.1-20120401.tar.gz.asc 'http://sourceforge.jp/frs/redir.php?m=jaist&amp;f=/caitsith/55464/caitsith-patch-0.1-20120401.tar.gz.asc'
170     $ wget http://I-love.SAKURA.ne.jp/kumaneko-key
171     $ gpg --import kumaneko-key
172     $ gpg caitsith-patch-0.1-20120401.tar.gz.asc
173     $ tar -zxf caitsith-patch-0.1-20120401.tar.gz
174 kumaneko 10 $ cat patches/ccs-patch-$VERSION.$PATCHLEVEL.diff | sed -e 's/CCSECURITY/CAITSITH/g' -e 's/ccsecurity/caitsith/g' | patch -sp1
175 kumaneko 15 </pre>
176 kumaneko 10
177 kumaneko 15 <h3><a name="2.3">2.3. Configure the kernel</a></h3>
178 kumaneko 10
179 kumaneko 15 <pre class="command">
180     $ make -s menuconfig
181     </pre>
182 kumaneko 10
183 kumaneko 15 <p>Choose the following options in "Security options" section:</p>
184 kumaneko 10
185 kumaneko 15 <ul>
186     <li>[*] CaitSith support</li>
187     <li>[ ] &nbsp;&nbsp;Compile as loadable kernel module</li>
188     <li>[ ] &nbsp;&nbsp;Disable by default</li>
189     <li>[ ] &nbsp;&nbsp;Do not modify 'struct task_struct' in order to keep KABI</li>
190     <li>[ ] &nbsp;&nbsp;Activate without calling userspace policy loader.</li>
191     <li>(/sbin/caitsith-init) Location of userspace policy loader</li>
192     <li>(/sbin/init) Trigger for calling userspace policy loader</li>
193     <li>[*] &nbsp;&nbsp;Enable readdir operation restriction.</li>
194     <li>[*] &nbsp;&nbsp;Enable getattr operation restriction.</li>
195     <li>[*] &nbsp;&nbsp;Enable socket operation restriction.</li>
196     <li>[*] &nbsp;&nbsp;Enable non-POSIX capability operation restriction.</li>
197     <li>[*] &nbsp;&nbsp;Enable ptrace operation restriction.</li>
198     <li>[*] &nbsp;&nbsp;Enable kill operation restriction.</li>
199     <li>[*] &nbsp;&nbsp;Enable environment variable names/values restriction.</li>
200     <li>[*] &nbsp;&nbsp;Enable execute handler functionality.</li>
201     <li>[*] &nbsp;&nbsp;Enable domain transition without program execution request.</li>
202     <li>[*] &nbsp;&nbsp;Enable automatic domain transition.</li>
203     </ul>
204    
205     <p><em>"Compile as loadable kernel module"</em> is useful when there is a file size limitation for vmlinux (e.g. embedded systems).</p>
206    
207     <p><em>"Disable by default"</em> will enable CaitSith only when "caitsith=on" is passed to the kernel's command line options. If this option is not selected, "caitsith=off" will disable CaitSith.</p>
208    
209     <p><em>"Do not modify 'struct task_struct' in order to keep KABI"</em> will manage "struct task_struct" variables outside "struct task_struct" in order to avoid Kernel Application Binary Interface (KABI) breakage. Choose this option if wanting to patch against distributor's kernels without breaking KABI. However, since "struct caitsith_operations" must be exported to loadable kernel modules (LKMs) in order to allow them to call CaitSith's functions, build scripts may still print warning messages.</p>
210    
211     <p>There are two types of CaitSith's policy configuration. The former is embedded into the kernel and the latter is saved as files on the filesystems (e.g. /etc/caitsith/ directory). You will need to rebuild the kernel whenever updating the former, but allows you to load policy without using userspace policy loader (e.g. /sbin/caitsith-init ). The latter is loaded by executing userspace policy loader when the access control by CaitSith is about to be activated (e.g. when /sbin/init starts). <em>Activate without calling userspace policy loader.</em> allows you to activate access control by CaitSith as soon as the former is loaded. This option is useful when it is difficult to call policy loader (e.g. embedded systems).</p>
212    
213     <p><em>Location of userspace policy loader</em> is available only when <em>Activate without calling userspace policy loader.</em> is not selected. This option specifies the default pathname of the userspace policy loader. You can override this setting via the "CCS_loader=" kernel command-line option.</p>
214    
215     <p><em>Trigger for calling userspace policy loader</em> is available only when <em>Activate without calling userspace policy loader.</em> is not selected. This option specifies the default pathname of the activation trigger. You can override this setting via the "CCS_trigger=" kernel command-line option. For example, if you pass "init=/bin/systemd" option, you may also want to pass "CCS_trigger=/bin/systemd" option.</p>
216    
217     <h3><a name="2.4">2.4. Compile and install the kernel</a></h3>
218    
219     <p>The policy configuration which will be embedded into the kernel needs to exist as security/caitsith/policy/policy.conf . But you can proceed without creating that file because you don't have the policy configuration to embed as of this step. (You may come back here after you developed policy configuration to embed.)</p>
220    
221     <p>Once the kernel has been configured, compile and install the kernel with the following commands:</p>
222    
223     <pre class="command">
224     $ make -s
225     $ su
226     # make -s modules_install install
227     </pre>
228    
229     <p>Create initrd/initramfs if required.</p>
230    
231     <h3><a name="2.5">2.5. Install the userspace tools</a></h3>
232    
233     <p>Make sure the dependencies described above have been installed. Compile and install the tools with the following commands:</p>
234    
235     <pre class="command">
236     $ wget -O caitsith-tools-0.1-20120401.tar.gz 'http://sourceforge.jp/frs/redir.php?m=jaist&amp;f=/caitsith/55465/caitsith-tools-0.1-20120401.tar.gz'
237     $ wget -O caitsith-tools-0.1-20120401.tar.gz.asc 'http://sourceforge.jp/frs/redir.php?m=jaist&amp;f=/caitsith/55465/caitsith-tools-0.1-20120401.tar.gz.asc'
238     $ gpg caitsith-tools-0.1-20120401.tar.gz.asc
239     $ tar -zxf caitsith-tools-0.1-20120401.tar.gz
240 kumaneko 10 $ cd caitsith-tools/
241 kumaneko 15 $ make -s USRLIBDIR=/usr/lib
242     $ su
243     # make -s USRLIBDIR=/usr/lib install
244     </pre>
245 kumaneko 10
246 kumaneko 15 <p>Please change USRLIBDIR=/usr/lib to USRLIBDIR=/usr/lib64 (for 64bits userspace) or USRLIBDIR=/usr/lib32 (for 32bits userspace) if needed.</p>
247 kumaneko 10
248 kumaneko 15 <p>Programs listed below are main userspace tools used for administrating CaitSith.</p>
249 kumaneko 10
250 kumaneko 15 <ul>
251     <li>/sbin/caitsith-init</li>
252     <li>/usr/sbin/caitsith-auditd</li>
253     <li>/usr/sbin/caitsith-loadpolicy</li>
254     <li>/usr/sbin/caitsith-notifyd</li>
255     <li>/usr/sbin/caitsith-pstree</li>
256     <li>/usr/sbin/caitsith-queryd</li>
257     <li>/usr/sbin/caitsith-savepolicy</li>
258     </ul>
259    
260     <p>You will probably want to add /usr/sbin to your PATH so that the commands can be run easily. If you are using <code>/bin/bash</code>, append the following line to ~/.bashrc:</p>
261    
262     <pre>
263     export PATH=$PATH:/usr/sbin
264     </pre>
265    
266     <h3><a name="2.6">2.6. Initializing configuration</a></h3>
267    
268     <p>Before you can make use of CaitSith, an initialization procedure must take place. This prepares the files in which policy information will be stored. All policy files are <strong>stored in the "/etc/caitsith/" directory</strong>.</p>
269    
270     <p>Run the following command as root user to initialize:</p>
271    
272     <pre class="command">
273     # /usr/lib/caitsith/init_policy
274     </pre>
275     <pre class="output">
276     Creating policy directory... OK
277     Creating configuration directory... OK
278     Creating default policy... OK.
279     Creating module loader... OK.
280     Creating configuration file for caitsith-auditd ... OK.
281     Creating configuration file for caitsith-notifyd ... OK.
282     </pre>
283    
284 kumaneko 17 <p>CaitSith can generate audit logs and allows you to read them via /proc/caitsith/audit interface. To save /proc/caitsith/audit automatically, start /usr/sbin/caitsith-auditd from somewhere. Default setting (specified in /etc/caitsith/tools/auditd.conf) sends access allowed logs to /dev/null, access unmatched logs to /var/log/caitsith/unmatched.log, access denied logs to /var/log/caitsith/denied.log. (The meaning and example of allowed/unmatched/denied will be explained in <a href="#3.3">Example of simple access restriction rule</a>.)</p>
285 kumaneko 15
286     <p>CaitSith can ask for your decision about access requests which will be denied unless you grant them via /proc/caitsith/query interface. To notify immediately the occurrence of access requests which CaitSith is about to deny, start /usr/sbin/caitsith-notifyd from somewhere. Default setting (specified in /etc/caitsith/tools/notifyd.conf) sends mails to root@localhost with subject "Notification from caitsith-notifyd" up to once per a minute.</p>
287    
288     <p>Below example launches /usr/sbin/caitsith-auditd and /usr/sbin/caitsith-notifyd from /etc/rc.local script:</p>
289    
290     <pre>
291     #!/bin/sh
292     #
293     # This script will be executed *after* all the other init scripts.
294     # You can put your own initialization stuff in here if you don't
295     # want to do the full Sys V style init stuff.
296    
297     touch /var/lock/subsys/local
298     /usr/sbin/caitsith-auditd
299     /usr/sbin/caitsith-notifyd
300     </pre>
301    
302     <h3><a name="2.7">2.7. Configuring your bootloader</a></h3>
303    
304     <p>Now edit your bootloader (e.g. GRUB) to include the kernel you have just compiled. If the <em>"Disable by default"</em> option was selected during kernel configuration, remember to include "caitsith=on" in the kernel boot options. Consult the documentation for your distribution and bootloader to find out how to boot your CaitSith kernel.</p>
305    
306     <p>CaitSith supports the kernel boot option "CCS_trigger". This is useful for systems that run a program other than <code>/sbin/init</code> on startup, for example when booting using systemd which uses <code>/bin/systemd</code>. In this case, you should include "CCS_trigger=/bin/systemd" in the kernel boot options.</p>
307    
308 kumaneko 16 <pre>
309     # grub.conf generated by anaconda
310     #
311     # Note that you do not have to rerun grub after making changes to this file
312     # NOTICE: You do not have a /boot partition. This means that
313     # all kernel and initrd paths are relative to /, eg.
314     # root (hd0,0)
315     # kernel /boot/vmlinuz-version ro root=/dev/sda1
316     # initrd /boot/initrd-[generic-]version.img
317     #boot=/dev/sda
318     default=1
319     timeout=5
320     splashimage=(hd0,0)/boot/grub/splash.xpm.gz
321     #hiddenmenu
322     title CentOS (3.2.14-caitsith)
323     root (hd0,0)
324     kernel /boot/vmlinuz-3.2.14-caitsith ro root=UUID=cc8371f3-bb2c-47b4-bd8f-318124f523df rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=jp106 crashkernel=auto
325     initrd /boot/initramfs-3.2.14-caitsith.img
326     title CentOS (2.6.32-220.7.1.el6.i686)
327     root (hd0,0)
328     kernel /boot/vmlinuz-2.6.32-220.7.1.el6.i686 ro root=UUID=cc8371f3-bb2c-47b4-bd8f-318124f523df rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=jp106 crashkernel=auto
329     initrd /boot/initramfs-2.6.32-220.7.1.el6.i686.img
330     </pre>
331    
332 kumaneko 15 <h3><a name="2.8">2.8. Rebooting your system</a></h3>
333    
334 kumaneko 16 <p>Now you have finished all preparation. Reboot your system and choose the entry with CaitSith kernel at the GRUB screen, or at whatever other bootloader you have installed:</p>
335 kumaneko 15
336 kumaneko 16 <img src="media/grub-screen.png" alt="grub-screen.png" title="Select CaitSith enabled kernel" width="640" height="480">
337 kumaneko 15
338     <p>If everything was installed properly and the bootloader was correctly configured, the kernel should boot as normal and CaitSith should be activated:</p>
339    
340 kumaneko 16 <img src="media/caitsith-activated.png" alt="caitsith-activated.png" title="CaitSith activated" width="720" height="400">
341 kumaneko 15
342     <h3><a name="2.9">2.9. How can I disable/uninstall CaitSith?</a></h3>
343    
344     <p>If your system becomes unable to boot during the course of this guide or any time in the future, it may be due to policy configuration or something related to CaitSith. If this is the case, it is possible that the kernel can still be booted by disabling CaitSith. This can be done by appending "caitsith=off" at the kernel command-line parameters.</p>
345    
346     <p>CaitSith fortunately does not require the modification of any existing Linux binaries, libraries or applications. Thus, uninstalling CaitSith is very easy. It is simply a matter of uninstalling the kernel and userspace tools that you installed above. You can reboot with the kernel provided by your distribution and then remove the entry from your bootloader.</p>
347    
348 kumaneko 10 <h2><a name="how_to_develop_policy">3. How to develop policy</a></h2>
349    
350 kumaneko 16 <h3><a name="3.1">3.1. Policy file structure</a></h3>
351 kumaneko 10
352 kumaneko 16 <p>CaitSith's policy file consists with "Header part" and "ACL part".</p>
353 kumaneko 10
354 kumaneko 17 <h4><a name="3.1.1">3.1.1. Header part of policy file</a></h4>
355    
356 kumaneko 16 <p>Header part consists with below lines.</p>
357 kumaneko 10
358 kumaneko 16 <pre>
359     POLICY_VERSION=20120401
360 kumaneko 17 stat $stat_name $stat_value
361 kumaneko 16 quota memory policy $max_byte_for_policy
362     quota memory audit $max_byte_for_audit_logs
363     quota memory query $max_byte_for_query
364     quota audit[$audit_index] allowed=$max_logs_for_allowed_request unmatched=$max_logs_for_unmatched_request denied=$max_logs_for_denied_request
365     string_group $string_group_name $string_group_member
366     number_group $number_group_name $number_group_member
367     ip_group $ip_group_name $ip_group_member
368     </pre>
369 kumaneko 10
370 kumaneko 16 <ul>
371     <li>POLICY_VERSION line defines policy version.</li>
372 kumaneko 17 <li>stat lines are for showing statistics information such as memory usage. $stat_name and $stat_value are simply ignored.</li>
373 kumaneko 16 <li>$max_byte_for_policy is max amount of memory in byte which can be allocated for policy. Default is unlimited.</li>
374     <li>$max_byte_for_audit_logs is max amount of memory in byte which can be allocated for audit logs. Default is unlimited. $max_byte_for_audit_logs=16777216 should be sufficient.</li>
375     <li>$max_byte_for_query is max amount of memory in byte which can be allocated for interactive enforcement. Default is unlimited. $max_byte_for_audit_logs=1048576 should be sufficient.</li>
376     <li>quota audit[$audit_index] lines (0 &lt;= $audit_index &lt;= 255) are max number of audit logs which can be held in the kernel space. $max_logs_for_allowed_request is for allowed requests. $max_logs_for_unmatched_request is for unmatched requests. $max_logs_for_denied_request is for denied requests. Default is 0. Unless you have special reasons, you should set 0 to $max_logs_for_allowed_request. Regarding $max_logs_for_unmatched_request and $max_logs_for_denied_request, 1024 should be sufficient.</li>
377     <li>string_group $string_group_name lines define group of strings. $string_group_member is a member for $string_group_name group.</li>
378     <li>number_group $number_group_name lines define group of numbers. $number_group_member is a member for $number_group_name group.</li>
379     <li>ip_group $ip_group_name lines define group of IP addresses. $ip_group_member is a member for $ip_group_name group.</li>
380     </ul>
381 kumaneko 10
382 kumaneko 17 <h4><a name="3.1.2">3.1.2. ACL part of policy file</a></h4>
383 kumaneko 16
384 kumaneko 17 <p>ACL part consists with 0 or more repetitions of below block.</p>
385    
386 kumaneko 16 <pre>
387     $acl_priority acl $operation $conditions_to_filter
388     audit $audit_index
389     $cond_priority $decision $conditions_to_allow_or_deny
390     </pre>
391    
392     <ul>
393     <li>A block which starts with $acl_priority determines whether to evaluate rules in this block or not.</li>
394     <li>Blocks which start with $acl_priority can be defined as many as you need.</li>
395     <li>$acl_priority is a priority (an integer between 0 and 65535) which controls which block should be evaluated first (among all blocks defined in the policy).</li>
396     <li>Blocks are evaluated from smaller $acl_priority values to larger $acl_priority values.</li>
397     <li>If two blocks have same $acl_priority value, the block which is defined first is evaluated first.</li>
398     <li>$operation is "operation".</li>
399     <li>$conditions_to_filter is "conditional expressions" which can be applied to "operation". Omit $conditions_to_filter to evaluate this block unconditionally.</li>
400     <li>Access requests will be denied if one of deny lines (among all blocks defined in the policy) matches.</li>
401     </ul>
402    
403     <p>$decision lines in a block is evaluated only when the block's $acl_priority line matched.</p>
404    
405     <ul>
406     <li>A line which starts with $cond_priority determines whether to grant the access request or not.</li>
407     <li>Lines which start with $cond_priority can be defined as many as you need.</li>
408     <li>$cond_priority is a priority (an integer between 0 and 65535) which controls which line should be checked first (among all lines defined in the block).</li>
409     <li>Lines are checked from smaller $cond_priority values to larger priority values.</li>
410     <li>If two lines have same $cond_priority value, the line which is defined first is checked first.</li>
411     <li>$decision is either allow or deny.</li>
412     <li>$conditions_to_allow_or_deny is "conditional expressions" which can be applied to "operation". Omit $conditions_to_allow_or_deny to match this line unconditionally.</li>
413     </ul>
414    
415     <p>Checking of $decision lines in a block lasts until it matches a $decision line or it reaches to the end of block.</p>
416    
417     <ul>
418     <li>If $conditions_to_allow_or_deny of a deny line matches, the access request is denied. At the same time, access denied log is generated if memory used for audit logs is smaller than $max_byte_for_audit_logs bytes and number of denied logs which is in the kernel is smaller than $max_logs_for_denied_request of quota audit[$audit_index] line where $audit_index is specified by audit line of this block.</li>
419     <li>If $conditions_to_allow_or_deny of an allow line matches, the evaluation of this block ends and proceeds to next block. At the same time, access allowed log is generated if memory used for audit logs is smaller than $max_byte_for_audit_logs bytes and number of allowed logs which is in the kernel is smaller than $max_logs_for_allowed_request of quota audit[$audit_index] line where $audit_index is specified by audit line of this block.</li>
420     <li>If none of $conditions_to_allow_or_deny matches, the evaluation of this block ends and proceeds to next block. At the same time, access unmatched log is generated if memory used for audit logs is smaller than $max_byte_for_audit_logs bytes and number of unmatched logs which is in the kernel is smaller than $max_logs_for_unmatched_request of quota audit[$audit_index] line where $audit_index is specified by audit line of this block.</li>
421     </ul>
422    
423     <p>Access requests will be denied only when "deny" line of "acl" block matched. (There are two exceptions which will be explained later.)</p>
424    
425     <p>$acl_priority and $cond_priority values are used for two purposes. One is for selectively deny operations using "deny" lines. For example,</p>
426    
427     <pre>
428     10 acl read path.fsmagic=0x9FA0
429     audit 0
430     10 deny path="proc:/cmdline"
431     20 allow
432     </pre>
433    
434     <p>denies opening /proc/cmdline on the proc filesystem (proc filesystem's magic number is 0x9FA0) for reading while allowing opening all other files.</p>
435    
436     <p>The other is for controlling which "transition=" and "handler=" arguments should be used when these arguments matched more than once. This will be explained later.</p>
437    
438 kumaneko 17 <h4><a name="3.1.3">3.1.3. An example policy file</a></h4>
439    
440 kumaneko 16 <p>Below is an example of /etc/caitsith/policy/current file on CentOS. The content of this file varies depending on environments you are using, and will be updated as you develop policy.</p>
441    
442     <pre>
443     POLICY_VERSION=20120401
444    
445     quota memory audit 16777216
446     quota memory query 1048576
447     quota audit[1] allowed=0 denied=1024 unmatched=1024
448    
449     10000 acl execute
450     audit 0
451     10 allow path="/sbin/modprobe" transition="/sbin/modprobe"
452     10 allow path="/sbin/init" transition="/sbin/init"
453     10 allow path="/sbin/mingetty" transition="/sbin/mingetty"
454     10 allow path="/sbin/udevd" transition="/sbin/udevd"
455     10 allow path="/usr/sbin/anacron" transition="/usr/sbin/anacron"
456     10 allow path="/usr/sbin/crond" transition="/usr/sbin/crond"
457     10 allow path="/usr/sbin/httpd" transition="/usr/sbin/httpd"
458     10 allow path="/usr/sbin/logrotate" transition="/usr/sbin/logrotate"
459     10 allow path="/usr/sbin/nmbd" transition="/usr/sbin/nmbd"
460     10 allow path="/usr/sbin/smbd" transition="/usr/sbin/smbd"
461     10 allow path="/usr/sbin/sshd" transition="/usr/sbin/sshd"
462     10 allow path="/etc/rc.d/init.d/ntpd" transition="/etc/rc.d/init.d/ntpd"
463     10 allow path="/etc/rc.d/init.d/single" transition="/etc/rc.d/init.d/single"
464     10 allow path="/etc/rc.d/init.d/killall" transition="/etc/rc.d/init.d/killall"
465     10 allow path="/etc/rc.d/init.d/ip6tables" transition="/etc/rc.d/init.d/ip6tables"
466     10 allow path="/etc/rc.d/init.d/halt" transition="/etc/rc.d/init.d/halt"
467     10 allow path="/etc/rc.d/init.d/netfs" transition="/etc/rc.d/init.d/netfs"
468     10 allow path="/etc/rc.d/init.d/messagebus" transition="/etc/rc.d/init.d/messagebus"
469     10 allow path="/etc/rc.d/init.d/sandbox" transition="/etc/rc.d/init.d/sandbox"
470     10 allow path="/etc/rc.d/init.d/rsyslog" transition="/etc/rc.d/init.d/rsyslog"
471     10 allow path="/etc/rc.d/init.d/smb" transition="/etc/rc.d/init.d/smb"
472     10 allow path="/etc/rc.d/init.d/sshd" transition="/etc/rc.d/init.d/sshd"
473     10 allow path="/etc/rc.d/init.d/cgconfig" transition="/etc/rc.d/init.d/cgconfig"
474     10 allow path="/etc/rc.d/init.d/udev-post" transition="/etc/rc.d/init.d/udev-post"
475     10 allow path="/etc/rc.d/init.d/firstboot" transition="/etc/rc.d/init.d/firstboot"
476     10 allow path="/etc/rc.d/init.d/ntpdate" transition="/etc/rc.d/init.d/ntpdate"
477     10 allow path="/etc/rc.d/init.d/crond" transition="/etc/rc.d/init.d/crond"
478     10 allow path="/etc/rc.d/init.d/restorecond" transition="/etc/rc.d/init.d/restorecond"
479     10 allow path="/etc/rc.d/init.d/httpd" transition="/etc/rc.d/init.d/httpd"
480     10 allow path="/etc/rc.d/init.d/rdisc" transition="/etc/rc.d/init.d/rdisc"
481     10 allow path="/etc/rc.d/init.d/postfix" transition="/etc/rc.d/init.d/postfix"
482     10 allow path="/etc/rc.d/init.d/saslauthd" transition="/etc/rc.d/init.d/saslauthd"
483     10 allow path="/etc/rc.d/init.d/netconsole" transition="/etc/rc.d/init.d/netconsole"
484     10 allow path="/etc/rc.d/init.d/network" transition="/etc/rc.d/init.d/network"
485     10 allow path="/etc/rc.d/init.d/avahi-daemon" transition="/etc/rc.d/init.d/avahi-daemon"
486     10 allow path="/etc/rc.d/init.d/auditd" transition="/etc/rc.d/init.d/auditd"
487     10 allow path="/etc/rc.d/init.d/nmb" transition="/etc/rc.d/init.d/nmb"
488     10 allow path="/etc/rc.d/init.d/iptables" transition="/etc/rc.d/init.d/iptables"
489     10 allow path="/etc/rc.d/init.d/cgred" transition="/etc/rc.d/init.d/cgred"
490    
491     0 acl modify_policy
492     audit 1
493     1 deny task.uid!=0
494     1 deny task.euid!=0
495     100 allow task.exe="/usr/sbin/caitsith-loadpolicy"
496     100 allow task.exe="/usr/sbin/caitsith-queryd"
497     10000 deny
498     </pre>
499    
500     <h3><a name="3.2">3.2. Updating policy configuration</a></h3>
501    
502     <p>There are two ways to update policy configuration.</p>
503    
504     <p>One is to use /sbin/caitsith-init which is automatically called when /sbin/init starts. /sbin/caitsith-init reads policy from /etc/caitsith/policy/current and writes to /proc/caitsith/policy interface. Therefore, you can update policy configuration by updating /etc/caitsith/policy/current and rebooting your system.</p>
505    
506     <p>The other is to use /usr/sbin/caitsith-loadpolicy which is defined for loading policy after your system has booted. /sbin/caitsith-loadpolicy reads policy from standard input and writes to /proc/caitsith/policy interface. Therefore, you can update policy configuration without updating /etc/caitsith/policy/current and rebooting your system. For example, if you want to append a "string_group mygroup1 /" line to /proc/caitsith/policy interface, run below command:</p>
507    
508     <pre class="command">
509     # echo 'string_group mygroup1 /' | /usr/sbin/caitsith-loadpolicy
510     </pre>
511    
512     <p>If you want to delete the "string_group mygroup1 /" line from /proc/caitsith/policy interface, run below command:</p>
513    
514     <pre class="command">
515     # echo 'delete string_group mygroup1 /' | /usr/sbin/caitsith-loadpolicy
516     </pre>
517    
518     <p>The contents in /proc/caitsith/policy will be lost when your system shuts down or reboots. To save /proc/caitsith/policy as /etc/caitsith/policy/current , run below command:</p>
519    
520     <pre class="command">
521     # /usr/sbin/caitsith-savepolicy
522     </pre>
523    
524     <h3><a name="3.3">3.3. Example of simple access restriction rule</a></h3>
525    
526 kumaneko 17 <p>Let's experience how CaitSith restricts access using simple examples.</p>
527    
528     <h4><a name="3.3.1">3.3.1. Telling CaitSith which access requests should be checked</a></h4>
529    
530     <p>By default, CaitSith does not deny access requests. To restrict access requests, you need to tell CaitSith which access requests should be denied.</p>
531    
532     <p>Below rule will check access requests which open /tmp/file1 for reading.</p>
533    
534     <pre>
535     100 acl read path="/tmp/file1"
536     audit 1
537     </pre>
538    
539     <p>Append above rule using /usr/sbin/caitsith-loadpolicy . Since caitsith-loadpolicy reads policy from standard input, you can use ^D (Ctrl-D) to indicate end of input:</p>
540    
541     <pre class="command">
542     # /usr/sbin/caitsith-loadpolicy
543     </pre>
544     <pre>
545     100 acl read path="/tmp/file1"
546     audit 1
547     ^D
548     </pre>
549    
550     <p>You may use a temporary file if you worry typos.</p>
551    
552     <pre class="command">
553     # cat &gt; ~/policy.tmp
554     </pre>
555     <pre>
556     100 acl read path="/tmp/file1"
557     audit 1
558     ^D
559     </pre>
560     <pre class="command">
561     # /usr/sbin/caitsith-loadpolicy &lt; ~/policy.tmp
562     # rm ~/policy.tmp
563     </pre>
564    
565     <p>You can confirm that above rule is appended to /proc/caitsith/policy by reading /proc/caitsith/policy .</p>
566    
567     <pre class="command">
568     # cat /proc/caitsith/policy
569     </pre>
570     <pre>
571     POLICY_VERSION=20120401
572     stat Policy updated: 7 (Last: 2012/04/08 04:56:45)
573     stat Requests denied: 0
574     stat Memory used by policy: 6048
575     stat Memory used by audit: 0
576     stat Memory used by query: 0
577     quota memory audit 16777216
578     quota memory query 1048576
579     quota audit[1] allowed=0 denied=1024 unmatched=1024
580    
581     10000 acl execute
582     audit 0
583     10 allow path="/sbin/modprobe" transition="/sbin/modprobe"
584     10 allow path="/sbin/init" transition="/sbin/init"
585     10 allow path="/sbin/mingetty" transition="/sbin/mingetty"
586     10 allow path="/sbin/udevd" transition="/sbin/udevd"
587     10 allow path="/usr/sbin/anacron" transition="/usr/sbin/anacron"
588     10 allow path="/usr/sbin/crond" transition="/usr/sbin/crond"
589     10 allow path="/usr/sbin/httpd" transition="/usr/sbin/httpd"
590     10 allow path="/usr/sbin/logrotate" transition="/usr/sbin/logrotate"
591     10 allow path="/usr/sbin/nmbd" transition="/usr/sbin/nmbd"
592     10 allow path="/usr/sbin/smbd" transition="/usr/sbin/smbd"
593     10 allow path="/usr/sbin/sshd" transition="/usr/sbin/sshd"
594     10 allow path="/etc/rc.d/init.d/ntpd" transition="/etc/rc.d/init.d/ntpd"
595     10 allow path="/etc/rc.d/init.d/single" transition="/etc/rc.d/init.d/single"
596     10 allow path="/etc/rc.d/init.d/killall" transition="/etc/rc.d/init.d/killall"
597     10 allow path="/etc/rc.d/init.d/ip6tables" transition="/etc/rc.d/init.d/ip6tables"
598     10 allow path="/etc/rc.d/init.d/halt" transition="/etc/rc.d/init.d/halt"
599     10 allow path="/etc/rc.d/init.d/netfs" transition="/etc/rc.d/init.d/netfs"
600     10 allow path="/etc/rc.d/init.d/messagebus" transition="/etc/rc.d/init.d/messagebus"
601     10 allow path="/etc/rc.d/init.d/sandbox" transition="/etc/rc.d/init.d/sandbox"
602     10 allow path="/etc/rc.d/init.d/rsyslog" transition="/etc/rc.d/init.d/rsyslog"
603     10 allow path="/etc/rc.d/init.d/smb" transition="/etc/rc.d/init.d/smb"
604     10 allow path="/etc/rc.d/init.d/sshd" transition="/etc/rc.d/init.d/sshd"
605     10 allow path="/etc/rc.d/init.d/cgconfig" transition="/etc/rc.d/init.d/cgconfig"
606     10 allow path="/etc/rc.d/init.d/udev-post" transition="/etc/rc.d/init.d/udev-post"
607     10 allow path="/etc/rc.d/init.d/firstboot" transition="/etc/rc.d/init.d/firstboot"
608     10 allow path="/etc/rc.d/init.d/ntpdate" transition="/etc/rc.d/init.d/ntpdate"
609     10 allow path="/etc/rc.d/init.d/crond" transition="/etc/rc.d/init.d/crond"
610     10 allow path="/etc/rc.d/init.d/restorecond" transition="/etc/rc.d/init.d/restorecond"
611     10 allow path="/etc/rc.d/init.d/httpd" transition="/etc/rc.d/init.d/httpd"
612     10 allow path="/etc/rc.d/init.d/rdisc" transition="/etc/rc.d/init.d/rdisc"
613     10 allow path="/etc/rc.d/init.d/postfix" transition="/etc/rc.d/init.d/postfix"
614     10 allow path="/etc/rc.d/init.d/saslauthd" transition="/etc/rc.d/init.d/saslauthd"
615     10 allow path="/etc/rc.d/init.d/netconsole" transition="/etc/rc.d/init.d/netconsole"
616     10 allow path="/etc/rc.d/init.d/network" transition="/etc/rc.d/init.d/network"
617     10 allow path="/etc/rc.d/init.d/avahi-daemon" transition="/etc/rc.d/init.d/avahi-daemon"
618     10 allow path="/etc/rc.d/init.d/auditd" transition="/etc/rc.d/init.d/auditd"
619     10 allow path="/etc/rc.d/init.d/nmb" transition="/etc/rc.d/init.d/nmb"
620     10 allow path="/etc/rc.d/init.d/iptables" transition="/etc/rc.d/init.d/iptables"
621     10 allow path="/etc/rc.d/init.d/cgred" transition="/etc/rc.d/init.d/cgred"
622    
623     100 acl read path="/tmp/file1"
624     audit 1
625    
626     0 acl modify_policy
627     audit 1
628     1 deny task.uid!=0
629     1 deny task.euid!=0
630     100 allow task.exe="/usr/sbin/caitsith-loadpolicy"
631     100 allow task.exe="/usr/sbin/caitsith-queryd"
632     10000 deny
633     </pre>
634    
635     <h4><a name="3.3.2">3.3.2. Access requests which will be implicitly allowed by CaitSith</a></h4>
636    
637     <p>Make sure that /usr/sbin/caitsith-auditd is running.</p>
638    
639     <pre class="command">
640     # pidof caitsith-auditd
641     </pre>
642     <pre>
643     3627
644     </pre>
645    
646     <p>Now, create /tmp/file1 file.</p>
647    
648     <pre class="command">
649     # touch /tmp/file1
650     </pre>
651    
652     <p>Then, open /tmp/file1 for reading.</p>
653    
654     <pre class="command">
655     # cat /tmp/file1
656     </pre>
657    
658     <p>Check /var/log/caitsith/unmatched.log for access unmatched log of this access request. You will find an entry like below:</p>
659    
660     <pre class="command">
661     # grep /tmp/file1 /var/log/caitsith/unmatched.log
662     </pre>
663     <pre>
664     #2012/04/08 04:58:40# global-pid=3678 result=unmatched priority=100 / read path="/tmp/file1" task.pid=3678 task.ppid=3653 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/bin/cat" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=0 path.ino=2113451 path.major=8 path.minor=1 path.perm=0644 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=2097153 path.parent.major=8 path.parent.minor=1 path.parent.perm=01777 path.parent.type=directory path.parent.fsmagic=0xEF53
665     </pre>
666    
667     <p>Note the <em>result=unmatched</em> part of the entry. This indicates that access request was checked but matched neither "allow" nor "deny" rule.</p>
668    
669     <p>Note the <em>priority=100</em> part of the entry. This indicates that this entry was generated by rules which have 100 as priority.</p>
670    
671     <p>Note the <em>read path="/tmp/file1"</em> part of the entry. This indicates that this entry was generated by access request of opening /tmp/file1 for reading.</p>
672    
673     <h4><a name="3.3.3">3.3.3. Access requests which will be explicitly denied by CaitSith</a></h4>
674    
675     <p>Now, let's add a rule to explicitly deny this request.</p>
676    
677     <pre>
678     100 acl read path="/tmp/file1"
679     1000 deny
680     </pre>
681    
682     <p>Append above rule using /usr/sbin/caitsith-loadpolicy :</p>
683    
684     <pre class="command">
685     # /usr/sbin/caitsith-loadpolicy
686     </pre>
687     <pre>
688     100 acl read path="/tmp/file1"
689     1000 deny
690     ^D
691     </pre>
692    
693     <p>Rules that have same priority (in this rule, 100) and same operation (in this rule, read) and same condition (in this rule, path="/tmp/file1") are automatically merged. Therefore, you will find</p>
694    
695     <pre>
696     100 acl read path="/tmp/file1"
697     audit 1
698     1000 deny
699     </pre>
700    
701     <p>rather than</p>
702    
703     <pre>
704     100 acl read path="/tmp/file1"
705     audit 1
706    
707     100 acl read path="/tmp/file1"
708     1000 deny
709     </pre>
710    
711     <p>when you read /proc/caitsith/policy .</p>
712    
713     <p>Then, open /tmp/file1 for reading.</p>
714    
715     <pre class="command">
716     # cat /tmp/file1
717     </pre>
718     <pre>
719     cat: /tmp/file1: Operation not permitted
720     </pre>
721    
722     <p>This time, access request was denied by CaitSith.</p>
723    
724     <p>Check /var/log/caitsith/denied.log for access denied log of this access request. You will find an entry like below:</p>
725    
726     <pre class="command">
727     # grep /tmp/file1 /var/log/caitsith/denied.log
728     </pre>
729     <pre>
730     #2012/04/08 04:59:53# global-pid=3682 result=denied priority=100 / read path="/tmp/file1" task.pid=3682 task.ppid=3653 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/bin/cat" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=0 path.ino=2113451 path.major=8 path.minor=1 path.perm=0644 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=2097153 path.parent.major=8 path.parent.minor=1 path.parent.perm=01777 path.parent.type=directory path.parent.fsmagic=0xEF53
731     </pre>
732    
733     <p>Note the <em>result=denied</em> part of the entry. This indicates that access request was checked and matched "deny" rule.</p>
734    
735     <p>If /usr/sbin/ccs-notifyd is running, you will receive a notification mail. The content is same with access denied logs.</p>
736    
737     <pre class="command">
738     # mail
739     </pre>
740     <pre>
741     Heirloom Mail version 12.4 7/29/08. Type ? for help.
742     "/var/spool/mail/root": 1 message 1 new
743     &gt;N 1 root Sun Apr 8 13:59 20/1231 "Notification from caitsith-notifyd"
744     &amp;
745     Message 1:
746     From root@ccsecurity.localdomain Sun Apr 8 13:59:53 2012
747     Return-Path: &lt;root@ccsecurity.localdomain&gt;
748     X-Original-To: root@localhost
749     Delivered-To: root@localhost.localdomain
750     Date: Sun, 08 Apr 2012 13:59:53 +0900
751     To: root@localhost.localdomain
752     Subject: Notification from caitsith-notifyd
753     User-Agent: Heirloom mailx 12.4 7/29/08
754     Content-Type: text/plain; charset=us-ascii
755     From: root@caitsith.localdomain (root)
756     Status: R
757    
758     Q0-0
759     #2012/04/08 04:59:53# global-pid=3682 result=denied priority=100 / read path="/tmp/file1" task.pid=3682 task.ppid=3653 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/bin/cat" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=0 path.ino=2113451 path.major=8 path.minor=1 path.perm=0644 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=2097153 path.parent.major=8 path.parent.minor=1 path.parent.perm=01777 path.parent.type=directory path.parent.fsmagic=0xEF53
760     </pre>
761    
762     <p>Now, let's remove a rule to explicitly deny this request.</p>
763    
764     <pre>
765     100 acl read path="/tmp/file1"
766     delete 1000 deny
767     </pre>
768    
769     <p>Append above rule using /usr/sbin/caitsith-loadpolicy :</p>
770    
771     <pre class="command">
772     # /usr/sbin/caitsith-loadpolicy
773     </pre>
774     <pre>
775     100 acl read path="/tmp/file1"
776     delete 1000 deny
777     ^D
778     </pre>
779    
780     <p>You will find</p>
781    
782     <pre>
783     100 acl read path="/tmp/file1"
784     audit 1
785     </pre>
786    
787     <p>rather than</p>
788    
789     <pre>
790     100 acl read path="/tmp/file1"
791     audit 1
792     1000 deny
793     delete 1000 deny
794     </pre>
795    
796     <p>when you read /proc/caitsith/policy .</p>
797    
798     <h4><a name="3.3.4">3.3.4. Filtering audit logs</a></h4>
799    
800     <p>Now, open /tmp/file1 for reading.</p>
801    
802     <pre class="command">
803     # cat /tmp/file1
804     </pre>
805    
806     <p>Check /var/log/caitsith/unmatched.log for access unmatched log of this access request. You will find entries like below:</p>
807    
808     <pre class="command">
809     # grep /tmp/file1 /var/log/caitsith/unmatched.log
810     </pre>
811     <pre>
812     #2012/04/08 04:58:40# global-pid=3678 result=unmatched priority=100 / read path="/tmp/file1" task.pid=3678 task.ppid=3653 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/bin/cat" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=0 path.ino=2113451 path.major=8 path.minor=1 path.perm=0644 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=2097153 path.parent.major=8 path.parent.minor=1 path.parent.perm=01777 path.parent.type=directory path.parent.fsmagic=0xEF53
813     #2012/04/08 05:01:00# global-pid=3695 result=unmatched priority=100 / read path="/tmp/file1" task.pid=3695 task.ppid=3653 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/bin/cat" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=0 path.ino=2113451 path.major=8 path.minor=1 path.perm=0644 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=2097153 path.parent.major=8 path.parent.minor=1 path.parent.perm=01777 path.parent.type=directory path.parent.fsmagic=0xEF53
814     </pre>
815    
816     <p>The former entry was generated before adding explicit "deny" rule. The latter entry was generated after removing explicit "deny" rule. You might want to filter the output using tail command:</p>
817    
818     <pre class="command">
819     # grep /tmp/file1 /var/log/caitsith/unmatched.log | tail -n 1
820     </pre>
821     <pre>
822     #2012/04/08 05:01:00# global-pid=3695 result=unmatched priority=100 / read path="/tmp/file1" task.pid=3695 task.ppid=3653 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/bin/cat" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=0 path.ino=2113451 path.major=8 path.minor=1 path.perm=0644 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=2097153 path.parent.major=8 path.parent.minor=1 path.parent.perm=01777 path.parent.type=directory path.parent.fsmagic=0xEF53
823     </pre>
824    
825     <h4><a name="3.3.5">3.3.5. Access requests which will be explicitly allowed by CaitSith</a></h4>
826    
827     <p>Next, let's see audit logs with explicitly matching "allow" rules.</p>
828    
829     <p>By default CaitSith does not generate audit logs with explicitly matching "allow" rules. Change policy configuration to generate such logs.</p>
830    
831     <pre>
832     quota audit[1] allowed=1024
833     </pre>
834    
835     <p>Append above rule using /usr/sbin/caitsith-loadpolicy :</p>
836    
837     <pre class="command">
838     # echo 'quota audit[1] allowed=1024' | /usr/sbin/caitsith-loadpolicy
839     </pre>
840    
841     <p>Preferences that have same name (in this rule, audit[1]) are automatically merged. Therefore, you will find</p>
842    
843     <pre>
844     quota audit[1] allowed=1024 denied=1024 unmatched=1024
845     </pre>
846    
847     <p>rather than</p>
848    
849     <pre>
850     quota audit[1] allowed=0 denied=1024 unmatched=1024
851     quota audit[1] allowed=1024
852     </pre>
853    
854     <p>when you read /proc/caitsith/policy .</p>
855    
856     <pre>
857     100 acl read path="/tmp/file1"
858     1000 allow
859     </pre>
860    
861     <p>Append above rule using /usr/sbin/caitsith-loadpolicy :</p>
862    
863     <pre class="command">
864     # /usr/sbin/caitsith-loadpolicy
865     </pre>
866     <pre>
867     100 acl read path="/tmp/file1"
868     1000 allow
869     ^D
870     </pre>
871    
872     <p>Since audit logs with explicitly matching "allow" rules tend to grow rapidly, by default /usr/sbin/caitsith-auditd discards such logs by writing to /dev/null (specified in /etc/caitsith/tools/auditd.conf).
873     Therefore, temporarily stop /usr/sbin/caitsith-auditd process in order to read audit logs from /proc/caitsith/audit interface.</p>
874    
875     <pre class="command">
876     # killall -KILL caitsith-auditd
877     </pre>
878    
879     <p>Then, open /tmp/file1 for reading.</p>
880    
881     <pre class="command">
882     # cat /tmp/file1
883     </pre>
884    
885     <p>Check /proc/caitsith/audit for audit log of this access request. This time, you will find an entry like below:</p>
886    
887     <pre class="command">
888     # cat -v /proc/caitsith/audit
889     </pre>
890     <pre>
891     #2012/04/08 05:03:03# global-pid=3720 result=allowed priority=100 / read path="/tmp/file1" task.pid=3720 task.ppid=3653 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/bin/cat" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=0 path.ino=2113451 path.major=8 path.minor=1 path.perm=0644 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=2097153 path.parent.major=8 path.parent.minor=1 path.parent.perm=01777 path.parent.type=directory path.parent.fsmagic=0xEF53
892     ^@
893     </pre>
894    
895     <p>Note the <em>result=allowed</em> part of the entry. This indicates that access request was checked and matched "allow" rule.</p>
896    
897     <p>Restart /usr/sbin/caitsith-auditd process.</p>
898    
899     <pre class="command">
900     # /usr/sbin/caitsith-auditd
901     </pre>
902    
903     <p>Also, restore the audit logs configuration:</p>
904    
905     <pre>
906     quota audit[1] allowed=0
907     </pre>
908    
909     <p>Append above rule using /usr/sbin/caitsith-loadpolicy :</p>
910    
911     <pre class="command">
912     # echo 'quota audit[1] allowed=0' | /usr/sbin/caitsith-loadpolicy
913     </pre>
914    
915 kumaneko 16 <hr>
916    
917     <p>Please read <a href="#policy_specification">Policy Specification</a> before continue.</p>
918    
919 kumaneko 10 <p>Then, decide conditions to restrict access. Below example restricts opening /etc/shadow for reading.</p>
920    
921     <table border="1">
922     <tr><td>
923     100 acl read path="/etc/shadow"<br>
924     &nbsp;&nbsp;&nbsp;&nbsp;audit 1
925     </td></tr>
926     </table>
927    
928     <p>By operating the system, access unmatched logs are generated and spooled in /proc/caitsith/audit interface when access request of opening /etc/shadow for reading happens. If /usr/sbin/caitsith-auditd is running , access unmatched logs will be moved to /var/log/caitsith/unmatched.log .</p>
929    
930     <table border="1">
931     <tr><td>
932     #2012/03/02 08:11:51# global-pid=2826 result=unmatched priority=100 / read path="/etc/shadow" task.pid=2826 task.ppid=2814 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/usr/bin/passwd" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=42 path.ino=33708 path.major=8 path.minor=1 path.perm=0640 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=32769 path.parent.major=8 path.parent.minor=1 path.parent.perm=0755 path.parent.type=directory path.parent.fsmagic=0xEF53
933     </td></tr>
934     </table>
935    
936     <p>Examine the log and decide whether to grant this access request or not. To grant this request, add an allow line. Below example grants this request to /usr/bin/passwd program.</p>
937    
938     <table border="1">
939     <tr><td>
940     100 acl read path="/etc/shadow"<br>
941     &nbsp;&nbsp;&nbsp;&nbsp;audit 1<br>
942     &nbsp;&nbsp;&nbsp;&nbsp;100 allow task.exe="/usr/bin/passwd"
943     </td></tr>
944     </table>
945    
946     <p>Operate the system again. For example, /usr/sbin/sshd program and /bin/cat program have requested opening /etc/shadow for reading.</p>
947    
948     <table border="1">
949     <tr><td>
950     #2012/03/02 08:13:06# global-pid=2831 result=unmatched priority=100 / read path="/etc/shadow" task.pid=2831 task.ppid=2691 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/usr/sbin/sshd" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=42 path.ino=33716 path.major=8 path.minor=1 path.perm=0640 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=32769 path.parent.major=8 path.parent.minor=1 path.parent.perm=0755 path.parent.type=directory path.parent.fsmagic=0xEF53<br>
951     #2012/03/02 08:13:12# global-pid=2837 result=unmatched priority=100 / read path="/etc/shadow" task.pid=2837 task.ppid=2833 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/bin/cat" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=42 path.ino=33716 path.major=8 path.minor=1 path.perm=0640 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=32769 path.parent.major=8 path.parent.minor=1 path.parent.perm=0755 path.parent.type=directory path.parent.fsmagic=0xEF53
952     </td></tr>
953     </table>
954    
955     <p>Add an allow line with /usr/sbin/sshd program in order to allow access by /usr/sbin/sshd program. Also, add a deny line with /bin/cat program in order to deny access by /bin/cat program. Give higher priority (i.e. smaller $cond_priority value) to deny line than allow line so that deny lines are checked before allow lines are checked.</p>
956    
957     <table border="1">
958     <tr><td>
959     100 acl read path="/etc/shadow"<br>
960     &nbsp;&nbsp;&nbsp;&nbsp;audit 1<br>
961     &nbsp;&nbsp;&nbsp;&nbsp;10 deny task.exe="/bin/cat"<br>
962     &nbsp;&nbsp;&nbsp;&nbsp;100 allow task.exe="/usr/bin/passwd"<br>
963     &nbsp;&nbsp;&nbsp;&nbsp;100 allow task.exe="/usr/sbin/sshd"
964     </td></tr>
965     </table>
966    
967     <p>From now on, attempt to read /etc/shadow using /bin/cat should be denied and access denied logs should be generated. If /usr/sbin/caitsith-auditd is running , access denied logs will be moved to /var/log/caitsith/denied.log .</p>
968    
969     <table border="1">
970     <tr><td>
971     #2012/03/02 08:14:38# global-pid=2842 result=denied priority=100 / read path="/etc/shadow" task.pid=2842 task.ppid=2833 task.uid=0 task.gid=0 task.euid=0 task.egid=0 task.suid=0 task.sgid=0 task.fsuid=0 task.fsgid=0 task.type!=execute_handler task.exe="/bin/cat" task.domain="/usr/sbin/sshd" path.uid=0 path.gid=42 path.ino=33716 path.major=8 path.minor=1 path.perm=0640 path.type=file path.fsmagic=0xEF53 path.parent.uid=0 path.parent.gid=0 path.parent.ino=32769 path.parent.major=8 path.parent.minor=1 path.parent.perm=0755 path.parent.type=directory path.parent.fsmagic=0xEF53
972     </td></tr>
973     </table>
974    
975     <p>After you have finished enumerating all allow lines and deny lines, add a deny line with lowest priority (i.e. largest $cond_priority value within this block).</p>
976    
977     <table border="1">
978     <tr><td>
979     100 acl read path="/etc/shadow"<br>
980     &nbsp;&nbsp;&nbsp;&nbsp;audit 1<br>
981     &nbsp;&nbsp;&nbsp;&nbsp;10 deny task.exe="/bin/cat"<br>
982     &nbsp;&nbsp;&nbsp;&nbsp;100 allow task.exe="/usr/bin/passwd"<br>
983     &nbsp;&nbsp;&nbsp;&nbsp;100 allow task.exe="/usr/sbin/sshd"<br>
984     &nbsp;&nbsp;&nbsp;&nbsp;10000 deny
985     </td></tr>
986     </table>
987    
988     <p>A rule for restricting /etc/shadow for opening is now completed.</p>
989    
990     <p>Note that the rule explained above alone cannot prevent diverted accesses such as creating a hard link of /etc/shadow . If the resource to protect has characteristic attribute, it is recommended to utilize such attributes. On several distributions, /etc/shadow is owned by shadow group. In that case, this rule can be modified to below. (Below example assumes that shadow group's group ID is 42.)</p>
991    
992     <table border="1">
993     <tr><td>
994     100 acl read path.gid=42<br>
995     &nbsp;&nbsp;&nbsp;&nbsp;audit 1<br>
996     &nbsp;&nbsp;&nbsp;&nbsp;10 deny task.exe="/bin/cat"<br>
997     &nbsp;&nbsp;&nbsp;&nbsp;100 allow task.exe="/usr/bin/passwd"<br>
998     &nbsp;&nbsp;&nbsp;&nbsp;100 allow task.exe="/usr/sbin/sshd"<br>
999     &nbsp;&nbsp;&nbsp;&nbsp;10000 deny
1000     </td></tr>
1001     </table>
1002    
1003     <p>On several distributions, /etc/shadow is owned by root user and root group and has DAC permissions 0400. In that case, you might want to use a rule like below. (You should check whether there are other files with such attributes.)</p>
1004    
1005     <table border="1">
1006     <tr><td>
1007     100 acl read path.uid=0 path.gid=0 path.perm=0400<br>
1008     &nbsp;&nbsp;&nbsp;&nbsp;audit 1<br>
1009     &nbsp;&nbsp;&nbsp;&nbsp;10 deny task.exe="/bin/cat"<br>
1010     &nbsp;&nbsp;&nbsp;&nbsp;100 allow task.exe="/usr/bin/passwd"<br>
1011     &nbsp;&nbsp;&nbsp;&nbsp;100 allow task.exe="/usr/sbin/sshd"<br>
1012     &nbsp;&nbsp;&nbsp;&nbsp;10000 deny
1013     </td></tr>
1014     </table>
1015    
1016     <p>It is recommended to restrict other operations such as mount, link and rename. For example, a rule to deny creation of hard links which is not owned by the user would look like below. (Note that the variable which refers source pathname of link operation is "old_path" rather than "path" because the operation is "link".)</p>
1017    
1018     <table border="1">
1019     <tr><td>
1020     100 acl link old_path.uid!=task.uid<br>
1021     &nbsp;&nbsp;&nbsp;&nbsp;audit 1<br>
1022     &nbsp;&nbsp;&nbsp;&nbsp;100 deny
1023     </td></tr>
1024     </table>
1025    
1026     <p>If you can split files into different filesystems or different partitions, you might be able to utilize more variables. For example, rules for denying creation of hard links on tmpfs filesystem (tmpfs filesystem's magic number is 0x01021994) would look like below.</p>
1027    
1028     <table border="1">
1029     <tr><td>
1030     100 acl link old_path.fsmagic=0x01021994<br>
1031     &nbsp;&nbsp;&nbsp;&nbsp;audit 1<br>
1032     &nbsp;&nbsp;&nbsp;&nbsp;10 deny
1033     </td></tr>
1034     </table>
1035    
1036     <p>Splitting into different partitions and defining rules based on partition's attributes will help preventing diverted access via creating hard links, for hard links cannot be created across partitions. Separating /home partition from / partition will be useful when protecting resources in /home partition.</p>
1037    
1038     <hr>
1039    
1040     <h1><a name="policy_specification">Policy Specification</a></h1>
1041    
1042     <h2><a name="available_parameters">1. About parameters which can be handled via policy</a></h2>
1043    
1044     <p>Each entry in the policy has a keyword that specifies "operation", and can optionally have "conditional expressions".</p>
1045    
1046     <p>It is possible to check parameters which can be represented as string data or numeric data using "conditional expressions".</p>
1047    
1048     <h3><a name="string_expression">1.1. String parameters representation rule</a></h3>
1049    
1050     <p>Parameters such as file's pathnames and command line arguments and environment variables are handled as string data.</p>
1051    
1052     <p>All ASCII printable characters other than \ character (i.e. from 33 to 91 and from 93 to 126) are represented as is.</p>
1053    
1054     <p>All other characters (i.e. from 0 to 32, 92 and from 127 to 255) are represented using \ooo style octal form.</p>
1055    
1056     <table border="1">
1057     <tr>
1058     <td>
1059     <table><tr><td></td><td>Lower 4 bits</td></tr><tr><td>Upper 4 bits</td><td></td></tr></table>
1060     </td>
1061     <th><p>0x0</p></th>
1062     <th><p>0x1</p></th>
1063     <th><p>0x2</p></th>
1064     <th><p>0x3</p></th>
1065     <th><p>0x4</p></th>
1066     <th><p>0x5</p></th>
1067     <th><p>0x6</p></th>
1068     <th><p>0x7</p></th>
1069     <th><p>0x8</p></th>
1070     <th><p>0x9</p></th>
1071     <th><p>0xA</p></th>
1072     <th><p>0xB</p></th>
1073     <th><p>0xC</p></th>
1074     <th><p>0xD</p></th>
1075     <th><p>0xE</p></th>
1076     <th><p>0xF</p></th>
1077     </tr>
1078     <tr>
1079     <th><p>0x0</p></th>
1080     <td><p>\000</p></td>
1081     <td><p>\001</p></td>
1082     <td><p>\002</p></td>
1083     <td><p>\003</p></td>
1084     <td><p>\004</p></td>
1085     <td><p>\005</p></td>
1086     <td><p>\006</p></td>
1087     <td><p>\007</p></td>
1088     <td><p>\010</p></td>
1089     <td><p>\011</p></td>
1090     <td><p>\012</p></td>
1091     <td><p>\013</p></td>
1092     <td><p>\014</p></td>
1093     <td><p>\015</p></td>
1094     <td><p>\016</p></td>
1095     <td><p>\017</p></td>
1096     </tr>
1097     <tr>
1098     <th><p>0x1</p></th>
1099     <td><p>\020</p></td>
1100     <td><p>\021</p></td>
1101     <td><p>\022</p></td>
1102     <td><p>\023</p></td>
1103     <td><p>\024</p></td>
1104     <td><p>\025</p></td>
1105     <td><p>\026</p></td>
1106     <td><p>\027</p></td>
1107     <td><p>\030</p></td>
1108     <td><p>\031</p></td>
1109     <td><p>\032</p></td>
1110     <td><p>\033</p></td>
1111     <td><p>\034</p></td>
1112     <td><p>\035</p></td>
1113     <td><p>\036</p></td>
1114     <td><p>\037</p></td>
1115     </tr>
1116     <tr>
1117     <th><p>0x2</p></th>
1118     <td><p>\040</p></td>
1119     <td><p>!</p></td>
1120     <td><p>"</p></td>
1121     <td><p>#</p></td>
1122     <td><p>$</p></td>
1123     <td><p>%</p></td>
1124     <td><p>&amp;</p></td>
1125     <td><p>'</p></td>
1126     <td><p>(</p></td>
1127     <td><p>)</p></td>
1128     <td><p>*</p></td>
1129     <td><p>+</p></td>
1130     <td><p>,</p></td>
1131     <td><p>-</p></td>
1132     <td><p>.</p></td>
1133     <td><p>/</p></td>
1134     </tr>
1135     <tr>
1136     <th><p>0x3</p></th>
1137     <td><p>0</p></td>
1138     <td><p>1</p></td>
1139     <td><p>2</p></td>
1140     <td><p>3</p></td>
1141     <td><p>4</p></td>
1142     <td><p>5</p></td>
1143     <td><p>6</p></td>
1144     <td><p>7</p></td>
1145     <td><p>8</p></td>
1146     <td><p>9</p></td>
1147     <td><p>:</p></td>
1148     <td><p>;</p></td>
1149     <td><p>&lt;</p></td>
1150     <td><p>=</p></td>
1151     <td><p>&gt;</p></td>
1152     <td><p>?</p></td>
1153     </tr>
1154     <tr>
1155     <th><p>0x4</p></th>
1156     <td><p>@</p></td>
1157     <td><p>A</p></td>
1158     <td><p>B</p></td>
1159     <td><p>C</p></td>
1160     <td><p>D</p></td>
1161     <td><p>E</p></td>
1162     <td><p>F</p></td>
1163     <td><p>G</p></td>
1164     <td><p>H</p></td>
1165     <td><p>I</p></td>
1166     <td><p>J</p></td>
1167     <td><p>K</p></td>
1168     <td><p>L</p></td>
1169     <td><p>M</p></td>
1170     <td><p>N</p></td>
1171     <td><p>O</p></td>
1172     </tr>
1173     <tr>
1174     <th><p>0x5</p></th>
1175     <td><p>P</p></td>
1176     <td><p>Q</p></td>
1177     <td><p>R</p></td>
1178     <td><p>S</p></td>
1179     <td><p>T</p></td>
1180     <td><p>U</p></td>
1181     <td><p>V</p></td>
1182     <td><p>W</p></td>
1183     <td><p>X</p></td>
1184     <td><p>Y</p></td>
1185     <td><p>Z</p></td>
1186     <td><p>[</p></td>
1187     <td><p>\134</p></td>
1188     <td><p>]</p></td>
1189     <td><p>^</p></td>
1190     <td><p>_</p></td>
1191     </tr>
1192     <tr>
1193     <th><p>0x6</p></th>
1194     <td><p>`</p></td>
1195     <td><p>a</p></td>
1196     <td><p>b</p></td>
1197     <td><p>c</p></td>
1198     <td><p>d</p></td>
1199     <td><p>e</p></td>
1200     <td><p>f</p></td>
1201     <td><p>g</p></td>
1202     <td><p>h</p></td>
1203     <td><p>i</p></td>
1204     <td><p>j</p></td>
1205     <td><p>k</p></td>
1206     <td><p>l</p></td>
1207     <td><p>m</p></td>
1208     <td><p>n</p></td>
1209     <td><p>o</p></td>
1210     </tr>
1211     <tr>
1212     <th><p>0x7</p></th>
1213     <td><p>p</p></td>
1214     <td><p>q</p></td>
1215     <td><p>r</p></td>
1216     <td><p>s</p></td>
1217     <td><p>t</p></td>
1218     <td><p>u</p></td>
1219     <td><p>v</p></td>
1220     <td><p>w</p></td>
1221     <td><p>x</p></td>
1222     <td><p>y</p></td>
1223     <td><p>z</p></td>
1224     <td><p>{</p></td>
1225     <td><p>|</p></td>
1226     <td><p>}</p></td>
1227     <td><p>~</p></td>
1228     <td><p>\177</p></td>
1229     </tr>
1230     <tr>
1231     <th><p>0x8</p></th>
1232     <td><p>\200</p></td>
1233     <td><p>\201</p></td>
1234     <td><p>\202</p></td>
1235     <td><p>\203</p></td>
1236     <td><p>\204</p></td>
1237     <td><p>\205</p></td>
1238     <td><p>\206</p></td>
1239     <td><p>\207</p></td>
1240     <td><p>\210</p></td>
1241     <td><p>\211</p></td>
1242     <td><p>\212</p></td>
1243     <td><p>\213</p></td>
1244     <td><p>\214</p></td>
1245     <td><p>\215</p></td>
1246     <td><p>\216</p></td>
1247     <td><p>\217</p></td>
1248     </tr>
1249     <tr>
1250     <th><p>0x9</p></th>
1251     <td><p>\220</p></td>
1252     <td><p>\221</p></td>
1253     <td><p>\222</p></td>
1254     <td><p>\223</p></td>
1255     <td><p>\224</p></td>
1256     <td><p>\225</p></td>
1257     <td><p>\226</p></td>
1258     <td><p>\227</p></td>
1259     <td><p>\230</p></td>
1260     <td><p>\231</p></td>
1261     <td><p>\232</p></td>
1262     <td><p>\233</p></td>
1263     <td><p>\234</p></td>
1264     <td><p>\235</p></td>
1265     <td><p>\236</p></td>
1266     <td><p>\237</p></td>
1267     </tr>
1268     <tr>
1269     <th><p>0xA</p></th>
1270     <td><p>\240</p></td>
1271     <td><p>\241</p></td>
1272     <td><p>\242</p></td>
1273     <td><p>\243</p></td>
1274     <td><p>\244</p></td>
1275     <td><p>\245</p></td>
1276     <td><p>\246</p></td>
1277     <td><p>\247</p></td>
1278     <td><p>\250</p></td>
1279     <td><p>\251</p></td>
1280     <td><p>\252</p></td>
1281     <td><p>\253</p></td>
1282     <td><p>\254</p></td>
1283     <td><p>\255</p></td>
1284     <td><p>\256</p></td>
1285     <td><p>\257</p></td>
1286     </tr>
1287     <tr>
1288     <th><p>0xB</p></th>
1289     <td><p>\260</p></td>
1290     <td><p>\261</p></td>
1291     <td><p>\262</p></td>
1292     <td><p>\263</p></td>
1293     <td><p>\264</p></td>
1294     <td><p>\265</p></td>
1295     <td><p>\266</p></td>
1296     <td><p>\267</p></td>
1297     <td><p>\270</p></td>
1298     <td><p>\271</p></td>
1299     <td><p>\272</p></td>
1300     <td><p>\273</p></td>
1301     <td><p>\274</p></td>
1302     <td><p>\275</p></td>
1303     <td><p>\276</p></td>
1304     <td><p>\277</p></td>
1305     </tr>
1306     <tr>
1307     <th><p>0xC</p></th>
1308     <td><p>\300</p></td>
1309     <td><p>\301</p></td>
1310     <td><p>\302</p></td>
1311     <td><p>\303</p></td>
1312     <td><p>\304</p></td>
1313     <td><p>\305</p></td>
1314     <td><p>\306</p></td>
1315     <td><p>\307</p></td>
1316     <td><p>\310</p></td>
1317     <td><p>\311</p></td>
1318     <td><p>\312</p></td>
1319     <td><p>\313</p></td>
1320     <td><p>\314</p></td>
1321     <td><p>\315</p></td>
1322     <td><p>\316</p></td>
1323     <td><p>\317</p></td>
1324     </tr>
1325     <tr>
1326     <th><p>0xD</p></th>
1327     <td><p>\320</p></td>
1328     <td><p>\321</p></td>
1329     <td><p>\322</p></td>
1330     <td><p>\323</p></td>
1331     <td><p>\324</p></td>
1332     <td><p>\325</p></td>
1333     <td><p>\326</p></td>
1334     <td><p>\327</p></td>
1335     <td><p>\330</p></td>
1336     <td><p>\331</p></td>
1337     <td><p>\332</p></td>
1338     <td><p>\333</p></td>
1339     <td><p>\334</p></td>
1340     <td><p>\335</p></td>
1341     <td><p>\336</p></td>
1342     <td><p>\337</p></td>
1343     </tr>
1344     <tr>
1345     <th><p>0xE</p></th>
1346     <td><p>\340</p></td>
1347     <td><p>\341</p></td>
1348     <td><p>\342</p></td>
1349     <td><p>\343</p></td>
1350     <td><p>\344</p></td>
1351     <td><p>\345</p></td>
1352     <td><p>\346</p></td>
1353     <td><p>\347</p></td>
1354     <td><p>\350</p></td>
1355     <td><p>\351</p></td>
1356     <td><p>\352</p></td>
1357     <td><p>\353</p></td>
1358     <td><p>\354</p></td>
1359     <td><p>\355</p></td>
1360     <td><p>\356</p></td>
1361     <td><p>\357</p></td>
1362     </tr>
1363     <tr>
1364     <th><p>0xF</p></th>
1365     <td><p>\360</p></td>
1366     <td><p>\361</p></td>
1367     <td><p>\362</p></td>
1368     <td><p>\363</p></td>
1369     <td><p>\364</p></td>
1370     <td><p>\365</p></td>
1371     <td><p>\366</p></td>
1372     <td><p>\367</p></td>
1373     <td><p>\370</p></td>
1374     <td><p>\371</p></td>
1375     <td><p>\372</p></td>
1376     <td><p>\373</p></td>
1377     <td><p>\374</p></td>
1378     <td><p>\375</p></td>
1379     <td><p>\376</p></td>
1380     <td><p>\377</p></td>
1381     </tr>
1382     </table>
1383    
1384     <p>It is possible to use wildcards listed below in order to match string patterns.</p>
1385    
1386     <table border="1">
1387     <tr>
1388     <th><p>Wildcard</p></th>
1389     <th><p>Pattern match</p></th>
1390     <th><p>Examples</p></th>
1391     </tr>
1392     <tr>
1393     <td><p>\*</p></td>
1394     <td><p>0 or more repetitions of characters other than "/"</p></td>
1395     <td><p>/var/log/samba/\*</p></td>
1396     </tr>
1397     <tr>
1398     <td><p>\@</p></td>
1399     <td><p>0 or more repetitions of characters other than "/" or "."</p></td>
1400     <td><p>/var/www/html/\@.html</p></td>
1401     </tr>
1402     <tr>
1403     <td><p>\?</p></td>
1404     <td><p>1 byte character other than "/"</p></td>
1405     <td><p>/tmp/mail.\?\?\?\?\?\?</p></td>
1406     </tr>
1407     <tr>
1408     <td><p>\$</p></td>
1409     <td><p>1 or more repetitions of decimal digits</p></td>
1410     <td><p>/proc/\$/cmdline</p></td>
1411     </tr>
1412     <tr>
1413     <td><p>\+</p></td>
1414     <td><p>1 decimal digit</p></td>
1415     <td><p>/var/tmp/my_work.\+</p></td>
1416     </tr>
1417     <tr>
1418     <td><p>\X</p></td>
1419     <td><p>1 or more repetitions of hexadecimal digits</p></td>
1420     <td><p>/var/tmp/my-work.\X</p></td>
1421     </tr>
1422     <tr>
1423     <td><p>\x</p></td>
1424     <td><p>1 hexadecimal digit</p></td>
1425     <td><p>/tmp/my-work.\x</p></td>
1426     </tr>
1427     <tr>
1428     <td><p>\A</p></td>
1429     <td><p>1 or more repetitions of alphabet characters</p></td>
1430     <td><p>/var/log/my-work/\$-\A-\$.log</p></td>
1431     </tr>
1432     <tr>
1433     <td><p>\a</p></td>
1434     <td><p>1 alphabet character</p></td>
1435     <td><p>/home/users/\a/\*/public_html/\*.html</p></td>
1436     </tr>
1437     <tr>
1438     <td><p>\-</p></td>
1439     <td><p>Pathname subtraction operator (negative match)</p></td>
1440     <td>
1441     <p>/\*\-proc\-sys</p>
1442     <p>This will match /\* except "/proc" and "/sys".</p>
1443     </td>
1444     </tr>
1445     <tr>
1446     <td><p>/\{dir\}/</p></td>
1447     <td><p>Recursive directory matching operator.</p>
1448     <p>Matches "/" and 1 or more repetitions of "dir/".</p></td>
1449     <td>
1450     <p>/var/www/html/\{\*\}/\*.html</p>
1451     <p>This will match all *.html files in subdirectories under /var/www/html/ directory. Note that /var/www/html/\*.html will not match.</p>
1452     </td>
1453     </tr>
1454     <tr>
1455     <td><p>/({dir\)/</p></td>
1456     <td><p>Recursive directory matching operator.</p>
1457     <p>Matches "/" and 0 or more repetitions of "dir/".</p></td>
1458     <td>
1459     <p>/var/www/html/\(\*\)/\*.html</p>
1460     <p>This will match all *.html files under /var/www/html/ directory. Note that /var/www/html/\*.html will match.</p>
1461     </td>
1462     </tr>
1463     </table>
1464    
1465     <p>It is possible to group string data using "<a href="#string_comparison">string_group</a>" syntax.</p>
1466    
1467     <h3><a name="numeric_expression">1.2. Numeric parameters representation rule</a></h3>
1468    
1469     <p>Parameters such as user ID and process ID are handled as numeric data.</p>
1470    
1471     <p>Decimal form, octal form and hexadecimal form are supported. Octal form is prefixed with 0 and Hexadecimal form is prefixed with 0x. For example, 010 in octal form is equivalent with 8 in decimal form, 0x10 in hexadecimal form is equivalent with 16 in decimal form.</p>
1472    
1473     <p>Since numeric data is handled using C language's "unsigned long" type, minimal value is 0 and maximal value is 0xFFFFFFFF (for 32 bit environments) or 0xFFFFFFFFFFFFFFFF (for 64 bit environments).</p>
1474    
1475     <p>It is possible to specify numeric data ranges in $min_value-$max_value form. If specifying in range, $min_value has to be smaller or equals to $max_value. For example, 0-100 is valid but 100-0 is invalid.</p>
1476    
1477     <p>It is possible to group numeric data or numeric data range using "<a href="#integer_comparison">number_group</a>" syntax.</p>
1478    
1479     <h3><a name="ipaddress_expression">1.3. IP address parameters representation rule</a></h3>
1480    
1481     <p>It is possible to handle IPv4 address and IPv6 address. IPv4 address (32 bit) is represented using dot separated decimal form. and IPv6 address (128 bit) is represented using forms defined in RFC 2373.</p>
1482    
1483     <p>It is possible to specify IP address ranges in $min_address-$max_address form. If specifying in range, $min_address has to be smaller or equals to $max_address. For example, 1.2.3.4-5.6.7.8 is valid but 5.6.7.8-1.2.3.4 is invalid.</p>
1484    
1485     <p>It is possible to group IP address and IP address range using "<a href="#ipaddr_comparison">ip_group</a>" syntax.</p>
1486    
1487     <h2><a name="conditions">2. About conditional expressions</a></h2>
1488    
1489     <p>Valid conditions are determined by "operation". See <a href="#syntax_list">List of syntaxes sorted by operations</a> for "operation".</p>
1490    
1491     <p>Some examples are shown below. Details of conditions are explained later.</p>
1492    
1493     <table border="1">
1494     <tr><td>Example of policy</td><td>Meaning</td></tr>
1495     <tr><td>acl execute</td><td>Execution of any program</td></tr>
1496     <tr><td>acl execute task.uid=0</td><td>Execution of any program by current thread's user ID is 0</td></tr>
1497     <tr><td>acl execute task.uid=0 task.gid=0</td><td>Execution of any program by current thread's user ID and group ID are both 0</td></tr>
1498     <tr><td>acl execute path="/bin/true"</td><td>Execution of any program where normalized pathname is /bin/true .</td></tr>
1499     <tr><td>acl execute path="/bin/true" argv[1]="--help"</td><td>Execution of any program where normalized pathname is /bin/true and the first command line argument is --help</td></tr>
1500     <tr><td>acl execute task.uid=0 path="/sbin/init"</td><td>Execution of any program where normalized pathname is /sbin/init by current thread's user ID is 0</td></tr>
1501     </table>
1502    
1503     <p>Basically conditions are omissible. But a few "operation" have mandatory conditions and parameters which controls behavior after policy matches. Such conditions/parameters are explained in individual topics.</p>
1504    
1505     <h3><a name="string_comparison">2.1. Conditional expressions which handle string parameters</a></h3>
1506    
1507     <p>Number of parameters which is represented as string data depends on "operation". For example, "read" operation has one and "rename" operation has two. Thus, the name of variables which references string data varies on "operation". See <a href="#syntax_list">List of syntaxes sorted by operations</a> for name of variables that handle string data. Below description assumes that the name of variable is "path".</p>
1508    
1509     <p>Comparison with string data is defined as below.</p>
1510    
1511     <table border="1">
1512     <tr><td>Conditions example</td><td>Value of variable "path"</td><td>Comparison result</td></tr>
1513     <tr><td rowspan="5">path="/tmp/\*"</td>
1514     <td>/</td><td>Does not match</td></tr>
1515     <tr><td>/tmp</td><td>Does not match</td></tr>
1516     <tr><td>/tmp/</td><td>Matches</td></tr>
1517     <tr><td>/tmp/rt6bh84t</td><td>Matches</td></tr>
1518     <tr><td>/tmp/349gy08t/y8024fgf</td><td>Does not match</td></tr>
1519     <tr><td rowspan="5">path!="/tmp/\*"</td>
1520     <td>/</td><td>Matches</td></tr>
1521     <tr><td>/tmp</td><td>Matches</td></tr>
1522     <tr><td>/tmp/</td><td>Does not match</td></tr>
1523     <tr><td>/tmp/rt6bh84t</td><td>Does not match</td></tr>
1524     <tr><td>/tmp/349gy08t/y8024fgf</td><td>Matches</td></tr>
1525     </table>
1526    
1527     <p>If a string_group group named TMPDIR is defined as</p>
1528    
1529     <table border="1">
1530     <tr><td>
1531     string_group TMPDIR /tmp<br>
1532     string_group TMPDIR /tmp/\(\*\)/\*
1533     </td></tr>
1534     </table>
1535    
1536     <p>it is possible to define conditions like below.</p>
1537    
1538     <table border="1">
1539     <tr><td>Conditions example</td><td>Value of variable "path"</td><td>Value of TMPDIR group</td><td>Comparison result</td></tr>
1540     <tr><td rowspan="4">path=@TMPDIR</td>
1541     <td>/</td><td rowspan="4">/tmp<br>/tmp/\(\*\)/\*</td><td>Does not match</td></tr>
1542     <tr><td>/tmp</td><td>Matches</td></tr>
1543     <tr><td>/tmp/rt6bh84t</td><td>Matches</td></tr>
1544     <tr><td>/tmp/349gy08t/y8024fgf</td><td>Matches</td></tr>
1545     <tr><td rowspan="4">path!=@TMPDIR</td>
1546     <td>/</td><td rowspan="4">/tmp<br>/tmp/\(\*\)/\*</td><td>Matches</td></tr>
1547     <tr><td>/tmp</td><td>Does not match</td></tr>
1548     <tr><td>/tmp/rt6bh84t</td><td>Does not match</td></tr>
1549     <tr><td>/tmp/349gy08t/y8024fgf</td><td>Does not match</td></tr>
1550     </table>
1551    
1552     <h3><a name="integer_comparison">2.2. Conditional expressions which handle numeric parameters</a></h3>
1553    
1554     <p>Number of parameters which is represented as numeric data depends on "operation". For example, "create" operation has one and "mkblock" operation has three. Thus, the name of variables which references numeric parameters varies on "operation". See <a href="#syntax_list">List of syntaxes sorted by operations</a> for name of variables that handle numeric data. Below description uses "task.uid" (which references current thread's user ID) and "task.gid" (which references current thread's group ID) as an example.</p>
1555    
1556     <p>Comparison with numeric value is defined as below.</p>
1557    
1558     <table border="1">
1559     <tr><td>Conditions example</td><td>Value of variable "task.uid"</td><td>Comparison result</td></tr>
1560     <tr><td rowspan="3">task.uid=0</td>
1561     <td>0</td><td>Matches</td></tr>
1562     <tr><td>100</td><td>Does not match</td></tr>
1563     <tr><td>500</td><td>Does not match</td></tr>
1564     <tr><td rowspan="3">task.uid!=0</td>
1565     <td>0</td><td>Does not match</td></tr>
1566     <tr><td>100</td><td>Matches</td></tr>
1567     <tr><td>500</td><td>Matches</td></tr>
1568     </table>
1569    
1570     <p>Comparison with numeric value range is defined as below.</p>
1571    
1572     <table border="1">
1573     <tr><td>Conditions example</td><td>Value of variable "task.gid"</td><td>Comparison result</td></tr>
1574     <tr><td rowspan="3">task.gid=0-100</td>
1575     <td>0</td><td>Matches</td></tr>
1576     <tr><td>100</td><td>Matches</td></tr>
1577     <tr><td>500</td><td>Does not match</td></tr>
1578     <tr><td rowspan="3">task.gid!=0-100</td><td>0</td><td>Does not match</td></tr>
1579     <tr><td>100</td><td>Does not match</td></tr>
1580     <tr><td>500</td><td>Matches</td></tr>
1581     </table>
1582    
1583     <p>It is possible to compare one variable which references numeric value with another variable which references numeric value.</p>
1584    
1585     <table border="1">
1586     <tr><td>Conditions example</td><td>Value of variable "task.uid"</td><td>Value of variable "task.gid"</td><td>Comparison result</td></tr>
1587     <tr><td rowspan="4">task.uid=task.gid</td>
1588     <td>0</td><td>0</td><td>Matches</td></tr>
1589     <tr><td>0</td><td>100</td><td>Does not match</td></tr>
1590     <tr><td>100</td><td>0</td><td>Does not match</td></tr>
1591     <tr><td>100</td><td>100</td><td>Matches</td></tr>
1592     <tr><td rowspan="4">task.uid!=task.gid</td>
1593     <td>0</td><td>0</td><td>Does not match</td></tr>
1594     <tr><td>0</td><td>100</td><td>Matches</td></tr>
1595     <tr><td>100</td><td>0</td><td>Matches</td></tr>
1596     <tr><td>100</td><td>100</td><td>Does not match</td></tr>
1597     </table>
1598    
1599     <p>If a number_group group named ID_GROUP is defined as</p>
1600    
1601     <table border="1">
1602     <tr><td>
1603     number_group ID_GROUP 100<br>
1604     number_group ID_GROUP 200-500
1605     </td></tr>
1606     </table>
1607    
1608     <p>it is possible to define conditions like below.</p>
1609    
1610     <table border="1">
1611     <tr><td>Conditions example</td><td>Value of variable "task.uid"</td><td>Values in ID_GROUP group</td><td>Comparison result</td></tr>
1612     <tr><td rowspan="4">task.uid=@ID_GROUP</td>
1613     <td>0</td><td rowspan="4">100<br>200-500</td><td>Does not match</td></tr>
1614     <tr><td>100</td><td>Matches</td></tr>
1615     <tr><td>500</td><td>Matches</td></tr>
1616     <tr><td>1000</td><td>Does not match</td></tr>
1617     <tr><td rowspan="4">task.uid!=@ID_GROUP</td>
1618     <td>0</td><td rowspan="4">100<br>200-500</td><td>Matches</td></tr>
1619     <tr><td>100</td><td>Does not match</td></tr>
1620     <tr><td>500</td><td>Does not match</td></tr>
1621     <tr><td>1000</td><td>Matches</td></tr>
1622     </table>
1623    
1624     <h3><a name="ipaddr_comparison">2.3. Conditional expressions which handle IP address parameters</a></h3>
1625    
1626     <p>Any "operation" which handles IPv4/IPv6 network address can check IP address using variable "ip". See <a href="#syntax_list">List of syntaxes sorted by operations</a> for operations that can handle IP address.</p>
1627    
1628     <p>Comparison with IP address value is defined as below. Note that comparison between an IPv4 address and an IPv6 address does not match.</p>
1629    
1630     <table border="1">
1631     <tr><td>Conditions example</td><td>Value of variable "ip"</td><td>Comparison result</td></tr>
1632     <tr><td rowspan="4">ip=127.0.0.1</td><td>127.0.0.1</td><td>Matches</td></tr>
1633     <tr><td>0.0.0.0</td><td>Does not match</td></tr>
1634     <tr><td>::1</td><td>Does not match</td></tr>
1635     <tr><td>::ffff:127.0.0.1</td><td>Does not match</td></tr>
1636     <tr><td rowspan="4">ip!=127.0.0.1</td><td>127.0.0.1</td><td>Does not match</td></tr>
1637     <tr><td>0.0.0.0</td><td>Matches</td></tr>
1638     <tr><td>::1</td><td>Does not match</td></tr>
1639     <tr><td>::ffff:127.0.0.1</td><td>Does not match</td></tr>
1640     <tr><td rowspan="4">ip=::1</td><td>127.0.0.1</td><td>Does not match</td></tr>
1641     <tr><td>0.0.0.0</td><td>Does not match</td></tr>
1642     <tr><td>::1</td><td>Matches</td></tr>
1643     <tr><td>::ffff:127.0.0.1</td><td>Does not match</td></tr>
1644     <tr><td rowspan="4">ip!=::1</td><td>127.0.0.1</td><td>Does not match</td></tr>
1645     <tr><td>0.0.0.0</td><td>Does not match</td></tr>
1646     <tr><td>::1</td><td>Does not match</td></tr>
1647     <tr><td>::ffff:127.0.0.1</td><td>Matches</td></tr>
1648     </table>
1649    
1650     <p>Comparison with IP address range is defined as below.</p>
1651    
1652     <table border="1">
1653     <tr><td>Conditions example</td><td>Value of variable "ip"</td><td>Comparison result</td></tr>
1654     <tr><td rowspan="3">ip=127.0.0.0-127.255.255.255</td>
1655     <td>127.0.0.1</td><td>Matches</td></tr>
1656     <tr><td>10.0.0.1</td><td>Does not match</td></tr>
1657     <tr><td>::ffff:127.0.0.1</td><td>Does not match</td></tr>
1658     <tr><td rowspan="3">ip!=127.0.0.0-127.255.255.255</td>
1659     <td>127.0.0.1</td><td>Does not match</td></tr>
1660     <tr><td>10.0.0.1</td><td>Matches</td></tr>
1661     <tr><td>::ffff:127.0.0.1</td><td>Does not match</td></tr>
1662     <tr><td rowspan="3">ip=::-::1</td><td>::ffff:127.0.0.1</td><td>Does not match</td></tr>
1663     <tr><td>127.0.0.1</td><td>Does not match</td></tr>
1664     <tr><td>::1</td><td>Matches</td></tr>
1665     <tr><td rowspan="3">ip!=::-::1</td><td>::ffff:127.0.0.1</td><td>Matches</td></tr>
1666     <tr><td>127.0.0.1</td><td>Does not match</td></tr>
1667     <tr><td>::1</td><td>Does not match</td></tr>
1668     </table>
1669    
1670     <p>If an ip_group group named PRIVATE_ADDRESS is defined as</p>
1671    
1672     <table border="1">
1673     <tr><td>
1674     ip_group PRIVATE_ADDRESS 10.0.0.0-10.255.255.255<br>
1675     ip_group PRIVATE_ADDRESS 172.16.0.0-172.31.255.255<br>
1676     ip_group PRIVATE_ADDRESS 192.168.0.0-192.168.255.255<br>
1677     ip_group PRIVATE_ADDRESS fd00::-fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
1678     </td></tr>
1679     </table>
1680    
1681     <p>it is possible to define conditions like below.</p>
1682    
1683     <table border="1">
1684     <tr><td>Conditions example</td><td>Value of variable "ip"</td><td>Values in PRIVATE_ADDRESS group</td><td>Comparison result</td></tr>
1685     <tr><td rowspan="5">ip=@PRIVATE_ADDRESS</td>
1686     <td>127.0.0.1</td><td rowspan="5">10.0.0.0-10.255.255.255<br>172.16.0.0-172.31.255.255<br>192.168.0.0-192.168.255.255<br>fd00::-fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff</td><td>Does not match</td></tr>
1687     <tr><td>10.0.0.1</td><td>Matches</td></tr>
1688     <tr><td>192.168.0.1</td><td>Matches</td></tr>
1689     <tr><td>::ffff:172.16.0.1</td><td>Does not match</td></tr>
1690     <tr><td>fd01::</td><td>Matches</td></tr>
1691     <tr><td rowspan="5">ip!=@PRIVATE_ADDRESS</td><td>127.0.0.1</td><td rowspan="5">10.0.0.0-10.255.255.255<br>172.16.0.0-172.31.255.255<br>192.168.0.0-192.168.255.255<br>fd00::-fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff</td><td>Matches</td></tr>
1692     <tr><td>10.0.0.1</td><td>Does not match</td></tr>
1693     <tr><td>::ffff:192.168.0.1</td><td>Matches</td></tr>
1694     <tr><td>::ffff:127.0.0.1</td><td>Matches</td></tr>
1695     <tr><td>fd01::</td><td>Does not match</td></tr>
1696     </table>
1697    
1698     <h3><a name="task_attributes_comparison">2.4. Conditional expressions which handle current thread's attributes</a></h3>
1699    
1700     <p>It is possible to use current thread's attributes as part of conditions. Below variables are always available.</p>
1701    
1702     <table border="1">
1703     <tr><td>Variable's name</td><td>Comparison method</td><td>Meaning</td><td></td></tr>
1704     <tr><td>task.uid</td><td><a href="#integer_comparison">Numeric</a></td><td>Current thread's user ID</td></tr>
1705     <tr><td>task.gid</td><td><a href="#integer_comparison">Numeric</a></td><td>Current thread's group ID</td></tr>
1706     <tr><td>task.euid</td><td><a href="#integer_comparison">Numeric</a></td><td>Current thread's effective user ID</td></tr>
1707     <tr><td>task.egid</td><td><a href="#integer_comparison">Numeric</a></td><td>Current thread's effective group ID</td></tr>
1708     <tr><td>task.suid</td><td><a href="#integer_comparison">Numeric</a></td><td>Current thread's saved user ID</td></tr>
1709     <tr><td>task.sgid</td><td><a href="#integer_comparison">Numeric</a></td><td>Current thread's saved group ID</td></tr>
1710     <tr><td>task.fsuid</td><td><a href="#integer_comparison">Numeric</a></td><td>Current thread's filesystem user ID</td></tr>
1711     <tr><td>task.fsgid</td><td><a href="#integer_comparison">Numeric</a></td><td>Current thread's filesystem group ID</td></tr>
1712     <tr><td>task.pid</td><td><a href="#integer_comparison">Numeric</a></td><td>Current thread's process ID </td></tr>
1713     <tr><td>task.ppid</td><td><a href="#integer_comparison">Numeric</a></td><td>Process ID of current thread's parent process</td></tr>
1714     <tr><td>task.exe</td><td><a href="#string_comparison">String</a></td><td>Current thread's program name (the content of /proc/self/exe)</td></tr>
1715     <tr><td>task.domain</td><td><a href="#string_comparison">String</a></td><td>Current thread's domainname (the content of /proc/caitsith/self_domain)</td></tr>
1716     <tr><td>task.type</td><td>Literal</td><td>Matches execute_handler if running as an execute handler, does not match execute_handler otherwise</td></tr>
1717     </table>
1718    
1719     <h3><a name="argv_comparison">2.5. Conditional expressions which handle command line arguments</a></h3>
1720    
1721     <p>It is possible to check command line arguments (a.k.a. argv[]) when checking permissions for program execution.</p>
1722    
1723     <table border="1">
1724     <tr><td>Conditions example</td><td>Comparison method</td><td>Meaning</td><td></td></tr>
1725     <tr><td>argv[0]="true"</td><td><a href="#string_comparison">String</a></td><td>argv[0] matches "true"</td></tr>
1726     <tr><td>argv[0]!="false"</td><td><a href="#string_comparison">String</a></td><td>argv[0] does not match "false"</td></tr>
1727     <tr><td>argv[1]=@ARGV1_GROUPS</td><td><a href="#string_comparison">String</a></td><td>argv[0] matches one of strings in string_group ARGV1_GROUPS group</td></tr>
1728     <tr><td>argv[1]!=@ARGV1_GROUPS</td><td><a href="#string_comparison">String</a></td><td>argv[0] matches none of strings in string_group ARGV1_GROUPS group</td></tr>
1729     </table>
1730    
1731     <p>Applications can pass a string data up to 32 * PAGE_SIZE bytes to each argv[]. But due to difficulty of allocating contiguous memory in the kernel, only up to 4085 bytes can be checked using variable "argv[$index]". If you want to check strictly, please consider using handler= argument of "allow " lines in "acl execute" block.</p>
1732    
1733     <h3><a name="envp_comparison">2.6. Conditional expressions which handle environment variable arguments</a></h3>
1734    
1735     <p>It is possible to check environment variables (a.k.a. envp[]) when checking permissions for program execution.</p>
1736    
1737     <table border="1">
1738     <tr><td>Conditions example</td><td>Comparison method</td><td>Meaning</td><td></td></tr>
1739     <tr><td>envp["PATH"]="/"</td><td><a href="#string_comparison">String</a></td><td>Environment variable PATH is defined and its value is "/"</td></tr>
1740     <tr><td>envp["PATH"]!="/"</td><td><a href="#string_comparison">String</a></td><td>Either<br>&nbsp;&nbsp;&nbsp;&nbsp;Environment variable PATH is not defined<br>or<br>&nbsp;&nbsp;&nbsp;&nbsp;Environment variable PATH is defined but its value is not "/"</td></tr>
1741     <tr><td>envp["PATH"]=@ENV_PATH_VALUES</td><td><a href="#string_comparison">String</a></td><td>Environment variable PATH is defined and its value matches one of strings in string_group ENVP_PATH_VALUES group</td></tr>
1742     <tr><td>envp["PATH"]!=@ENV_PATH_VALUES</td><td><a href="#string_comparison">String</a></td><td>Either<br>&nbsp;&nbsp;&nbsp;&nbsp;Environment variable PATH is not defined<br>or<br>&nbsp;&nbsp;&nbsp;&nbsp;Environment variable PATH is defined but its value matches none of strings in string_group ENVP_PATH_VALUES group</td></tr>
1743     <tr><td>envp["PATH"]=NULL</td><td>None</td><td>Environment variable PATH is not defined</td></tr>
1744     <tr><td>envp["PATH"]!=NULL</td><td>None</td><td>Environment variable PATH is not defined</td></tr>
1745     </table>
1746    
1747     <p>Applications can pass a string data up to 32 * PAGE_SIZE bytes to each envp[]. But due to difficulty of allocating contiguous memory in the kernel, only up to 4085 bytes can be checked using variable "envp["$name"]". If you want to check strictly, please consider using handler= argument of "allow " lines in "acl execute" block.</p>
1748    
1749     <h3><a name="dac_permission_comparison">2.7. Conditional expressions which handle file's DAC permissions</a></h3>
1750    
1751     <p>When checking permissions for file related operations, it is possible to check its DAC permissions if the file already exists as of permission check.
1752     Below table assumes that the variable name for referencing the requested pathname is "path".</p>
1753    
1754     <p>Value of DAC permissions can be referenced using variable "path.perm", and its value is between 0 and 07777. Although it is possible to do normal <a href="#integer_comparison">numeric comparison</a>, below constants are provided in order to make it easier to compare whether specific bit is set or not.</p>
1755    
1756     <table border="1">
1757     <tr><td>Constant</td><td>Value ranges that match </td></tr>
1758     <tr><td>setuid</td><td>Values where bitwise AND between path.perm and 04000 are 04000. (i.e. 04000-07777)</td></tr>
1759     <tr><td>setgid</td><td>Values where bitwise AND between path.perm and 02000 are 02000. (i.e. 02000-03777 06000-07777)</td></tr>
1760     <tr><td>sticky</td><td>Values where bitwise AND between path.perm and 01000 are 01000. (i.e. 01000-01777 03000-03777 05000-05777 07000-07777)</td></tr>
1761     <tr><td>owner_read</td><td>Values where bitwise AND between path.perm and 00400 are 00400. (e.g. 00400-00777 01400-01777 02400-02777)</td></tr>
1762     <tr><td>owner_write</td><td>Values where bitwise AND between path.perm and 00200 are 00200. (e.g. 00200-00377 00600-00777 01200-01377)</td></tr>
1763     <tr><td>owner_execute</td><td>Values where bitwise AND between path.perm and 00100 are 00100. (e.g. 00100-00177 00300-00377 00500-00577)</td></tr>
1764     <tr><td>group_read</td><td>Values where bitwise AND between path.perm and 00040 are 00040. (e.g. 00040-00077 00140-00177 00240-00277)</td></tr>
1765     <tr><td>group_write</td><td>Values where bitwise AND between path.perm and 00020 are 00020. (e.g. 00020-00037 00060-00077 00120-00137)</td></tr>
1766     <tr><td>group_execute</td><td>Values where bitwise AND between path.perm and 00010 are 00010. (e.g. 00010-00017 00030-00037 00050-00057)</td></tr>
1767     <tr><td>others_read</td><td>Values where bitwise AND between path.perm and 00004 are 00004. (e.g. 00004-00007 00014-00017 00024-00027)</td></tr>
1768     <tr><td>others_write</td><td>Values where bitwise AND between path.perm and 00002 are 00002. (e.g. 00002-00003 00006-00007 00012-00013)</td></tr>
1769     <tr><td>others_execute</td><td>Values where bitwise AND between path.perm and 00001 are 00001. (e.g. 00001 00003 00005 00007 00011 00013)</td></tr>
1770     </table>
1771    
1772     <p>Below are some examples that use constants.</p>
1773    
1774     <table border="1">
1775     <tr><td>Conditions example</td><td>Permissions of file referenced by variable "path"</td><td>Comparison result</td></tr>
1776     <tr><td>path.perm=setuid</td><td>04755</td><td>Matches</td></tr>
1777     <tr><td>path.perm!=setuid</td><td>04755</td><td>Does not match</td></tr>
1778     <tr><td>path.perm=setuid path.perm=setgid path.perm=sticky</td><td>0755</td><td>Does not match</td></tr>
1779     <tr><td>path.perm!=setuid path.perm!=setgid path.perm!=sticky</td><td>0755</td><td>Matches</td></tr>
1780     </table>
1781    
1782     <h3><a name="file_type_comparison">2.8. Conditional expressions which handle file's type</a></h3>
1783    
1784     <p>When checking permissions for file related operations, it is possible to check its type if the file already exists as of permission check.
1785     Below table assumes that the variable name for referencing the requested pathname is "path".</p>
1786    
1787     <p>Type of a file can be referenced using variable "path.type", and its value takes one of "file", "directory", "socket", "fifo", "block", "char", "symlink".</p>
1788    
1789     <table border="1">
1790     <tr><td>Possible conditions</td><td>Type of file referenced by variable "path"</td><td>Comparison result</td></tr>
1791     <tr><td>path.type=file</td><td>Regular file</td><td>Matches</td></tr>
1792     <tr><td>path.type!=file</td><td>Other than regular file</td><td>Matches</td></tr>
1793     <tr><td>path.type=directory</td><td>Directory</td><td>Matches</td></tr>
1794     <tr><td>path.type!=directory</td><td>Other than directory</td><td>Matches</td></tr>
1795     <tr><td>path.type=socket</td><td>Unix domain socket</td><td>Matches</td></tr>
1796     <tr><td>path.type!=socket</td><td>Other than Unix domain socket</td><td>Matches</td></tr>
1797     <tr><td>path.type=fifo</td><td>FIFO</td><td>Matches</td></tr>
1798     <tr><td>path.type!=fifo</td><td>Other than FIFO</td><td>Matches</td></tr>
1799     <tr><td>path.type=block</td><td>Block device file</td><td>Matches</td></tr>
1800     <tr><td>path.type!=block</td><td>Other than block device file</td><td>Matches</td></tr>
1801     <tr><td>path.type=char</td><td>Character device file</td><td>Matches</td></tr>
1802     <tr><td>path.type!=char</td><td>Other than character device file</td><td>Matches</td></tr>
1803     <tr><td>path.type=symlink</td><td>Symbolic link</td><td>Matches</td></tr>
1804     <tr><td>path.type!=symlink</td><td>Other than symbolic link</td><td>Matches</td></tr>
1805     </table>
1806    
1807     <h3><a name="file_attributes_comparison">2.9. Conditional expressions which handle file's attributes</a></h3>
1808    
1809     <p>When checking permissions for file related operations, it is possible to check its attributes if the file already exists as of permission check.
1810     Below table assumes that the variable name for referencing the requested pathname is "path".</p>
1811    
1812     <table border="1">
1813     <tr><td>Variable's name</td><td>Comparison method</td><td>Meaning</td></tr>
1814     <tr><td>path.uid</td><td><a href="#integer_comparison">Numeric</a></td><td>Owner ID</td></tr>
1815     <tr><td>path.gid</td><td><a href="#integer_comparison">Numeric</a></td><td>Group ID</td></tr>
1816     <tr><td>path.ino</td><td><a href="#integer_comparison">Numeric</a></td><td>i-node number on the filesystem</td></tr>
1817     <tr><td>path.major</td><td><a href="#integer_comparison">Numeric</a></td><td>Device major number on the filesystem</td></tr>
1818     <tr><td>path.minor</td><td><a href="#integer_comparison">Numeric</a></td><td>Device minor number on the filesystem</td></tr>
1819     <tr><td>path.perm</td><td><a href="#dac_permission_comparison">Permission</a></td><td>DAC permissions</td></tr>
1820     <tr><td>path.type</td><td><a href="#file_type_comparison">File's type</a></td><td>Type of the file</td></tr>
1821     <tr><td>path.dev_major</td><td><a href="#integer_comparison">Numeric</a></td><td>Device major number of the file if path.type=block or path.type=char</td></tr>
1822     <tr><td>path.dev_minor</td><td><a href="#integer_comparison">Numeric</a></td><td>Device minor number of the file if path.type=block or path.type=char</td></tr>
1823     <tr><td>path.fsmagic</td><td><a href="#integer_comparison">Numeric</a></td><td>Magic number of filesystem</td></tr>
1824     </table>
1825    
1826     <p>When checking permissions for file related operations, it is possible to also check its parent directory's attributes.
1827     Below table assumes that the variable name for referencing the requested pathname is "path".</p>
1828    
1829     <table border="1">
1830     <tr><td>Variable's name</td><td>Comparison method</td><td>Meaning</td></tr>
1831     <tr><td>path.parent.uid</td><td><a href="#integer_comparison">Numeric</a></td><td>Owner ID</td></tr>
1832     <tr><td>path.parent.gid</td><td><a href="#integer_comparison">Numeric</a></td><td>Group ID</td></tr>
1833     <tr><td>path.parent.ino</td><td><a href="#integer_comparison">Numeric</a></td><td>i-node number on the filesystem</td></tr>
1834     <tr><td>path.parent.major</td><td><a href="#integer_comparison">Numeric</a></td><td>Device major number on the filesystem</td></tr>
1835     <tr><td>path.parent.minor</td><td><a href="#integer_comparison">Numeric</a></td><td>Device minor number on the filesystem</td></tr>
1836     <tr><td>path.parent.perm</td><td><a href="#dac_permission_comparison">Permission</a></td><td>DAC permissions</td></tr>
1837     <tr><td>path.parent.fsmagic</td><td><a href="#integer_comparison">Numeric</a></td><td>Magic number of filesystem</td></tr>
1838     </table>
1839    
1840     <p>It does not make sense to use path.parent.type path.parent.dev_major path.parent.dev_minor because path.parent is always a directory.</p>
1841    
1842     <p>If path refers a mount point (root of directory entry tree within that partition), path.parent refers the same path rather than referring mount point's parent.</p>
1843    
1844     <h2><a name="syntax_list">3. List of syntaxes sorted by operations</a></h2>
1845    
1846     <table border="1">
1847     <tr><td>Operation</td><td>Meaning</td><td>Available variables</td><td>Content of variable</td><td>Related man pages</td></tr>
1848    
1849     <tr><td rowspan="11">execute</td><td rowspan="11">Execute a program</td><td><a href="#string_comparison">path</a></td><td>Requested program's pathname</td><td rowspan="11">execve(2)</td></tr>
1850     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>
1851     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</tr>
1852     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1853     <tr><td><a href="#string_comparison">exec</a></td><td>Requested program's pathname, but maybe a symbolic link</td></tr>
1854     <tr><td><a href="#integer_comparison">argc</a></td><td>Number of command line arguments passed to this request</td></tr>
1855     <tr><td><a href="#integer_comparison">envc</a></td><td>Number of environment variables arguments</td></tr>
1856     <tr><td><a href="#argv_comparison">argv[$index]</a></td><td>$index'th (0 &lt;= $index &lt; argc) value of command line arguments</td></tr>
1857     <tr><td><a href="#envp_comparison">envp["$name"]</a></td><td>Value of environment variable named $name</td></tr>
1858     <tr><td>handler</td><td>Pathname of a wrapper program for preprocessing (available to only "allow" lines)</td></tr>
1859     <tr><td>transition</td><td>New domainname to transit to if operation was successful (available to only "allow" lines)</td></tr>
1860    
1861     <tr><td rowspan="4">read</td><td rowspan="4">Open a pathname for reading</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">open(2)</td></tr>
1862     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>
1863     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1864     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1865    
1866     <tr><td rowspan="4">write</td><td rowspan="4">Open a pathname for writing</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">open(2)</td></tr>
1867     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>
1868     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1869     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1870    
1871     <tr><td rowspan="4">append</td><td rowspan="4">Open a pathname for appending</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">open(2)</td></tr>
1872     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>
1873     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1874     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1875    
1876     <tr><td rowspan="4">create</td><td rowspan="4">Create a regular file</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">open(2), mknod(2)</td></tr>
1877     <tr><td><a href="#integer_comparison">perm</a></td><td>DAC permissions of a new object referenced by variable "path"</td></tr>
1878     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1879     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1880    
1881     <tr><td rowspan="4">unlink</td><td rowspan="4">Delete a non directory pathname</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">unlink(2)</td></tr>
1882     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>
1883     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1884     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1885    
1886     <tr><td rowspan="4">getattr</td><td rowspan="4">Get attributes of a pathname</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">stat(2)</td></tr>
1887     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>
1888     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1889     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1890    
1891     <tr><td rowspan="4">mkdir</td><td rowspan="4">Create a directory</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">mkdir(2)</td></tr>
1892     <tr><td><a href="#integer_comparison">perm</a></td><td>DAC permissions of a new object referenced by variable "path"</td></tr>
1893     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1894     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1895    
1896     <tr><td rowspan="4">rmdir</td><td rowspan="4">Delete a directory pathname</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">rmdir(2)</td></tr>
1897     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>
1898     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1899     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1900    
1901     <tr><td rowspan="4">mkfifo</td><td rowspan="4">Create a FIFO</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">mknod(2)</td></tr>
1902     <tr><td><a href="#integer_comparison">perm</a></td><td>DAC permissions of a new object referenced by variable "path"</td></tr>
1903     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1904     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1905    
1906     <tr><td rowspan="4">mksock</td><td rowspan="4">Create a Unix domain socket</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">mknod(2)</td></tr>
1907     <tr><td><a href="#integer_comparison">perm</a></td><td>DAC permissions of a new object referenced by variable "path"</td></tr>
1908     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1909     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1910    
1911     <tr><td rowspan="4">truncate</td><td rowspan="4">Truncate a regular file</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">open(2), truncate(2)</td></tr>
1912     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>
1913     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1914     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1915    
1916     <tr><td rowspan="4">symlink</td><td rowspan="4">Create a symbolic link</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="4">symlink(2)</td></tr>
1917     <tr><td><a href="#string_comparison">target</a></td><td>Symbolic link's content</td></tr>
1918     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1919     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1920    
1921     <tr><td rowspan="6">mkblock</td><td rowspan="6">Create a block device file</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="6">mknod(2)</td></tr>
1922     <tr><td><a href="#integer_comparison">perm</a></td><td>DAC permissions of a new object referenced by variable "path"</td></tr>
1923     <tr><td><a href="#integer_comparison">dev_major</a></td><td>Major device number of a new object referenced by variable "path"</td></tr>
1924     <tr><td><a href="#integer_comparison">dev_minor</a></td><td>Minor device number of a new object referenced by variable "path"</td></tr>
1925     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1926     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1927    
1928     <tr><td rowspan="6">mkchar</td><td rowspan="6">Create a character device file</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="6">mknod(2)</td></tr>
1929     <tr><td><a href="#integer_comparison">perm</a></td><td>DAC permissions of a new object referenced by variable "path"</td></tr>
1930     <tr><td><a href="#integer_comparison">dev_major</a></td><td>Major device number of a new object referenced by variable "path"</td></tr>
1931     <tr><td><a href="#integer_comparison">dev_minor</a></td><td>Minor device number of a new object referenced by variable "path"</td></tr>
1932     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1933     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1934    
1935     <tr><td rowspan="6">link</td><td rowspan="6">Create a link</td><td><a href="#string_comparison">old_path</a></td><td>Link source's pathname</td><td rowspan="6">link(2)</td></tr>
1936     <tr><td><a href="#string_comparison">new_path</a></td><td>Link target's pathname</td></tr>
1937     <tr><td><a href="#file_attributes_comparison">old_path.$attribute</a></td><td>Attributes of an object referenced by variable "old_path"</td></tr>
1938     <tr><td><a href="#file_attributes_comparison">old_path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1939     <tr><td><a href="#file_attributes_comparison">new_path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1940     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1941    
1942     <tr><td rowspan="6">rename</td><td rowspan="6">Rename a pathname</td><td><a href="#string_comparison">old_path</a></td><td>Old pathname</td><td rowspan="6">rename(2)</td></tr>
1943     <tr><td><a href="#string_comparison">new_path</a></td><td>New pathname</td></tr>
1944     <tr><td><a href="#file_attributes_comparison">old_path.$attribute</a></td><td>Attributes of an object referenced by variable "old_path"</td></tr>
1945     <tr><td><a href="#file_attributes_comparison">old_path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1946     <tr><td><a href="#file_attributes_comparison">new_path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1947     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1948    
1949     <tr><td rowspan="5">chmod</td><td rowspan="5">Change DAC's permission</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="5">chmod(2)</td></tr>
1950     <tr><td><a href="#integer_comparison">perm</a></td><td>New DAC permissions of an object referenced by variable "path"</td></tr>
1951     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>
1952     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1953     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1954    
1955     <tr><td rowspan="5">chown</td><td rowspan="5">Change DAC's owner ID</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="5">chown(2)</td></tr>
1956     <tr><td><a href="#integer_comparison">uid</a></td><td>New DAC owner ID of an object referenced by variable "path"</td></tr>
1957     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>
1958     <tr><td><a href="#file_attributes_comparison">path.parent.$attribute</a></td><td>Parent directory's attributes</td></tr>
1959     <tr><td><a href="#task_attributes_comparison">task.$attribute</a></td><td>Current thread's attributes</td></tr>
1960    
1961     <tr><td rowspan="5">chgrp</td><td rowspan="5">Change DAC's group ID</td><td><a href="#string_comparison">path</a></td><td>Requested pathname</td><td rowspan="5">chown(2)</td></tr>
1962     <tr><td><a href="#integer_comparison">gid</a></td><td>New DAC group ID of an object referenced by variable "path"</td></tr>
1963     <tr><td><a href="#file_attributes_comparison">path.$attribute</a></td><td>Attributes of an object referenced by variable "path"</td></tr>