Skip to content

Commit 2420eb1

Browse files
committed
The setupUserNamespace function is always called.
The function is called even if the usernamespace is not set. This results having wrong uid/gid set on devices. This fix add a test to check if usernamespace is set befor calling setupUserNamespace. Fixes #1742 Signed-off-by: Julien Lavesque <[email protected]>
1 parent b50fa98 commit 2420eb1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libcontainer/specconv/spec_linux.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
192192
if err := createDevices(spec, config); err != nil {
193193
return nil, err
194194
}
195-
if err := setupUserNamespace(spec, config); err != nil {
196-
return nil, err
197-
}
198195
c, err := createCgroupConfig(opts)
199196
if err != nil {
200197
return nil, err
@@ -226,6 +223,11 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
226223
},
227224
}
228225
}
226+
if config.Namespaces.Contains(configs.NEWUSER) {
227+
if err := setupUserNamespace(spec, config); err != nil {
228+
return nil, err
229+
}
230+
}
229231
config.MaskPaths = spec.Linux.MaskedPaths
230232
config.ReadonlyPaths = spec.Linux.ReadonlyPaths
231233
config.MountLabel = spec.Linux.MountLabel

0 commit comments

Comments
 (0)