Merge pull request #3947 from lifubang/followup-3939

use the length of UIDMappings/GIDMappings to check whether empty or not
This commit is contained in:
Sebastiaan van Stijn authored and GitHub committed 2023-07-23 09:02:23 +02:00
commit a5777e8716
1 file changed
+2 -2
+2 -2
View File
@@ -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)