Skip to content

Commit a5777e8

Browse files
authored
Merge pull request #3947 from lifubang/followup-3939
use the length of UIDMappings/GIDMappings to check whether empty or not
2 parents b4f3891 + c875ea8 commit a5777e8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libcontainer/configs/config_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var (
1313
// different when user namespaces are enabled.
1414
func (c Config) HostUID(containerId int) (int, error) {
1515
if c.Namespaces.Contains(NEWUSER) {
16-
if c.UIDMappings == nil {
16+
if len(c.UIDMappings) == 0 {
1717
return -1, errNoUIDMap
1818
}
1919
id, found := c.hostIDFromMapping(containerId, c.UIDMappings)
@@ -36,7 +36,7 @@ func (c Config) HostRootUID() (int, error) {
3636
// different when user namespaces are enabled.
3737
func (c Config) HostGID(containerId int) (int, error) {
3838
if c.Namespaces.Contains(NEWUSER) {
39-
if c.GIDMappings == nil {
39+
if len(c.GIDMappings) == 0 {
4040
return -1, errNoGIDMap
4141
}
4242
id, found := c.hostIDFromMapping(containerId, c.GIDMappings)

0 commit comments

Comments
 (0)