diff --git a/README.md b/README.md index 9ec623970..14da37664 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,11 @@ user named `daemon` defined within that file-system. }, "process": { "terminal": true, - "user": "daemon", + "user": { + "uid": 0, + "gid": 0, + "additionalGids": null + }, "args": [ "sh" ], diff --git a/main_unsupported.go b/main_unsupported.go index 7cb1e9abb..be33a6587 100644 --- a/main_unsupported.go +++ b/main_unsupported.go @@ -7,6 +7,10 @@ import ( "github.com/codegangsta/cli" ) +type User struct { + NOTSUPPORTED string +} + func getDefaultID() string { return "" } diff --git a/spec.go b/spec.go index 42f80c89d..47cf34677 100644 --- a/spec.go +++ b/spec.go @@ -9,8 +9,6 @@ import ( "github.com/codegangsta/cli" ) -const cpuQuotaMultiplyer = 100000 - type Mount struct { Type string `json:"type"` Source string `json:"source"` @@ -20,7 +18,7 @@ type Mount struct { type Process struct { Terminal bool `json:"terminal"` - User string `json:"user"` + User User `json:"user"` Args []string `json:"args"` Env []string `json:"env"` Cwd string `json:"cwd"` @@ -61,7 +59,7 @@ var specCommand = cli.Command{ }, Process: Process{ Terminal: true, - User: "daemon", + User: User{}, Args: []string{ "sh", }, diff --git a/spec_linux.go b/spec_linux.go index 6725e9c40..d49dbdca4 100644 --- a/spec_linux.go +++ b/spec_linux.go @@ -30,6 +30,12 @@ type Linux struct { Devices []string `json:"devices"` } +type User struct { + Uid int32 `json:"uid"` + Gid int32 `json:"gid"` + AdditionalGids []int32 `json:"additionalGids"` +} + type Namespace struct { Type string `json:"type"` Path string `json:"path"` @@ -273,10 +279,6 @@ func setReadonly(config *configs.Config) { } } -func getCPUQuota(cpus float64) int64 { - return int64(cpus * cpuQuotaMultiplyer) -} - func setupUserNamespace(spec *Spec, config *configs.Config) error { if len(spec.Linux.UserMapping) == 0 { return nil diff --git a/utils.go b/utils.go index 7153c4d44..8d9f5a67e 100644 --- a/utils.go +++ b/utils.go @@ -166,7 +166,7 @@ func newProcess(p Process) *libcontainer.Process { return &libcontainer.Process{ Args: p.Args, Env: p.Env, - User: p.User, + User: fmt.Sprintf("%d:%d", p.User.Uid, p.User.Gid), Cwd: p.Cwd, Stdin: os.Stdin, Stdout: os.Stdout,