Skip to content

Commit

Permalink
syscall: fix skip condition in skipUnprivilegedUserClone
Browse files Browse the repository at this point in the history
This is a follow up CL of CL 180877:
It will skip test create user namespaces under 3 conditions:

1. sysctl file is missing
2. file reads nothing
3. user don't have permission to create namespaces

Change-Id: I25f00a6b67213bf98d654972388637789978e1fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/180937
Run-TryBot: Tobias Klauser <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Tobias Klauser <[email protected]>
  • Loading branch information
mengzhuo authored and tklauser committed Jun 6, 2019
1 parent 037ac2b commit 5ec1406
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/syscall/exec_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func skipUnprivilegedUserClone(t *testing.T) {
// Skip the test if the sysctl that prevents unprivileged user
// from creating user namespaces is enabled.
data, errRead := ioutil.ReadFile("/proc/sys/kernel/unprivileged_userns_clone")
if errRead != nil || len(data) < 1 && data[0] == '0' {
if errRead != nil || len(data) < 1 || data[0] == '0' {
t.Skip("kernel prohibits user namespace in unprivileged process")
}
}
Expand Down

0 comments on commit 5ec1406

Please sign in to comment.