| 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 |
|
|
<hr> |
| 16 |
kumaneko |
29 |
<h2><a name="index">Index</a></h2> |
| 17 |
kumaneko |
10 |
|
| 18 |
kumaneko |
15 |
<p><a href="#difference_with_tomoyo">1. Difference with TOMOYO (for existing TOMOYO users)</a></p> |
| 19 |
|
|
|
| 20 |
kumaneko |
10 |
<ul> |
| 21 |
kumaneko |
15 |
<li><a href="#1.1">1.1. About pathnames and management programs</a></li> |
| 22 |
|
|
<li><a href="#1.2">1.2. About policy syntax</a></li> |
| 23 |
kumaneko |
54 |
<li><a href="#1.3">1.3. Why CaitSith was developed</a></li> |
| 24 |
kumaneko |
10 |
</ul> |
| 25 |
|
|
|
| 26 |
kumaneko |
15 |
<p><a href="#how_to_install">2. How to install</a></p> |
| 27 |
|
|
|
| 28 |
|
|
<ul> |
| 29 |
kumaneko |
97 |
<li><a href="#2.1">2.1 How to install LKM-based LSM version</a><br> |
| 30 |
|
|
<ul> |
| 31 |
|
|
<li><a href="#2.1.1">2.1.1. Install dependencies</a></li> |
| 32 |
|
|
<li><a href="#2.1.2">2.1.2. Building the kernel module</a></li> |
| 33 |
kumaneko |
123 |
<li><a href="#2.1.3">2.1.3. Check whether CaitSith kernel module can be loaded or not (Optional)</a> |
| 34 |
|
|
<li><a href="#2.1.4">2.1.4. Install the userspace tools</a></li> |
| 35 |
|
|
<li><a href="#2.1.5">2.1.5. Initializing configuration</a></li> |
| 36 |
|
|
<li><a href="#2.1.6">2.1.6. Configuring your bootloader</a></li> |
| 37 |
|
|
<li><a href="#2.1.7">2.1.7. Rebooting your system</a></li> |
| 38 |
|
|
<li><a href="#2.1.8">2.1.8. How can I disable/uninstall CaitSith?</a></li> |
| 39 |
kumaneko |
15 |
</ul> |
| 40 |
kumaneko |
97 |
</li> |
| 41 |
|
|
<li><a href="#2.2">2.2. How to install fully featured version</a><br> |
| 42 |
|
|
<ul> |
| 43 |
|
|
<li><a href="#2.2.1">2.2.1. Install dependencies</a></li> |
| 44 |
|
|
<li><a href="#2.2.2">2.2.2. Download and patch the kernel</a></li> |
| 45 |
|
|
<li><a href="#2.2.3">2.2.3. Configure the kernel</a></li> |
| 46 |
|
|
<li><a href="#2.2.4">2.2.4. Compile and install the kernel</a></li> |
| 47 |
|
|
<li><a href="#2.2.5">2.2.5. Install the userspace tools</a></li> |
| 48 |
|
|
<li><a href="#2.2.6">2.2.6. Initializing configuration</a></li> |
| 49 |
|
|
<li><a href="#2.2.7">2.2.7. Configuring your bootloader</a></li> |
| 50 |
|
|
<li><a href="#2.2.8">2.2.8. Rebooting your system</a></li> |
| 51 |
|
|
<li><a href="#2.2.9">2.2.9. How can I disable/uninstall CaitSith?</a></li> |
| 52 |
|
|
</ul> |
| 53 |
|
|
</li> |
| 54 |
|
|
</ul> |
| 55 |
kumaneko |
15 |
|
| 56 |
|
|
<p><a href="#how_to_develop_policy">3. How to develop policy</a></p> |
| 57 |
|
|
|
| 58 |
kumaneko |
16 |
<ul> |
| 59 |
|
|
<li><a href="#3.1">3.1. Policy file structure</a></li> |
| 60 |
|
|
<li><a href="#3.2">3.2. Updating policy configuration</a></li> |
| 61 |
|
|
<li><a href="#3.3">3.3. Example of simple access restriction rule</a></li> |
| 62 |
kumaneko |
20 |
<li><a href="#3.4">3.4. Understanding two viewpoints</a></li> |
| 63 |
kumaneko |
112 |
<li><a href="#3.5">3.5. Steps for writing access restriction rules</a></li> |
| 64 |
|
|
<li><a href="#3.6">3.6. Restricting access in various ways</a></li> |
| 65 |
kumaneko |
16 |
</ul> |
| 66 |
|
|
|
| 67 |
kumaneko |
29 |
<p><a href="#condition_list">4. List of conditions</a></p> |
| 68 |
kumaneko |
10 |
|
| 69 |
|
|
<ul> |
| 70 |
kumaneko |
29 |
<li><a href="#4.1">4.1. Using string arguments in conditions</a></li> |
| 71 |
|
|
<li><a href="#4.2">4.2. Using numeric arguments in conditions</a></li> |
| 72 |
|
|
<li><a href="#4.3">4.3. Using process's information in conditions</a></li> |
| 73 |
|
|
<li><a href="#4.4">4.4. Using IP address arguments in conditions</a></li> |
| 74 |
|
|
<li><a href="#4.5">4.5. Using command line arguments in conditions</a></li> |
| 75 |
|
|
<li><a href="#4.6">4.6. Using environment variable arguments in conditions</a></li> |
| 76 |
|
|
<li><a href="#4.7">4.7. Using file's DAC permissions in conditions</a></li> |
| 77 |
|
|
<li><a href="#4.8">4.8. Using handle file's type in conditions</a></li> |
| 78 |
|
|
<li><a href="#4.9">4.9. Using file's attributes in conditions</a></li> |
| 79 |
kumaneko |
10 |
</ul> |
| 80 |
|
|
|
| 81 |
kumaneko |
30 |
<p><a href="#syntax_list">5. List of syntaxes</a></p> |
| 82 |
kumaneko |
29 |
|
| 83 |
kumaneko |
30 |
<ul> |
| 84 |
|
|
<li><a href="#5.1">5.1. execute</a></li> |
| 85 |
|
|
<li><a href="#5.2">5.2. read</a></li> |
| 86 |
|
|
<li><a href="#5.3">5.3. write</a></li> |
| 87 |
|
|
<li><a href="#5.4">5.4. append</a></li> |
| 88 |
|
|
<li><a href="#5.5">5.5. create</a></li> |
| 89 |
|
|
<li><a href="#5.6">5.6. unlink</a></li> |
| 90 |
|
|
<li><a href="#5.7">5.7. getattr</a></li> |
| 91 |
|
|
<li><a href="#5.8">5.8. mkdir</a></li> |
| 92 |
|
|
<li><a href="#5.9">5.9. rmdir</a></li> |
| 93 |
|
|
<li><a href="#5.10">5.10. mkfifo</a></li> |
| 94 |
|
|
<li><a href="#5.11">5.11. mksock</a></li> |
| 95 |
|
|
<li><a href="#5.12">5.12. truncate</a></li> |
| 96 |
|
|
<li><a href="#5.13">5.13. symlink</a></li> |
| 97 |
|
|
<li><a href="#5.14">5.14. mkblock</a></li> |
| 98 |
|
|
<li><a href="#5.15">5.15. mkchar</a></li> |
| 99 |
|
|
<li><a href="#5.16">5.16. link</a></li> |
| 100 |
|
|
<li><a href="#5.17">5.17. rename</a></li> |
| 101 |
|
|
<li><a href="#5.18">5.18. chmod</a></li> |
| 102 |
|
|
<li><a href="#5.19">5.19. chown</a></li> |
| 103 |
|
|
<li><a href="#5.20">5.20. chgrp</a></li> |
| 104 |
|
|
<li><a href="#5.21">5.21. ioctl</a></li> |
| 105 |
|
|
<li><a href="#5.22">5.22. chroot</a></li> |
| 106 |
|
|
<li><a href="#5.23">5.23. mount</a></li> |
| 107 |
|
|
<li><a href="#5.24">5.24. unmount</a></li> |
| 108 |
|
|
<li><a href="#5.25">5.25. pivot_root</a></li> |
| 109 |
|
|
<li><a href="#5.26">5.26. inet_stream_bind</a></li> |
| 110 |
|
|
<li><a href="#5.27">5.27. inet_stream_listen</a></li> |
| 111 |
|
|
<li><a href="#5.28">5.28. inet_stream_connect</a></li> |
| 112 |
|
|
<li><a href="#5.29">5.29. inet_stream_accept</a></li> |
| 113 |
|
|
<li><a href="#5.30">5.30. inet_dgram_bind</a></li> |
| 114 |
|
|
<li><a href="#5.31">5.31. inet_dgram_send</a></li> |
| 115 |
|
|
<li><a href="#5.32">5.32. inet_dgram_recv</a></li> |
| 116 |
|
|
<li><a href="#5.33">5.33. inet_raw_bind</a></li> |
| 117 |
|
|
<li><a href="#5.34">5.34. inet_raw_send</a></li> |
| 118 |
|
|
<li><a href="#5.35">5.35. inet_raw_recv</a></li> |
| 119 |
|
|
<li><a href="#5.36">5.36. unix_stream_bind</a></li> |
| 120 |
|
|
<li><a href="#5.37">5.37. unix_stream_listen</a></li> |
| 121 |
|
|
<li><a href="#5.38">5.38. unix_stream_connect</a></li> |
| 122 |
|
|
<li><a href="#5.39">5.39. unix_stream_accept</a></li> |
| 123 |
|
|
<li><a href="#5.40">5.40. unix_dgram_bind</a></li> |
| 124 |
|
|
<li><a href="#5.41">5.41. unix_dgram_send</a></li> |
| 125 |
|
|
<li><a href="#5.42">5.42. unix_dgram_recv</a></li> |
| 126 |
|
|
<li><a href="#5.43">5.43. unix_seqpacket_bind</a></li> |
| 127 |
|
|
<li><a href="#5.44">5.44. unix_seqpacket_listen</a></li> |
| 128 |
|
|
<li><a href="#5.45">5.45. unix_seqpacket_connect</a></li> |
| 129 |
|
|
<li><a href="#5.46">5.46. unix_seqpacket_accept</a></li> |
| 130 |
|
|
<li><a href="#5.47">5.47. ptrace</a></li> |
| 131 |
|
|
<li><a href="#5.48">5.48. signal</a></li> |
| 132 |
|
|
<li><a href="#5.49">5.49. environ</a></li> |
| 133 |
|
|
<li><a href="#5.50">5.50. modify_policy</a></li> |
| 134 |
|
|
<li><a href="#5.51">5.51. use_netlink_socket</a></li> |
| 135 |
|
|
<li><a href="#5.52">5.52. use_packet_socket</a></li> |
| 136 |
|
|
<li><a href="#5.53">5.53. use_reboot</a></li> |
| 137 |
|
|
<li><a href="#5.54">5.54. use_vhangup</a></li> |
| 138 |
|
|
<li><a href="#5.55">5.55. set_time</a></li> |
| 139 |
|
|
<li><a href="#5.56">5.56. set_priority</a></li> |
| 140 |
|
|
<li><a href="#5.57">5.57. set_hostname</a></li> |
| 141 |
|
|
<li><a href="#5.58">5.58. use_kernel_module</a></li> |
| 142 |
|
|
<li><a href="#5.59">5.59. use_new_kernel</a></li> |
| 143 |
|
|
<li><a href="#5.60">5.60. manual_domain_transition</a></li> |
| 144 |
|
|
<li><a href="#5.61">5.61. auto_domain_transition</a></li> |
| 145 |
|
|
</ul> |
| 146 |
|
|
|
| 147 |
|
|
<p><a href="#advanced_usage">6. Advanced usage</a></p> |
| 148 |
kumaneko |
112 |
<ul> |
| 149 |
|
|
<li><a href="#6.1">6.1. Controlling domain transition</a></li> |
| 150 |
|
|
<li><a href="#6.2">6.2. Using execute handler</a></li> |
| 151 |
|
|
</ul> |
| 152 |
kumaneko |
30 |
|
| 153 |
kumaneko |
10 |
<hr> |
| 154 |
|
|
<h2><a name="difference_with_tomoyo">1. Difference with TOMOYO (for existing TOMOYO users)</a></h2> |
| 155 |
|
|
|
| 156 |
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> |
| 157 |
kumaneko |
10 |
|
| 158 |
kumaneko |
30 |
<hr> |
| 159 |
kumaneko |
15 |
<h3><a name="1.1">1.1. About pathnames and management programs</a></h3> |
| 160 |
kumaneko |
10 |
|
| 161 |
kumaneko |
22 |
<p><code>/proc/ccs/domain_policy</code>, <code>/proc/ccs/exception_policy</code>, <code>/proc/ccs/profile</code>, <code>/proc/ccs/manager</code> and <code>/proc/ccs/stat</code> have been aggregated into <code>/proc/caitsith/policy</code>.</p> |
| 162 |
kumaneko |
10 |
|
| 163 |
kumaneko |
22 |
<p><code>/etc/ccs/policy/current/domain_policy.conf</code>, <code>/etc/ccs/policy/current/exception_policy.conf</code>, <code>/etc/ccs/policy/current/profile.conf</code>, <code>/etc/ccs/policy/current/manager.conf</code> and <code>/etc/ccs/policy/current/stat.conf</code> have been aggregated into <code>/etc/caitsith/policy/current</code>.</p> |
| 164 |
kumaneko |
10 |
|
| 165 |
kumaneko |
22 |
<p>Built-in policy files which are located under kernel source directory as <code>security/ccsecurity/policy/domain_policy.conf</code>, <code>security/ccsecurity/policy/exception_policy.conf</code>, <code>security/ccsecurity/policy/profile.conf</code>, <code>security/ccsecurity/policy/manager.conf</code> and <code>security/ccsecurity/policy/stat.conf</code> have been aggregated into <code>security/caitsith/policy/policy.conf</code>.</p> |
| 166 |
kumaneko |
10 |
|
| 167 |
kumaneko |
124 |
<p>Only <code>/sbin/caitsith-init</code>, <code>/usr/sbin/caitsith-auditd</code>, <code>/usr/sbin/caitsith-loadpolicy</code>, <code>/usr/sbin/caitsith-notifyd</code>, <code>/usr/sbin/caitsith-pstree</code>, <code>/usr/sbin/caitsith-queryd</code>, <code>/usr/sbin/caitsith-savepolicy</code>, <code>/usr/lib64/caitsith/audit-exec-param</code>, <code>/usr/lib64/caitsith/caitsith-agent</code> and <code>/usr/lib64/caitsith/init_policy</code> are provided for managing policy. (In other words, programs such as <code>/usr/sbin/ccs-editpolicy</code> and <code>/usr/sbin/ccs-setprofile</code> have been removed.)</p> |
| 168 |
kumaneko |
10 |
|
| 169 |
kumaneko |
28 |
<p>Command line arguments for specifying type of policy to load/save have been removed from <code>/usr/sbin/caitsith-loadpolicy</code> and <code>/usr/sbin/caitsith-savepolicy</code>.</p> |
| 170 |
kumaneko |
10 |
|
| 171 |
kumaneko |
124 |
<p>Command line arguments for specifying profile type have been removed from <code>/usr/lib64/caitsith/init_policy</code>.</p> |
| 172 |
kumaneko |
10 |
|
| 173 |
kumaneko |
30 |
<hr> |
| 174 |
kumaneko |
15 |
<h3><a name="1.2">1.2. About policy syntax</a></h3> |
| 175 |
kumaneko |
10 |
|
| 176 |
kumaneko |
28 |
<p>Policy syntax has been drastically changed. TOMOYO Linux uses 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, CaitSith uses operation as a key for checking permission. In other words, CaitSith'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 CaitSith, 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> |
| 177 |
kumaneko |
10 |
|
| 178 |
|
|
<p>Process's domainname representation has changed from space delimited multiple words (e.g. "<kernel> /sbin/init /etc/rc.d/rc.sysinit") to a single word (e.g. "/sbin/init").</p> |
| 179 |
|
|
|
| 180 |
|
|
<p>Domain transitions no longer happen unless explicitly specified by policy.</p> |
| 181 |
|
|
|
| 182 |
|
|
<p>Distinction of disabled/learning/permissive/enforcing mode has been removed.</p> |
| 183 |
|
|
|
| 184 |
|
|
<p>"path_group" keyword has been renamed to "string_group", and "address_group" keyword has been renamed to "ip_group".</p> |
| 185 |
|
|
|
| 186 |
|
|
<p>Representation of \ character has been changed from \\ to \134.</p> |
| 187 |
|
|
|
| 188 |
kumaneko |
28 |
<p>Distinction between directory's pathname and non-directory's pathname has been removed by removing trailing / character from pathname.</p> |
| 189 |
kumaneko |
10 |
|
| 190 |
|
|
<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> |
| 191 |
|
|
|
| 192 |
|
|
<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> |
| 193 |
|
|
|
| 194 |
|
|
<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> |
| 195 |
|
|
|
| 196 |
|
|
<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> |
| 197 |
|
|
|
| 198 |
|
|
<p>Restriction granularity for ptrace operation has changed from boolean (i.e. "capability SYS_PTRACE") to command number + domainname.</p> |
| 199 |
|
|
|
| 200 |
|
|
<p>Restriction granularity for environment variables has changed from name only to both name and values.</p> |
| 201 |
|
|
|
| 202 |
|
|
<p>Several variables for referencing file's attributes have been added.</p> |
| 203 |
|
|
|
| 204 |
|
|
<p>Local port reserve functionality (i.e. "deny_autobind" keyword) has been removed.</p> |
| 205 |
|
|
|
| 206 |
kumaneko |
30 |
<hr> |
| 207 |
kumaneko |
54 |
<h3><a name="1.3">1.3. Why CaitSith was developed?</a></h3> |
| 208 |
|
|
|
| 209 |
|
|
<p>Presentation slides which I used at LinuxCon North America 2012 that explain why CaitSith was developed are available.</p> |
| 210 |
|
|
|
| 211 |
|
|
<ul> |
| 212 |
|
|
<li><a href="http://I-love.SAKURA.ne.jp/tomoyo/CaitSith-en.pdf">English</a></li> |
| 213 |
|
|
<li><a href="http://I-love.SAKURA.ne.jp/tomoyo/CaitSith-ja.pdf">Japanese</a></li> |
| 214 |
|
|
</ul> |
| 215 |
|
|
|
| 216 |
|
|
<hr> |
| 217 |
kumaneko |
10 |
<h2><a name="how_to_install">2. How to install</a></h2> |
| 218 |
|
|
|
| 219 |
kumaneko |
97 |
<p>CaitSith supports Linux kernel 2.6.27 and later.</p> |
| 220 |
kumaneko |
10 |
|
| 221 |
kumaneko |
97 |
<p>There are two ways to compile CaitSith kernel module. Please choose one, but please accept that you need to choose <a href="#2.2">fully featured version</a> if you can't choose <a href="#2.1">LKM-based LSM version</a>.</p> |
| 222 |
|
|
|
| 223 |
|
|
<table border="1"> |
| 224 |
|
|
<tr><td></td><td><a href="#2.1">LKM-based LSM version</a></td><td><a href="#2.2">fully featured version</a></td></tr> |
| 225 |
|
|
<tr><td>Advantages</td><td>No need to replace kernel package.</td><td>Complete functionality and syntax are supported.</td></tr> |
| 226 |
|
|
<tr><td>Disadvantages</td><td>Supported functionality and syntax depend on kernel's version and kernel's configuration options.</td><td>Need to replace kernel package.</td></tr> |
| 227 |
|
|
<tr><td>Dependency</td><td> |
| 228 |
|
|
Kernel package must be built with below configuration options.<br> |
| 229 |
|
|
<ul> |
| 230 |
|
|
<li>CONFIG_SECURITY=y</li> |
| 231 |
|
|
<li>CONFIG_KALLSYMS=y</li> |
| 232 |
|
|
<li>CONFIG_PROC_FS=y</li> |
| 233 |
|
|
<li>CONFIG_MODULES=y</li> |
| 234 |
|
|
</ul> |
| 235 |
|
|
The kernel package should be built with below configuration options in addition to above configuration options for supporting further functionality.<br> |
| 236 |
|
|
<ul> |
| 237 |
|
|
<li>CONFIG_SECURITY_NETWORK=y</li> |
| 238 |
|
|
<li>CONFIG_SECURITY_PATH=y</li> |
| 239 |
|
|
</ul> |
| 240 |
|
|
Currently known to work on x86_32 x86_64 SH and ARM. Other architectures are not tested yet. |
| 241 |
|
|
</td><td> |
| 242 |
|
|
Requires patching against kernel's source and rebuilding from source. |
| 243 |
|
|
</td></tr> |
| 244 |
|
|
</table> |
| 245 |
|
|
|
| 246 |
kumaneko |
30 |
<hr> |
| 247 |
kumaneko |
97 |
<h2><a name="2.1">2.1. How to install LKM-based LSM version</a></h2> |
| 248 |
kumaneko |
10 |
|
| 249 |
kumaneko |
97 |
<hr> |
| 250 |
|
|
<h3><a name="2.1.1">2.1.1. Install dependencies</a></h3> |
| 251 |
|
|
|
| 252 |
|
|
<p>These packages are required for compiling the kernel module and the userspace tools:</p> |
| 253 |
|
|
|
| 254 |
|
|
<ul> |
| 255 |
|
|
<li><strong>wget</strong>: to download sources</li> |
| 256 |
|
|
<li><strong>gcc</strong>: to build the module and tools</li> |
| 257 |
|
|
<li><strong>make</strong>: to build the module and tools</li> |
| 258 |
|
|
<li><strong>ncurses-devel</strong> or <strong>libncurses-dev</strong>: to build the tools</li> |
| 259 |
|
|
</ul> |
| 260 |
|
|
|
| 261 |
|
|
<p>These can be installed with the following commands:</p> |
| 262 |
|
|
|
| 263 |
|
|
<p><strong>RedHat distributions</strong></p> |
| 264 |
|
|
<pre class="command"> |
| 265 |
|
|
# yum -y install wget gcc make ncurses-devel |
| 266 |
|
|
</pre> |
| 267 |
|
|
<p><strong>Debian distributions</strong></p> |
| 268 |
|
|
<pre class="command"> |
| 269 |
|
|
# apt-get -y install wget gcc make libncurses-dev |
| 270 |
|
|
</pre> |
| 271 |
|
|
<p><strong>SUSE distributions</strong></p> |
| 272 |
|
|
<pre class="command"> |
| 273 |
|
|
# yast -i wget gcc make ncurses-devel |
| 274 |
|
|
</pre> |
| 275 |
|
|
|
| 276 |
|
|
<hr> |
| 277 |
|
|
<h3><a name="2.1.2">2.1.2. Building the kernel module</a></h3> |
| 278 |
|
|
|
| 279 |
|
|
<p>Install the kernel development package and go to the directory that it has installed into:</p> |
| 280 |
|
|
|
| 281 |
|
|
<p><strong>RedHat distributions</strong></p> |
| 282 |
|
|
<pre class="command"> |
| 283 |
|
|
# VERSION=$(uname -r) |
| 284 |
|
|
# yum -y install kernel-devel-${VERSION} |
| 285 |
|
|
# cd /usr/src/kernels/${VERSION}*/ |
| 286 |
|
|
</pre> |
| 287 |
|
|
|
| 288 |
|
|
<p><strong>Debian distributions</strong></p> |
| 289 |
|
|
<pre class="command"> |
| 290 |
|
|
# VERSION=$(uname -r) |
| 291 |
|
|
# apt-get -y install linux-headers-${VERSION} |
| 292 |
|
|
# cd /usr/src/linux-headers-${VERSION}/ |
| 293 |
|
|
</pre> |
| 294 |
|
|
|
| 295 |
|
|
<p><strong>SUSE distributions</strong></p> |
| 296 |
|
|
<pre class="command"> |
| 297 |
|
|
# VERSION=$(uname -r) |
| 298 |
|
|
# yast -i kernel-devel |
| 299 |
|
|
# cd /lib/modules/${VERSION}/build/ |
| 300 |
|
|
</pre> |
| 301 |
|
|
|
| 302 |
|
|
<p>Run the following commands in order to extract source code of CaitSith:</p> |
| 303 |
|
|
|
| 304 |
|
|
<pre class="command"> |
| 305 |
kumaneko |
128 |
# wget -O caitsith-patch-0.1-20140915.tar.gz 'http://sourceforge.jp/frs/redir.php?m=jaist&f=/caitsith/55464/caitsith-patch-0.1-20140915.tar.gz' |
| 306 |
|
|
# wget -O caitsith-patch-0.1-20140915.tar.gz.asc 'http://sourceforge.jp/frs/redir.php?m=jaist&f=/caitsith/55464/caitsith-patch-0.1-20140915.tar.gz.asc' |
| 307 |
kumaneko |
97 |
# wget http://I-love.SAKURA.ne.jp/kumaneko-key |
| 308 |
|
|
# gpg --import kumaneko-key |
| 309 |
kumaneko |
128 |
# gpg caitsith-patch-0.1-20140915.tar.gz.asc |
| 310 |
|
|
# tar -zxf caitsith-patch-0.1-20140915.tar.gz |
| 311 |
kumaneko |
97 |
</pre> |
| 312 |
|
|
|
| 313 |
kumaneko |
123 |
<p>On systemd environments, <code>/usr/lib/systemd/systemd</code> will be executed rather than <code>/sbin/init</code>. If your system is using systemd, please edit CONFIG_CAITSITH_ACTIVATION_TRIGGER line in caitsith/config.h like below:</p> |
| 314 |
kumaneko |
97 |
|
| 315 |
kumaneko |
123 |
<p>Before:</p> |
| 316 |
|
|
<pre>#define CONFIG_CAITSITH_ACTIVATION_TRIGGER "/sbin/init" |
| 317 |
|
|
</pre> |
| 318 |
|
|
|
| 319 |
|
|
<p>After:</p> |
| 320 |
|
|
<pre>#define CONFIG_CAITSITH_ACTIVATION_TRIGGER "/usr/lib/systemd/systemd" |
| 321 |
|
|
</pre> |
| 322 |
|
|
|
| 323 |
|
|
<p>You can override CONFIG_CAITSITH_ACTIVATION_TRIGGER setting via CS_trigger= kernel boot option (e.g. CS_trigger=<code>/usr/lib/systemd/systemd</code>).</p> |
| 324 |
|
|
|
| 325 |
|
|
<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. <code>/etc/caitsith/</code> directory). You will need to rebuild the CaitSIth kernel module whenever updating the former, but allows you to load policy without using userspace policy loader (e.g. <code>/sbin/caitsith-init</code>). The latter is loaded by executing userspace policy loader when the access control by CaitSith is about to be activated (e.g. when <code>/sbin/init</code> or <code>/usr/lib/systemd/systemd</code>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> |
| 326 |
|
|
|
| 327 |
kumaneko |
97 |
<p>If you want to activate CaitSith as soon as the kernel module is loaded, you can define CONFIG_CAITSITH_OMIT_USERSPACE_LOADER line in caitsith/config.h like below. (But be sure to supply built-in policy configuration located at caitsith/policy/ directory if you define CONFIG_CAITSITH_OMIT_USERSPACE_LOADER, or the system will panic as soon as the kernel module is loaded.):</p> |
| 328 |
|
|
|
| 329 |
|
|
<p>Before:</p> |
| 330 |
|
|
<pre>//#define CONFIG_CAITSITH_OMIT_USERSPACE_LOADER |
| 331 |
|
|
</pre> |
| 332 |
|
|
|
| 333 |
|
|
<p>After:</p> |
| 334 |
|
|
<pre |
| 335 |
|
|
>#define CONFIG_CAITSITH_OMIT_USERSPACE_LOADER |
| 336 |
|
|
</pre> |
| 337 |
|
|
|
| 338 |
|
|
<p>Run the following commands in order to build and install CaitSith:</p> |
| 339 |
|
|
|
| 340 |
|
|
<pre class="command"> |
| 341 |
|
|
# make SUBDIRS=$PWD/caitsith modules |
| 342 |
|
|
# make SUBDIRS=$PWD/caitsith modules_install |
| 343 |
|
|
# depmod ${VERSION} |
| 344 |
|
|
</pre> |
| 345 |
|
|
|
| 346 |
|
|
<p>If you encountered one of errors listed below, you cannot use CaitSith for your kernel. Please jump to <a href="#2.2">2.2. How to install fully featured version</a>. |
| 347 |
|
|
For other errors, please contact the author ( penguin-kernel@I-love.SAKURA.ne.jp ).</p> |
| 348 |
|
|
|
| 349 |
|
|
<pre class="output"> |
| 350 |
|
|
You must choose CONFIG_SECURITY=y for building this module. |
| 351 |
|
|
You must choose CONFIG_KALLSYMS=y for building this module. |
| 352 |
|
|
You must choose CONFIG_PROC_FS=y for building this module. |
| 353 |
|
|
You must choose CONFIG_MODULES=y for building this module. |
| 354 |
|
|
</pre> |
| 355 |
|
|
|
| 356 |
kumaneko |
123 |
<h3><a name="2.1.3">2.1.3. Check whether CaitSith kernel module can be loaded or not (Optional)</a></h3> |
| 357 |
|
|
|
| 358 |
kumaneko |
97 |
<p>Since registering CaitSith module depends on your environment, you might encounter problems. Therefore, I recommend you to confirm that CaitSith module can be loaded at this step.</p> |
| 359 |
|
|
|
| 360 |
|
|
<p>Run the following commands in order to try to load caitsith_test.ko module:</p> |
| 361 |
|
|
|
| 362 |
|
|
<pre class="command"> |
| 363 |
|
|
# dmesg -c > /dev/null |
| 364 |
|
|
# modprobe caitsith_test |
| 365 |
|
|
# dmesg |
| 366 |
|
|
</pre> |
| 367 |
|
|
<pre class="output"> |
| 368 |
kumaneko |
124 |
caitsith_test: module verification failed: signature and/or required key missing - tainting kernel |
| 369 |
|
|
security_ops=ffffffff81df6c80 |
| 370 |
|
|
find_task_by_vpid=ffffffff810821a0 |
| 371 |
|
|
find_task_by_pid_ns=ffffffff81082170 |
| 372 |
|
|
d_absolute_path=ffffffff811c8f10 |
| 373 |
kumaneko |
97 |
All dependent symbols have been guessed. |
| 374 |
|
|
Please verify these addresses using System.map for this kernel (e.g. /boot/System.map-`uname -r` ). |
| 375 |
|
|
If these addresses are correct, you can try loading CaitSith module on this kernel. |
| 376 |
|
|
</pre> |
| 377 |
|
|
|
| 378 |
|
|
<p>If caitsith_test.ko was loaded successfully, guessed addresses like above are printed. Therefore, please compare guessed addresses from caitsith_test.ko and actual addresses from System.map file. (Number of symbols and addresses printed depends on your environment.):</p> |
| 379 |
|
|
|
| 380 |
|
|
<pre class="command"> |
| 381 |
kumaneko |
124 |
# for i in ffffffff81df6c80 ffffffff810821a0 ffffffff81082170 ffffffff811c8f10; do grep $i /boot/System.map-${VERSION}; done |
| 382 |
kumaneko |
97 |
</pre> |
| 383 |
|
|
<pre class="output"> |
| 384 |
kumaneko |
124 |
ffffffff81df6c80 b security_ops |
| 385 |
|
|
ffffffff810821a0 T find_task_by_vpid |
| 386 |
|
|
ffffffff81082170 T find_task_by_pid_ns |
| 387 |
|
|
ffffffff811c8f10 T d_absolute_path |
| 388 |
kumaneko |
97 |
</pre> |
| 389 |
|
|
|
| 390 |
|
|
<p>Please proceed if these addresses are correct. Otherwise, please contact the author since CaitSith module will not work even if you continue.</p> |
| 391 |
|
|
|
| 392 |
|
|
<p>If caitsith_test.ko was not loaded successfully, error messages like below are printed. In this case, please contact the author since CaitSith module will not work even if you continue:</p> |
| 393 |
|
|
|
| 394 |
|
|
<pre class="command"> |
| 395 |
|
|
# dmesg -c > /dev/null |
| 396 |
|
|
# modprobe caitsith_test |
| 397 |
|
|
</pre> |
| 398 |
|
|
<pre class="output">FATAL: Error inserting caitsith_test (/lib/modules/2.6.32/extra/caitsith_test.ko): Invalid argument |
| 399 |
|
|
</pre> |
| 400 |
|
|
<pre class="command"> |
| 401 |
|
|
# dmesg |
| 402 |
|
|
</pre> |
| 403 |
|
|
<pre class="output"> |
| 404 |
|
|
Sorry, I couldn't guess dependent symbols. |
| 405 |
|
|
I need some changes for supporting your environment. |
| 406 |
|
|
Please contact the author. |
| 407 |
|
|
</pre> |
| 408 |
|
|
|
| 409 |
|
|
<hr> |
| 410 |
kumaneko |
123 |
<h3><a name="2.1.4">2.1.4. Install the userspace tools</a></h3> |
| 411 |
kumaneko |
97 |
|
| 412 |
kumaneko |
124 |
<p>Make sure the dependencies described above have been installed. Compile and install the tools with the following commands. (Please use USRLIBDIR=<code>/usr/lib</code> or USRLIBDIR=<code>/usr/lib32</code> if needed):</p> |
| 413 |
kumaneko |
97 |
|
| 414 |
|
|
<pre class="command"> |
| 415 |
kumaneko |
115 |
$ wget -O caitsith-tools-0.1-20140105.tar.gz 'http://sourceforge.jp/frs/redir.php?m=jaist&f=/caitsith/55465/caitsith-tools-0.1-20140105.tar.gz' |
| 416 |
|
|
$ wget -O caitsith-tools-0.1-20140105.tar.gz.asc 'http://sourceforge.jp/frs/redir.php?m=jaist&f=/caitsith/55465/caitsith-tools-0.1-20140105.tar.gz.asc' |
| 417 |
|
|
$ gpg caitsith-tools-0.1-20140105.tar.gz.asc |
| 418 |
|
|
$ tar -zxf caitsith-tools-0.1-20140105.tar.gz |
| 419 |
kumaneko |
97 |
$ cd caitsith-tools/ |
| 420 |
kumaneko |
124 |
$ make -s USRLIBDIR=/usr/lib64 |
| 421 |
kumaneko |
97 |
$ su |
| 422 |
kumaneko |
124 |
# make -s USRLIBDIR=/usr/lib64 install |
| 423 |
kumaneko |
97 |
</pre> |
| 424 |
|
|
|
| 425 |
|
|
<p>Programs listed below are main userspace tools used for administrating CaitSith.</p> |
| 426 |
|
|
|
| 427 |
|
|
<ul> |
| 428 |
|
|
<li><code>/sbin/caitsith-init</code></li> |
| 429 |
|
|
<li><code>/usr/sbin/caitsith-auditd</code></li> |
| 430 |
|
|
<li><code>/usr/sbin/caitsith-loadpolicy</code></li> |
| 431 |
|
|
<li><code>/usr/sbin/caitsith-notifyd</code></li> |
| 432 |
|
|
<li><code>/usr/sbin/caitsith-pstree</code></li> |
| 433 |
|
|
<li><code>/usr/sbin/caitsith-queryd</code></li> |
| 434 |
|
|
<li><code>/usr/sbin/caitsith-savepolicy</code></li> |
| 435 |
|
|
</ul> |
| 436 |
|
|
|
| 437 |
|
|
<p>FYI: If your system has rpm-build package installed, you can make a tools RPM package with the following commands:</p> |
| 438 |
|
|
|
| 439 |
|
|
<pre class="command"> |
| 440 |
kumaneko |
115 |
$ rpmbuild -tb caitsith-tools-0.1-20140105.tar.gz |
| 441 |
kumaneko |
97 |
</pre> |
| 442 |
|
|
|
| 443 |
|
|
<hr> |
| 444 |
kumaneko |
123 |
<h3><a name="2.1.5">2.1.5. Initializing configuration</a></h3> |
| 445 |
kumaneko |
97 |
|
| 446 |
kumaneko |
124 |
<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 stored in the "<code>/etc/caitsith/</code>" directory.</p> |
| 447 |
kumaneko |
97 |
|
| 448 |
kumaneko |
124 |
<p>Run the following command as root user to initialize. (Please use <code>/usr/lib/caitsith/init_policy</code> or <code>/usr/lib32/caitsith/init_policy</code> if needed):</p> |
| 449 |
kumaneko |
97 |
|
| 450 |
|
|
<pre class="command"> |
| 451 |
kumaneko |
124 |
# /usr/lib64/caitsith/init_policy |
| 452 |
kumaneko |
97 |
</pre> |
| 453 |
|
|
<pre class="output"> |
| 454 |
|
|
Creating policy directory... OK |
| 455 |
|
|
Creating configuration directory... OK |
| 456 |
|
|
Creating default policy... OK. |
| 457 |
|
|
Creating module loader... OK. |
| 458 |
|
|
Creating configuration file for caitsith-auditd ... OK. |
| 459 |
|
|
Creating configuration file for caitsith-notifyd ... OK. |
| 460 |
|
|
</pre> |
| 461 |
|
|
|
| 462 |
|
|
<p>CaitSith can generate audit logs and allows you to read them via <code>/proc/caitsith/audit</code> interface. To save <code>/proc/caitsith/audit</code> automatically, start <code>/usr/sbin/caitsith-auditd</code> from somewhere. Default setting (specified in <code>/etc/caitsith/tools/auditd.conf</code>) sends access allowed logs to <code>/dev/null</code>, access unmatched logs to <code>/var/log/caitsith/unmatched.log</code>, access denied logs to <code>/var/log/caitsith/denied.log</code>. (The meaning and example of allowed/unmatched/denied will be explained in <a href="#3.3">Example of simple access restriction rule</a>.)</p> |
| 463 |
|
|
|
| 464 |
|
|
<p>CaitSith can ask for your decision about access requests which will be denied unless you grant them via <code>/proc/caitsith/query</code> interface. To notify immediately the occurrence of access requests which CaitSith is about to deny, start <code>/usr/sbin/caitsith-notifyd</code> from somewhere. Default setting (specified in <code>/etc/caitsith/tools/notifyd.conf</code>) sends mails to root@localhost with subject "Notification from caitsith-notifyd" up to once per a minute.</p> |
| 465 |
|
|
|
| 466 |
|
|
<p>Below example launches <code>/usr/sbin/caitsith-auditd</code> and <code>/usr/sbin/caitsith-notifyd</code> from <code>/etc/rc.local</code> script:</p> |
| 467 |
|
|
|
| 468 |
|
|
<pre> |
| 469 |
kumaneko |
124 |
#!/bin/bash |
| 470 |
|
|
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES |
| 471 |
kumaneko |
97 |
# |
| 472 |
kumaneko |
124 |
# It is highly advisable to create own systemd services or udev rules |
| 473 |
|
|
# to run scripts during boot instead of using this file. |
| 474 |
|
|
# |
| 475 |
|
|
# In constrast to previous versions due to parallel execution during boot |
| 476 |
|
|
# this script will NOT be run after all other services. |
| 477 |
|
|
# |
| 478 |
|
|
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure |
| 479 |
|
|
# that this script will be executed during boot. |
| 480 |
kumaneko |
97 |
|
| 481 |
|
|
touch /var/lock/subsys/local |
| 482 |
|
|
/usr/sbin/caitsith-auditd |
| 483 |
|
|
/usr/sbin/caitsith-notifyd |
| 484 |
|
|
</pre> |
| 485 |
|
|
|
| 486 |
|
|
<hr> |
| 487 |
kumaneko |
123 |
<h3><a name="2.1.6">2.1.6. Configuring your bootloader</a></h3> |
| 488 |
kumaneko |
97 |
|
| 489 |
kumaneko |
123 |
<p>On systems where use of init= kernel boot option causes boot failures (e.g. RHEL 7), you need to choose <a href="#2.1.6.1">Loading CaitSith's module from initramfs</a>. On systems where it does not cause boot failures (e.g. RHEL 6), you can choose <a href="#2.1.6.2">Loading CaitSith's module from the init process</a>.</p> |
| 490 |
kumaneko |
97 |
|
| 491 |
kumaneko |
123 |
<h4><a name="2.1.6.1">2.1.6.1. Loading CaitSith's module from initramfs</a></h4> |
| 492 |
|
|
|
| 493 |
|
|
<p>This section assumes that you are using dracut and GRUB2.</p> |
| 494 |
|
|
|
| 495 |
|
|
<p>Create /etc/dracut.conf.d/caitsith.conf like below and rebuild the initramfs:</p> |
| 496 |
|
|
|
| 497 |
|
|
<pre class="command"> |
| 498 |
|
|
# echo 'add_drivers+=" caitsith "' > /etc/dracut.conf.d/caitsith.conf |
| 499 |
|
|
# dracut -f |
| 500 |
kumaneko |
97 |
</pre> |
| 501 |
|
|
|
| 502 |
kumaneko |
123 |
<p>Edit your bootloader to add "rd.driver.pre=caitsith" to the kernel boot options. An example is shown below:</p> |
| 503 |
kumaneko |
97 |
|
| 504 |
kumaneko |
123 |
<p>Before:</p> |
| 505 |
|
|
<pre>linux16 /boot/vmlinuz-3.10.0-123.1.2.el7.x86_64 ro root=LABEL=/ |
| 506 |
|
|
</pre> |
| 507 |
|
|
|
| 508 |
|
|
<p>After:</p> |
| 509 |
|
|
<pre>linux16 /boot/vmlinuz-3.10.0-123.1.2.el7.x86_64 ro root=LABEL=/ rd.driver.pre=caitsith |
| 510 |
|
|
</pre> |
| 511 |
|
|
|
| 512 |
|
|
<p>It is recommended that you also modify GRUB_CMDLINE_LINUX line in <code>/etc/default/grub</code> file like below in case you update kernel packages in the future:</p> |
| 513 |
|
|
|
| 514 |
|
|
<p>Before:</p> |
| 515 |
kumaneko |
97 |
<pre> |
| 516 |
kumaneko |
123 |
GRUB_CMDLINE_LINUX="vconsole.keymap=us crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet" |
| 517 |
kumaneko |
97 |
</pre> |
| 518 |
|
|
|
| 519 |
kumaneko |
123 |
<p>After:</p> |
| 520 |
|
|
<pre> |
| 521 |
|
|
GRUB_CMDLINE_LINUX="vconsole.keymap=us crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet rd.driver.pre=caitsith" |
| 522 |
|
|
</pre> |
| 523 |
|
|
|
| 524 |
|
|
<h4><a name="2.1.6.2">2.1.6.2. Loading CaitSith's module from the init process</a></h4> |
| 525 |
|
|
<p>Edit your bootloader (e.g. GRUB) to add "init=/sbin/caitsith-init" to the kernel boot options. An example is shown below:</p> |
| 526 |
|
|
|
| 527 |
|
|
<p>Before:</p> |
| 528 |
kumaneko |
124 |
<pre>kernel /boot/vmlinuz-2.6.32-431.17.1.el6.x86_64 ro root=LABEL=/ |
| 529 |
kumaneko |
123 |
</pre> |
| 530 |
|
|
|
| 531 |
|
|
<p>After:</p> |
| 532 |
kumaneko |
124 |
<pre>kernel /boot/vmlinuz-2.6.32-431.17.1.el6.x86_64 ro root=LABEL=/ init=/sbin/caitsith-init |
| 533 |
kumaneko |
123 |
</pre> |
| 534 |
|
|
|
| 535 |
kumaneko |
97 |
<hr> |
| 536 |
kumaneko |
123 |
<h3><a name="2.1.7">2.1.7. Rebooting your system</a></h3> |
| 537 |
kumaneko |
97 |
|
| 538 |
|
|
<p>Now you have finished all preparation. Reboot your system.</p> |
| 539 |
|
|
|
| 540 |
|
|
<p>If everything was installed properly and the bootloader was correctly configured, the kernel should boot as normal and CaitSith should be activated:</p> |
| 541 |
|
|
|
| 542 |
kumaneko |
124 |
<img src="media/caitsith-lsm-activated.png" alt="caitsith-lsm-activated.png" title="CaitSith(LSM) activated" width="872" height="512"> |
| 543 |
kumaneko |
97 |
|
| 544 |
kumaneko |
124 |
<p>Note that you won't be able to see CaitSith's messages if you are using "quiet" or "rhgb" kernel boot option because these options prevent most of kernel messages from being printed.</p> |
| 545 |
|
|
|
| 546 |
kumaneko |
123 |
<p>Although CaitSith is a LSM module, CaitSith can coexist with other LSM modules. However, you need to also add "selinux=0" to the kernel boot options if you disable SELinux by specifying SELINUX=disabled in /etc/selinux/config . This is because the init process unregisters LSM hooks which CaitSith module depends on if SELINUX=disabled is specified in /etc/selinux/config .</p> |
| 547 |
|
|
|
| 548 |
kumaneko |
97 |
<hr> |
| 549 |
kumaneko |
123 |
<h3><a name="2.1.8">2.1.8. How can I disable/uninstall CaitSith?</a></h3> |
| 550 |
kumaneko |
97 |
|
| 551 |
kumaneko |
124 |
<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 removing "rd.driver.pre=caitsith" or "init=/sbin/caitsith-init" from the kernel boot options.</p> |
| 552 |
kumaneko |
97 |
|
| 553 |
kumaneko |
124 |
<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 removing "rd.driver.pre=caitsith" or "init=/sbin/caitsith-init" from the kernel boot options and uninstalling the userspace tools that you installed above.</p> |
| 554 |
kumaneko |
97 |
|
| 555 |
|
|
<hr> |
| 556 |
|
|
<h2><a name="2.2">2.2. How to install fully featured version</a></h2> |
| 557 |
|
|
|
| 558 |
|
|
<hr> |
| 559 |
|
|
<h3><a name="2.2.1">2.2.1. Install dependencies</a></h3> |
| 560 |
|
|
|
| 561 |
kumaneko |
15 |
<p>These packages are required for compiling the kernel and the userspace tools:</p> |
| 562 |
kumaneko |
10 |
|
| 563 |
kumaneko |
15 |
<ul> |
| 564 |
|
|
<li><strong>wget</strong>: to download sources</li> |
| 565 |
|
|
<li><strong>patch</strong>: to patch the kernel</li> |
| 566 |
|
|
<li><strong>gcc</strong>: to build the kernel and tools</li> |
| 567 |
|
|
<li><strong>make</strong>: to build the kernel and tools</li> |
| 568 |
|
|
<li><strong>ncurses-devel</strong> or <strong>libncurses-dev</strong>: to build the tools</li> |
| 569 |
|
|
</ul> |
| 570 |
|
|
|
| 571 |
|
|
<p>These can be installed with the following commands:</p> |
| 572 |
|
|
|
| 573 |
|
|
<p><strong>RedHat distributions</strong></p> |
| 574 |
|
|
<pre class="command"> |
| 575 |
|
|
# yum -y install wget patch gcc make ncurses-devel |
| 576 |
|
|
</pre> |
| 577 |
|
|
<p><strong>Debian distributions</strong></p> |
| 578 |
|
|
<pre class="command"> |
| 579 |
|
|
# apt-get -y install wget patch gcc make libncurses-dev |
| 580 |
|
|
</pre> |
| 581 |
|
|
<p><strong>SUSE distributions</strong></p> |
| 582 |
|
|
<pre class="command"> |
| 583 |
|
|
# yast -i wget patch gcc make ncurses-devel |
| 584 |
|
|
</pre> |
| 585 |
|
|
|
| 586 |
kumaneko |
30 |
<hr> |
| 587 |
kumaneko |
97 |
<h3><a name="2.2.2">2.2.2. Download and patch the kernel</a></h3> |
| 588 |
kumaneko |
15 |
|
| 589 |
|
|
<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> |
| 590 |
|
|
Linux kernel 2.6.27 and later are supported from the linux-2.6 tree.<br> |
| 591 |
|
|
Linux kernel 3.0 and later are supported from the linux-3 tree.</p> |
| 592 |
|
|
|
| 593 |
|
|
<p>Extract the kernel source and go to the extracted directory.<br> |
| 594 |
kumaneko |
124 |
In the operations below, "$VERSION" should be replaced with appropriate kernel version. For example "3.14" if using Linux kernel 3.14.5, "2.6.27" if using Linux kernel 2.6.27.62.<br> |
| 595 |
kumaneko |
117 |
Also, there are several patches which can be applied to distributor's latest kernels. For example "2.6.32-centos-6.5" if using CentOS 6.5's latest kernel:</p> |
| 596 |
kumaneko |
15 |
|
| 597 |
|
|
<pre class="command"> |
| 598 |
kumaneko |
128 |
$ wget -O caitsith-patch-0.1-20140915.tar.gz 'http://sourceforge.jp/frs/redir.php?m=jaist&f=/caitsith/55464/caitsith-patch-0.1-20140915.tar.gz' |
| 599 |
|
|
$ wget -O caitsith-patch-0.1-20140915.tar.gz.asc 'http://sourceforge.jp/frs/redir.php?m=jaist&f=/caitsith/55464/caitsith-patch-0.1-20140915.tar.gz.asc' |
| 600 |
kumaneko |
15 |
$ wget http://I-love.SAKURA.ne.jp/kumaneko-key |
| 601 |
|
|
$ gpg --import kumaneko-key |
| 602 |
kumaneko |
128 |
$ gpg caitsith-patch-0.1-20140915.tar.gz.asc |
| 603 |
|
|
$ tar -zxf caitsith-patch-0.1-20140915.tar.gz |
| 604 |
kumaneko |
107 |
$ sed -i -e 's/CCSECURITY/CAITSITH/g' -e 's/ccsecurity/caitsith/g' -e 's/ccs_domain_info/cs_domain_info/g' -e 's/ccs_flags/cs_flags/g' -- patches/ccs-patch-*.diff |
| 605 |
kumaneko |
28 |
$ patch -sp1 < patches/ccs-patch-$VERSION.diff |
| 606 |
kumaneko |
15 |
</pre> |
| 607 |
kumaneko |
10 |
|
| 608 |
kumaneko |
30 |
<hr> |
| 609 |
kumaneko |
97 |
<h3><a name="2.2.3">2.2.3. Configure the kernel</a></h3> |
| 610 |
kumaneko |
10 |
|
| 611 |
kumaneko |
15 |
<pre class="command"> |
| 612 |
|
|
$ make -s menuconfig |
| 613 |
|
|
</pre> |
| 614 |
kumaneko |
10 |
|
| 615 |
kumaneko |
15 |
<p>Choose the following options in "Security options" section:</p> |
| 616 |
kumaneko |
10 |
|
| 617 |
kumaneko |
15 |
<ul> |
| 618 |
|
|
<li>[*] CaitSith support</li> |
| 619 |
|
|
<li>[ ] Compile as loadable kernel module</li> |
| 620 |
|
|
<li>[ ] Disable by default</li> |
| 621 |
|
|
<li>[ ] Do not modify 'struct task_struct' in order to keep KABI</li> |
| 622 |
|
|
<li>[ ] Activate without calling userspace policy loader.</li> |
| 623 |
kumaneko |
22 |
<li>(<code>/sbin/caitsith-init</code>) Location of userspace policy loader</li> |
| 624 |
|
|
<li>(<code>/sbin/init</code>) Trigger for calling userspace policy loader</li> |
| 625 |
kumaneko |
15 |
<li>[*] Enable readdir operation restriction.</li> |
| 626 |
|
|
<li>[*] Enable getattr operation restriction.</li> |
| 627 |
|
|
<li>[*] Enable socket operation restriction.</li> |
| 628 |
|
|
<li>[*] Enable non-POSIX capability operation restriction.</li> |
| 629 |
|
|
<li>[*] Enable ptrace operation restriction.</li> |
| 630 |
|
|
<li>[*] Enable kill operation restriction.</li> |
| 631 |
|
|
<li>[*] Enable environment variable names/values restriction.</li> |
| 632 |
|
|
<li>[*] Enable execute handler functionality.</li> |
| 633 |
|
|
<li>[*] Enable domain transition without program execution request.</li> |
| 634 |
|
|
<li>[*] Enable automatic domain transition.</li> |
| 635 |
|
|
</ul> |
| 636 |
|
|
|
| 637 |
|
|
<p><em>"Compile as loadable kernel module"</em> is useful when there is a file size limitation for vmlinux (e.g. embedded systems).</p> |
| 638 |
|
|
|
| 639 |
kumaneko |
123 |
<p><em>"Disable by default"</em> will enable CaitSith only when "caitsith=on" is passed to the kernel boot options. If this option is not selected, "caitsith=off" will disable CaitSith.</p> |
| 640 |
kumaneko |
15 |
|
| 641 |
|
|
<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> |
| 642 |
|
|
|
| 643 |
kumaneko |
22 |
<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. <code>/etc/caitsith/</code> 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. <code>/sbin/caitsith-init</code>). The latter is loaded by executing userspace policy loader when the access control by CaitSith is about to be activated (e.g. when <code>/sbin/init</code> 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> |
| 644 |
kumaneko |
15 |
|
| 645 |
kumaneko |
123 |
<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 "CS_loader=" kernel boot option.</p> |
| 646 |
kumaneko |
15 |
|
| 647 |
kumaneko |
123 |
<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 "CS_trigger=" kernel boot option. For example, if you pass "init=<code>/usr/lib/systemd/systemd</code>" option, you may also want to pass "CS_trigger=<code>/usr/lib/systemd/systemd</code>" option.</p> |
| 648 |
kumaneko |
15 |
|
| 649 |
kumaneko |
30 |
<hr> |
| 650 |
kumaneko |
97 |
<h3><a name="2.2.4">2.2.4. Compile and install the kernel</a></h3> |
| 651 |
kumaneko |
15 |
|
| 652 |
kumaneko |
22 |
<p>The policy configuration which will be embedded into the kernel needs to exist as <code>security/caitsith/policy/policy.conf</code>. 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> |
| 653 |
kumaneko |
15 |
|
| 654 |
|
|
<p>Once the kernel has been configured, compile and install the kernel with the following commands:</p> |
| 655 |
|
|
|
| 656 |
|
|
<pre class="command"> |
| 657 |
|
|
$ make -s |
| 658 |
|
|
$ su |
| 659 |
|
|
# make -s modules_install install |
| 660 |
|
|
</pre> |
| 661 |
|
|
|
| 662 |
|
|
<p>Create initrd/initramfs if required.</p> |
| 663 |
|
|
|
| 664 |
kumaneko |
30 |
<hr> |
| 665 |
kumaneko |
97 |
<h3><a name="2.2.5">2.2.5. Install the userspace tools</a></h3> |
| 666 |
kumaneko |
15 |
|
| 667 |
kumaneko |
124 |
<p>Make sure the dependencies described above have been installed. Compile and install the tools with the following commands. (Please use USRLIBDIR=<code>/usr/lib</code> or USRLIBDIR=<code>/usr/lib32</code> if needed):</p> |
| 668 |
kumaneko |
15 |
|
| 669 |
|
|
<pre class="command"> |
| 670 |
kumaneko |
115 |
$ wget -O caitsith-tools-0.1-20140105.tar.gz 'http://sourceforge.jp/frs/redir.php?m=jaist&f=/caitsith/55465/caitsith-tools-0.1-20140105.tar.gz' |
| 671 |
|
|
$ wget -O caitsith-tools-0.1-20140105.tar.gz.asc 'http://sourceforge.jp/frs/redir.php?m=jaist&f=/caitsith/55465/caitsith-tools-0.1-20140105.tar.gz.asc' |
| 672 |
|
|
$ gpg caitsith-tools-0.1-20140105.tar.gz.asc |
| 673 |
|
|
$ tar -zxf caitsith-tools-0.1-20140105.tar.gz |
| 674 |
kumaneko |
10 |
$ cd caitsith-tools/ |
| 675 |
kumaneko |
124 |
$ make -s USRLIBDIR=/usr/lib64 |
| 676 |
kumaneko |
15 |
$ su |
| 677 |
kumaneko |
124 |
# make -s USRLIBDIR=/usr/lib64 install |
| 678 |
kumaneko |
15 |
</pre> |
| 679 |
kumaneko |
10 |
|
| 680 |
kumaneko |
15 |
<p>Programs listed below are main userspace tools used for administrating CaitSith.</p> |
| 681 |
kumaneko |
10 |
|
| 682 |
kumaneko |
15 |
<ul> |
| 683 |
kumaneko |
22 |
<li><code>/sbin/caitsith-init</code></li> |
| 684 |
|
|
<li><code>/usr/sbin/caitsith-auditd</code></li> |
| 685 |
|
|
<li><code>/usr/sbin/caitsith-loadpolicy</code></li> |
| 686 |
|
|
<li><code>/usr/sbin/caitsith-notifyd</code></li> |
| 687 |
|
|
<li><code>/usr/sbin/caitsith-pstree</code></li> |
| 688 |
|
|
<li><code>/usr/sbin/caitsith-queryd</code></li> |
| 689 |
|
|
<li><code>/usr/sbin/caitsith-savepolicy</code></li> |
| 690 |
kumaneko |
15 |
</ul> |
| 691 |
|
|
|
| 692 |
kumaneko |
97 |
<p>FYI: If your system has rpm-build package installed, you can make a tools RPM package with the following commands:</p> |
| 693 |
kumaneko |
15 |
|
| 694 |
kumaneko |
97 |
<pre class="command"> |
| 695 |
kumaneko |
115 |
$ rpmbuild -tb caitsith-tools-0.1-20140105.tar.gz |
| 696 |
kumaneko |
15 |
</pre> |
| 697 |
|
|
|
| 698 |
kumaneko |
30 |
<hr> |
| 699 |
kumaneko |
97 |
<h3><a name="2.2.6">2.2.6. Initializing configuration</a></h3> |
| 700 |
kumaneko |
15 |
|
| 701 |
kumaneko |
124 |
<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 stored in the "<code>/etc/caitsith/</code>" directory.</p> |
| 702 |
kumaneko |
15 |
|
| 703 |
kumaneko |
124 |
<p>Run the following command as root user to initialize. (Please use <code>/usr/lib/caitsith/init_policy</code> or <code>/usr/lib32/caitsith/init_policy</code> if needed):</p> |
| 704 |
kumaneko |
15 |
|
| 705 |
|
|
<pre class="command"> |
| 706 |
kumaneko |
124 |
# /usr/lib64/caitsith/init_policy |
| 707 |
kumaneko |
15 |
</pre> |
| 708 |
|
|
<pre class="output"> |
| 709 |
|
|
Creating policy directory... OK |
| 710 |
|
|
Creating configuration directory... OK |
| 711 |
|
|
Creating default policy... OK. |
| 712 |
|
|
Creating module loader... OK. |
| 713 |
|
|
Creating configuration file for caitsith-auditd ... OK. |
| 714 |
|
|
Creating configuration file for caitsith-notifyd ... OK. |
| 715 |
|
|
</pre> |
| 716 |
|
|
|
| 717 |
kumaneko |
22 |
<p>CaitSith can generate audit logs and allows you to read them via <code>/proc/caitsith/audit</code> interface. To save <code>/proc/caitsith/audit</code> automatically, start <code>/usr/sbin/caitsith-auditd</code> from somewhere. Default setting (specified in <code>/etc/caitsith/tools/auditd.conf</code>) sends access allowed logs to <code>/dev/null</code>, access unmatched logs to <code>/var/log/caitsith/unmatched.log</code>, access denied logs to <code>/var/log/caitsith/denied.log</code>. (The meaning and example of allowed/unmatched/denied will be explained in <a href="#3.3">Example of simple access restriction rule</a>.)</p> |
| 718 |
kumaneko |
15 |
|
| 719 |
kumaneko |
22 |
<p>CaitSith can ask for your decision about access requests which will be denied unless you grant them via <code>/proc/caitsith/query</code> interface. To notify immediately the occurrence of access requests which CaitSith is about to deny, start <code>/usr/sbin/caitsith-notifyd</code> from somewhere. Default setting (specified in <code>/etc/caitsith/tools/notifyd.conf</code>) sends mails to root@localhost with subject "Notification from caitsith-notifyd" up to once per a minute.</p> |
| 720 |
kumaneko |
15 |
|
| 721 |
kumaneko |
22 |
<p>Below example launches <code>/usr/sbin/caitsith-auditd</code> and <code>/usr/sbin/caitsith-notifyd</code> from <code>/etc/rc.local</code> script:</p> |
| 722 |
kumaneko |
15 |
|
| 723 |
|
|
<pre> |
| 724 |
kumaneko |
124 |
#!/bin/bash |
| 725 |
|
|
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES |
| 726 |
kumaneko |
15 |
# |
| 727 |
kumaneko |
124 |
# It is highly advisable to create own systemd services or udev rules |
| 728 |
|
|
# to run scripts during boot instead of using this file. |
| 729 |
|
|
# |
| 730 |
|
|
# In constrast to previous versions due to parallel execution during boot |
| 731 |
|
|
# this script will NOT be run after all other services. |
| 732 |
|
|
# |
| 733 |
|
|
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure |
| 734 |
|
|
# that this script will be executed during boot. |
| 735 |
kumaneko |
15 |
|
| 736 |
|
|
touch /var/lock/subsys/local |
| 737 |
|
|
/usr/sbin/caitsith-auditd |
| 738 |
|
|
/usr/sbin/caitsith-notifyd |
| 739 |
|
|
</pre> |
| 740 |
|
|
|
| 741 |
kumaneko |
30 |
<hr> |
| 742 |
kumaneko |
97 |
<h3><a name="2.2.7">2.2.7. Configuring your bootloader</a></h3> |
| 743 |
kumaneko |
15 |
|
| 744 |
kumaneko |
124 |
<p>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 include your CaitSith kernel.</p> |
| 745 |
kumaneko |
15 |
|
| 746 |
kumaneko |
30 |
<hr> |
| 747 |
kumaneko |
97 |
<h3><a name="2.2.8">2.2.8. Rebooting your system</a></h3> |
| 748 |
kumaneko |
15 |
|
| 749 |
kumaneko |
124 |
<p>Now you have finished all preparation. Reboot your system.</p> |
| 750 |
kumaneko |
15 |
|
| 751 |
|
|
<p>If everything was installed properly and the bootloader was correctly configured, the kernel should boot as normal and CaitSith should be activated:</p> |
| 752 |
|
|
|
| 753 |
kumaneko |
124 |
<img src="media/caitsith-activated.png" alt="caitsith-activated.png" title="CaitSith activated" width="928" height="496"> |
| 754 |
kumaneko |
15 |
|
| 755 |
kumaneko |
124 |
<p>Note that you won't be able to see CaitSith's messages if you are using "quiet" or "rhgb" kernel boot option because these options prevent most of kernel messages from being printed.</p> |
| 756 |
|
|
|
| 757 |
kumaneko |
30 |
<hr> |
| 758 |
kumaneko |
97 |
<h3><a name="2.2.9">2.2.9. How can I disable/uninstall CaitSith?</a></h3> |
| 759 |
kumaneko |
15 |
|
| 760 |
kumaneko |
123 |
<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" to the kernel boot options.</p> |
| 761 |
kumaneko |
15 |
|
| 762 |
|
|
<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> |
| 763 |
|
|
|
| 764 |
kumaneko |
30 |
<hr> |
| 765 |
kumaneko |
10 |
<h2><a name="how_to_develop_policy">3. How to develop policy</a></h2> |
| 766 |
|
|
|
| 767 |
kumaneko |
30 |
<hr> |
| 768 |
kumaneko |
16 |
<h3><a name="3.1">3.1. Policy file structure</a></h3> |
| 769 |
kumaneko |
10 |
|
| 770 |
kumaneko |
16 |
<p>CaitSith's policy file consists with "Header part" and "ACL part".</p> |
| 771 |
kumaneko |
10 |
|
| 772 |
kumaneko |
17 |
<h4><a name="3.1.1">3.1.1. Header part of policy file</a></h4> |
| 773 |
|
|
|
| 774 |
kumaneko |
16 |
<p>Header part consists with below lines.</p> |
| 775 |
kumaneko |
10 |
|
| 776 |
kumaneko |
16 |
<pre> |
| 777 |
|
|
POLICY_VERSION=20120401 |
| 778 |
kumaneko |
17 |
stat $stat_name $stat_value |
| 779 |
kumaneko |
16 |
quota memory policy $max_byte_for_policy |
| 780 |
|
|
quota memory audit $max_byte_for_audit_logs |
| 781 |
|
|
quota memory query $max_byte_for_query |
| 782 |
|
|
quota audit[$audit_index] allowed=$max_logs_for_allowed_request unmatched=$max_logs_for_unmatched_request denied=$max_logs_for_denied_request |
| 783 |
|
|
string_group $string_group_name $string_group_member |
| 784 |
|
|
number_group $number_group_name $number_group_member |
| 785 |
|
|
ip_group $ip_group_name $ip_group_member |
| 786 |
|
|
</pre> |
| 787 |
kumaneko |
10 |
|
| 788 |
kumaneko |
16 |
<ul> |
| 789 |
|
|
<li>POLICY_VERSION line defines policy version.</li> |
| 790 |
kumaneko |
17 |
<li>stat lines are for showing statistics information such as memory usage. $stat_name and $stat_value are simply ignored.</li> |
| 791 |
kumaneko |
16 |
<li>$max_byte_for_policy is max amount of memory in byte which can be allocated for policy. Default is unlimited.</li> |
| 792 |
|
|
<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> |
| 793 |
|
|
<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> |
| 794 |
|
|
<li>quota audit[$audit_index] lines (0 <= $audit_index <= 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> |
| 795 |
|
|
<li>string_group $string_group_name lines define group of strings. $string_group_member is a member for $string_group_name group.</li> |
| 796 |
|
|
<li>number_group $number_group_name lines define group of numbers. $number_group_member is a member for $number_group_name group.</li> |
| 797 |
|
|
<li>ip_group $ip_group_name lines define group of IP addresses. $ip_group_member is a member for $ip_group_name group.</li> |
| 798 |
|
|
</ul> |
| 799 |
kumaneko |
10 |
|
| 800 |
kumaneko |
17 |
<h4><a name="3.1.2">3.1.2. ACL part of policy file</a></h4> |
| 801 |
kumaneko |
16 |
|
| 802 |
kumaneko |
17 |
<p>ACL part consists with 0 or more repetitions of below block.</p> |
| 803 |
|
|
|
| 804 |
kumaneko |
16 |
<pre> |
| 805 |
|
|
$acl_priority acl $operation $conditions_to_filter |
| 806 |
|
|
audit $audit_index |
| 807 |
|
|
$cond_priority $decision $conditions_to_allow_or_deny |
| 808 |
|
|
</pre> |
| 809 |
|
|
|
| 810 |
|
|
<ul> |
| 811 |
|
|
<li>A block which starts with $acl_priority determines whether to evaluate rules in this block or not.</li> |
| 812 |
|
|
<li>Blocks which start with $acl_priority can be defined as many as you need.</li> |
| 813 |
|
|
<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> |
| 814 |
|
|
<li>Blocks are evaluated from smaller $acl_priority values to larger $acl_priority values.</li> |
| 815 |
|
|
<li>If two blocks have same $acl_priority value, the block which is defined first is evaluated first.</li> |
| 816 |
|
|
<li>$operation is "operation".</li> |
| 817 |
|
|
<li>$conditions_to_filter is "conditional expressions" which can be applied to "operation". Omit $conditions_to_filter to evaluate this block unconditionally.</li> |
| 818 |
|
|
<li>Access requests will be denied if one of deny lines (among all blocks defined in the policy) matches.</li> |
| 819 |
|
|
</ul> |
| 820 |
|
|
|
| 821 |
|
|
<p>$decision lines in a block is evaluated only when the block's $acl_priority line matched.</p> |
| 822 |
|
|
|
| 823 |
|
|
<ul> |
| 824 |
|
|
<li>A line which starts with $cond_priority determines whether to grant the access request or not.</li> |
| 825 |
|
|
<li>Lines which start with $cond_priority can be defined as many as you need.</li> |
| 826 |
|
|
<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> |
| 827 |
|
|
<li>Lines are checked from smaller $cond_priority values to larger priority values.</li> |
| 828 |
|
|
<li>If two lines have same $cond_priority value, the line which is defined first is checked first.</li> |
| 829 |
|
|
<li>$decision is either allow or deny.</li> |
| 830 |
|
|
<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> |
| 831 |
|
|
</ul> |
| 832 |
|
|
|
| 833 |
|
|
<p>Checking of $decision lines in a block lasts until it matches a $decision line or it reaches to the end of block.</p> |
| 834 |
|
|
|
| 835 |
|
|
<ul> |
| 836 |
|
|
<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> |
| 837 |
|
|
<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> |
| 838 |
|
|
<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> |
| 839 |
|
|
</ul> |
| 840 |
|
|
|
| 841 |
kumaneko |
30 |
<p>Access requests will be denied only when "deny" line of "acl" block matched. (There are two exceptions. Regarding permission to change domains manually (i.e. <a href="#5.60">acl manual_domain_transition</a> blocks) and permission to change domains automatically (i.e. <a href="#5.61">acl auto_domain_transition</a> blocks), access requests will be granted only when "allow" line of all blocks match, in order to avoid unintended domain transition.)</p> |
| 842 |
kumaneko |
16 |
|
| 843 |
|
|
<p>$acl_priority and $cond_priority values are used for two purposes. One is for selectively deny operations using "deny" lines. For example,</p> |
| 844 |
|
|
|
| 845 |
|
|
<pre> |
| 846 |
|
|
10 acl read path.fsmagic=0x9FA0 |
| 847 |
|
|
audit 0 |
| 848 |
|
|
10 deny path="proc:/cmdline" |
| 849 |
|
|
20 allow |
| 850 |
|
|
</pre> |
| 851 |
|
|
|
| 852 |
kumaneko |
22 |
<p>denies opening <code>/proc/cmdline</code> on the proc filesystem (proc filesystem's magic number is 0x9FA0) for reading while allowing opening all other files.</p> |
| 853 |
kumaneko |
16 |
|
| 854 |
kumaneko |
30 |
<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 in <a href="#advanced_usage">advanced usage</a>.</p> |
| 855 |
kumaneko |
16 |
|
| 856 |
kumaneko |
17 |
<h4><a name="3.1.3">3.1.3. An example policy file</a></h4> |
| 857 |
|
|
|
| 858 |
kumaneko |
22 |
<p>Below is an example of <code>/etc/caitsith/policy/current</code> file on CentOS. The content of this file varies depending on environments you are using, and will be updated as you develop policy.</p> |
| 859 |
kumaneko |
16 |
|
| 860 |
|
|
<pre> |
| 861 |
|
|
POLICY_VERSION=20120401 |
| 862 |
|
|
|
| 863 |
|
|
quota memory audit 16777216 |
| 864 |
|
|
quota memory query 1048576 |
| 865 |
|
|
quota audit[1] allowed=0 denied=1024 unmatched=1024 |
| 866 |
|
|
|
| 867 |
|
|
10000 acl execute |
| 868 |
|
|
audit 0 |
| 869 |
|
|
10 allow path="/sbin/modprobe" transition="/sbin/modprobe" |
| 870 |
|
|
10 allow path="/sbin/init" transition="/sbin/init" |
| 871 |
|
|
10 allow path="/sbin/mingetty" transition="/sbin/mingetty" |
| 872 |
|
|
10 allow path="/sbin/udevd" transition="/sbin/udevd" |
| 873 |
|
|
10 allow path="/usr/sbin/anacron" transition="/usr/sbin/anacron" |
| 874 |
|
|
10 allow path="/usr/sbin/crond" transition="/usr/sbin/crond" |
| 875 |
|
|
10 allow path="/usr/sbin/httpd" transition="/usr/sbin/httpd" |
| 876 |
|
|
10 allow path="/usr/sbin/logrotate" transition="/usr/sbin/logrotate" |
| 877 |
|
|
10 allow path="/usr/sbin/nmbd" transition="/usr/sbin/nmbd" |
| 878 |
|
|
10 allow path="/usr/sbin/smbd" transition="/usr/sbin/smbd" |
| 879 |
|
|
10 allow path="/usr/sbin/sshd" transition="/usr/sbin/sshd" |
| 880 |
|
|
10 allow path="/etc/rc.d/init.d/ntpd" transition="/etc/rc.d/init.d/ntpd" |
| 881 |
|
|
10 allow path="/etc/rc.d/init.d/single" transition="/etc/rc.d/init.d/single" |
| 882 |
|
|
10 allow path="/etc/rc.d/init.d/killall" transition="/etc/rc.d/init.d/killall" |
| 883 |
|
|
10 allow path="/etc/rc.d/init.d/ip6tables" transition="/etc/rc.d/init.d/ip6tables" |
| 884 |
|
|
10 allow path="/etc/rc.d/init.d/halt" transition="/etc/rc.d/init.d/halt" |
| 885 |
|
|
10 allow path="/etc/rc.d/init.d/netfs" transition="/etc/rc.d/init.d/netfs" |
| 886 |
|
|
10 allow path="/etc/rc.d/init.d/messagebus" transition="/etc/rc.d/init.d/messagebus" |
| 887 |
|
|
10 allow path="/etc/rc.d/init.d/sandbox" transition="/etc/rc.d/init.d/sandbox" |
| 888 |
|
|
10 allow path="/etc/rc.d/init.d/rsyslog" transition="/etc/rc.d/init.d/rsyslog" |
| 889 |
|
|
10 allow path="/etc/rc.d/init.d/smb" transition="/etc/rc.d/init.d/smb" |
| 890 |
|
|
10 allow path="/etc/rc.d/init.d/sshd" transition="/etc/rc.d/init.d/sshd" |
| 891 |
|
|
10 allow path="/etc/rc.d/init.d/cgconfig" transition="/etc/rc.d/init.d/cgconfig" |
| 892 |
|
|
10 allow path="/etc/rc.d/init.d/udev-post" transition="/etc/rc.d/init.d/udev-post" |
| 893 |
|
|
10 allow path="/etc/rc.d/init.d/firstboot" transition="/etc/rc.d/init.d/firstboot" |
| 894 |
|
|
10 allow path="/etc/rc.d/init.d/ntpdate" transition="/etc/rc.d/init.d/ntpdate" |
| 895 |
|
|
10 allow path="/etc/rc.d/init.d/crond" transition="/etc/rc.d/init.d/crond" |
| 896 |
|
|
10 allow path="/etc/rc.d/init.d/restorecond" transition="/etc/rc.d/init.d/restorecond" |
| 897 |
|
|
10 allow path="/etc/rc.d/init.d/httpd" transition="/etc/rc.d/init.d/httpd" |
| 898 |
|
|
10 allow path="/etc/rc.d/init.d/rdisc" transition="/etc/rc.d/init.d/rdisc" |
| 899 |
|
|
10 allow path="/etc/rc.d/init.d/postfix" transition="/etc/rc.d/init.d/postfix" |
| 900 |
|
|
10 allow path="/etc/rc.d/init.d/saslauthd" transition="/etc/rc.d/init.d/saslauthd" |
| 901 |
|
|
10 allow path="/etc/rc.d/init.d/netconsole" transition="/etc/rc.d/init.d/netconsole" |
| 902 |
|
|
10 allow path="/etc/rc.d/init.d/network" transition="/etc/rc.d/init.d/network" |
| 903 |
|
|
10 allow path="/etc/rc.d/init.d/avahi-daemon" transition="/etc/rc.d/init.d/avahi-daemon" |
| 904 |
|
|
10 allow path="/etc/rc.d/init.d/auditd" transition="/etc/rc.d/init.d/auditd" |
| 905 |
|
|
10 allow path="/etc/rc.d/init.d/nmb" transition="/etc/rc.d/init.d/nmb" |
| 906 |
|
|
10 allow path="/etc/rc.d/init.d/iptables" transition="/etc/rc.d/init.d/iptables" |
| 907 |
|
|
10 allow path="/etc/rc.d/init.d/cgred" transition="/etc/rc.d/init.d/cgred" |
| 908 |
|
|
|
| 909 |
|
|
0 acl modify_policy |
| 910 |
|
|
audit 1 |
| 911 |
|
|
1 deny task.uid!=0 |
| 912 |
|
|
1 deny task.euid!=0 |
| 913 |
|
|
100 allow task.exe="/usr/sbin/caitsith-loadpolicy" |
| 914 |
|
|
100 allow task.exe="/usr/sbin/caitsith-queryd" |
| 915 |
|
|
10000 deny |
| 916 |
|
|
</pre> |
| 917 |
|
|
|
| 918 |
kumaneko |
30 |
<hr> |
| 919 |
kumaneko |
16 |
<h3><a name="3.2">3.2. Updating policy configuration</a></h3> |
| 920 |
|
|
|
| 921 |
|
|
<p>There are two ways to update policy configuration.</p> |
| 922 |
|
|
|
| 923 |
kumaneko |
22 |
<p>One is to use <code>/sbin/caitsith-init</code> which is automatically called when <code>/sbin/init</code> starts. <code>/sbin/caitsith-init</code> reads policy from <code>/etc/caitsith/policy/current</code> and writes to <code>/proc/caitsith/policy</code> interface. Therefore, you can update policy configuration by updating <code>/etc/caitsith/policy/current</code> and rebooting your system.</p> |
| 924 |
kumaneko |
16 |
|
| 925 |
kumaneko |
22 |
<p>The other is to use <code>/usr/sbin/caitsith-loadpolicy</code> which is defined for loading policy after your system has booted. <code>/usr/sbin/caitsith-loadpolicy</code> reads policy from standard input and writes to <code>/proc/caitsith/policy</code> interface. Therefore, you can update policy configuration without updating <code>/etc/caitsith/policy/current</code> and rebooting your system. For example, if you want to append a "string_group mygroup1 /" line to <code>/proc/caitsith/policy</code> interface, run below command:</p> |
| 926 |
kumaneko |
16 |
|
| 927 |
|
|
<pre class="command"> |
| 928 |
|
|
# echo 'string_group mygroup1 /' | /usr/sbin/caitsith-loadpolicy |
| 929 |
|
|
</pre> |
| 930 |
|
|
|
| 931 |
kumaneko |
22 |
<p>If you want to delete the "string_group mygroup1 /" line from <code>/proc/caitsith/policy</code> interface, run below command:</p> |
| 932 |
kumaneko |
16 |
|
| 933 |
|
|
<pre class="command"> |
| 934 |
|
|
# echo 'delete string_group mygroup1 /' | /usr/sbin/caitsith-loadpolicy |
| 935 |
|
|
</pre> |
| 936 |
|
|
|
| 937 |
kumaneko |
22 |
<p>The contents in <code>/proc/caitsith/policy</code> will be lost when your system shuts down or reboots. To save <code>/proc/caitsith/policy</code> as <code>/etc/caitsith/policy/current</code>, run below command:</p> |
| 938 |
kumaneko |
16 |
|
| 939 |
|
|
<pre class="command"> |
| 940 |
|
|
# /usr/sbin/caitsith-savepolicy |
| 941 |
|
|
</pre> |
| 942 |
|
|
|
| 943 |
kumaneko |
30 |
<hr> |
| 944 |
kumaneko |
16 |
<h3><a name="3.3">3.3. Example of simple access restriction rule</a></h3> |
| 945 |
|
|
|
| 946 |
kumaneko |
17 |
<p>Let's experience how CaitSith restricts access using simple examples.</p> |
| 947 |
|
|
|
| 948 |
|
|
<h4><a name="3.3.1">3.3.1. Telling CaitSith which access requests should be checked</a></h4> |
| 949 |
|
|
|
| 950 |
|
|
<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> |
| 951 |
|
|
|
| 952 |
kumaneko |
22 |
<p>Below rule will check access requests which open <code>/tmp/file1</code> for reading.</p> |
| 953 |
kumaneko |
17 |
|
| 954 |
|
|
<pre> |
| 955 |
|
|
100 acl read path="/tmp/file1" |
| 956 |
|
|
audit 1 |
| 957 |
|
|
</pre> |
| 958 |
|
|
|
| 959 |
kumaneko |
22 |
<p>Append above rule using <code>/usr/sbin/caitsith-loadpolicy</code>. Since <code>/usr/sbin/caitsith-loadpolicy</code> reads policy from standard input, you can use ^D (Ctrl-D) to indicate end of input:</p> |
| 960 |
kumaneko |
17 |
|
| 961 |
|
|
<pre class="command"> |
| 962 |
|
|
# /usr/sbin/caitsith-loadpolicy |
| 963 |
|
|
</pre> |
| 964 |
|
|
<pre> |
| 965 |
|
|
100 acl read path="/tmp/file1" |
| 966 |
|
|
audit 1 |
| 967 |
|
|
^D |
| 968 |
|
|
</pre> |
| 969 |
|
|
|
| 970 |
|
|
<p>You may use a temporary file if you worry typos.</p> |
| 971 |
|
|
|
| 972 |
|
|
<pre class="command"> |
| 973 |
|
|
# cat > ~/policy.tmp |
| 974 |
|
|
</pre> |
| 975 |
|
|
<pre> |
| 976 |
|
|
100 acl read path="/tmp/file1" |
| 977 |
|
|
audit 1 |
| 978 |
|
|
^D |
| 979 |
|
|
</pre> |
| 980 |
|
|
<pre class="command"> |
| 981 |
|
|
# /usr/sbin/caitsith-loadpolicy < ~/policy.tmp |
| 982 |
|
|
# rm ~/policy.tmp |
| 983 |
|
|
</pre> |
| 984 |
|
|
|
| 985 |
kumaneko |
22 |
<p>You can confirm that above rule is appended to <code>/proc/caitsith/policy</code> by reading <code>/proc/caitsith/policy</code>.</p> |
| 986 |
kumaneko |
17 |
|
| 987 |
|
|
<pre class="command"> |
| 988 |
|
|
# cat /proc/caitsith/policy |
| 989 |
|
|
</pre> |
| 990 |
|
|
<pre> |
| 991 |
|
|
POLICY_VERSION=20120401 |
| 992 |
|
|
stat Policy updated: 7 (Last: 2012/04/08 04:56:45) |
| 993 |
|
|
stat Requests denied: 0 |
| 994 |
|
|
stat Memory used by policy: 6048 |
| 995 |
|
|
stat Memory used by audit: 0 |
| 996 |
|
|
stat Memory used by query: 0 |
| 997 |
|
|
quota memory audit 16777216 |
| 998 |
|
|
quota memory query 1048576 |
| 999 |
|
|
quota audit[1] allowed=0 denied=1024 unmatched=1024 |
| 1000 |
|
|
|
| 1001 |
|
|
10000 acl execute |
| 1002 |
|
|
audit 0 |
| 1003 |
|
|
10 allow path="/sbin/modprobe" transition="/sbin/modprobe" |
| 1004 |
|
|
10 allow path="/sbin/init" transition="/sbin/init" |
| 1005 |
|
|
10 allow path="/sbin/mingetty" transition="/sbin/mingetty" |
| 1006 |
|
|
10 allow path="/sbin/udevd" transition="/sbin/udevd" |
| 1007 |
|
|
10 allow path="/usr/sbin/anacron" transition="/usr/sbin/anacron" |
| 1008 |
|
|
10 allow path="/usr/sbin/crond" transition="/usr/sbin/crond" |
| 1009 |
|
|
10 allow path="/usr/sbin/httpd" transition="/usr/sbin/httpd" |
| 1010 |
|
|
10 allow path="/usr/sbin/logrotate" transition="/usr/sbin/logrotate" |
| 1011 |
|
|
10 allow path="/usr/sbin/nmbd" transition="/usr/sbin/nmbd" |
| 1012 |
|
|
10 allow path="/usr/sbin/smbd" transition="/usr/sbin/smbd" |
| 1013 |
|
|
10 allow path="/usr/sbin/sshd" transition="/usr/sbin/sshd" |
| 1014 |
|
|
10 allow path="/etc/rc.d/init.d/ntpd" transition="/etc/rc.d/init.d/ntpd" |
| 1015 |
|
|
10 allow path="/etc/rc.d/init.d/single" transition="/etc/rc.d/init.d/single" |
| 1016 |
|
|
10 allow path="/etc/rc.d/init.d/killall" transition="/etc/rc.d/init.d/killall" |
| 1017 |
|
|
10 allow path="/etc/rc.d/init.d/ip6tables" transition="/etc/rc.d/init.d/ip6tables" |
| 1018 |
|
|
10 allow path="/etc/rc.d/init.d/halt" transition="/etc/rc.d/init.d/halt" |
| 1019 |
|
|
10 allow path="/etc/rc.d/init.d/netfs" transition="/etc/rc.d/init.d/netfs" |
| 1020 |
|
|
10 allow path="/etc/rc.d/init.d/messagebus" transition="/etc/rc.d/init.d/messagebus" |
| 1021 |
|
|
10 allow path="/etc/rc.d/init.d/sandbox" transition="/etc/rc.d/init.d/sandbox" |
| 1022 |
|
|
10 allow path="/etc/rc.d/init.d/rsyslog" transition="/etc/rc.d/init.d/rsyslog" |
| 1023 |
|
|
10 allow path="/etc/rc.d/init.d/smb" transition="/etc/rc.d/init.d/smb" |
| 1024 |
|
|
10 allow path="/etc/rc.d/init.d/sshd" transition="/etc/rc.d/init.d/sshd" |
| 1025 |
|
|
10 allow path="/etc/rc.d/init.d/cgconfig" transition="/etc/rc.d/init.d/cgconfig" |
| 1026 |
|
|
10 allow path="/etc/rc.d/init.d/udev-post" transition="/etc/rc.d/init.d/udev-post" |
| 1027 |
|
|
10 allow path="/etc/rc.d/init.d/firstboot" transition="/etc/rc.d/init.d/firstboot" |
| 1028 |
|
|
10 allow path="/etc/rc.d/init.d/ntpdate" transition="/etc/rc.d/init.d/ntpdate" |
| 1029 |
|
|
10 allow path="/etc/rc.d/init.d/crond" transition="/etc/rc.d/init.d/crond" |
| 1030 |
|
|
10 allow path="/etc/rc.d/init.d/restorecond" transition="/etc/rc.d/init.d/restorecond" |
| 1031 |
|
|
10 allow path="/etc/rc.d/init.d/httpd" transition="/etc/rc.d/init.d/httpd" |
| 1032 |
|
|
10 allow path="/etc/rc.d/init.d/rdisc" transition="/etc/rc.d/init.d/rdisc" |
| 1033 |
|
|
10 allow path="/etc/rc.d/init.d/postfix" transition="/etc/rc.d/init.d/postfix" |
| 1034 |
|
|
10 allow path="/etc/rc.d/init.d/saslauthd" transition="/etc/rc.d/init.d/saslauthd" |
| 1035 |
|
|
10 allow path="/etc/rc.d/init.d/netconsole" transition="/etc/rc.d/init.d/netconsole" |
| 1036 |
|
|
10 allow path="/etc/rc.d/init.d/network" transition="/etc/rc.d/init.d/network" |
| 1037 |
|
|
10 allow path="/etc/rc.d/init.d/avahi-daemon" transition="/etc/rc.d/init.d/avahi-daemon" |
| 1038 |
|
|
10 allow path="/etc/rc.d/init.d/auditd" transition="/etc/rc.d/init.d/auditd" |
| 1039 |
|
|
10 allow path="/etc/rc.d/init.d/nmb" transition="/etc/rc.d/init.d/nmb" |
| 1040 |
|
|
10 allow path="/etc/rc.d/init.d/iptables" transition="/etc/rc.d/init.d/iptables" |
| 1041 |
|
|
10 allow path="/etc/rc.d/init.d/cgred" transition="/etc/rc.d/init.d/cgred" |
| 1042 |
|
|
|
| 1043 |
|
|
100 acl read path="/tmp/file1" |
| 1044 |
|
|
audit 1 |
| 1045 |
|
|
|
| 1046 |
|
|
0 acl modify_policy |
| 1047 |
|
|
audit 1 |
| 1048 |
|
|
1 deny task.uid!=0 |
| 1049 |
|
|
1 deny task.euid!=0 |
| 1050 |
|
|
100 allow task.exe="/usr/sbin/caitsith-loadpolicy" |
| 1051 |
|
|
100 allow task.exe="/usr/sbin/caitsith-queryd" |
| 1052 |
|
|
10000 deny |
| 1053 |
|
|
</pre> |
| 1054 |
|
|
|
| 1055 |
|
|
<h4><a name="3.3.2">3.3.2. Access requests which will be implicitly allowed by CaitSith</a></h4> |
| 1056 |
|
|
|
| 1057 |
kumaneko |
22 |
<p>Make sure that <code>/usr/sbin/caitsith-auditd</code> is running.</p> |
| 1058 |
kumaneko |
17 |
|
| 1059 |
|
|
<pre class="command"> |
| 1060 |
|
|
# pidof caitsith-auditd |
| 1061 |
|
|
</pre> |
| 1062 |
|
|
<pre> |
| 1063 |
|
|
3627 |
| 1064 |
|
|
</pre> |
| 1065 |
|
|
|
| 1066 |
kumaneko |
22 |
<p>Now, create <code>/tmp/file1</code> file.</p> |
| 1067 |
kumaneko |
17 |
|
| 1068 |
|
|
<pre class="command"> |
| 1069 |
|
|
# touch /tmp/file1 |
| 1070 |
|
|
</pre> |
| 1071 |
|
|
|
| 1072 |
kumaneko |
22 |
<p>Then, open <code>/tmp/file1</code> for reading.</p> |
| 1073 |
kumaneko |
17 |
|
| 1074 |
|
|
<pre class="command"> |
| 1075 |
|
|
# cat /tmp/file1 |
| 1076 |
|
|
</pre> |
| 1077 |
|
|
|
| 1078 |
kumaneko |
22 |
<p>Check <code>/var/log/caitsith/unmatched.log</code> for access unmatched log of this access request. You will find an entry like below:</p> |
| 1079 |
kumaneko |
17 |
|
| 1080 |
|
|
<pre class="command"> |
| 1081 |
|
|
# grep /tmp/file1 /var/log/caitsith/unmatched.log |
| 1082 |
|
|
</pre> |
| 1083 |
|
|
<pre> |
| 1084 |
|
|
#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 |
| 1085 |
|
|
</pre> |
| 1086 |
|
|
|
| 1087 |
kumaneko |
19 |
<p>Note the <strong>result=unmatched</strong> part of the entry. This indicates that access request was checked but matched neither "allow" nor "deny" rule.</p> |
| 1088 |
kumaneko |
17 |
|
| 1089 |
kumaneko |
19 |
<p>Note the <strong>priority=100</strong> part of the entry. This indicates that this entry was generated by rules which have 100 as priority.</p> |
| 1090 |
kumaneko |
17 |
|
| 1091 |
kumaneko |
22 |
<p>Note the <strong>read path="<code>/tmp/file1</code>"</strong> part of the entry. This indicates that this entry was generated by access request of opening <code>/tmp/file1</code> for reading.</p> |
| 1092 |
kumaneko |
17 |
|
| 1093 |
|
|
<h4><a name="3.3.3">3.3.3. Access requests which will be explicitly denied by CaitSith</a></h4> |
| 1094 |
|
|
|
| 1095 |
|
|
<p>Now, let's add a rule to explicitly deny this request.</p> |
| 1096 |
|
|
|
| 1097 |
|
|
<pre> |
| 1098 |
|
|
100 acl read path="/tmp/file1" |
| 1099 |
|
|
1000 deny |
| 1100 |
|
|
</pre> |
| 1101 |
|
|
|
| 1102 |
kumaneko |
22 |
<p>Append above rule using <code>/usr/sbin/caitsith-loadpolicy</code>:</p> |
| 1103 |
kumaneko |
17 |
|
| 1104 |
|
|
<pre class="command"> |
| 1105 |
|
|
# /usr/sbin/caitsith-loadpolicy |
| 1106 |
|
|
</pre> |
| 1107 |
|
|
<pre> |
| 1108 |
|
|
100 acl read path="/tmp/file1" |
| 1109 |
|
|
1000 deny |
| 1110 |
|
|
^D |
| 1111 |
|
|
</pre> |
| 1112 |
|
|
|
| 1113 |
kumaneko |
22 |
<p>Rules that have same priority (in this rule, 100) and same operation (in this rule, read) and same condition (in this rule, path="<code>/tmp/file1</code>") are automatically merged. Therefore, you will find</p> |
| 1114 |
kumaneko |
17 |
|
| 1115 |
|
|
<pre> |
| 1116 |
|
|
100 acl read path="/tmp/file1" |
| 1117 |
|
|
audit 1 |
| 1118 |
|
|
1000 deny |
| 1119 |
|
|
</pre> |
| 1120 |
|
|
|
| 1121 |
|
|
<p>rather than</p> |
| 1122 |
|
|
|
| 1123 |
|
|
<pre> |
| 1124 |
|
|
100 acl read path="/tmp/file1" |
| 1125 |
|
|
audit 1 |
| 1126 |
|
|
|
| 1127 |
|
|
100 acl read path="/tmp/file1" |
| 1128 |
|
|
1000 deny |
| 1129 |
|
|
</pre> |
| 1130 |
|
|
|
| 1131 |
kumaneko |
22 |
<p>when you read <code>/proc/caitsith/policy</code>.</p> |
| 1132 |
kumaneko |
17 |
|
| 1133 |
kumaneko |
22 |
<p>Then, open <code>/tmp/file1</code> for reading.</p> |
| 1134 |
kumaneko |
17 |
|
| 1135 |
|
|
<pre class="command"> |
| 1136 |
|
|
# cat /tmp/file1 |
| 1137 |
|
|
</pre> |
| 1138 |
|
|
<pre> |
| 1139 |
|
|
cat: /tmp/file1: Operation not permitted |
| 1140 |
|
|
</pre> |
| 1141 |
|
|
|
| 1142 |
|
|
<p>This time, access request was denied by CaitSith.</p> |
| 1143 |
|
|
|
| 1144 |
kumaneko |
22 |
<p>Check <code>/var/log/caitsith/denied.log</code> for access denied log of this access request. You will find an entry like below:</p> |
| 1145 |
kumaneko |
17 |
|
| 1146 |
|
|
<pre class="command"> |
| 1147 |
|
|
# grep /tmp/file1 /var/log/caitsith/denied.log |
| 1148 |
|
|
</pre> |
| 1149 |
|
|
<pre> |
| 1150 |
|
|
#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 |
| 1151 |
|
|
</pre> |
| 1152 |
|
|
|
| 1153 |
kumaneko |
19 |
<p>Note the <strong>result=denied</strong> part of the entry. This indicates that access request was checked and matched "deny" rule.</p> |
| 1154 |
kumaneko |
17 |
|
| 1155 |
kumaneko |
100 |
<p>If <code>/usr/sbin/caitsith-notifyd</code> is running, you will receive a notification mail. The content is same with access denied logs.</p> |
| 1156 |
kumaneko |
17 |
|
| 1157 |
|
|
<pre class="command"> |
| 1158 |
|
|
# mail |
| 1159 |
|
|
</pre> |
| 1160 |
|
|
<pre> |
| 1161 |
|
|
Heirloom Mail version 12.4 7/29/08. Type ? for help. |
| 1162 |
|
|
"/var/spool/mail/root": 1 message 1 new |
| 1163 |
|
|
>N 1 root Sun Apr 8 13:59 20/1231 "Notification from caitsith-notifyd" |
| 1164 |
|
|
& |
| 1165 |
|
|
Message 1: |
| 1166 |
|
|
From root@ccsecurity.localdomain Sun Apr 8 13:59:53 2012 |
| 1167 |
|
|
Return-Path: <root@ccsecurity.localdomain> |
| 1168 |
|
|
X-Original-To: root@localhost |
| 1169 |
|
|
Delivered-To: root@localhost.localdomain |
| 1170 |
|
|
Date: Sun, 08 Apr 2012 13:59:53 +0900 |
| 1171 |
|
|
To: root@localhost.localdomain |
| 1172 |
|
|
Subject: Notification from caitsith-notifyd |
| 1173 |
|
|
User-Agent: Heirloom mailx 12.4 7/29/08 |
| 1174 |
|
|
Content-Type: text/plain; charset=us-ascii |
| 1175 |
|
|
From: root@caitsith.localdomain (root) |
| 1176 |
|
|
Status: R |
| 1177 |
|
|
|
| 1178 |
|
|
Q0-0 |
| 1179 |
|
|
#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 |
| 1180 |
|
|
</pre> |
| 1181 |
|
|
|
| 1182 |
|
|
<p>Now, let's remove a rule to explicitly deny this request.</p> |
| 1183 |
|
|
|
| 1184 |
|
|
<pre> |
| 1185 |
|
|
100 acl read path="/tmp/file1" |
| 1186 |
|
|
delete 1000 deny |
| 1187 |
|
|
</pre> |
| 1188 |
|
|
|
| 1189 |
kumaneko |
22 |
<p>Append above rule using <code>/usr/sbin/caitsith-loadpolicy</code>:</p> |
| 1190 |
kumaneko |
17 |
|
| 1191 |
|
|
<pre class="command"> |
| 1192 |
|
|
# /usr/sbin/caitsith-loadpolicy |
| 1193 |
|
|
</pre> |
| 1194 |
|
|
<pre> |
| 1195 |
|
|
100 acl read path="/tmp/file1" |
| 1196 |
|
|
delete 1000 deny |
| 1197 |
|
|
^D |
| 1198 |
|
|
</pre> |
| 1199 |
|
|
|
| 1200 |
|
|
<p>You will find</p> |
| 1201 |
|
|
|
| 1202 |
|
|
<pre> |
| 1203 |
|
|
100 acl read path="/tmp/file1" |
| 1204 |
|
|
audit 1 |
| 1205 |
|
|
</pre> |
| 1206 |
|
|
|
| 1207 |
|
|
<p>rather than</p> |
| 1208 |
|
|
|
| 1209 |
|
|
<pre> |
| 1210 |
|
|
100 acl read path="/tmp/file1" |
| 1211 |
|
|
audit 1 |
| 1212 |
|
|
1000 deny |
| 1213 |
|
|
delete 1000 deny |
| 1214 |
|
|
</pre> |
| 1215 |
|
|
|
| 1216 |
kumaneko |
22 |
<p>when you read <code>/proc/caitsith/policy</code>.</p> |
| 1217 |
kumaneko |
17 |
|
| 1218 |
|
|
<h4><a name="3.3.4">3.3.4. Filtering audit logs</a></h4> |
| 1219 |
|
|
|
| 1220 |
kumaneko |
22 |
<p>Now, open <code>/tmp/file1</code> for reading.</p> |
| 1221 |
kumaneko |
17 |
|
| 1222 |
|
|
<pre class="command"> |
| 1223 |
|
|
# cat /tmp/file1 |
| 1224 |
|
|
</pre> |
| 1225 |
|
|
|
| 1226 |
kumaneko |
22 |
<p>Check <code>/var/log/caitsith/unmatched.log</code> for access unmatched log of this access request. You will find entries like below:</p> |
| 1227 |
kumaneko |
17 |
|
| 1228 |
|
|
<pre class="command"> |
| 1229 |
|
|
# grep /tmp/file1 /var/log/caitsith/unmatched.log |
| 1230 |
|
|
</pre> |
| 1231 |
|
|
<pre> |
| 1232 |
|
|
#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 |
| 1233 |
|
|
#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 |
| 1234 |
|
|
</pre> |
| 1235 |
|
|
|
| 1236 |
|
|
<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> |
| 1237 |
|
|
|
| 1238 |
|
|
<pre class="command"> |
| 1239 |
|
|
# grep /tmp/file1 /var/log/caitsith/unmatched.log | tail -n 1 |
| 1240 |
|
|
</pre> |
| 1241 |
|
|
<pre> |
| 1242 |
|
|
#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 |
| 1243 |
|
|
</pre> |
| 1244 |
|
|
|
| 1245 |
|
|
<h4><a name="3.3.5">3.3.5. Access requests which will be explicitly allowed by CaitSith</a></h4> |
| 1246 |
|
|
|
| 1247 |
|
|
<p>Next, let's see audit logs with explicitly matching "allow" rules.</p> |
| 1248 |
|
|
|
| 1249 |
|
|
<p>By default CaitSith does not generate audit logs with explicitly matching "allow" rules. Change policy configuration to generate such logs.</p> |
| 1250 |
|
|
|
| 1251 |
|
|
<pre> |
| 1252 |
|
|
quota audit[1] allowed=1024 |
| 1253 |
|
|
</pre> |
| 1254 |
|
|
|
| 1255 |
kumaneko |
22 |
<p>Append above rule using <code>/usr/sbin/caitsith-loadpolicy</code>:</p> |
| 1256 |
kumaneko |
17 |
|
| 1257 |
|
|
<pre class="command"> |
| 1258 |
|
|
# echo 'quota audit[1] allowed=1024' | /usr/sbin/caitsith-loadpolicy |
| 1259 |
|
|
</pre> |
| 1260 |
|
|
|
| 1261 |
|
|
<p>Preferences that have same name (in this rule, audit[1]) are automatically merged. Therefore, you will find</p> |
| 1262 |
|
|
|
| 1263 |
|
|
<pre> |
| 1264 |
|
|
quota audit[1] allowed=1024 denied=1024 unmatched=1024 |
| 1265 |
|
|
</pre> |
| 1266 |
|
|
|
| 1267 |
|
|
<p>rather than</p> |
| 1268 |
|
|
|
| 1269 |
|
|
<pre> |
| 1270 |
|
|
quota audit[1] allowed=0 denied=1024 unmatched=1024 |
| 1271 |
|
|
quota audit[1] allowed=1024 |
| 1272 |
|
|
</pre> |
| 1273 |
|
|
|
| 1274 |
kumaneko |
22 |
<p>when you read <code>/proc/caitsith/policy</code>.</p> |
| 1275 |
kumaneko |
17 |
|
| 1276 |
|
|
<pre> |
| 1277 |
|
|
100 acl read path="/tmp/file1" |
| 1278 |
|
|
1000 allow |
| 1279 |
|
|
</pre> |
| 1280 |
|
|
|
| 1281 |
kumaneko |
22 |
<p>Append above rule using <code>/usr/sbin/caitsith-loadpolicy</code>:</p> |
| 1282 |
kumaneko |
17 |
|
| 1283 |
|
|
<pre class="command"> |
| 1284 |
|
|
# /usr/sbin/caitsith-loadpolicy |
| 1285 |
|
|
</pre> |
| 1286 |
|
|
<pre> |
| 1287 |
|
|
100 acl read path="/tmp/file1" |
| 1288 |
|
|
1000 allow |
| 1289 |
|
|
^D |
| 1290 |
|
|
</pre> |
| 1291 |
|
|
|
| 1292 |
kumaneko |
22 |
<p>Since audit logs with explicitly matching "allow" rules tend to grow rapidly, by default <code>/usr/sbin/caitsith-auditd</code> discards such logs by writing to <code>/dev/null</code> (specified in <code>/etc/caitsith/tools/auditd.conf</code>). |
| 1293 |
|
|
Therefore, temporarily stop <code>/usr/sbin/caitsith-auditd</code> process in order to read audit logs from <code>/proc/caitsith/audit</code> interface.</p> |
| 1294 |
kumaneko |
17 |
|
| 1295 |
|
|
<pre class="command"> |
| 1296 |
|
|
# killall -KILL caitsith-auditd |
| 1297 |
|
|
</pre> |
| 1298 |
|
|
|
| 1299 |
kumaneko |
22 |
<p>Then, open <code>/tmp/file1</code> for reading.</p> |
| 1300 |
kumaneko |
17 |
|
| 1301 |
|
|
<pre class="command"> |
| 1302 |
|
|
# cat /tmp/file1 |
| 1303 |
|
|
</pre> |
| 1304 |
|
|
|
| 1305 |
kumaneko |
22 |
<p>Check <code>/proc/caitsith/audit</code> for audit log of this access request. This time, you will find an entry like below:</p> |
| 1306 |
kumaneko |
17 |
|
| 1307 |
|
|
<pre class="command"> |
| 1308 |
|
|
# cat -v /proc/caitsith/audit |
| 1309 |
|
|
</pre> |
| 1310 |
|
|
<pre> |
| 1311 |
|
|
#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 |
| 1312 |
|
|
^@ |
| 1313 |
|
|
</pre> |
| 1314 |
|
|
|
| 1315 |
kumaneko |
19 |
<p>Note the <strong>result=allowed</strong> part of the entry. This indicates that access request was checked and matched "allow" rule.</p> |
| 1316 |
kumaneko |
17 |
|
| 1317 |
kumaneko |
22 |
<p>Restart <code>/usr/sbin/caitsith-auditd</code> process.</p> |
| 1318 |
kumaneko |
17 |
|
| 1319 |
|
|
<pre class="command"> |
| 1320 |
|
|
# /usr/sbin/caitsith-auditd |
| 1321 |
|
|
</pre> |
| 1322 |
|
|
|
| 1323 |
|
|
<p>Also, restore the audit logs configuration:</p> |
| 1324 |
|
|
|
| 1325 |
|
|
<pre> |
| 1326 |
|
|
quota audit[1] allowed=0 |
| 1327 |
|
|
</pre> |
| 1328 |
|
|
|
| 1329 |
kumaneko |
22 |
<p>Append above rule using <code>/usr/sbin/caitsith-loadpolicy</code>:</p> |
| 1330 |
kumaneko |
17 |
|
| 1331 |
|
|
<pre class="command"> |
| 1332 |
|
|
# echo 'quota audit[1] allowed=0' | /usr/sbin/caitsith-loadpolicy |
| 1333 |
|
|
</pre> |
| 1334 |
|
|
|
| 1335 |
kumaneko |
30 |
<hr> |
| 1336 |
kumaneko |
20 |
<h3><a name="3.4">3.4. Understanding two viewpoints</a></h3> |
| 1337 |
kumaneko |
18 |
|
| 1338 |
kumaneko |
20 |
<p>CaitSith supports writing access restriction rules from two viewpoints. One is from the point of view of "subject" (a resource which requests access on object). The other is from the point of view of "object" (a resource which subject requests access).</p> |
| 1339 |
|
|
|
| 1340 |
|
|
<p>The advantage of the former approach is that the rules clearly explains and restricts what each subject is allowed to access which object. |
| 1341 |
|
|
This approach is powerful when you can afford identifying all possible subjects and defining the rules for each subject. |
| 1342 |
|
|
But the disadvantage is that it is difficult to identify all possible subjects and define the rules for each subject. |
| 1343 |
|
|
Therefore, in reality, this approach tends to restrict only specific subjects. |
| 1344 |
|
|
If one of subjects which is not restricted by this approach is cracked or misbehaved, nothing can protect objects you want to protect.</p> |
| 1345 |
|
|
|
| 1346 |
|
|
<p>The advantage of the latter approach is that the rules clearly explains and restricts what object might be accessed by which subject. |
| 1347 |
|
|
This approach is powerful when you can afford identifying objects you want to protect and defining rules for each object. |
| 1348 |
kumaneko |
60 |
This approach can compensate for the disadvantage of the former approach because this approach can restrict access even when it is difficult to |
| 1349 |
kumaneko |
20 |
identify all possible subjects and define the rules for each possible subjects.</p> |
| 1350 |
|
|
|
| 1351 |
|
|
<h4><a name="3.4.1">3.4.1. Writing access restriction rules from the point of view of "subject".</a></h4> |
| 1352 |
|
|
|
| 1353 |
kumaneko |
22 |
<p>Below entry is an example of restricting programs which can be executed from <code>/usr/sbin/httpd</code> program.</p> |
| 1354 |
kumaneko |
20 |
|
| 1355 |
|
|
<pre> |
| 1356 |
|
|
0 acl execute task.exe="/usr/sbin/httpd" |
| 1357 |
|
|
audit 1 |
| 1358 |
|
|
1 allow path="/var/www/cgi-bin/counter.cgi" |
| 1359 |
|
|
100 deny |
| 1360 |
|
|
</pre> |
| 1361 |
|
|
|
| 1362 |
kumaneko |
22 |
<p>The <strong>0 acl execute task.exe="<code>/usr/sbin/httpd</code>"</strong> line means check rules for executing programs from <code>/usr/sbin/httpd</code> program. Since <strong>task.exe="<code>/usr/sbin/httpd</code>"</strong> is specified in this line, this line tells CaitSith <strong>check rules for executing programs only if current thread's program name is <code>/usr/sbin/httpd</code></strong>.</p> |
| 1363 |
kumaneko |
20 |
|
| 1364 |
kumaneko |
22 |
<p>The line <strong>1 allow path="<code>/var/www/cgi-bin/counter.cgi</code>"</strong> means that allow if the pathname of the program to execute is <code>/var/www/cgi-bin/counter.cgi</code>. This line tells CaitSith "allow execution of <code>/var/www/cgi-bin/counter.cgi</code>".</p> |
| 1365 |
kumaneko |
20 |
|
| 1366 |
|
|
<p>The line <strong>100 deny</strong> means deny unconditionally. This tells CaitSith "unconditionally deny execution of programs".</p> |
| 1367 |
|
|
|
| 1368 |
kumaneko |
22 |
<p>Since the line starting with <strong>1 allow</strong> has higher priority than the line starting with <strong>100 deny</strong>, CaitSith will allow execution of <code>/var/www/cgi-bin/counter.cgi</code>.</p> |
| 1369 |
kumaneko |
20 |
|
| 1370 |
kumaneko |
22 |
<p>To summarize this rule, <code>/usr/sbin/httpd</code> can execute <strong>only</strong> <code>/var/www/cgi-bin/counter.cgi</code>.</p> |
| 1371 |
kumaneko |
20 |
|
| 1372 |
kumaneko |
124 |
<p>The line <strong>audit 1</strong> means that use audit rules defined in the <strong>quota audit[1]</strong> line. This line tells CaitSith generate audit logs up to entries defined in the <strong>quota audit[1]</strong> line. The default configuration generated by executing <code>/usr/lib64/caitsith/init_policy</code> command is</p> |
| 1373 |
kumaneko |
20 |
|
| 1374 |
|
|
<pre> |
| 1375 |
|
|
quota audit[1] allowed=0 denied=1024 unmatched=1024 |
| 1376 |
|
|
</pre> |
| 1377 |
|
|
|
| 1378 |
kumaneko |
22 |
<p>which means do not generate audit logs if matched an "allow" line and generate audit logs up to 1024 entries if matched a "deny" line and generate audit logs up to 1024 lines if matched neither an "allow" line nor a "deny" line. Though, since the block starting with <strong>0 acl execute task.exe="<code>/usr/sbin/httpd</code>"</strong> is terminated with explicit <strong>100 deny</strong> line, this block shall match either an "allow" line or a "deny" line.</p> |
| 1379 |
kumaneko |
20 |
|
| 1380 |
|
|
<h4><a name="3.4.2">3.4.2. Writing access restriction rules from the point of view of "object".</a></h4> |
| 1381 |
|
|
|
| 1382 |
kumaneko |
124 |
<p>Below entry is default configuration generated by executing <code>/usr/lib64/caitsith/init_policy</code> command.</p> |
| 1383 |
kumaneko |
20 |
|
| 1384 |
|
|
<pre> |
| 1385 |
|
|
0 acl modify_policy |
| 1386 |
|
|
audit 1 |
| 1387 |
|
|
1 deny task.uid!=0 |
| 1388 |
|
|
1 deny task.euid!=0 |
| 1389 |
|
|
100 allow task.exe="/usr/sbin/caitsith-loadpolicy" |
| 1390 |
|
|
100 allow task.exe="/usr/sbin/caitsith-queryd" |
| 1391 |
|
|
10000 deny |
| 1392 |
|
|
</pre> |
| 1393 |
|
|
|
| 1394 |
kumaneko |
22 |
<p>The <strong>0 acl modify_policy</strong> line means check rules for modifying policy configuration via <code>/proc/caitsith/policy</code> interface. Since no additional conditions are specified in this line, this line tells CaitSith <strong>unconditionally check</strong> rules for modifying policy configuration via <code>/proc/caitsith/policy</code> interface.</p> |
| 1395 |
kumaneko |
20 |
|
| 1396 |
kumaneko |
22 |
<p>The line <strong>1 deny task.uid!=0</strong> means that deny if current thread's user ID is not 0. This line tells CaitSith "deny modification of policy configuration via <code>/proc/caitsith/policy</code> interface if current thread's user ID is not 0".</p> |
| 1397 |
kumaneko |
20 |
|
| 1398 |
kumaneko |
22 |
<p>The line <strong>1 deny task.euid!=0</strong> means that deny if current thread's effective user ID is not 0. This line tells CaitSith "deny modification of policy configuration via <code>/proc/caitsith/policy</code> interface if current thread's effective user ID is not 0".</p> |
| 1399 |
kumaneko |
20 |
|
| 1400 |
|
|
<p>Note the difference between</p> |
| 1401 |
|
|
|
| 1402 |
|
|
<pre> |
| 1403 |
|
|
1 deny task.uid!=0 |
| 1404 |
|
|
1 deny task.euid!=0 |
| 1405 |
|
|
</pre> |
| 1406 |
|
|
|
| 1407 |
|
|
<p>and</p> |
| 1408 |
|
|
|
| 1409 |
|
|
<pre> |
| 1410 |
|
|
1 deny task.uid!=0 task.euid!=0 |
| 1411 |
|
|
</pre> |
| 1412 |
|
|
|
| 1413 |
|
|
<p>. The former conditions tell CaitSith "deny if current thread's user ID is not 0 <strong>or</strong> current thread's effective user ID is not 0", while the latter conditions tell CaitSith "deny if current thread's user ID is not 0 <strong>and</strong> current thread's effective user ID is not 0".</p> |
| 1414 |
|
|
|
| 1415 |
kumaneko |
22 |
<p>The line <strong>100 allow task.exe="<code>/usr/sbin/caitsith-loadpolicy</code>"</strong> means that allow if current thread's program name is <code>/usr/sbin/caitsith-loadpolicy</code>. This tells CaitSith finish evaluation of this block starting with the <strong>0 acl modify_policy</strong> line if current thread's program name is <code>/usr/sbin/caitsith-loadpolicy</code>. If there are more blocks, CaitSith will evaluate them. If there are no more blocks, CaitSith will allow modifying policy configuration via <code>/proc/caitsith/policy</code> interface.</p> |
| 1416 |
kumaneko |
20 |
|
| 1417 |
kumaneko |
22 |
<p>The line <strong>100 allow task.exe="<code>/usr/sbin/caitsith-queryd</code>"</strong> means that allow if current thread's program name is <code>/usr/sbin/caitsith-queryd</code>. This tells CaitSith finish evaluation of this block starting with the <strong>0 acl modify_policy</strong> line if current thread's program name is <code>/usr/sbin/caitsith-queryd</code>. The usage of <code>/usr/sbin/caitsith-queryd</code> will be explained later.</p> |
| 1418 |
kumaneko |
20 |
|
| 1419 |
kumaneko |
22 |
<p>The line <strong>10000 deny</strong> means deny unconditionally. This tells CaitSith "unconditionally deny modification of policy configuration via <code>/proc/caitsith/policy</code> interface".</p> |
| 1420 |
kumaneko |
20 |
|
| 1421 |
kumaneko |
22 |
<p>Since lines starting with <strong>1 deny</strong> have higher priority than lines starting with <strong>100 allow</strong>, CaitSith will deny modifying policy configuration via <code>/proc/caitsith/policy</code> interface if current thread's user ID is not 0 or current thread's effective user ID is not 0. In other words, only root user (where current thread's user ID and effective user ID are both 0) can modify policy configuration via <code>/proc/caitsith/policy</code> interface.</p> |
| 1422 |
kumaneko |
20 |
|
| 1423 |
kumaneko |
22 |
<p>Since lines starting with <strong>100 allow</strong> have higher priority than a line starting with <strong>10000 deny</strong>, CaitSith will allow modifying policy configuration via <code>/proc/caitsith/policy</code> interface if current thread's program name is <code>/usr/sbin/caitsith-loadpolicy</code> or current thread's program name is <code>/usr/sbin/caitsith-queryd</code>. In other words, other programs such as <code>/bin/sh</code>, <code>/bin/echo</code>, <code>/bin/cat</code> are not allowed to modify policy configuration via <code>/proc/caitsith/policy</code> interface.</p> |
| 1424 |
kumaneko |
20 |
|
| 1425 |
kumaneko |
22 |
<p>To summarize this rule, only <code>/usr/sbin/caitsith-loadpolicy</code> or <code>/usr/sbin/caitsith-queryd</code> command running as root user can modify policy configuration via <code>/proc/caitsith/policy</code> interface.</p> |
| 1426 |
kumaneko |
20 |
|
| 1427 |
|
|
<p>Note the difference between</p> |
| 1428 |
|
|
|
| 1429 |
|
|
<pre> |
| 1430 |
|
|
0 acl execute task.exe="/usr/sbin/httpd" |
| 1431 |
|
|
audit 1 |
| 1432 |
|
|
1 allow path="/var/www/cgi-bin/counter.cgi" |
| 1433 |
|
|
100 deny |
| 1434 |
|
|
</pre> |
| 1435 |
|
|
|
| 1436 |
|
|
<p>and</p> |
| 1437 |
|
|
|
| 1438 |
|
|
<pre> |
| 1439 |
|
|
0 acl execute path="/var/www/cgi-bin/counter.cgi" |
| 1440 |
|
|
audit 1 |
| 1441 |
|
|
1 allow task.exe="/usr/sbin/httpd" |
| 1442 |
|
|
100 deny |
| 1443 |
|
|
</pre> |
| 1444 |
|
|
|
| 1445 |
kumaneko |
22 |
<p>. The former means "<code>/usr/sbin/httpd</code> can execute <strong>only</strong> <code>/var/www/cgi-bin/counter.cgi</code>", while the latter means "<strong>only</strong> <code>/usr/sbin/httpd</code> can execute <code>/var/www/cgi-bin/counter.cgi</code>".</p> |
| 1446 |
kumaneko |
20 |
|
| 1447 |
|
|
<p>CaitSith supports restricting other arguments such as command line arguments and environment variables. Syntax for restricting other arguments will be explained later.</p> |
| 1448 |
|
|
|
| 1449 |
|
|
<h4><a name="3.4.3">3.4.3. Writing access restriction rules from the point of view of both "subject" and "object".</a></h4> |
| 1450 |
|
|
|
| 1451 |
|
|
<p>It is possible to write access restriction rules like</p> |
| 1452 |
|
|
|
| 1453 |
|
|
<pre> |
| 1454 |
|
|
0 acl execute task.exe="/usr/sbin/httpd" path="/var/www/cgi-bin/counter.cgi" |
| 1455 |
|
|
audit 1 |
| 1456 |
|
|
1 allow task.uid!=0 |
| 1457 |
|
|
100 deny |
| 1458 |
|
|
</pre> |
| 1459 |
|
|
|
| 1460 |
|
|
<p>and</p> |
| 1461 |
|
|
|
| 1462 |
|
|
<pre> |
| 1463 |
|
|
0 acl execute task.uid!=0 |
| 1464 |
|
|
audit 1 |
| 1465 |
|
|
1 allow task.exe="/usr/sbin/httpd" path="/var/www/cgi-bin/counter.cgi" |
| 1466 |
|
|
100 deny |
| 1467 |
|
|
</pre> |
| 1468 |
|
|
|
| 1469 |
kumaneko |
22 |
<p>. The former means "<code>/usr/sbin/httpd</code> is allowed to execute <code>/var/www/cgi-bin/counter.cgi</code> only if current thread's user ID is not 0", while the latter means "only execution of <code>/var/www/cgi-bin/counter.cgi</code> from <code>/usr/sbin/httpd</code> is allowed if current thread's user ID is not 0".</p> |
| 1470 |
kumaneko |
20 |
|
| 1471 |
|
|
<p>Also, it is possible to write access restriction rules like</p> |
| 1472 |
|
|
|
| 1473 |
|
|
<pre> |
| 1474 |
|
|
0 acl execute |
| 1475 |
|
|
audit 1 |
| 1476 |
|
|
1 allow task.exe="/usr/sbin/httpd" path="/var/www/cgi-bin/counter.cgi" |
| 1477 |
|
|
100 deny |
| 1478 |
|
|
</pre> |
| 1479 |
|
|
|
| 1480 |
kumaneko |
22 |
<p>which means "any execute requests other than execution of <code>/var/www/cgi-bin/counter.cgi</code> from <code>/usr/sbin/httpd</code> are denied" (DO NOT TRY THIS EXAMPLE, or you will no longer be able to run any commands).</p> |
| 1481 |
kumaneko |
20 |
|
| 1482 |
kumaneko |
30 |
<hr> |
| 1483 |
kumaneko |
112 |
<h3><a name="3.5">3.5. Steps for writing access restriction rules</a></h3> |
| 1484 |
|
|
|
| 1485 |
|
|
<p>An example of steps for writing access restriction rules using pathnames is shown here.</p> |
| 1486 |
|
|
|
| 1487 |
|
|
<p>Step 1: Determine resource to restrict access.</p> |
| 1488 |
|
|
|
| 1489 |
|
|
<p>Below example restricts opening <code>/etc/shadow</code> for reading.</p> |
| 1490 |
|
|
|
| 1491 |
|
|
<pre> |
| 1492 |
|
|
100 acl read path="/etc/shadow" |
| 1493 |
|
|
audit 1 |
| 1494 |
|
|
</pre> |
| 1495 |
|
|
|
| 1496 |
|
|
<p>Step 2: Gather logs of accessing resources.</p> |
| 1497 |
|
|
|
| 1498 |
|
|
<p>As you operate the system with above example, access unmatched logs are generated and spooled in <code>/proc/caitsith/audit</code> interface when access request of opening <code>/etc/shadow</code> for reading happens. If <code>/usr/sbin/caitsith-auditd</code> is running, access unmatched logs will be moved to <code>/var/log/caitsith/unmatched.log</code>.</p> |
| 1499 |
|
|
|
| 1500 |
|
|
<pre> |
| 1501 |
|
|
#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 |
| 1502 |
|
|
</pre> |
| 1503 |
|
|
|
| 1504 |
|
|
<p>Step 3: Decide whether to grant or reject.</p> |
| 1505 |
|
|
|
| 1506 |
|
|
<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 <code>/usr/bin/passwd</code> program.</p> |
| 1507 |
|
|
|
| 1508 |
|
|
<pre> |
| 1509 |
|
|
100 acl read path="/etc/shadow" |
| 1510 |
|
|
audit 1 |
| 1511 |
|
|
100 allow task.exe="/usr/bin/passwd" |
| 1512 |
|
|
</pre> |
| 1513 |
|
|
|
| 1514 |
|
|
<p>Step 4: Gather again logs of accessing resources.</p> |
| 1515 |
|
|
|
| 1516 |
|
|
<p>Operate the system again. For example, <code>/usr/sbin/sshd</code> program and <code>/bin/cat</code> program have requested opening <code>/etc/shadow</code> for reading.</p> |
| 1517 |
|
|
|
| 1518 |
|
|
<pre> |
| 1519 |
|
|
#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 |
| 1520 |
|
|
#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 |
| 1521 |
|
|
</pre> |
| 1522 |
|
|
|
| 1523 |
|
|
<p>Step 5: Decide again whether to grant or reject.</p> |
| 1524 |
|
|
|
| 1525 |
|
|
<p>Add an allow line with <code>/usr/sbin/sshd</code> program in order to allow access by <code>/usr/sbin/sshd</code> program. Also, add a deny line with <code>/bin/cat</code> program in order to deny access by <code>/bin/cat</code> 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> |
| 1526 |
|
|
|
| 1527 |
|
|
<pre> |
| 1528 |
|
|
100 acl read path="/etc/shadow" |
| 1529 |
|
|
audit 1 |
| 1530 |
|
|
10 deny task.exe="/bin/cat" |
| 1531 |
|
|
100 allow task.exe="/usr/bin/passwd" |
| 1532 |
|
|
100 allow task.exe="/usr/sbin/sshd" |
| 1533 |
|
|
</pre> |
| 1534 |
|
|
|
| 1535 |
|
|
<p>From now on, attempt to read <code>/etc/shadow</code> using <code>/bin/cat</code> should be denied and access denied logs should be generated. If <code>/usr/sbin/caitsith-auditd</code> is running, access denied logs will be moved to <code>/var/log/caitsith/denied.log</code>.</p> |
| 1536 |
|
|
|
| 1537 |
|
|
<pre> |
| 1538 |
|
|
#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 |
| 1539 |
|
|
</pre> |
| 1540 |
|
|
|
| 1541 |
|
|
<p>Step 6: Finish up a rule.</p> |
| 1542 |
|
|
|
| 1543 |
|
|
<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> |
| 1544 |
|
|
|
| 1545 |
|
|
<pre> |
| 1546 |
|
|
100 acl read path="/etc/shadow" |
| 1547 |
|
|
audit 1 |
| 1548 |
|
|
10 deny task.exe="/bin/cat" |
| 1549 |
|
|
100 allow task.exe="/usr/bin/passwd" |
| 1550 |
|
|
100 allow task.exe="/usr/sbin/sshd" |
| 1551 |
|
|
10000 deny |
| 1552 |
|
|
</pre> |
| 1553 |
|
|
|
| 1554 |
|
|
<p>A rule for restricting <code>/etc/shadow</code> for opening is now completed. Please do not copy and paste this example, for there must be other programs which need to open <code>/etc/shadow</code> for reading.</p> |
| 1555 |
|
|
|
| 1556 |
|
|
<hr> |
| 1557 |
|
|
<h3><a name="3.6">3.6. Restricting access in various ways</a></h3> |
| 1558 |
|
|
|
| 1559 |
|
|
<p>The rule demonstrated in <a href="#3.5">3.5. Steps for writing access restriction rules</a> alone cannot prevent diverted accesses such as creating a hard link of <code>/etc/shadow</code>. CaitSith supports various variables for writing access restriction rules. If the resource to protect has characteristic attribute, it is recommended to utilize such attributes. (The full list of available variables/attributes will be explained in <a href="#condition_list">4. List of conditions</a>.)</p> |
| 1560 |
|
|
|
| 1561 |
|
|
<p>On several distributions, <code>/etc/shadow</code> 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> |
| 1562 |
|
|
|
| 1563 |
|
|
<pre> |
| 1564 |
|
|
100 acl read path.gid=42 |
| 1565 |
|
|
audit 1 |
| 1566 |
|
|
10 deny task.exe="/bin/cat" |
| 1567 |
|
|
100 allow task.exe="/usr/bin/passwd" |
| 1568 |
|
|
100 allow task.exe="/usr/sbin/sshd" |
| 1569 |
|
|
10000 deny |
| 1570 |
|
|
</pre> |
| 1571 |
|
|
|
| 1572 |
|
|
<p>On several distributions, <code>/etc/shadow</code> 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> |
| 1573 |
|
|
|
| 1574 |
|
|
<pre> |
| 1575 |
|
|
100 acl read path.uid=0 path.gid=0 path.perm=0400 |
| 1576 |
|
|
audit 1 |
| 1577 |
|
|
10 deny task.exe="/bin/cat" |
| 1578 |
|
|
100 allow task.exe="/usr/bin/passwd" |
| 1579 |
|
|
100 allow task.exe="/usr/sbin/sshd" |
| 1580 |
|
|
10000 deny |
| 1581 |
|
|
</pre> |
| 1582 |
|
|
|
| 1583 |
|
|
<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> |
| 1584 |
|
|
|
| 1585 |
|
|
<pre> |
| 1586 |
|
|
100 acl link old_path.uid!=task.uid |
| 1587 |
|
|
audit 1 |
| 1588 |
|
|
100 deny |
| 1589 |
|
|
</pre> |
| 1590 |
|
|
|
| 1591 |
|
|
<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> |
| 1592 |
|
|
|
| 1593 |
|
|
<pre> |
| 1594 |
|
|
100 acl link old_path.fsmagic=0x01021994 |
| 1595 |
|
|
audit 1 |
| 1596 |
|
|
10 deny |
| 1597 |
|
|
</pre> |
| 1598 |
|
|
|
| 1599 |
|
|
<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 <code>/home</code> partition from <code>/</code> partition will be useful when protecting resources in <code>/home</code> partition.</p> |
| 1600 |
|
|
|
| 1601 |
|
|
<hr> |
| 1602 |
kumaneko |
29 |
<h2><a name="condition_list">4. List of conditions</a></h2> |
| 1603 |
kumaneko |
20 |
|
| 1604 |
kumaneko |
30 |
<hr> |
| 1605 |
kumaneko |
29 |
<h3><a name="4.1">4.1. Using string arguments in conditions</a></h3> |
| 1606 |
|
|
|
| 1607 |
kumaneko |
18 |
<p>Arguments such as file's pathnames and command line arguments and environment variables are handled as string argument.</p> |
| 1608 |
|
|
|
| 1609 |
kumaneko |
30 |
<h4><a name="4.1.1">4.1.1. About string argument representation rule</a></h4> |
| 1610 |
kumaneko |
18 |
|
| 1611 |
|
|
<p>All ASCII printable characters other than \ character (i.e. from 33 to 91 and from 93 to 126) are represented as is.</p> |
| 1612 |
|
|
|
| 1613 |
|
|
<p>All other characters (i.e. from 0 to 32, 92 and from 127 to 255) are represented using \ooo style octal form.</p> |
| 1614 |
|
|
|
| 1615 |
|
|
<table border="1"> |
| 1616 |
|
|
<tr> |
| 1617 |
|
|
<td> |
| 1618 |
|
|
<table><tr><td></td><td>Lower 4 bits</td></tr><tr><td>Upper 4 bits</td><td></td></tr></table> |
| 1619 |
|
|
</td> |
| 1620 |
|
|
<th><p>0x0</p></th> |
| 1621 |
|
|
<th><p>0x1</p></th> |
| 1622 |
|
|
<th><p>0x2</p></th> |
| 1623 |
|
|
<th><p>0x3</p></th> |
| 1624 |
|
|
<th><p>0x4</p></th> |
| 1625 |
|
|
<th><p>0x5</p></th> |
| 1626 |
|
|
<th><p>0x6</p></th> |
| 1627 |
|
|
<th><p>0x7</p></th> |
| 1628 |
|
|
<th><p>0x8</p></th> |
| 1629 |
|
|
<th><p>0x9</p></th> |
| 1630 |
|
|
<th><p>0xA</p></th> |
| 1631 |
|
|
<th><p>0xB</p></th> |
| 1632 |
|
|
<th><p>0xC</p></th> |
| 1633 |
|
|
<th><p>0xD</p></th> |
| 1634 |
|
|
<th><p>0xE</p></th> |
| 1635 |
|
|
<th><p>0xF</p></th> |
| 1636 |
|
|
</tr> |
| 1637 |
|
|
<tr> |
| 1638 |
|
|
<th><p>0x0</p></th> |
| 1639 |
|
|
<td><p>\000</p></td> |
| 1640 |
|
|
<td><p>\001</p></td> |
| 1641 |
|
|
<td><p>\002</p></td> |
| 1642 |
|
|
<td><p>\003</p></td> |
| 1643 |
|
|
<td><p>\004</p></td> |
| 1644 |
|
|
<td><p>\005</p></td> |
| 1645 |
|
|
<td><p>\006</p></td> |
| 1646 |
|
|
<td><p>\007</p></td> |
| 1647 |
|
|
<td><p>\010</p></td> |
| 1648 |
|
|
<td><p>\011</p></td> |
| 1649 |
|
|
<td><p>\012</p></td> |
| 1650 |
|
|
<td><p>\013</p></td> |
| 1651 |
|
|
<td><p>\014</p></td> |
| 1652 |
|
|
<td><p>\015</p></td> |
| 1653 |
|
|
<td><p>\016</p></td> |
| 1654 |
|
|
<td><p>\017</p></td> |
| 1655 |
|
|
</tr> |
| 1656 |
|
|
<tr> |
| 1657 |
|
|
<th><p>0x1</p></th> |
| 1658 |
|
|
<td><p>\020</p></td> |
| 1659 |
|
|
<td><p>\021</p></td> |
| 1660 |
|
|
<td><p>\022</p></td> |
| 1661 |
|
|
<td><p>\023</p></td> |
| 1662 |
|
|
<td><p>\024</p></td> |
| 1663 |
|
|
<td><p>\025</p></td> |
| 1664 |
|
|
<td><p>\026</p></td> |
| 1665 |
|
|
<td><p>\027</p></td> |
| 1666 |
|
|
<td><p>\030</p></td> |
| 1667 |
|
|
<td><p>\031</p></td> |
| 1668 |
|
|
<td><p>\032</p></td> |
| 1669 |
|
|
<td><p>\033</p></td> |
| 1670 |
|
|
<td><p>\034</p></td> |
| 1671 |
|
|
<td><p>\035</p></td> |
| 1672 |
|
|
<td><p>\036</p></td> |
| 1673 |
|
|
<td><p>\037</p></td> |
| 1674 |
|
|
</tr> |
| 1675 |
|
|
<tr> |
| 1676 |
|
|
<th><p>0x2</p></th> |
| 1677 |
|
|
<td><p>\040</p></td> |
| 1678 |
|
|
<td><p>!</p></td> |
| 1679 |
|
|
<td><p>"</p></td> |
| 1680 |
|
|
<td><p>#</p></td> |
| 1681 |
|
|
<td><p>$</p></td> |
| 1682 |
|
|
<td><p>%</p></td> |
| 1683 |
|
|
<td><p>&</p></td> |
| 1684 |
|
|
<td><p>'</p></td> |
| 1685 |
|
|
<td><p>(</p></td> |
| 1686 |
|
|
<td><p>)</p></td> |
| 1687 |
|
|
<td><p>*</p></td> |
| 1688 |
|
|
<td><p>+</p></td> |
| 1689 |
|
|
<td><p>,</p></td> |
| 1690 |
|
|
<td><p>-</p></td> |
| 1691 |
|
|
<td><p>.</p></td> |
| 1692 |
|
|
<td><p>/</p></td> |
| 1693 |
|
|
</tr> |
| 1694 |
|
|
<tr> |
| 1695 |
|
|
<th><p>0x3</p></th> |
| 1696 |
|
|
<td><p>0</p></td> |
| 1697 |
|
|
<td><p>1</p></td> |
| 1698 |
|
|
<td><p>2</p></td> |
| 1699 |
|
|
<td><p>3</p></td> |
| 1700 |
|
|
<td><p>4</p></td> |
| 1701 |
|
|
<td><p>5</p></td> |
| 1702 |
|
|
<td><p>6</p></td> |
| 1703 |
|
|
<td><p>7</p></td> |
| 1704 |
|
|
<td><p>8</p></td> |
| 1705 |
|
|
<td><p>9</p></td> |
| 1706 |
|
|
<td><p>:</p></td> |
| 1707 |
|
|
<td><p>;</p></td> |
| 1708 |
|
|
<td><p><</p></td> |
| 1709 |
|
|
<td><p>=</p></td> |
| 1710 |
|
|
<td><p>></p></td> |
| 1711 |
|
|
<td><p>?</p></td> |
| 1712 |
|
|
</tr> |
| 1713 |
|
|
<tr> |
| 1714 |
|
|
<th><p>0x4</p></th> |
| 1715 |
|
|
<td><p>@</p></td> |
| 1716 |
|
|
<td><p>A</p></td> |
| 1717 |
|
|
<td><p>B</p></td> |
| 1718 |
|
|
<td><p>C</p></td> |
| 1719 |
|
|
<td><p>D</p></td> |
| 1720 |
|
|
<td><p>E</p></td> |
| 1721 |
|
|
<td><p>F</p></td> |
| 1722 |
|
|
<td><p>G</p></td> |
| 1723 |
|
|
<td><p>H</p></td> |
| 1724 |
|
|
<td><p>I</p></td> |
| 1725 |
|
|
<td><p>J</p></td> |
| 1726 |
|
|
<td><p>K</p></td> |
| 1727 |
|
|
<td><p>L</p></td> |
| 1728 |
|
|
<td><p>M</p></td> |
| 1729 |
|
|
<td><p>N</p></td> |
| 1730 |
|
|
<td><p>O</p></td> |
| 1731 |
|
|
</tr> |
| 1732 |
|
|
<tr> |
| 1733 |
|
|
<th><p>0x5</p></th> |
| 1734 |
|
|
<td><p>P</p></td> |
| 1735 |
|
|
<td><p>Q</p></td> |
| 1736 |
|
|
<td><p>R</p></td> |
| 1737 |
|
|
<td><p>S</p></td> |
| 1738 |
|
|
<td><p>T</p></td> |
| 1739 |
|
|
<td><p>U</p></td> |
| 1740 |
|
|
<td><p>V</p></td> |
| 1741 |
|
|
<td><p>W</p></td> |
| 1742 |
|
|
<td><p>X</p></td> |
| 1743 |
|
|
<td><p>Y</p></td> |
| 1744 |
|
|
<td><p>Z</p></td> |
| 1745 |
|
|
<td><p>[</p></td> |
| 1746 |
|
|
<td><p>\134</p></td> |
| 1747 |
|
|
<td><p>]</p></td> |
| 1748 |
|
|
<td><p>^</p></td> |
| 1749 |
|
|
<td><p>_</p></td> |
| 1750 |
|
|
</tr> |
| 1751 |
|
|
<tr> |
| 1752 |
|
|
<th><p>0x6</p></th> |
| 1753 |
|
|
<td><p>`</p></td> |
| 1754 |
|
|
<td><p>a</p></td> |
| 1755 |
|
|
<td><p>b</p></td> |
| 1756 |
|
|
<td><p>c</p></td> |
| 1757 |
|
|
<td><p>d</p></td> |
| 1758 |
|
|
<td><p>e</p></td> |
| 1759 |
|
|
<td><p>f</p></td> |
| 1760 |
|
|
<td><p>g</p></td> |
| 1761 |
|
|
<td><p>h</p></td> |
| 1762 |
|
|
<td><p>i</p></td> |
| 1763 |
|
|
<td><p>j</p></td> |
| 1764 |
|
|
<td><p>k</p></td> |
| 1765 |
|
|
<td><p>l</p></td> |
| 1766 |
|
|
<td><p>m</p></td> |
| 1767 |
|
|
<td><p>n</p></td> |
| 1768 |
|
|
<td><p>o</p></td> |
| 1769 |
|
|
</tr> |
| 1770 |
|
|
<tr> |
| 1771 |
|
|
<th><p>0x7</p></th> |
| 1772 |
|
|
<td><p>p</p></td> |
| 1773 |
|
|
<td><p>q</p></td> |
| 1774 |
|
|
<td><p>r</p></td> |
| 1775 |
|
|
<td><p>s</p></td> |
| 1776 |
|
|
<td><p>t</p></td> |
| 1777 |
|
|
<td><p>u</p></td> |
| 1778 |
|
|
<td><p>v</p></td> |
| 1779 |
|
|
<td><p>w</p></td> |
| 1780 |
|
|
<td><p>x</p></td> |
| 1781 |
|
|
<td><p>y</p></td> |
| 1782 |
|
|
<td><p>z</p></td> |
| 1783 |
|
|
<td><p>{</p></td> |
| 1784 |
|
|
<td><p>|</p></td> |
| 1785 |
|
|
<td><p>}</p></td> |
| 1786 |
|
|
<td><p>~</p></td> |
| 1787 |
|
|
<td><p>\177</p></td> |
| 1788 |
|
|
</tr> |
| 1789 |
|
|
<tr> |
| 1790 |
|
|
<th><p>0x8</p></th> |
| 1791 |
|
|
<td><p>\200</p></td> |
| 1792 |
|
|
<td><p>\201</p></td> |
| 1793 |
|
|
<td><p>\202</p></td> |
| 1794 |
|
|
<td><p>\203</p></td> |
| 1795 |
|
|
<td><p>\204</p></td> |
| 1796 |
|
|
<td><p>\205</p></td> |
| 1797 |
|
|
<td><p>\206</p></td> |
| 1798 |
|
|
<td><p>\207</p></td> |
| 1799 |
|
|
<td><p>\210</p></td> |
| 1800 |
|
|
<td><p>\211</p></td> |
| 1801 |
|
|
<td><p>\212</p></td> |
| 1802 |
|
|
<td><p>\213</p></td> |
| 1803 |
|
|
<td><p>\214</p></td> |
| 1804 |
|
|
<td><p>\215</p></td> |
| 1805 |
|
|
<td><p>\216</p></td> |
| 1806 |
|
|
<td><p>\217</p></td> |
| 1807 |
|
|
</tr> |
| 1808 |
|
|
<tr> |
| 1809 |
|
|
<th><p>0x9</p></th> |
| 1810 |
|
|
<td><p>\220</p></td> |
| 1811 |
|
|
<td><p>\221</p></td> |
| 1812 |
|
|
<td><p>\222</p></td> |
| 1813 |
|
|
<td><p>\223</p></td> |
| 1814 |
|
|
<td><p>\224</p></td> |
| 1815 |
|
|
<td><p>\225</p></td> |
| 1816 |
|
|
<td><p>\226</p></td> |
| 1817 |
|
|
<td><p>\227</p></td> |
| 1818 |
|
|
<td><p>\230</p></td> |
| 1819 |
|
|
<td><p>\231</p></td> |
| 1820 |
|
|
<td><p>\232</p></td> |
| 1821 |
|
|
<td><p>\233</p></td> |
| 1822 |
|
|
<td><p>\234</p></td> |
| 1823 |
|
|
<td><p>\235</p></td> |
| 1824 |
|
|
<td><p>\236</p></td> |
| 1825 |
|
|
<td><p>\237</p></td> |
| 1826 |
|
|
</tr> |
| 1827 |
|
|
<tr> |
| 1828 |
|
|
<th><p>0xA</p></th> |
| 1829 |
|
|
<td><p>\240</p></td> |
| 1830 |
|
|
<td><p>\241</p></td> |
| 1831 |
|
|
<td><p>\242</p></td> |
| 1832 |
|
|
<td><p>\243</p></td> |
| 1833 |
|
|
<td><p>\244</p></td> |
| 1834 |
|
|
<td><p>\245</p></td> |
| 1835 |
|
|
<td><p>\246</p></td> |
| 1836 |
|
|
<td><p>\247</p></td> |
| 1837 |
|
|
<td><p>\250</p></td> |
| 1838 |
|
|
<td><p>\251</p></td> |
| 1839 |
|
|
<td><p>\252</p></td> |
| 1840 |
|
|
<td><p>\253</p></td> |
| 1841 |
|
|
<td><p>\254</p></td> |
| 1842 |
|
|
<td><p>\255</p></td> |
| 1843 |
|
|
<td><p>\256</p></td> |
| 1844 |
|
|
<td><p>\257</p></td> |
| 1845 |
|
|
</tr> |
| 1846 |
|
|
<tr> |
| 1847 |
|
|
<th><p>0xB</p></th> |
| 1848 |
|
|
<td><p>\260</p></td> |
| 1849 |
|
|
<td><p>\261</p></td> |
| 1850 |
|
|
<td><p>\262</p></td> |
| 1851 |
|
|
<td><p>\263</p></td> |
| 1852 |
|
|
<td><p>\264</p></td> |
| 1853 |
|
|
<td><p>\265</p></td> |
| 1854 |
|
|
<td><p>\266</p></td> |
| 1855 |
|
|
<td><p>\267</p></td> |
| 1856 |
|
|
<td><p>\270</p></td> |
| 1857 |
|
|
<td><p>\271</p></td> |
| 1858 |
|
|
<td><p>\272</p></td> |
| 1859 |
|
|
<td><p>\273</p></td> |
| 1860 |
|
|
<td><p>\274</p></td> |
| 1861 |
|
|
<td><p>\275</p></td> |
| 1862 |
|
|
<td><p>\276</p></td> |
| 1863 |
|
|
<td><p>\277</p></td> |
| 1864 |
|
|
</tr> |
| 1865 |
|
|
<tr> |
| 1866 |
|
|
<th><p>0xC</p></th> |
| 1867 |
|
|
<td><p>\300</p></td> |
| 1868 |
|
|
<td><p>\301</p></td> |
| 1869 |
|
|
<td><p>\302</p></td> |
| 1870 |
|
|
<td><p>\303</p></td> |
| 1871 |
|
|
<td><p>\304</p></td> |
| 1872 |
|
|
<td><p>\305</p></td> |
| 1873 |
|
|
<td><p>\306</p></td> |
| 1874 |
|
|
<td><p>\307</p></td> |
| 1875 |
|
|
<td><p>\310</p></td> |
| 1876 |
|
|
<td><p>\311</p></td> |
| 1877 |
|
|
<td><p>\312</p></td> |
| 1878 |
|
|
<td><p>\313</p></td> |
| 1879 |
|
|
<td><p>\314</p></td> |
| 1880 |
|
|
<td><p>\315</p></td> |
| 1881 |
|
|
<td><p>\316</p></td> |
| 1882 |
|
|
<td><p>\317</p></td> |
| 1883 |
|
|
</tr> |
| 1884 |
|
|
<tr> |
| 1885 |
|
|
<th><p>0xD</p></th> |
| 1886 |
|
|
<td><p>\320</p></td> |
| 1887 |
|
|
<td><p>\321</p></td> |
| 1888 |
|
|
<td><p>\322</p></td> |
| 1889 |
|
|
<td><p>\323</p></td> |
| 1890 |
|
|
<td><p>\324</p></td> |
| 1891 |
|
|
<td><p>\325</p></td> |
| 1892 |
|
|
<td><p>\326</p></td> |
| 1893 |
|
|
<td><p>\327</p></td> |
| 1894 |
|
|
<td><p>\330</p></td> |
| 1895 |
|
|
<td><p>\331</p></td> |
| 1896 |
|
|
<td><p>\332</p></td> |
| 1897 |
|
|
<td><p>\333</p></td> |
| 1898 |
|
|
<td><p>\334</p></td> |
| 1899 |
|
|
<td><p>\335</p></td> |
| 1900 |
|
|
<td><p>\336</p></td> |
| 1901 |
|
|
<td><p>\337</p></td> |
| 1902 |
|
|
</tr> |
| 1903 |
|
|
<tr> |
| 1904 |
|
|
<th><p>0xE</p></th> |
| 1905 |
|
|
<td><p>\340</p></td> |
| 1906 |
|
|
<td><p>\341</p></td> |
| 1907 |
|
|
<td><p>\342</p></td> |
| 1908 |
|
|
<td><p>\343</p></td> |
| 1909 |
|
|
<td><p>\344</p></td> |
| 1910 |
|
|
<td><p>\345</p></td> |
| 1911 |
|
|
<td><p>\346</p></td> |
| 1912 |
|
|
<td><p>\347</p></td> |
| 1913 |
|
|
<td><p>\350</p></td> |
| 1914 |
|
|
<td><p>\351</p></td> |
| 1915 |
|
|
<td><p>\352</p></td> |
| 1916 |
|
|
<td><p>\353</p></td> |
| 1917 |
|
|
<td><p>\354</p></td> |
| 1918 |
|
|
<td><p>\355</p></td> |
| 1919 |
|
|
<td><p>\356</p></td> |
| 1920 |
|
|
<td><p>\357</p></td> |
| 1921 |
|
|
</tr> |
| 1922 |
|
|
<tr> |
| 1923 |
|
|
<th><p>0xF</p></th> |
| 1924 |
|
|
<td><p>\360</p></td> |
| 1925 |
|
|
<td><p>\361</p></td> |
| 1926 |
|
|
<td><p>\362</p></td> |
| 1927 |
|
|
<td><p>\363</p></td> |
| 1928 |
|
|
<td><p>\364</p></td> |
| 1929 |
|
|
<td><p>\365</p></td> |
| 1930 |
|
|
<td><p>\366</p></td> |
| 1931 |
|
|
<td><p>\367</p></td> |
| 1932 |
|
|
<td><p>\370</p></td> |
| 1933 |
|
|
<td><p>\371</p></td> |
| 1934 |
|
|
<td><p>\372</p></td> |
| 1935 |
|
|
<td><p>\373</p></td> |
| 1936 |
|
|
<td><p>\374</p></td> |
| 1937 |
|
|
<td><p>\375</p></td> |
| 1938 |
|
|
<td><p>\376</p></td> |
| 1939 |
|
|
<td><p>\377</p></td> |
| 1940 |
|
|
</tr> |
| 1941 |
|
|
</table> |
| 1942 |
|
|
|
| 1943 |
|
|
<p>Some examples are shown below.</p> |
| 1944 |
|
|
|
| 1945 |
|
|
<pre> |
| 1946 |
|
|
/bin/sh |
| 1947 |
|
|
/home/demo/Documents\040and\040Settings |
| 1948 |
|
|
</pre> |
| 1949 |
|
|
|
| 1950 |
kumaneko |
30 |
<h4><a name="4.1.2">4.1.2. Grouping string arguments using wildcard expressions.</a></h4> |
| 1951 |
kumaneko |
18 |
|
| 1952 |
|
|
<p>It is possible to use wildcards listed below in order to match string patterns.</p> |
| 1953 |
|
|
|
| 1954 |
|
|
<table border="1"> |
| 1955 |
|
|
<tr> |
| 1956 |
|
|
<th><p>Wildcard</p></th> |
| 1957 |
|
|
<th><p>Pattern match</p></th> |
| 1958 |
|
|
<th><p>Examples</p></th> |
| 1959 |
|
|
</tr> |
| 1960 |
|
|
<tr> |
| 1961 |
|
|
<td><p>\*</p></td> |
| 1962 |
|
|
<td><p>0 or more repetitions of characters other than "/"</p></td> |
| 1963 |
|
|
<td><p>/var/log/samba/\*</p></td> |
| 1964 |
|
|
</tr> |
| 1965 |
|
|
<tr> |
| 1966 |
|
|
<td><p>\@</p></td> |
| 1967 |
|
|
<td><p>0 or more repetitions of characters other than "/" or "."</p></td> |
| 1968 |
|
|
<td><p>/var/www/html/\@.html</p></td> |
| 1969 |
|
|
</tr> |
| 1970 |
|
|
<tr> |
| 1971 |
|
|
<td><p>\?</p></td> |
| 1972 |
|
|
<td><p>1 byte character other than "/"</p></td> |
| 1973 |
|
|
<td><p>/tmp/mail.\?\?\?\?\?\?</p></td> |
| 1974 |
|
|
</tr> |
| 1975 |
|
|
<tr> |
| 1976 |
|
|
<td><p>\$</p></td> |
| 1977 |
|
|
<td><p>1 or more repetitions of decimal digits</p></td> |
| 1978 |
|
|
<td><p>/proc/\$/cmdline</p></td> |
| 1979 |
|
|
</tr> |
| 1980 |
|
|
<tr> |
| 1981 |
|
|
<td><p>\+</p></td> |
| 1982 |
|
|
<td><p>1 decimal digit</p></td> |
| 1983 |
|
|
<td><p>/var/tmp/my_work.\+</p></td> |
| 1984 |
|
|
</tr> |
| 1985 |
|
|
<tr> |
| 1986 |
|
|
<td><p>\X</p></td> |
| 1987 |
|
|
<td><p>1 or more repetitions of hexadecimal digits</p></td> |
| 1988 |
|
|
<td><p>/var/tmp/my-work.\X</p></td> |
| 1989 |
|
|
</tr> |
| 1990 |
|
|
<tr> |
| 1991 |
|
|
<td><p>\x</p></td> |
| 1992 |
|
|
<td><p>1 hexadecimal digit</p></td> |
| 1993 |
|
|
<td><p>/tmp/my-work.\x</p></td> |
| 1994 |
|
|
</tr> |
| 1995 |
|
|
<tr> |
| 1996 |
|
|
<td><p>\A</p></td> |
| 1997 |
|
|
<td><p>1 or more repetitions of alphabet characters</p></td> |
| 1998 |
|
|
<td><p>/var/log/my-work/\$-\A-\$.log</p></td> |
| 1999 |
|
|
</tr> |
| 2000 |
|
|
<tr> |
| 2001 |
|
|
<td><p>\a</p></td> |
| 2002 |
|
|
<td><p>1 alphabet character</p></td> |
| 2003 |
|
|
<td><p>/home/users/\a/\*/public_html/\*.html</p></td> |
| 2004 |
|
|
</tr> |
| 2005 |
|
|
<tr> |
| 2006 |
|
|
<td><p>\-</p></td> |
| 2007 |
|
|
<td><p>Pathname subtraction operator (negative match)</p></td> |
| 2008 |
|
|
<td> |
| 2009 |
|
|
<p>/\*\-proc\-sys</p> |
| 2010 |
|
|
<p>This will match /\* except "/proc" and "/sys".</p> |
| 2011 |
|
|
</td> |
| 2012 |
|
|
</tr> |
| 2013 |
|
|
<tr> |
| 2014 |
|
|
<td><p>/\{dir\}/</p></td> |
| 2015 |
|
|
<td><p>Recursive directory matching operator.</p> |
| 2016 |
|
|
<p>Matches "/" and 1 or more repetitions of "dir/".</p></td> |
| 2017 |
|
|
<td> |
| 2018 |
|
|
<p>/var/www/html/\{\*\}/\*.html</p> |
| 2019 |
|
|
<p>This will match all *.html files in subdirectories under /var/www/html/ directory. Note that /var/www/html/\*.html will not match.</p> |
| 2020 |
|
|
</td> |
| 2021 |
|
|
</tr> |
| 2022 |
|
|
<tr> |
| 2023 |
|
|
<td><p>/({dir\)/</p></td> |
| 2024 |
|
|
<td><p>Recursive directory matching operator.</p> |
| 2025 |
|
|
<p>Matches "/" and 0 or more repetitions of "dir/".</p></td> |
| 2026 |
|
|
<td> |
| 2027 |
|
|
<p>/var/www/html/\(\*\)/\*.html</p> |
| 2028 |
|
|
<p>This will match all *.html files under /var/www/html/ directory. Note that /var/www/html/\*.html will match.</p> |
| 2029 |
|
|
</td> |
| 2030 |
|
|
</tr> |
| 2031 |
|
|
</table> |
| 2032 |
|
|
|
| 2033 |
kumaneko |
30 |
<h4><a name="4.1.3">4.1.3. Grouping string arguments using string_group keyword.</a></h4> |
| 2034 |
kumaneko |
18 |
|
| 2035 |
|
|
<p>It is possible to define groups of string arguments using string_group keyword followed by $string_group_name and $string_group_member.</p> |
| 2036 |
|
|
|
| 2037 |
|
|
<pre> |
| 2038 |
|
|
string_group TMPDIR /tmp |
| 2039 |
|
|
string_group TMPDIR /tmp/\(\*\)/\* |
| 2040 |
|
|
</pre> |
| 2041 |
|
|
|
| 2042 |
kumaneko |
30 |
<h4><a name="4.1.4">4.1.4. Example of conditions that use string arguments.</a></h4> |
| 2043 |
kumaneko |
18 |
|
| 2044 |
|
|
<p>When string argument is specified in condition part, it is quoted by " character in order to clarify that the argument is a string argument rather than name of variable.</p> |
| 2045 |
|
|
|
| 2046 |
|
|
<table border="1"> |
| 2047 |
|
|
<tr><td>Conditions example</td><td>Value of variable "path"</td><td>Comparison result</td></tr> |
| 2048 |
|
|
<tr><td rowspan="5">path="/tmp/\*"</td> |
| 2049 |
|
|
<td>/</td><td>Does not match</td></tr> |
| 2050 |
|
|
<tr><td>/tmp</td><td>Does not match</td></tr> |
| 2051 |
|
|
<tr><td>/tmp/</td><td>Matches</td></tr> |
| 2052 |
|
|
<tr><td>/tmp/rt6bh84t</td><td>Matches</td></tr> |
| 2053 |
|
|
<tr><td>/tmp/349gy08t/y8024fgf</td><td>Does not match</td></tr> |
| 2054 |
|
|
<tr><td rowspan="5">path!="/tmp/\*"</td> |
| 2055 |
|
|
<td>/</td><td>Matches</td></tr> |
| 2056 |
|
|
<tr><td>/tmp</td><td>Matches</td></tr> |
| 2057 |
|
|
<tr><td>/tmp/</td><td>Does not match</td></tr> |
| 2058 |
|
|
<tr><td>/tmp/rt6bh84t</td><td>Does not match</td></tr> |
| 2059 |
|
|
<tr><td>/tmp/349gy08t/y8024fgf</td><td>Matches</td></tr> |
| 2060 |
|
|
</table> |
| 2061 |
|
|
|
| 2062 |
|
|
<p>When string_group argument is specified in condition part, it is prefixed by @ character in order to clarify that the argument is a string_group argument rather than name of variable.</p> |
| 2063 |
|
|
|
| 2064 |
|
|
<table border="1"> |
| 2065 |
|
|
<tr><td>Conditions example</td><td>Value of variable "path"</td><td>Values in TMPDIR group</td><td>Comparison result</td></tr> |
| 2066 |
|
|
<tr><td rowspan="4">path=@TMPDIR</td> |
| 2067 |
|
|
<td>/</td><td rowspan="4">/tmp<br>/tmp/\(\*\)/\*</td><td>Does not match</td></tr> |
| 2068 |
|
|
<tr><td>/tmp</td><td>Matches</td></tr> |
| 2069 |
|
|
<tr><td>/tmp/rt6bh84t</td><td>Matches</td></tr> |
| 2070 |
|
|
<tr><td>/tmp/349gy08t/y8024fgf</td><td>Matches</td></tr> |
| 2071 |
|
|
<tr><td rowspan="4">path!=@TMPDIR</td> |
| 2072 |
|
|
<td>/</td><td rowspan="4">/tmp<br>/tmp/\(\*\)/\*</td><td>Matches</td></tr> |
| 2073 |
|
|
<tr><td>/tmp</td><td>Does not match</td></tr> |
| 2074 |
|
|
<tr><td>/tmp/rt6bh84t</td><td>Does not match</td></tr> |
| 2075 |
|
|
<tr><td>/tmp/349gy08t/y8024fgf</td><td>Does not match</td></tr> |
| 2076 |
|
|
</table> |
| 2077 |
|
|
|
| 2078 |
|
|
<p>List of name of variables which reference string data is explained later.</p> |
| 2079 |
|
|
|
| 2080 |
kumaneko |
30 |
<hr> |
| 2081 |
kumaneko |
29 |
<h3><a name="4.2">4.2. Using numeric arguments in conditions</a></h3> |
| 2082 |
kumaneko |
18 |
|
| 2083 |
|
|
<p>Arguments such as user ID and process ID are handled as numeric argument.</p> |
| 2084 |
|
|
|
| 2085 |
kumaneko |
30 |
<h4><a name="4.2.1">4.2.1. About numeric argument representation rule</a></h4> |
| 2086 |
kumaneko |
18 |
|
| 2087 |
|
|
<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> |
| 2088 |
|
|
|
| 2089 |
|
|
<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> |
| 2090 |
|
|
|
| 2091 |
|
|
<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> |
| 2092 |
|
|
|
| 2093 |
|
|
<p>Some examples are shown below.</p> |
| 2094 |
|
|
|
| 2095 |
|
|
<pre> |
| 2096 |
|
|
0 |
| 2097 |
|
|
100 |
| 2098 |
|
|
0xFFFF |
| 2099 |
|
|
0777 |
| 2100 |
|
|
500-1000 |
| 2101 |
|
|
0x0-0xFFFFFFFF |
| 2102 |
|
|
00-07777 |
| 2103 |
|
|
</pre> |
| 2104 |
|
|
|
| 2105 |
kumaneko |
30 |
<h4><a name="4.2.2">4.2.2. Grouping numeric arguments using number_group keyword.</a></h4> |
| 2106 |
kumaneko |
18 |
|
| 2107 |
|
|
<p>It is possible to define groups of numeric arguments using number_group keyword followed by $number_group_name and $number_group_member.</p> |
| 2108 |
|
|
|
| 2109 |
|
|
<pre> |
| 2110 |
|
|
number_group ID_GROUP 100 |
| 2111 |
|
|
number_group ID_GROUP 200-500 |
| 2112 |
|
|
</pre> |
| 2113 |
|
|
|
| 2114 |
kumaneko |
30 |
<h4><a name="4.2.3">4.2.3. Example of conditions that use numeric arguments.</a></h4> |
| 2115 |
kumaneko |
18 |
|
| 2116 |
|
|
<p>Comparison with numeric value is defined as below.</p> |
| 2117 |
|
|
|
| 2118 |
|
|
<table border="1"> |
| 2119 |
|
|
<tr><td>Conditions example</td><td>Value of variable "task.uid"</td><td>Comparison result</td></tr> |
| 2120 |
|
|
<tr><td rowspan="3">task.uid=0</td> |
| 2121 |
|
|
<td>0</td><td>Matches</td></tr> |
| 2122 |
|
|
<tr><td>100</td><td>Does not match</td></tr> |
| 2123 |
|
|
<tr><td>500</td><td>Does not match</td></tr> |
| 2124 |
|
|
<tr><td rowspan="3">task.uid!=0</td> |
| 2125 |
|
|
<td>0</td><td>Does not match</td></tr> |
| 2126 |
|
|
<tr><td>100</td><td>Matches</td></tr> |
| 2127 |
|
|
<tr><td>500</td><td>Matches</td></tr> |
| 2128 |
|
|
</table> |
| 2129 |
|
|
|
| 2130 |
|
|
<p>Comparison with numeric value range is defined as below.</p> |
| 2131 |
|
|
|
| 2132 |
|
|
<table border="1"> |
| 2133 |
|
|
<tr><td>Conditions example</td><td>Value of variable "task.gid"</td><td>Comparison result</td></tr> |
| 2134 |
|
|
<tr><td rowspan="3">task.gid=0-100</td> |
| 2135 |
|
|
<td>0</td><td>Matches</td></tr> |
| 2136 |
|
|
<tr><td>100</td><td>Matches</td></tr> |
| 2137 |
|
|
<tr><td>500</td><td>Does not match</td></tr> |
| 2138 |
|
|
<tr><td rowspan="3">task.gid!=0-100</td><td>0</td><td>Does not match</td></tr> |
| 2139 |
|
|
<tr><td>100</td><td>Does not match</td></tr> |
| 2140 |
|
|
<tr><td>500</td><td>Matches</td></tr> |
| 2141 |
|
|
</table> |
| 2142 |
|
|
|
| 2143 |
|
|
<p>It is possible to compare one variable which references numeric value with another variable which references numeric value.</p> |
| 2144 |
|
|
|
| 2145 |
|
|
<table border="1"> |
| 2146 |
|
|
<tr><td>Conditions example</td><td>Value of variable "task.uid"</td><td>Value of variable "task.gid"</td><td>Comparison result</td></tr> |
| 2147 |
|
|
<tr><td rowspan="4">task.uid=task.gid</td> |
| 2148 |
|
|
<td>0</td><td>0</td><td>Matches</td></tr> |
| 2149 |
|
|
<tr><td>0</td><td>100</td><td>Does not match</td></tr> |
| 2150 |
|
|
<tr><td>100</td><td>0</td><td>Does not match</td></tr> |
| 2151 |
|
|
<tr><td>100</td><td>100</td><td>Matches</td></tr> |
| 2152 |
|
|
<tr><td rowspan="4">task.uid!=task.gid</td> |
| 2153 |
|
|
<td>0</td><td>0</td><td>Does not match</td></tr> |
| 2154 |
|
|
<tr><td>0</td><td>100</td><td>Matches</td></tr> |
| 2155 |
|
|
<tr><td>100</td><td>0</td><td>Matches</td></tr> |
| 2156 |
|
|
<tr><td>100</td><td>100</td><td>Does not match</td></tr> |
| 2157 |
|
|
</table> |
| 2158 |
|
|
|
| 2159 |
|
|
<p>When number_group argument is specified in condition part, it is prefixed by @ character in order to clarify that the argument is a number_group argument rather than name of variable.</p> |
| 2160 |
|
|
|
| 2161 |
| |