1 // Copyright (c) 2013, Suryandaru Triandana <syndtr@gmail.com>
2 // All rights reserved.
4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file.
7 // Package capability provides utilities for manipulating POSIX capabilities.
10 type Capabilities interface {
11 // Get check whether a capability present in the given
12 // capabilities set. The 'which' value should be one of EFFECTIVE,
13 // PERMITTED, INHERITABLE, BOUNDING or AMBIENT.
14 Get(which CapType, what Cap) bool
16 // Empty check whether all capability bits of the given capabilities
17 // set are zero. The 'which' value should be one of EFFECTIVE,
18 // PERMITTED, INHERITABLE, BOUNDING or AMBIENT.
19 Empty(which CapType) bool
21 // Full check whether all capability bits of the given capabilities
22 // set are one. The 'which' value should be one of EFFECTIVE,
23 // PERMITTED, INHERITABLE, BOUNDING or AMBIENT.
24 Full(which CapType) bool
26 // Set sets capabilities of the given capabilities sets. The
27 // 'which' value should be one or combination (OR'ed) of EFFECTIVE,
28 // PERMITTED, INHERITABLE, BOUNDING or AMBIENT.
29 Set(which CapType, caps ...Cap)
31 // Unset unsets capabilities of the given capabilities sets. The
32 // 'which' value should be one or combination (OR'ed) of EFFECTIVE,
33 // PERMITTED, INHERITABLE, BOUNDING or AMBIENT.
34 Unset(which CapType, caps ...Cap)
36 // Fill sets all bits of the given capabilities kind to one. The
37 // 'kind' value should be one or combination (OR'ed) of CAPS,
41 // Clear sets all bits of the given capabilities kind to zero. The
42 // 'kind' value should be one or combination (OR'ed) of CAPS,
46 // String return current capabilities state of the given capabilities
47 // set as string. The 'which' value should be one of EFFECTIVE,
48 // PERMITTED, INHERITABLE BOUNDING or AMBIENT
49 StringCap(which CapType) string
51 // String return current capabilities state as string.
54 // Load load actual capabilities value. This will overwrite all
55 // outstanding changes.
58 // Apply apply the capabilities settings, so all changes will take
60 Apply(kind CapType) error
63 // NewPid create new initialized Capabilities object for given pid when it
64 // is nonzero, or for the current pid if pid is 0
65 func NewPid(pid int) (Capabilities, error) {
69 // NewFile create new initialized Capabilities object for given named file.
70 func NewFile(name string) (Capabilities, error) {