Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions nsinit/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"io"
"math"
"os"
"path/filepath"
"syscall"
Expand All @@ -27,6 +28,7 @@ var createFlags = []cli.Flag{
cli.StringFlag{Name: "apparmor-profile", Usage: "set the apparmor profile"},
cli.StringFlag{Name: "process-label", Usage: "set the process label"},
cli.StringFlag{Name: "mount-label", Usage: "set the mount label"},
cli.IntFlag{Name: "userns-root-uid", Usage: "set the user namespace root uid"},
}

var configCommand = cli.Command{
Expand Down Expand Up @@ -70,6 +72,21 @@ func modify(config *configs.Config, context *cli.Context) {
config.AppArmorProfile = context.String("apparmor-profile")
config.ProcessLabel = context.String("process-label")
config.MountLabel = context.String("mount-label")

userns_uid := context.Int("userns-root-uid")
if userns_uid != 0 {
config.Namespaces = append(config.Namespaces, configs.Namespace{Type: configs.NEWUSER})
config.UidMappings = []configs.IDMap{
{ContainerID: 0, HostID: userns_uid, Size: 1},
{ContainerID: 1, HostID: 1, Size: userns_uid - 1},
{ContainerID: userns_uid + 1, HostID: userns_uid + 1, Size: math.MaxInt32 - userns_uid},
}
config.GidMappings = []configs.IDMap{
{ContainerID: 0, HostID: userns_uid, Size: 1},
{ContainerID: 1, HostID: 1, Size: userns_uid - 1},
{ContainerID: userns_uid + 1, HostID: userns_uid + 1, Size: math.MaxInt32 - userns_uid},
}
}
}

func getTemplate() *configs.Config {
Expand Down