mirror of
https://github.com/opencontainers/runc.git
synced 2026-04-22 23:17:17 +08:00
d8e9ed3e08
This makes libcontainer/userns self-dependent, largely returning to the original implementation from lxc. The `uiMapInUserNS` is kept as a separate function for unit-testing and fuzzing. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
35 lines
713 B
Go
35 lines
713 B
Go
package userns
|
|
|
|
import "testing"
|
|
|
|
func TestUIDMapInUserNS(t *testing.T) {
|
|
cases := []struct {
|
|
s string
|
|
expected bool
|
|
}{
|
|
{
|
|
s: " 0 0 4294967295\n",
|
|
expected: false,
|
|
},
|
|
{
|
|
s: " 0 0 1\n",
|
|
expected: true,
|
|
},
|
|
{
|
|
s: " 0 1001 1\n 1 231072 65536\n",
|
|
expected: true,
|
|
},
|
|
{
|
|
// file exist but empty (the initial state when userns is created. see man 7 user_namespaces)
|
|
s: "",
|
|
expected: true,
|
|
},
|
|
}
|
|
for _, c := range cases {
|
|
actual := uidMapInUserNS(c.s)
|
|
if c.expected != actual {
|
|
t.Fatalf("expected %v, got %v for %q", c.expected, actual, c.s)
|
|
}
|
|
}
|
|
}
|