enum.go 8.5 KB

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