userns: add new option --userns=keep-id

it creates a namespace where the current UID:GID on the host is mapped
to the same UID:GID in the container.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2019-05-23 22:28:59 +02:00
parent 6df320c391
commit f09370c68b
7 changed files with 79 additions and 5 deletions

View File

@ -12,6 +12,11 @@ func (n UsernsMode) IsHost() bool {
return n == "host"
}
// IsKeepID indicates whether container uses a mapping where the (uid, gid) on the host is lept inside of the namespace.
func (n UsernsMode) IsKeepID() bool {
return n == "keep-id"
}
// IsPrivate indicates whether the container uses the a private userns.
func (n UsernsMode) IsPrivate() bool {
return !(n.IsHost())
@ -21,7 +26,7 @@ func (n UsernsMode) IsPrivate() bool {
func (n UsernsMode) Valid() bool {
parts := strings.Split(string(n), ":")
switch mode := parts[0]; mode {
case "", "host":
case "", "host", "keep-id":
default:
return false
}