Add user struct based on spec implementation.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2015-07-01 09:57:26 -07:00
parent 1865c0aac6
commit e15b86edb9
5 changed files with 18 additions and 10 deletions
+5 -1
View File
@@ -49,7 +49,11 @@ user named `daemon` defined within that file-system.
}, },
"process": { "process": {
"terminal": true, "terminal": true,
"user": "daemon", "user": {
"uid": 0,
"gid": 0,
"additionalGids": null
},
"args": [ "args": [
"sh" "sh"
], ],
+4
View File
@@ -7,6 +7,10 @@ import (
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
) )
type User struct {
NOTSUPPORTED string
}
func getDefaultID() string { func getDefaultID() string {
return "" return ""
} }
+2 -4
View File
@@ -9,8 +9,6 @@ import (
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
) )
const cpuQuotaMultiplyer = 100000
type Mount struct { type Mount struct {
Type string `json:"type"` Type string `json:"type"`
Source string `json:"source"` Source string `json:"source"`
@@ -20,7 +18,7 @@ type Mount struct {
type Process struct { type Process struct {
Terminal bool `json:"terminal"` Terminal bool `json:"terminal"`
User string `json:"user"` User User `json:"user"`
Args []string `json:"args"` Args []string `json:"args"`
Env []string `json:"env"` Env []string `json:"env"`
Cwd string `json:"cwd"` Cwd string `json:"cwd"`
@@ -61,7 +59,7 @@ var specCommand = cli.Command{
}, },
Process: Process{ Process: Process{
Terminal: true, Terminal: true,
User: "daemon", User: User{},
Args: []string{ Args: []string{
"sh", "sh",
}, },
+6 -4
View File
@@ -30,6 +30,12 @@ type Linux struct {
Devices []string `json:"devices"` Devices []string `json:"devices"`
} }
type User struct {
Uid int32 `json:"uid"`
Gid int32 `json:"gid"`
AdditionalGids []int32 `json:"additionalGids"`
}
type Namespace struct { type Namespace struct {
Type string `json:"type"` Type string `json:"type"`
Path string `json:"path"` 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 { func setupUserNamespace(spec *Spec, config *configs.Config) error {
if len(spec.Linux.UserMapping) == 0 { if len(spec.Linux.UserMapping) == 0 {
return nil return nil
+1 -1
View File
@@ -166,7 +166,7 @@ func newProcess(p Process) *libcontainer.Process {
return &libcontainer.Process{ return &libcontainer.Process{
Args: p.Args, Args: p.Args,
Env: p.Env, Env: p.Env,
User: p.User, User: fmt.Sprintf("%d:%d", p.User.Uid, p.User.Gid),
Cwd: p.Cwd, Cwd: p.Cwd,
Stdin: os.Stdin, Stdin: os.Stdin,
Stdout: os.Stdout, Stdout: os.Stdout,