forked from opencontainers/runc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opencontainers#1688 from AkihiroSuda/unshare-m-r
main: support rootless mode in userns
- Loading branch information
Showing
12 changed files
with
302 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// +build linux | ||
|
||
package system | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/opencontainers/runc/libcontainer/user" | ||
) | ||
|
||
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 { | ||
uidmap, err := user.ParseIDMap(strings.NewReader(c.s)) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
actual := UIDMapInUserNS(uidmap) | ||
if c.expected != actual { | ||
t.Fatalf("expected %v, got %v for %q", c.expected, actual, c.s) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.