Ядро Linux в комментариях

       

Include/linux/capability.h


13847 /* 13848 * This is <linux/capability.h> 13849 * 13850 * Andrew G. Morgan <morgan@transmeta.com> 13851 * Alexander Kjeldaas <astor@guardian.no> 13852 * with help from Aleph1, Roland Buresund and Andrew 13853 * Main. */ 13854 13855 #ifndef _LINUX_CAPABILITY_H 13856 #define _LINUX_CAPABILITY_H 13857 13858 #include <linux/types.h> 13859 #include <linux/fs.h> 13860 13861 /* User-level do most of the mapping between kernel and 13862 user capabilities based on the version tag given by 13863 the kernel. The kernel might be somewhat backwards 13864 compatible, but don't bet on it. */ 13865 13866 /* XXX - Note, cap_t, is defined by POSIX to be an 13867 "opaque" pointer to a set of three capability sets. 13868 The transposition of 3*the following structure to such 13869 a composite is better handled in a user library since 13870 the draft standard requires the use of malloc/free 13871 etc.. */ 13872 13873 #define _LINUX_CAPABILITY_VERSION 0x19980330 13874 13875 typedef struct __user_cap_header_struct { 13876 __u32 version; 13877 int pid; 13878 } *cap_user_header_t; 13879 13880 typedef struct __user_cap_data_struct { 13881 __u32 effective; 13882 __u32 permitted; 13883 __u32 inheritable; 13884 } *cap_user_data_t; 13885 13886 #ifdef __KERNEL__ 13887 13888 /* #define STRICT_CAP_T_TYPECHECKS */ 13889 13890 #ifdef STRICT_CAP_T_TYPECHECKS 13891 13892 typedef struct kernel_cap_struct { 13893 __u32 cap; 13894 } kernel_cap_t; 13895 13896 #else 13897 13898 typedef __u32 kernel_cap_t; 13899 13900 #endif 13901 13902 #define _USER_CAP_HEADER_SIZE (2*sizeof(__u32)) 13903 #define _KERNEL_CAP_T_SIZE (sizeof(kernel_cap_t)) 13904 13905 #endif 13906 13907 13908 /** 13909 ** POSIX-draft defined capabilities. 13910 **/ 13911 13912 /* In a system with the [_POSIX_CHOWN_RESTRICTED] option 13913 defined, this overrides the restriction of changing 13914 file ownership and group ownership. */ 13915

13916 #define CAP_CHOWN 0 13917 13918 /* Override all DAC access, including ACL execute access 13919 if [_POSIX_ACL] is defined. Excluding DAC access 13920 covered by CAP_LINUX_IMMUTABLE. */ 13921 13922 #define CAP_DAC_OVERRIDE 1 13923 13924 /* Overrides all DAC restrictions regarding read and 13925 search on files and directories, including ACL 13926 restrictions if [_POSIX_ACL] is defined. Excluding DAC 13927 access covered by CAP_LINUX_IMMUTABLE. */ 13928 13929 #define CAP_DAC_READ_SEARCH 2 13930 13931 /* Overrides all restrictions about allowed operations on 13932 files, where file owner ID must be equal to the user 13933 ID, except where CAP_FSETID is applicable. It doesn't 13934 override MAC and DAC restrictions. */ 13935 13936 #define CAP_FOWNER 3 13937 13938 /* Overrides the following restrictions that the 13939 effective user ID shall match the file owner ID when 13940 setting the S_ISUID and S_ISGID bits on that file; 13941 that the effective group ID (or one of the 13942 supplementary group IDs shall match the file owner ID 13943 when setting the S_ISGID bit on that file; that the 13944 S_ISUID and S_ISGID bits are cleared on successful 13945 return from chown(2). */ 13946 13947 #define CAP_FSETID 4 13948 13949 /* Used to decide between falling back on the old suser() 13950 or fsuser(). */ 13951 13952 #define CAP_FS_MASK 0x1f 13953 13954 /* Overrides the restriction that the real or effective 13955 user ID of a process sending a signal must match the 13956 real or effective user ID of the process receiving the 13957 signal. */ 13958 13959 #define CAP_KILL 5 13960 13961 /* Allows setgid(2) manipulation */ 13962 /* Allows setgroups(2) */ 13963 /* Allows forged gids on socket credentials passing. */ 13964 13965 #define CAP_SETGID 6 13966 13967 /* Allows set*uid(2) manipulation (including fsuid). */ 13968 /* Allows forged pids on socket credentials passing. */ 13969 13970 #define CAP_SETUID 7 13971 13972 13973 /** 13974 ** Linux-specific capabilities 13975 **/ 13976 13977 /* Transfer any capability in your permitted set to any 13978 pid, remove any capability in your permitted set from 13979 any pid */ 13980 13981 #define CAP_SETPCAP 8 13982 13983 /* Allow modification of S_IMMUTABLE and S_APPEND file 13984 attributes */ 13985 13986 #define CAP_LINUX_IMMUTABLE 9 13987 13988 /* Allows binding to TCP/UDP sockets below 1024 */ 13989 13990 #define CAP_NET_BIND_SERVICE 10 13991 13992 /* Allow broadcasting, listen to multicast */ 13993 13994 #define CAP_NET_BROADCAST 11 13995 13996 /* Allow interface configuration */ 13997 /* Allow administration of IP firewall, masquerading and 13998 accounting */ 13999 /* Allow setting debug option on sockets */ 14000 /* Allow modification of routing tables */ 14001 /* Allow setting arbitrary process / process group 14002 ownership on sockets */ 14003 /* Allow binding to any addr for transparent proxying */ 14004 /* Allow setting TOS (type of service) */ 14005 /* Allow setting promiscuous mode */ 14006 /* Allow clearing driver statistics */ 14007 /* Allow multicasting */ 14008 /* Allow read/write of device-specific registers */ 14009 14010 #define CAP_NET_ADMIN 12 14011 14012 /* Allow use of RAW sockets */ 14013 /* Allow use of PACKET sockets */ 14014 14015 #define CAP_NET_RAW 13 14016 14017 /* Allow locking of shared memory segments */ 14018 /* Allow mlock and mlockall (which doesn't really have 14019 anything to do with IPC) */ 14020 14021 #define CAP_IPC_LOCK 14 14022 14023 /* Override IPC ownership checks */ 14024 14025 #define CAP_IPC_OWNER 15 14026 14027 /* Insert and remove kernel modules */ 14028 14029 #define CAP_SYS_MODULE 16 14030 14031 /* Allow ioperm/iopl access */ 14032 14033 #define CAP_SYS_RAWIO 17 14034 14035 /* Allow use of chroot() */ 14036 14037 #define CAP_SYS_CHROOT 18 14038 14039 /* Allow ptrace() of any process */ 14040 14041 #define CAP_SYS_PTRACE 19 14042 14043 /* Allow configuration of process accounting */ 14044 14045 #define CAP_SYS_PACCT 20 14046 14047 /* Allow configuration of the secure attention key */ 14048 /* Allow administration of the random device */ 14049 /* Allow device administration (mknod)*/ 14050 /* Allow examination and configuration of disk quotas */ 14051 /* Allow configuring the kernel's syslog (printk 14052 behaviour) */ 14053 /* Allow sending a signal to any process */ 14054 /* Allow setting the domainname */ 14055 /* Allow setting the hostname */ 14056 /* Allow calling bdflush() */ 14057 /* Allow mount() and umount(), setting up new smb 14058 connection */ 14059 /* Allow some autofs root ioctls */ 14060 /* Allow nfsservctl */ 14061 /* Allow VM86_REQUEST_IRQ */ 14062 /* Allow to read/write pci config on alpha */ 14063 /* Allow irix_prctl on mips (setstacksize) */ 14064 /* Allow flushing all cache on m68k (sys_cacheflush) */ 14065 /* Allow removing semaphores */ 14066 /* Used instead of CAP_CHOWN to "chown" IPC message 14067 queues, semaphores and shared memory */ 14068 /* Allow locking/unlocking of shared memory segment */ 14069 /* Allow turning swap on/off */ 14070 /* Allow forged pids on socket credentials passing */ 14071 /* Allow setting readahead and flushing buffers on block 14072 devices */ 14073 /* Allow setting geometry in floppy driver */ 14074 /* Allow turning DMA on/off in xd driver */ 14075 /* Allow administration of md devices (mostly the above, 14076 but some extra ioctls) */ 14077 /* Allow tuning the ide driver */ 14078 /* Allow access to the nvram device */ 14079 /* Allow administration of apm_bios, serial and bttv (TV) 14080 device */ 14081 /* Allow manufacturer commands in isdn CAPI support 14082 driver */ 14083 /* Allow reading non-standardized portions of pci 14084 configuration space */ 14085 /* Allow DDI debug ioctl on sbpcd driver */ 14086 /* Allow setting up serial ports */ 14087 /* Allow sending raw qic-117 commands */ 14088 /* Allow enabling/disabling tagged queuing on SCSI 14089 controllers and sending arbitrary SCSI commands */ 14090 /* Allow setting encryption key on loopback filesystem */ 14091 14092 #define CAP_SYS_ADMIN 21 14093 14094 /* Allow use of reboot() */ 14095 14096 #define CAP_SYS_BOOT 22 14097 14098 /* Allow raising priority and setting priority on other 14099 (different UID) processes */ 14100 /* Allow use of FIFO and round-robin (realtime) 14101 scheduling on own processes and setting the scheduling 14102 algorithm used by another process. */ 14103 14104 #define CAP_SYS_NICE 23 14105 14106 /* Override resource limits. Set resource limits. */ 14107 /* Override quota limits. */ 14108 /* Override reserved space on ext2 filesystem */ 14109 /* NOTE: ext2 honors fsuid when checking for resource 14110 overrides, so you can override using fsuid too */ 14111 /* Override size restrictions on IPC message queues */ 14112 /* Allow more than 64hz interrupts from the real-time 14113 clock */ 14114 /* Override max # of consoles on console allocation */ 14115 /* Override max # of keymaps */ 14116 14117 #define CAP_SYS_RESOURCE 24 14118 14119 /* Allow manipulation of system clock */ 14120 /* Allow irix_stime on mips */ 14121 /* Allow setting the real-time clock */ 14122 14123 #define CAP_SYS_TIME 25 14124 14125 /* Allow configuration of tty devices */ 14126 /* Allow vhangup() of tty */ 14127 14128 #define CAP_SYS_TTY_CONFIG 26 14129 14130 #ifdef __KERNEL__ 14131 14132 /* Internal kernel functions only */ 14133 14134 #ifdef STRICT_CAP_T_TYPECHECKS 14135 14136 #define to_cap_t(x) { x } 14137 #define cap_t(x) (x).cap 14138 14139 #else 14140 14141 #define to_cap_t(x) (x) 14142 #define cap_t(x) (x) 14143 14144 #endif 14145 14146 #define CAP_EMPTY_SET to_cap_t(0) 14147 #define CAP_FULL_SET to_cap_t(~0) 14148 #define CAP_INIT_EFF_SET to_cap_t(~0 & \ 14149 ~CAP_TO_MASK(CAP_SETPCAP)) 14150 #define CAP_INIT_INH_SET to_cap_t(~0 & \ 14151 ~CAP_TO_MASK(CAP_SETPCAP)) 14152 14153 #define CAP_TO_MASK(x) (1 << (x)) 14154 #define cap_raise(c, flag) \ 14155 (cap_t(c) |= CAP_TO_MASK(flag)) 14156 #define cap_lower(c, flag) \ 14157 (cap_t(c) &= ~CAP_TO_MASK(flag)) 14158 #define cap_raised(c, flag) \ 14159 (cap_t(c) & CAP_TO_MASK(flag)) 14160 14161 static inline kernel_cap_t cap_combine(kernel_cap_t a, 14162 kernel_cap_t b) 14163 { 14164 kernel_cap_t dest; 14165 cap_t(dest) = cap_t(a) | cap_t(b); 14166 return dest; 14167 } 14168 14169 static inline kernel_cap_t cap_intersect(kernel_cap_t a, 14170 kernel_cap_t b) 14171 { 14172 kernel_cap_t dest; 14173 cap_t(dest) = cap_t(a) & cap_t(b); 14174 return dest; 14175 } 14176 14177 static inline kernel_cap_t cap_drop(kernel_cap_t a, 14178 kernel_cap_t drop) 14179 { 14180 kernel_cap_t dest; 14181 cap_t(dest) = cap_t(a) & ~cap_t(drop); 14182 return dest; 14183 } 14184 14185 static inline kernel_cap_t cap_invert(kernel_cap_t c) 14186 { 14187 kernel_cap_t dest; 14188 cap_t(dest) = ~cap_t(c); 14189 return dest; 14190 } 14191 14192 #define cap_isclear(c) (!cap_t(c)) 14193 #define cap_issubset(a,set) (!(cap_t(a) & ~cap_t(set))) 14194 14195 #define cap_clear(c) do { cap_t(c) = 0; } while(0) 14196 #define cap_set_full(c) do { cap_t(c) = ~0; } while(0) 14197 #define cap_mask(c,mask) do { cap_t(c) &= cap_t(mask);\ 14198 } while(0) 14199 14200 #define cap_is_fs_cap(c) (CAP_TO_MASK(c) & CAP_FS_MASK) 14201 14202 #endif /* __KERNEL__ */ 14203 14204 #endif /* !_LINUX_CAPABILITY_H */



Содержание раздела