enum.go 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. // Copyright (c) 2013, Suryandaru Triandana <[email protected]>
  2. // All rights reserved.
  3. //
  4. // Use of this source code is governed by a BSD-style license that can be
  5. // found in the LICENSE file.
  6. package capability
  7. type CapType uint
  8. func (c CapType) String() string {
  9. switch c {
  10. case EFFECTIVE:
  11. return "effective"
  12. case PERMITTED:
  13. return "permitted"
  14. case INHERITABLE:
  15. return "inheritable"
  16. case BOUNDING:
  17. return "bounding"
  18. case CAPS:
  19. return "caps"
  20. }
  21. return "unknown"
  22. }
  23. const (
  24. EFFECTIVE CapType = 1 << iota
  25. PERMITTED
  26. INHERITABLE
  27. BOUNDING
  28. CAPS = EFFECTIVE | PERMITTED | INHERITABLE
  29. BOUNDS = BOUNDING
  30. )
  31. //go:generate go run enumgen/gen.go
  32. type Cap int
  33. // POSIX-draft defined capabilities.
  34. const (
  35. // In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this
  36. // overrides the restriction of changing file ownership and group
  37. // ownership.
  38. CAP_CHOWN = Cap(0)
  39. // Override all DAC access, including ACL execute access if
  40. // [_POSIX_ACL] is defined. Excluding DAC access covered by
  41. // CAP_LINUX_IMMUTABLE.
  42. CAP_DAC_OVERRIDE = Cap(1)
  43. // Overrides all DAC restrictions regarding read and search on files
  44. // and directories, including ACL restrictions if [_POSIX_ACL] is
  45. // defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.
  46. CAP_DAC_READ_SEARCH = Cap(2)
  47. // Overrides all restrictions about allowed operations on files, where
  48. // file owner ID must be equal to the user ID, except where CAP_FSETID
  49. // is applicable. It doesn't override MAC and DAC restrictions.
  50. CAP_FOWNER = Cap(3)
  51. // Overrides the following restrictions that the effective user ID
  52. // shall match the file owner ID when setting the S_ISUID and S_ISGID
  53. // bits on that file; that the effective group ID (or one of the
  54. // supplementary group IDs) shall match the file owner ID when setting
  55. // the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are
  56. // cleared on successful return from chown(2) (not implemented).
  57. CAP_FSETID = Cap(4)
  58. // Overrides the restriction that the real or effective user ID of a
  59. // process sending a signal must match the real or effective user ID
  60. // of the process receiving the signal.
  61. CAP_KILL = Cap(5)
  62. // Allows setgid(2) manipulation
  63. // Allows setgroups(2)
  64. // Allows forged gids on socket credentials passing.
  65. CAP_SETGID = Cap(6)
  66. // Allows set*uid(2) manipulation (including fsuid).
  67. // Allows forged pids on socket credentials passing.
  68. CAP_SETUID = Cap(7)
  69. // Linux-specific capabilities
  70. // Without VFS support for capabilities:
  71. // Transfer any capability in your permitted set to any pid,
  72. // remove any capability in your permitted set from any pid
  73. // With VFS support for capabilities (neither of above, but)
  74. // Add any capability from current's capability bounding set
  75. // to the current process' inheritable set
  76. // Allow taking bits out of capability bounding set
  77. // Allow modification of the securebits for a process
  78. CAP_SETPCAP = Cap(8)
  79. // Allow modification of S_IMMUTABLE and S_APPEND file attributes
  80. CAP_LINUX_IMMUTABLE = Cap(9)
  81. // Allows binding to TCP/UDP sockets below 1024
  82. // Allows binding to ATM VCIs below 32
  83. CAP_NET_BIND_SERVICE = Cap(10)
  84. // Allow broadcasting, listen to multicast
  85. CAP_NET_BROADCAST = Cap(11)
  86. // Allow interface configuration
  87. // Allow administration of IP firewall, masquerading and accounting
  88. // Allow setting debug option on sockets
  89. // Allow modification of routing tables
  90. // Allow setting arbitrary process / process group ownership on
  91. // sockets
  92. // Allow binding to any address for transparent proxying (also via NET_RAW)
  93. // Allow setting TOS (type of service)
  94. // Allow setting promiscuous mode
  95. // Allow clearing driver statistics
  96. // Allow multicasting
  97. // Allow read/write of device-specific registers
  98. // Allow activation of ATM control sockets
  99. CAP_NET_ADMIN = Cap(12)
  100. // Allow use of RAW sockets
  101. // Allow use of PACKET sockets
  102. // Allow binding to any address for transparent proxying (also via NET_ADMIN)
  103. CAP_NET_RAW = Cap(13)
  104. // Allow locking of shared memory segments
  105. // Allow mlock and mlockall (which doesn't really have anything to do
  106. // with IPC)
  107. CAP_IPC_LOCK = Cap(14)
  108. // Override IPC ownership checks
  109. CAP_IPC_OWNER = Cap(15)
  110. // Insert and remove kernel modules - modify kernel without limit
  111. CAP_SYS_MODULE = Cap(16)
  112. // Allow ioperm/iopl access
  113. // Allow sending USB messages to any device via /proc/bus/usb
  114. CAP_SYS_RAWIO = Cap(17)
  115. // Allow use of chroot()
  116. CAP_SYS_CHROOT = Cap(18)
  117. // Allow ptrace() of any process
  118. CAP_SYS_PTRACE = Cap(19)
  119. // Allow configuration of process accounting
  120. CAP_SYS_PACCT = Cap(20)
  121. // Allow configuration of the secure attention key
  122. // Allow administration of the random device
  123. // Allow examination and configuration of disk quotas
  124. // Allow setting the domainname
  125. // Allow setting the hostname
  126. // Allow calling bdflush()
  127. // Allow mount() and umount(), setting up new smb connection
  128. // Allow some autofs root ioctls
  129. // Allow nfsservctl
  130. // Allow VM86_REQUEST_IRQ
  131. // Allow to read/write pci config on alpha
  132. // Allow irix_prctl on mips (setstacksize)
  133. // Allow flushing all cache on m68k (sys_cacheflush)
  134. // Allow removing semaphores
  135. // Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores
  136. // and shared memory
  137. // Allow locking/unlocking of shared memory segment
  138. // Allow turning swap on/off
  139. // Allow forged pids on socket credentials passing
  140. // Allow setting readahead and flushing buffers on block devices
  141. // Allow setting geometry in floppy driver
  142. // Allow turning DMA on/off in xd driver
  143. // Allow administration of md devices (mostly the above, but some
  144. // extra ioctls)
  145. // Allow tuning the ide driver
  146. // Allow access to the nvram device
  147. // Allow administration of apm_bios, serial and bttv (TV) device
  148. // Allow manufacturer commands in isdn CAPI support driver
  149. // Allow reading non-standardized portions of pci configuration space
  150. // Allow DDI debug ioctl on sbpcd driver
  151. // Allow setting up serial ports
  152. // Allow sending raw qic-117 commands
  153. // Allow enabling/disabling tagged queuing on SCSI controllers and sending
  154. // arbitrary SCSI commands
  155. // Allow setting encryption key on loopback filesystem
  156. // Allow setting zone reclaim policy
  157. CAP_SYS_ADMIN = Cap(21)
  158. // Allow use of reboot()
  159. CAP_SYS_BOOT = Cap(22)
  160. // Allow raising priority and setting priority on other (different
  161. // UID) processes
  162. // Allow use of FIFO and round-robin (realtime) scheduling on own
  163. // processes and setting the scheduling algorithm used by another
  164. // process.
  165. // Allow setting cpu affinity on other processes
  166. CAP_SYS_NICE = Cap(23)
  167. // Override resource limits. Set resource limits.
  168. // Override quota limits.
  169. // Override reserved space on ext2 filesystem
  170. // Modify data journaling mode on ext3 filesystem (uses journaling
  171. // resources)
  172. // NOTE: ext2 honors fsuid when checking for resource overrides, so
  173. // you can override using fsuid too
  174. // Override size restrictions on IPC message queues
  175. // Allow more than 64hz interrupts from the real-time clock
  176. // Override max number of consoles on console allocation
  177. // Override max number of keymaps
  178. CAP_SYS_RESOURCE = Cap(24)
  179. // Allow manipulation of system clock
  180. // Allow irix_stime on mips
  181. // Allow setting the real-time clock
  182. CAP_SYS_TIME = Cap(25)
  183. // Allow configuration of tty devices
  184. // Allow vhangup() of tty
  185. CAP_SYS_TTY_CONFIG = Cap(26)
  186. // Allow the privileged aspects of mknod()
  187. CAP_MKNOD = Cap(27)
  188. // Allow taking of leases on files
  189. CAP_LEASE = Cap(28)
  190. CAP_AUDIT_WRITE = Cap(29)
  191. CAP_AUDIT_CONTROL = Cap(30)
  192. CAP_SETFCAP = Cap(31)
  193. // Override MAC access.
  194. // The base kernel enforces no MAC policy.
  195. // An LSM may enforce a MAC policy, and if it does and it chooses
  196. // to implement capability based overrides of that policy, this is
  197. // the capability it should use to do so.
  198. CAP_MAC_OVERRIDE = Cap(32)
  199. // Allow MAC configuration or state changes.
  200. // The base kernel requires no MAC configuration.
  201. // An LSM may enforce a MAC policy, and if it does and it chooses
  202. // to implement capability based checks on modifications to that
  203. // policy or the data required to maintain it, this is the
  204. // capability it should use to do so.
  205. CAP_MAC_ADMIN = Cap(33)
  206. // Allow configuring the kernel's syslog (printk behaviour)
  207. CAP_SYSLOG = Cap(34)
  208. // Allow triggering something that will wake the system
  209. CAP_WAKE_ALARM = Cap(35)
  210. // Allow preventing system suspends
  211. CAP_BLOCK_SUSPEND = Cap(36)
  212. // Allow reading audit messages from the kernel
  213. CAP_AUDIT_READ = Cap(37)
  214. )
  215. var (
  216. // Highest valid capability of the running kernel.
  217. CAP_LAST_CAP = Cap(63)
  218. capUpperMask = ^uint32(0)
  219. )