mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
Add support for --userns=nomap
From a security point of view, it would be nice to be able to map a rootless usernamespace that does not use your own UID within the container. This would add protection against a hostile process escapping the container and reading content in your homedir. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -96,6 +96,11 @@ func (n UsernsMode) IsKeepID() bool {
|
||||
return n == "keep-id"
|
||||
}
|
||||
|
||||
// IsNoMap indicates whether container uses a mapping where the (uid, gid) on the host is not present in the namespace.
|
||||
func (n UsernsMode) IsNoMap() bool {
|
||||
return n == "nomap"
|
||||
}
|
||||
|
||||
// IsAuto indicates whether container uses the "auto" userns mode.
|
||||
func (n UsernsMode) IsAuto() bool {
|
||||
parts := strings.Split(string(n), ":")
|
||||
@ -158,7 +163,7 @@ func (n UsernsMode) IsPrivate() bool {
|
||||
func (n UsernsMode) Valid() bool {
|
||||
parts := strings.Split(string(n), ":")
|
||||
switch mode := parts[0]; mode {
|
||||
case "", privateType, hostType, "keep-id", nsType, "auto":
|
||||
case "", privateType, hostType, "keep-id", nsType, "auto", "nomap":
|
||||
case containerType:
|
||||
if len(parts) != 2 || parts[1] == "" {
|
||||
return false
|
||||
|
Reference in New Issue
Block a user