Use Int64SliceFlag instead of StringFlag to get additional gids.
Signed-off-by: Sumit Sanghrajka <sumit.sanghrajka@gmail.com>
This commit is contained in:
parent
7a386c2b60
commit
f55f79d6ba
12
exec.go
12
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)
|
||||
}
|
||||
for _, gid := range context.Int64Slice("additional-gids") {
|
||||
p.User.AdditionalGids = append(p.User.AdditionalGids, uint32(gid))
|
||||
}
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
|
|
@ -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)" ]]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue