Debian Codegraph @

landlock/restrict_flags.go

raw
1 package landlock
2
3 import (
4 "strings"
5 )
6
7 // restrictFlagsSet is a set of logging directives.
8 type restrictFlagsSet uint32
9
10 var flagNames = []string{
11 "log_same_exec_off",
12 "log_new_exec_on",
13 "log_subdomains_off",
14 }
15
16 func (a restrictFlagsSet) String() string {
17 var b strings.Builder
18 for i, flagName := range flagNames {
19 if a&(1<<i) == 0 {
20 continue
21 }
22 if b.Len() > 1 {
23 b.WriteByte(',')
24 }
25 b.WriteString(flagName)
26 }
27 return b.String()
28 }
29
30 func (a restrictFlagsSet) isSubset(b restrictFlagsSet) bool {
31 return a&b == a
32 }
33
34 func (a restrictFlagsSet) intersect(b restrictFlagsSet) restrictFlagsSet {
35 return a & b
36 }