Skip to content

Commit

Permalink
Use Int64SliceFlag instead of StringFlag to get additional gids.
Browse files Browse the repository at this point in the history
Signed-off-by: Sumit Sanghrajka <sumit.sanghrajka@gmail.com>
  • Loading branch information
sumitsanghrajka authored and crosbymichael committed Oct 10, 2017
1 parent 7a386c2 commit f55f79d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
14 changes: 4 additions & 10 deletions exec.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ following will output a list of processes running in the container:
Name: "user, u", Name: "user, u",
Usage: "UID (format: <uid>[:<gid>])", Usage: "UID (format: <uid>[:<gid>])",
}, },
cli.StringFlag{ cli.Int64SliceFlag{
Name: "additional-gids, g", Name: "additional-gids, g",
Usage: "additional gids separated by comma", Usage: "additional gids",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "process, p", Name: "process, p",
Expand Down Expand Up @@ -212,14 +212,8 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
} }
p.User.UID = uint32(uid) p.User.UID = uint32(uid)
} }
if context.String("additional-gids") != "" { for _, gid := range context.Int64Slice("additional-gids") {
for _, i := range strings.Split(context.String("additional-gids"), ",") { p.User.AdditionalGids = append(p.User.AdditionalGids, uint32(gid))
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))
}
} }
return p, nil return p, nil
} }
2 changes: 1 addition & 1 deletion man/runc-exec.8.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ following will output a list of processes running in the container:
--env value, -e value set environment variables --env value, -e value set environment variables
--tty, -t allocate a pseudo-TTY --tty, -t allocate a pseudo-TTY
--user value, -u value UID (format: <uid>[:<gid>]) --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 --process value, -p value path to the process.json
--detach, -d detach from the container's process --detach, -d detach from the container's process
--pid-file value specify the file to write the process id to --pid-file value specify the file to write the process id to
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/exec.bats
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ function teardown() {


wait_for_container 15 1 test_busybox 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 ] [ "$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.