mirror of
https://github.com/opencontainers/runc.git
synced 2025-09-26 19:41:35 +08:00
@@ -3,7 +3,6 @@ package integration
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -30,9 +29,7 @@ func TestExecPS(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUsernsExecPS(t *testing.T) {
|
||||
if _, err := os.Stat("/proc/self/ns/user"); os.IsNotExist(err) {
|
||||
t.Skip("Test requires userns.")
|
||||
}
|
||||
needUserNS(t)
|
||||
testExecPS(t, true)
|
||||
}
|
||||
|
||||
@@ -122,10 +119,7 @@ func TestRlimit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUsernsRlimit(t *testing.T) {
|
||||
if _, err := os.Stat("/proc/self/ns/user"); os.IsNotExist(err) {
|
||||
t.Skip("Test requires userns.")
|
||||
}
|
||||
|
||||
needUserNS(t)
|
||||
testRlimit(t, true)
|
||||
}
|
||||
|
||||
@@ -1515,9 +1509,7 @@ func TestInitJoinPID(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInitJoinNetworkAndUser(t *testing.T) {
|
||||
if _, err := os.Stat("/proc/self/ns/user"); os.IsNotExist(err) {
|
||||
t.Skip("Test requires userns.")
|
||||
}
|
||||
needUserNS(t)
|
||||
if testing.Short() {
|
||||
return
|
||||
}
|
||||
@@ -1764,10 +1756,7 @@ next_fd:
|
||||
// Test that a container using user namespaces is able to bind mount a folder
|
||||
// that does not have permissions for group/others.
|
||||
func TestBindMountAndUser(t *testing.T) {
|
||||
if _, err := os.Stat("/proc/self/ns/user"); errors.Is(err, os.ErrNotExist) {
|
||||
t.Skip("userns is unsupported")
|
||||
}
|
||||
|
||||
needUserNS(t)
|
||||
if testing.Short() {
|
||||
return
|
||||
}
|
||||
|
@@ -69,10 +69,7 @@ func TestExecIn(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecInUsernsRlimit(t *testing.T) {
|
||||
if _, err := os.Stat("/proc/self/ns/user"); os.IsNotExist(err) {
|
||||
t.Skip("Test requires userns.")
|
||||
}
|
||||
|
||||
needUserNS(t)
|
||||
testExecInRlimit(t, true)
|
||||
}
|
||||
|
||||
@@ -502,9 +499,7 @@ func TestExecInOomScoreAdj(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecInUserns(t *testing.T) {
|
||||
if _, err := os.Stat("/proc/self/ns/user"); os.IsNotExist(err) {
|
||||
t.Skip("Test requires userns.")
|
||||
}
|
||||
needUserNS(t)
|
||||
if testing.Short() {
|
||||
return
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -231,3 +232,10 @@ func runContainerOk(t testing.TB, config *configs.Config, args ...string) *stdBu
|
||||
func destroyContainer(container *libcontainer.Container) {
|
||||
_ = container.Destroy()
|
||||
}
|
||||
|
||||
func needUserNS(t testing.TB) {
|
||||
t.Helper()
|
||||
if _, err := os.Stat("/proc/self/ns/user"); errors.Is(err, os.ErrNotExist) {
|
||||
t.Skip("Test requires userns.")
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ load helpers
|
||||
function setup() {
|
||||
requires root # for chcon
|
||||
if ! selinuxenabled; then
|
||||
skip "requires SELinux enabled and in enforcing mode"
|
||||
skip "requires SELinux enabled"
|
||||
fi
|
||||
|
||||
setup_busybox
|
||||
|
Reference in New Issue
Block a user