Documentation ¶
Index ¶
- Constants
- Variables
- func Compare(a, b Cap) error
- func SetFile(f *os.File, c Cap) error
- type Cap
- func (c Cap) Clear() error
- func (c Cap) ClearFlag(flag CapFlag) error
- func (c Cap) GetFlag(cap_value CapValue, flag CapFlag) (CapFlagValue, error)
- func (c Cap) SetFilePath(path string) error
- func (c Cap) SetFlag(flag CapFlag, caps []CapValue, value CapFlagValue) error
- func (c Cap) SetProc() error
- func (c Cap) String() (string, error)
- type CapFlag
- type CapFlagValue
- type CapValue
Constants ¶
const ( CAP_CHOWN = CapValue(C.CAP_CHOWN) CAP_DAC_OVERRIDE = CapValue(C.CAP_DAC_OVERRIDE) CAP_DAC_READ_SEARCH = CapValue(C.CAP_DAC_READ_SEARCH) CAP_FOWNER = CapValue(C.CAP_FOWNER) CAP_FSETID = CapValue(C.CAP_FSETID) CAP_KILL = CapValue(C.CAP_KILL) CAP_SETGID = CapValue(C.CAP_SETGID) CAP_SETUID = CapValue(C.CAP_SETUID) CAP_SETPCAP = CapValue(C.CAP_SETPCAP) CAP_LINUX_IMMUTABLE = CapValue(C.CAP_LINUX_IMMUTABLE) CAP_NET_BIND_SERVICE = CapValue(C.CAP_NET_BIND_SERVICE) CAP_NET_BROADCAST = CapValue(C.CAP_NET_BROADCAST) CAP_NET_ADMIN = CapValue(C.CAP_NET_ADMIN) CAP_NET_RAW = CapValue(C.CAP_NET_RAW) CAP_IPC_LOCK = CapValue(C.CAP_IPC_LOCK) CAP_IPC_OWNER = CapValue(C.CAP_IPC_OWNER) CAP_SYS_MODULE = CapValue(C.CAP_SYS_MODULE) CAP_SYS_RAWIO = CapValue(C.CAP_SYS_RAWIO) CAP_SYS_CHROOT = CapValue(C.CAP_SYS_CHROOT) CAP_SYS_PTRACE = CapValue(C.CAP_SYS_PTRACE) CAP_SYS_PACCT = CapValue(C.CAP_SYS_PACCT) CAP_SYS_ADMIN = CapValue(C.CAP_SYS_ADMIN) CAP_SYS_BOOT = CapValue(C.CAP_SYS_BOOT) CAP_SYS_NICE = CapValue(C.CAP_SYS_NICE) CAP_SYS_RESOURCE = CapValue(C.CAP_SYS_RESOURCE) CAP_SYS_TIME = CapValue(C.CAP_SYS_TIME) CAP_SYS_TTY_CONFIG = CapValue(C.CAP_SYS_TTY_CONFIG) CAP_MKNOD = CapValue(C.CAP_MKNOD) CAP_LEASE = CapValue(C.CAP_LEASE) CAP_AUDIT_WRITE = CapValue(C.CAP_AUDIT_WRITE) CAP_AUDIT_CONTROL = CapValue(C.CAP_AUDIT_CONTROL) CAP_SETFCAP = CapValue(C.CAP_SETFCAP) CAP_MAC_OVERRIDE = CapValue(C.CAP_MAC_OVERRIDE) CAP_MAC_ADMIN = CapValue(C.CAP_MAC_ADMIN) CAP_SYSLOG = CapValue(C.CAP_SYSLOG) CAP_WAKE_ALARM = CapValue(C.CAP_WAKE_ALARM) CAP_BLOCK_SUSPEND = CapValue(C.CAP_BLOCK_SUSPEND) CAP_AUDIT_READ = CapValue(C.CAP_AUDIT_READ) )
Generated using
awk '$1 == "#define" && \ $2 ~ /^CAP_\w+$/ && \ $2 != "CAP_LAST_CAP" \ { printf("%-20s%s= CapValue(C.%s)\n", $2, " ", $2) }' \ /usr/include/linux/capability.h
const ( CAP_EFFECTIVE = CapFlag(C.CAP_EFFECTIVE) CAP_PERMITTED = CapFlag(C.CAP_PERMITTED) CAP_INHERITABLE = CapFlag(C.CAP_INHERITABLE) )
const ( CAP_CLEAR = CapFlagValue(C.CAP_CLEAR) CAP_SET = CapFlagValue(C.CAP_SET) )
Variables ¶
var (
ErrCapNotEqual = errors.New("Capabilities not equal")
)
Functions ¶
func Compare ¶
Compare() compares two full capability sets and returns nil if the two capability sets are identical.
A difference between the two sets returns ErrCapNotEqual.
func SetFile ¶
SetFile set the values for all capability flags for all capabilities for the file with the given capability state.
For this functions to succeed, the calling process must have the effective capability, CAP_SETFCAP, enabled and either the effective user ID of the process must match the file owner or the calling process must have the CAP_FOWNER flag in its effective capability set. The effects of writing the capability state to any file type other than a regular file are undefined.
Types ¶
type Cap ¶
type Cap struct {
// contains filtered or unexported fields
}
Wrapping structure for cap_t
func FromText ¶
FromText() returns a capability set reflecting the state represented by a human-readable capability set.
func GetFile ¶
GetFile reads a capability state from the given file.
The effects of reading the capability state from any file other than a regular file is undefined.
func GetFilePath ¶
GetFilePath reads a capability state from the given file.
The effects of reading the capability state from any file other than a regular file is undefined.
func GetPid ¶
GetPid() returns a capability set reflecting the capabilities of the process indicated by pid.
This information can also be obtained from the /proc/<pid>/status file.
func GetProc ¶
GetProc() returns a capability set reflecting the capabilities of the calling process.
func (Cap) Clear ¶
Clear() initializes the capability state in working storage so that all capability flags are cleared.
func (Cap) GetFlag ¶
func (c Cap) GetFlag(cap_value CapValue, flag CapFlag) (CapFlagValue, error)
GetFlag() returns the current value of the capability flag.
func (Cap) SetFilePath ¶
SetFilePath set the values for all capability flags for all capabilities for the file with the given capability state.
For this functions to succeed, the calling process must have the effective capability, CAP_SETFCAP, enabled and either the effective user ID of the process must match the file owner or the calling process must have the CAP_FOWNER flag in its effective capability set. The effects of writing the capability state to any file type other than a regular file are undefined.
func (Cap) SetFlag ¶
func (c Cap) SetFlag(flag CapFlag, caps []CapValue, value CapFlagValue) error
SetFlag() sets the flag of each capability in the slice caps to the CapFlagValue value.