Skip to content

Commit f55f79d

Browse files
sumitsanghrajkacrosbymichael
authored andcommitted
Use Int64SliceFlag instead of StringFlag to get additional gids.
Signed-off-by: Sumit Sanghrajka <[email protected]>
1 parent 7a386c2 commit f55f79d

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

exec.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ following will output a list of processes running in the container:
5050
Name: "user, u",
5151
Usage: "UID (format: <uid>[:<gid>])",
5252
},
53-
cli.StringFlag{
53+
cli.Int64SliceFlag{
5454
Name: "additional-gids, g",
55-
Usage: "additional gids separated by comma",
55+
Usage: "additional gids",
5656
},
5757
cli.StringFlag{
5858
Name: "process, p",
@@ -212,14 +212,8 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
212212
}
213213
p.User.UID = uint32(uid)
214214
}
215-
if context.String("additional-gids") != "" {
216-
for _, i := range strings.Split(context.String("additional-gids"), ",") {
217-
gid, err := strconv.Atoi(i)
218-
if err != nil {
219-
return nil, fmt.Errorf("parsing %s as int for gid failed: %v", i, err)
220-
}
221-
p.User.AdditionalGids = append(p.User.AdditionalGids, uint32(gid))
222-
}
215+
for _, gid := range context.Int64Slice("additional-gids") {
216+
p.User.AdditionalGids = append(p.User.AdditionalGids, uint32(gid))
223217
}
224218
return p, nil
225219
}

man/runc-exec.8.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ following will output a list of processes running in the container:
1919
--env value, -e value set environment variables
2020
--tty, -t allocate a pseudo-TTY
2121
--user value, -u value UID (format: <uid>[:<gid>])
22-
--additional-gids value, -g value additional gids separated by comma
22+
--additional-gids value, -g value additional gids
2323
--process value, -p value path to the process.json
2424
--detach, -d detach from the container's process
2525
--pid-file value specify the file to write the process id to

tests/integration/exec.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ function teardown() {
120120

121121
wait_for_container 15 1 test_busybox
122122

123-
runc exec --user 1000:1000 --additional-gids 100 test_busybox id
123+
runc exec --user 1000:1000 --additional-gids 100 --additional-gids 99 test_busybox id
124124
[ "$status" -eq 0 ]
125125

126-
[[ ${output} == "uid=1000 gid=1000 groups=100(users)" ]]
126+
[[ ${output} == "uid=1000 gid=1000 groups=99(nogroup),100(users)" ]]
127127
}

0 commit comments

Comments
 (0)