Skip to content

Commit

Permalink
Merge pull request #3947 from lifubang/followup-3939
Browse files Browse the repository at this point in the history
use the length of UIDMappings/GIDMappings to check whether empty or not
  • Loading branch information
thaJeztah authored Jul 23, 2023
2 parents b4f3891 + c875ea8 commit a5777e8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libcontainer/configs/config_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit a5777e8

Please sign in to comment.