Debian Codegraph @

landlock/scoped.go

raw
1 package landlock
2
3 // ScopedSet is a set of restrictable IPC scopes.
4 //
5 // When the scope is restricted, these IPC operations can not be used
6 // to communicate with a process in a more privileged sandbox domain
7 // (e.g., a process in a parent domain or a non-sandboxed process).
8 type ScopedSet uint64
9
10 var scopedNames = []string{
11 "abstract_unix_socket",
12 "signal",
13 }
14
15 var supportedScoped = ScopedSet((1 << len(scopedNames)) - 1)
16
17 func (a ScopedSet) String() string {
18 return accessSetString(uint64(a), scopedNames)
19 }
20
21 func (a ScopedSet) isSubset(b ScopedSet) bool {
22 return a&b == a
23 }
24
25 func (a ScopedSet) intersect(b ScopedSet) ScopedSet {
26 return a & b
27 }
28
29 func (a ScopedSet) isEmpty() bool {
30 return a == 0
31 }
32
33 func (a ScopedSet) valid() bool {
34 return a.isSubset(supportedScoped)
35 }