From c875ea8529a2d9c89a5705f459acf91dc842d635 Mon Sep 17 00:00:00 2001 From: lifubang Date: Sun, 23 Jul 2023 11:59:18 +0800 Subject: [PATCH] use the length of UIDMappings/GIDMappings to check whether empty or not Signed-off-by: lifubang --- libcontainer/configs/config_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcontainer/configs/config_linux.go b/libcontainer/configs/config_linux.go index 41a365612..4e58bb396 100644 --- a/libcontainer/configs/config_linux.go +++ b/libcontainer/configs/config_linux.go @@ -13,7 +13,7 @@ var ( // different when user namespaces are enabled. func (c Config) HostUID(containerId int) (int, error) { if c.Namespaces.Contains(NEWUSER) { - if c.UIDMappings == nil { + if len(c.UIDMappings) == 0 { return -1, errNoUIDMap } id, found := c.hostIDFromMapping(containerId, c.UIDMappings) @@ -36,7 +36,7 @@ func (c Config) HostRootUID() (int, error) { // different when user namespaces are enabled. func (c Config) HostGID(containerId int) (int, error) { if c.Namespaces.Contains(NEWUSER) { - if c.GIDMappings == nil { + if len(c.GIDMappings) == 0 { return -1, errNoGIDMap } id, found := c.hostIDFromMapping(containerId, c.GIDMappings)