fix unused setup_nr_node_ids
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / capability.h
blobbbf8df7de28f0991fcc7a240eb8f70723b38eb35
1 /*
2 * This is <linux/capability.h>
4 * Andrew G. Morgan <morgan@transmeta.com>
5 * Alexander Kjeldaas <astor@guardian.no>
6 * with help from Aleph1, Roland Buresund and Andrew Main.
8 * See here for the libcap library ("POSIX draft" compliance):
10 * ftp://linux.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.2/
11 */
13 #ifndef _LINUX_CAPABILITY_H
14 #define _LINUX_CAPABILITY_H
16 #include <linux/types.h>
17 #include <linux/compiler.h>
19 struct task_struct;
21 /* User-level do most of the mapping between kernel and user
22 capabilities based on the version tag given by the kernel. The
23 kernel might be somewhat backwards compatible, but don't bet on
24 it. */
26 /* XXX - Note, cap_t, is defined by POSIX to be an "opaque" pointer to
27 a set of three capability sets. The transposition of 3*the
28 following structure to such a composite is better handled in a user
29 library since the draft standard requires the use of malloc/free
30 etc.. */
32 #define _LINUX_CAPABILITY_VERSION 0x19980330
34 typedef struct __user_cap_header_struct {
35 __u32 version;
36 int pid;
37 } __user *cap_user_header_t;
39 typedef struct __user_cap_data_struct {
40 __u32 effective;
41 __u32 permitted;
42 __u32 inheritable;
43 } __user *cap_user_data_t;
45 #ifdef __KERNEL__
47 #include <linux/spinlock.h>
48 #include <asm/current.h>
50 /* #define STRICT_CAP_T_TYPECHECKS */
52 #ifdef STRICT_CAP_T_TYPECHECKS
54 typedef struct kernel_cap_struct {
55 __u32 cap;
56 } kernel_cap_t;
58 #else
60 typedef __u32 kernel_cap_t;
62 #endif
64 #define _USER_CAP_HEADER_SIZE (2*sizeof(__u32))
65 #define _KERNEL_CAP_T_SIZE (sizeof(kernel_cap_t))
67 #endif
70 /**
71 ** POSIX-draft defined capabilities.
72 **/
74 /* In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this
75 overrides the restriction of changing file ownership and group
76 ownership. */
78 #define CAP_CHOWN 0
80 /* Override all DAC access, including ACL execute access if
81 [_POSIX_ACL] is defined. Excluding DAC access covered by
82 CAP_LINUX_IMMUTABLE. */
84 #define CAP_DAC_OVERRIDE 1
86 /* Overrides all DAC restrictions regarding read and search on files
87 and directories, including ACL restrictions if [_POSIX_ACL] is
88 defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */
90 #define CAP_DAC_READ_SEARCH 2
92 /* Overrides all restrictions about allowed operations on files, where
93 file owner ID must be equal to the user ID, except where CAP_FSETID
94 is applicable. It doesn't override MAC and DAC restrictions. */
96 #define CAP_FOWNER 3
98 /* Overrides the following restrictions that the effective user ID
99 shall match the file owner ID when setting the S_ISUID and S_ISGID
100 bits on that file; that the effective group ID (or one of the
101 supplementary group IDs) shall match the file owner ID when setting
102 the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are
103 cleared on successful return from chown(2) (not implemented). */
105 #define CAP_FSETID 4
107 /* Used to decide between falling back on the old suser() or fsuser(). */
109 #define CAP_FS_MASK 0x1f
111 /* Overrides the restriction that the real or effective user ID of a
112 process sending a signal must match the real or effective user ID
113 of the process receiving the signal. */
115 #define CAP_KILL 5
117 /* Allows setgid(2) manipulation */
118 /* Allows setgroups(2) */
119 /* Allows forged gids on socket credentials passing. */
121 #define CAP_SETGID 6
123 /* Allows set*uid(2) manipulation (including fsuid). */
124 /* Allows forged pids on socket credentials passing. */
126 #define CAP_SETUID 7
130 ** Linux-specific capabilities
133 /* Transfer any capability in your permitted set to any pid,
134 remove any capability in your permitted set from any pid */
136 #define CAP_SETPCAP 8
138 /* Allow modification of S_IMMUTABLE and S_APPEND file attributes */
140 #define CAP_LINUX_IMMUTABLE 9
142 /* Allows binding to TCP/UDP sockets below 1024 */
143 /* Allows binding to ATM VCIs below 32 */
145 #define CAP_NET_BIND_SERVICE 10
147 /* Allow broadcasting, listen to multicast */
149 #define CAP_NET_BROADCAST 11
151 /* Allow interface configuration */
152 /* Allow administration of IP firewall, masquerading and accounting */
153 /* Allow setting debug option on sockets */
154 /* Allow modification of routing tables */
155 /* Allow setting arbitrary process / process group ownership on
156 sockets */
157 /* Allow binding to any address for transparent proxying */
158 /* Allow setting TOS (type of service) */
159 /* Allow setting promiscuous mode */
160 /* Allow clearing driver statistics */
161 /* Allow multicasting */
162 /* Allow read/write of device-specific registers */
163 /* Allow activation of ATM control sockets */
165 #define CAP_NET_ADMIN 12
167 /* Allow use of RAW sockets */
168 /* Allow use of PACKET sockets */
170 #define CAP_NET_RAW 13
172 /* Allow locking of shared memory segments */
173 /* Allow mlock and mlockall (which doesn't really have anything to do
174 with IPC) */
176 #define CAP_IPC_LOCK 14
178 /* Override IPC ownership checks */
180 #define CAP_IPC_OWNER 15
182 /* Insert and remove kernel modules - modify kernel without limit */
183 /* Modify cap_bset */
184 #define CAP_SYS_MODULE 16
186 /* Allow ioperm/iopl access */
187 /* Allow sending USB messages to any device via /proc/bus/usb */
189 #define CAP_SYS_RAWIO 17
191 /* Allow use of chroot() */
193 #define CAP_SYS_CHROOT 18
195 /* Allow ptrace() of any process */
197 #define CAP_SYS_PTRACE 19
199 /* Allow configuration of process accounting */
201 #define CAP_SYS_PACCT 20
203 /* Allow configuration of the secure attention key */
204 /* Allow administration of the random device */
205 /* Allow examination and configuration of disk quotas */
206 /* Allow configuring the kernel's syslog (printk behaviour) */
207 /* Allow setting the domainname */
208 /* Allow setting the hostname */
209 /* Allow calling bdflush() */
210 /* Allow mount() and umount(), setting up new smb connection */
211 /* Allow some autofs root ioctls */
212 /* Allow nfsservctl */
213 /* Allow VM86_REQUEST_IRQ */
214 /* Allow to read/write pci config on alpha */
215 /* Allow irix_prctl on mips (setstacksize) */
216 /* Allow flushing all cache on m68k (sys_cacheflush) */
217 /* Allow removing semaphores */
218 /* Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores
219 and shared memory */
220 /* Allow locking/unlocking of shared memory segment */
221 /* Allow turning swap on/off */
222 /* Allow forged pids on socket credentials passing */
223 /* Allow setting readahead and flushing buffers on block devices */
224 /* Allow setting geometry in floppy driver */
225 /* Allow turning DMA on/off in xd driver */
226 /* Allow administration of md devices (mostly the above, but some
227 extra ioctls) */
228 /* Allow tuning the ide driver */
229 /* Allow access to the nvram device */
230 /* Allow administration of apm_bios, serial and bttv (TV) device */
231 /* Allow manufacturer commands in isdn CAPI support driver */
232 /* Allow reading non-standardized portions of pci configuration space */
233 /* Allow DDI debug ioctl on sbpcd driver */
234 /* Allow setting up serial ports */
235 /* Allow sending raw qic-117 commands */
236 /* Allow enabling/disabling tagged queuing on SCSI controllers and sending
237 arbitrary SCSI commands */
238 /* Allow setting encryption key on loopback filesystem */
239 /* Allow setting zone reclaim policy */
241 #define CAP_SYS_ADMIN 21
243 /* Allow use of reboot() */
245 #define CAP_SYS_BOOT 22
247 /* Allow raising priority and setting priority on other (different
248 UID) processes */
249 /* Allow use of FIFO and round-robin (realtime) scheduling on own
250 processes and setting the scheduling algorithm used by another
251 process. */
252 /* Allow setting cpu affinity on other processes */
254 #define CAP_SYS_NICE 23
256 /* Override resource limits. Set resource limits. */
257 /* Override quota limits. */
258 /* Override reserved space on ext2 filesystem */
259 /* Modify data journaling mode on ext3 filesystem (uses journaling
260 resources) */
261 /* NOTE: ext2 honors fsuid when checking for resource overrides, so
262 you can override using fsuid too */
263 /* Override size restrictions on IPC message queues */
264 /* Allow more than 64hz interrupts from the real-time clock */
265 /* Override max number of consoles on console allocation */
266 /* Override max number of keymaps */
268 #define CAP_SYS_RESOURCE 24
270 /* Allow manipulation of system clock */
271 /* Allow irix_stime on mips */
272 /* Allow setting the real-time clock */
274 #define CAP_SYS_TIME 25
276 /* Allow configuration of tty devices */
277 /* Allow vhangup() of tty */
279 #define CAP_SYS_TTY_CONFIG 26
281 /* Allow the privileged aspects of mknod() */
283 #define CAP_MKNOD 27
285 /* Allow taking of leases on files */
287 #define CAP_LEASE 28
289 #define CAP_AUDIT_WRITE 29
291 #define CAP_AUDIT_CONTROL 30
293 #ifdef __KERNEL__
295 * Bounding set
297 extern kernel_cap_t cap_bset;
300 * Internal kernel functions only
303 #ifdef STRICT_CAP_T_TYPECHECKS
305 #define to_cap_t(x) { x }
306 #define cap_t(x) (x).cap
308 #else
310 #define to_cap_t(x) (x)
311 #define cap_t(x) (x)
313 #endif
315 #define CAP_EMPTY_SET to_cap_t(0)
316 #define CAP_FULL_SET to_cap_t(~0)
317 #define CAP_INIT_EFF_SET to_cap_t(~0 & ~CAP_TO_MASK(CAP_SETPCAP))
318 #define CAP_INIT_INH_SET to_cap_t(0)
320 #define CAP_TO_MASK(x) (1 << (x))
321 #define cap_raise(c, flag) (cap_t(c) |= CAP_TO_MASK(flag))
322 #define cap_lower(c, flag) (cap_t(c) &= ~CAP_TO_MASK(flag))
323 #define cap_raised(c, flag) (cap_t(c) & CAP_TO_MASK(flag))
325 static inline kernel_cap_t cap_combine(kernel_cap_t a, kernel_cap_t b)
327 kernel_cap_t dest;
328 cap_t(dest) = cap_t(a) | cap_t(b);
329 return dest;
332 static inline kernel_cap_t cap_intersect(kernel_cap_t a, kernel_cap_t b)
334 kernel_cap_t dest;
335 cap_t(dest) = cap_t(a) & cap_t(b);
336 return dest;
339 static inline kernel_cap_t cap_drop(kernel_cap_t a, kernel_cap_t drop)
341 kernel_cap_t dest;
342 cap_t(dest) = cap_t(a) & ~cap_t(drop);
343 return dest;
346 static inline kernel_cap_t cap_invert(kernel_cap_t c)
348 kernel_cap_t dest;
349 cap_t(dest) = ~cap_t(c);
350 return dest;
353 #define cap_isclear(c) (!cap_t(c))
354 #define cap_issubset(a,set) (!(cap_t(a) & ~cap_t(set)))
356 #define cap_clear(c) do { cap_t(c) = 0; } while(0)
357 #define cap_set_full(c) do { cap_t(c) = ~0; } while(0)
358 #define cap_mask(c,mask) do { cap_t(c) &= cap_t(mask); } while(0)
360 #define cap_is_fs_cap(c) (CAP_TO_MASK(c) & CAP_FS_MASK)
362 int capable(int cap);
363 int __capable(struct task_struct *t, int cap);
365 #endif /* __KERNEL__ */
367 #endif /* !_LINUX_CAPABILITY_H */