Permalink
Browse files

Use Int64SliceFlag instead of StringFlag to get additional gids.

Signed-off-by: Sumit Sanghrajka <sumit.sanghrajka@gmail.com>
  • Loading branch information...
sumitsanghrajka authored and crosbymichael committed Feb 7, 2017
1 parent 7a386c2 commit f55f79d6ba93a2d212e247e12b6de0596fa7fbc8
Showing with 7 additions and 13 deletions.
  1. +4 −10 exec.go
  2. +1 −1 man/runc-exec.8.md
  3. +2 −2 tests/integration/exec.bats
View
14 exec.go
@@ -50,9 +50,9 @@ following will output a list of processes running in the container:
Name: "user, u",
Usage: "UID (format: <uid>[:<gid>])",
},
cli.StringFlag{
cli.Int64SliceFlag{
Name: "additional-gids, g",
Usage: "additional gids separated by comma",
Usage: "additional gids",
},
cli.StringFlag{
Name: "process, p",
@@ -212,14 +212,8 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
}
p.User.UID = uint32(uid)
}
if context.String("additional-gids") != "" {
for _, i := range strings.Split(context.String("additional-gids"), ",") {
gid, err := strconv.Atoi(i)
if err != nil {
return nil, fmt.Errorf("parsing %s as int for gid failed: %v", i, err)
}
p.User.AdditionalGids = append(p.User.AdditionalGids, uint32(gid))
}
for _, gid := range context.Int64Slice("additional-gids") {
p.User.AdditionalGids = append(p.User.AdditionalGids, uint32(gid))
}
return p, nil
}
View
@@ -19,7 +19,7 @@ following will output a list of processes running in the container:
--env value, -e value set environment variables
--tty, -t allocate a pseudo-TTY
--user value, -u value UID (format: <uid>[:<gid>])
--additional-gids value, -g value additional gids separated by comma
--additional-gids value, -g value additional gids
--process value, -p value path to the process.json
--detach, -d detach from the container's process
--pid-file value specify the file to write the process id to
@@ -120,8 +120,8 @@ function teardown() {
wait_for_container 15 1 test_busybox
runc exec --user 1000:1000 --additional-gids 100 test_busybox id
runc exec --user 1000:1000 --additional-gids 100 --additional-gids 99 test_busybox id
[ "$status" -eq 0 ]
[[ ${output} == "uid=1000 gid=1000 groups=100(users)" ]]
[[ ${output} == "uid=1000 gid=1000 groups=99(nogroup),100(users)" ]]
}

0 comments on commit f55f79d

Please sign in to comment.