@@ -6,82 +6,78 @@ import (
66 "github.com/opencontainers/runc/libcontainer/configs"
77)
88
9- func init () {
10- geteuid = func () int { return 1337 }
11- getegid = func () int { return 7331 }
12- }
13-
14- func rootlessConfig () * configs.Config {
9+ func rootlessEUIDConfig () * configs.Config {
1510 return & configs.Config {
16- Rootfs : "/var" ,
17- Rootless : true ,
11+ Rootfs : "/var" ,
12+ RootlessEUID : true ,
13+ RootlessCgroups : true ,
1814 Namespaces : configs .Namespaces (
1915 []configs.Namespace {
2016 {Type : configs .NEWUSER },
2117 },
2218 ),
2319 UidMappings : []configs.IDMap {
2420 {
25- HostID : geteuid () ,
21+ HostID : 1337 ,
2622 ContainerID : 0 ,
2723 Size : 1 ,
2824 },
2925 },
3026 GidMappings : []configs.IDMap {
3127 {
32- HostID : getegid () ,
28+ HostID : 7331 ,
3329 ContainerID : 0 ,
3430 Size : 1 ,
3531 },
3632 },
3733 }
3834}
3935
40- func TestValidateRootless (t * testing.T ) {
36+ func TestValidateRootlessEUID (t * testing.T ) {
4137 validator := New ()
4238
43- config := rootlessConfig ()
39+ config := rootlessEUIDConfig ()
4440 if err := validator .Validate (config ); err != nil {
4541 t .Errorf ("Expected error to not occur: %+v" , err )
4642 }
4743}
4844
49- /* rootlessMappings() */
45+ /* rootlessEUIDMappings */
5046
51- func TestValidateRootlessUserns (t * testing.T ) {
47+ func TestValidateRootlessEUIDUserns (t * testing.T ) {
5248 validator := New ()
5349
54- config := rootlessConfig ()
50+ config := rootlessEUIDConfig ()
5551 config .Namespaces = nil
5652 if err := validator .Validate (config ); err == nil {
5753 t .Errorf ("Expected error to occur if user namespaces not set" )
5854 }
5955}
6056
61- func TestValidateRootlessMappingUid (t * testing.T ) {
57+ func TestValidateRootlessEUIDMappingUid (t * testing.T ) {
6258 validator := New ()
6359
64- config := rootlessConfig ()
60+ config := rootlessEUIDConfig ()
6561 config .UidMappings = nil
6662 if err := validator .Validate (config ); err == nil {
6763 t .Errorf ("Expected error to occur if no uid mappings provided" )
6864 }
6965}
7066
71- func TestValidateRootlessMappingGid (t * testing.T ) {
67+ func TestValidateNonZeroEUIDMappingGid (t * testing.T ) {
7268 validator := New ()
7369
74- config := rootlessConfig ()
70+ config := rootlessEUIDConfig ()
7571 config .GidMappings = nil
7672 if err := validator .Validate (config ); err == nil {
7773 t .Errorf ("Expected error to occur if no gid mappings provided" )
7874 }
7975}
8076
81- /* rootlessMount () */
77+ /* rootlessEUIDMount () */
8278
83- func TestValidateRootlessMountUid (t * testing.T ) {
84- config := rootlessConfig ()
79+ func TestValidateRootlessEUIDMountUid (t * testing.T ) {
80+ config := rootlessEUIDConfig ()
8581 validator := New ()
8682
8783 config .Mounts = []* configs.Mount {
@@ -119,8 +115,8 @@ func TestValidateRootlessMountUid(t *testing.T) {
119115 }
120116}
121117
122- func TestValidateRootlessMountGid (t * testing.T ) {
123- config := rootlessConfig ()
118+ func TestValidateRootlessEUIDMountGid (t * testing.T ) {
119+ config := rootlessEUIDConfig ()
124120 validator := New ()
125121
126122 config .Mounts = []* configs.Mount {
0 commit comments