Skip to content

Commit

Permalink
lxd/device/device_utils_disk: fix diskAddRootUserNSEntry to add root …
Browse files Browse the repository at this point in the history
…mapping only if it's required

Fix diskAddRootUserNSEntry logic to correcly handle case when
we have not-groupped UID/GID mapping like this:
[{true false 1000 0 1} {false true 1000 0 1}]

because right now it assumes that mapping should be like
[{true true 1000 0 1}]

which is logically equivalent.

This become noticable after my change in #12718, before that
this issue in logic was reproducible only if user will do something like this:
  cat << EOF
uid $(id -u) 1000000
gid $(id -g) 1000000
EOF
  ) | lxc config set idmap raw.idmap -
which is an extremely rare usecase.

Fixes: #13325
Signed-off-by: Alexander Mikhalitsyn <[email protected]>
  • Loading branch information
mihalicyn authored and tomponline committed Apr 16, 2024
1 parent 0cdaa8a commit cc890c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lxd/device/device_utils_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func diskAddRootUserNSEntry(idmaps []idmap.IdmapEntry, hostRootID int64) []idmap
needsNSGIDRootEntry = false // Root GID mapping already present.
}

if !needsNSUIDRootEntry && needsNSGIDRootEntry {
if !needsNSUIDRootEntry && !needsNSGIDRootEntry {
break // If we've found a root entry for UID and GID then we don't need to add one.
}
}
Expand Down

0 comments on commit cc890c8

Please sign in to comment.