Skip to content

Commit

Permalink
pkg/process: Check using idmap mount options too
Browse files Browse the repository at this point in the history
The runtime-spec just merged this PR:
	opencontainers/runtime-spec#1224

This means that it is now possible to request idmap mounts by specifying
"idmap" or "ridmap" in the mount options, without any mappings.

Let's add a check to see if they are requested in that way too.

Signed-off-by: Rodrigo Campos <[email protected]>
  • Loading branch information
rata committed Dec 4, 2023
1 parent 47163c3 commit 8bbce8d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/containerd-shim-runc-v2/process/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ func (p *Init) validateIDMapMounts(ctx context.Context, spec *specs.Spec) error
used = true
break
}
if sliceContainsStr(m.Options, "idmap") || sliceContainsStr(m.Options, "ridmap") {
used = true
break
}
}

if !used {
Expand Down Expand Up @@ -552,3 +556,12 @@ func withConditionalIO(c stdio.Stdio) runc.IOOpt {
o.OpenStderr = c.Stderr != ""
}
}

func sliceContainsStr(s []string, str string) bool {
for _, s := range s {
if s == str {
return true
}
}
return false
}

0 comments on commit 8bbce8d

Please sign in to comment.