@@ -16,22 +16,22 @@ import (
16
16
// know about at compile time. That is: the kernel may have more caps
17
17
// available than we are aware of, leading to host=FFF... and ctr=3FF...
18
18
// because the latter is all we request. Accept that.
19
- func containerCapMatchesHost (ctr_cap string , host_cap string ) {
19
+ func containerCapMatchesHost (ctrCap string , hostCap string ) {
20
20
if isRootless () {
21
21
return
22
22
}
23
- ctr_cap_n , err := strconv .ParseUint (ctr_cap , 16 , 64 )
24
- Expect (err ).NotTo (HaveOccurred (), "Error parsing %q as hex" , ctr_cap )
23
+ ctrCap_n , err := strconv .ParseUint (ctrCap , 16 , 64 )
24
+ Expect (err ).NotTo (HaveOccurred (), "Error parsing %q as hex" , ctrCap )
25
25
26
- host_cap_n , err := strconv .ParseUint (host_cap , 16 , 64 )
27
- Expect (err ).NotTo (HaveOccurred (), "Error parsing %q as hex" , host_cap )
26
+ hostCap_n , err := strconv .ParseUint (hostCap , 16 , 64 )
27
+ Expect (err ).NotTo (HaveOccurred (), "Error parsing %q as hex" , hostCap )
28
28
29
29
// host caps can never be zero (except rootless).
30
30
// and host caps must always be a superset (inclusive) of container
31
- Expect (host_cap_n ).To (BeNumerically (">" , 0 ), "host cap %q should be nonzero" , host_cap )
32
- Expect (host_cap_n ).To (BeNumerically (">=" , ctr_cap_n ), "host cap %q should never be less than container cap %q" , host_cap , ctr_cap )
33
- host_cap_masked := host_cap_n & (1 << len (capability .List ()) - 1 )
34
- Expect (ctr_cap_n ).To (Equal (host_cap_masked ), "container cap %q is not a subset of host cap %q" , ctr_cap , host_cap )
31
+ Expect (hostCap_n ).To (BeNumerically (">" , 0 ), "host cap %q should be nonzero" , hostCap )
32
+ Expect (hostCap_n ).To (BeNumerically (">=" , ctrCap_n ), "host cap %q should never be less than container cap %q" , hostCap , ctrCap )
33
+ hostCap_masked := hostCap_n & (1 << len (capability .List ()) - 1 )
34
+ Expect (ctrCap_n ).To (Equal (hostCap_masked ), "container cap %q is not a subset of host cap %q" , ctrCap , hostCap )
35
35
}
36
36
37
37
var _ = Describe ("Podman privileged container tests" , func () {
@@ -68,38 +68,38 @@ var _ = Describe("Podman privileged container tests", func() {
68
68
})
69
69
70
70
It ("podman privileged CapEff" , func () {
71
- host_cap := SystemExec ("awk" , []string {"/^CapEff/ { print $2 }" , "/proc/self/status" })
72
- Expect (host_cap .ExitCode ()).To (Equal (0 ))
71
+ hostCap := SystemExec ("awk" , []string {"/^CapEff/ { print $2 }" , "/proc/self/status" })
72
+ Expect (hostCap .ExitCode ()).To (Equal (0 ))
73
73
74
74
session := podmanTest .Podman ([]string {"run" , "--privileged" , "busybox" , "awk" , "/^CapEff/ { print $2 }" , "/proc/self/status" })
75
75
session .WaitWithDefaultTimeout ()
76
76
Expect (session .ExitCode ()).To (Equal (0 ))
77
77
78
- containerCapMatchesHost (session .OutputToString (), host_cap .OutputToString ())
78
+ containerCapMatchesHost (session .OutputToString (), hostCap .OutputToString ())
79
79
})
80
80
81
81
It ("podman cap-add CapEff" , func () {
82
82
// Get caps of current process
83
- host_cap := SystemExec ("awk" , []string {"/^CapEff/ { print $2 }" , "/proc/self/status" })
84
- Expect (host_cap .ExitCode ()).To (Equal (0 ))
83
+ hostCap := SystemExec ("awk" , []string {"/^CapEff/ { print $2 }" , "/proc/self/status" })
84
+ Expect (hostCap .ExitCode ()).To (Equal (0 ))
85
85
86
86
session := podmanTest .Podman ([]string {"run" , "--cap-add" , "all" , "busybox" , "awk" , "/^CapEff/ { print $2 }" , "/proc/self/status" })
87
87
session .WaitWithDefaultTimeout ()
88
88
Expect (session .ExitCode ()).To (Equal (0 ))
89
89
90
- containerCapMatchesHost (session .OutputToString (), host_cap .OutputToString ())
90
+ containerCapMatchesHost (session .OutputToString (), hostCap .OutputToString ())
91
91
})
92
92
93
93
It ("podman cap-add CapEff with --user" , func () {
94
94
// Get caps of current process
95
- host_cap := SystemExec ("awk" , []string {"/^CapEff/ { print $2 }" , "/proc/self/status" })
96
- Expect (host_cap .ExitCode ()).To (Equal (0 ))
95
+ hostCap := SystemExec ("awk" , []string {"/^CapEff/ { print $2 }" , "/proc/self/status" })
96
+ Expect (hostCap .ExitCode ()).To (Equal (0 ))
97
97
98
98
session := podmanTest .Podman ([]string {"run" , "--user=bin" , "--cap-add" , "all" , "busybox" , "awk" , "/^CapEff/ { print $2 }" , "/proc/self/status" })
99
99
session .WaitWithDefaultTimeout ()
100
100
Expect (session .ExitCode ()).To (Equal (0 ))
101
101
102
- containerCapMatchesHost (session .OutputToString (), host_cap .OutputToString ())
102
+ containerCapMatchesHost (session .OutputToString (), hostCap .OutputToString ())
103
103
})
104
104
105
105
It ("podman cap-drop CapEff" , func () {
0 commit comments