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

View File

@ -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"
],

View File

@ -7,6 +7,10 @@ import (
"github.com/codegangsta/cli"
)
type User struct {
NOTSUPPORTED string
}
func getDefaultID() string {
return ""
}

View File

@ -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",
},

View File

@ -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

View File

@ -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,