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