Skip to content

Commit

Permalink
quadlet: do not reject RemapUsers=keep-id as root
Browse files Browse the repository at this point in the history
This is simply wrong, as of commit de63ad7 --userns=keep-id is also
allowed as root.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Oct 17, 2024
1 parent ada75c0 commit 9c6b1e2
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ func ConvertContainer(container *parser.UnitFile, isUser bool, unitsInfoMap map[
return nil, err
}

if err := handleUserMappings(container, ContainerGroup, podman, isUser, true); err != nil {
if err := handleUserMappings(container, ContainerGroup, podman, true); err != nil {
return nil, err
}

Expand Down Expand Up @@ -1224,7 +1224,7 @@ func ConvertKube(kube *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isUse
handleLogDriver(kube, KubeGroup, execStart)
handleLogOpt(kube, KubeGroup, execStart)

if err := handleUserMappings(kube, KubeGroup, execStart, isUser, false); err != nil {
if err := handleUserMappings(kube, KubeGroup, execStart, false); err != nil {
return nil, err
}

Expand Down Expand Up @@ -1613,7 +1613,7 @@ func ConvertPod(podUnit *parser.UnitFile, name string, unitsInfoMap map[string]*
"--replace",
)

if err := handleUserMappings(podUnit, PodGroup, execStartPre, isUser, true); err != nil {
if err := handleUserMappings(podUnit, PodGroup, execStartPre, true); err != nil {
return nil, err
}

Expand Down Expand Up @@ -1684,7 +1684,7 @@ func handleUser(unitFile *parser.UnitFile, groupName string, podman *PodmanCmdli
return nil
}

func handleUserMappings(unitFile *parser.UnitFile, groupName string, podman *PodmanCmdline, isUser, supportManual bool) error {
func handleUserMappings(unitFile *parser.UnitFile, groupName string, podman *PodmanCmdline, supportManual bool) error {
mappingsDefined := false

if userns, ok := unitFile.Lookup(groupName, KeyUserNS); ok && len(userns) > 0 {
Expand Down Expand Up @@ -1724,10 +1724,10 @@ func handleUserMappings(unitFile *parser.UnitFile, groupName string, podman *Pod
return nil
}

return handleUserRemap(unitFile, groupName, podman, isUser, supportManual)
return handleUserRemap(unitFile, groupName, podman, supportManual)
}

func handleUserRemap(unitFile *parser.UnitFile, groupName string, podman *PodmanCmdline, isUser, supportManual bool) error {
func handleUserRemap(unitFile *parser.UnitFile, groupName string, podman *PodmanCmdline, supportManual bool) error {
uidMaps := unitFile.LookupAllStrv(groupName, KeyRemapUid)
gidMaps := unitFile.LookupAllStrv(groupName, KeyRemapGid)
remapUsers, _ := unitFile.LookupLast(groupName, KeyRemapUsers)
Expand Down Expand Up @@ -1765,10 +1765,6 @@ func handleUserRemap(unitFile *parser.UnitFile, groupName string, podman *Podman

podman.add("--userns", usernsOpts("auto", autoOpts))
case "keep-id":
if !isUser {
return fmt.Errorf("RemapUsers=keep-id is unsupported for system units")
}

keepidOpts := make([]string, 0)
if len(uidMaps) > 0 {
if len(uidMaps) > 1 {
Expand Down

0 comments on commit 9c6b1e2

Please sign in to comment.