Add --additional-gids to runc exec.

This flag allows specifying additional gids for the process.
Without this flag, the user will have to provide process.json which allows additional gids.
Closes #1306

Signed-off-by: Sumit Sanghrajka <sumit.sanghrajka@gmail.com>
This commit is contained in:
Sumit Sanghrajka
2017-02-02 14:08:35 -08:00
committed by Michael Crosby
parent beb8716fcb
commit 7a386c2b60
3 changed files with 40 additions and 13 deletions
+13
View File
@@ -50,6 +50,10 @@ following will output a list of processes running in the container:
Name: "user, u",
Usage: "UID (format: <uid>[:<gid>])",
},
cli.StringFlag{
Name: "additional-gids, g",
Usage: "additional gids separated by comma",
},
cli.StringFlag{
Name: "process, p",
Usage: "path to the process.json",
@@ -208,5 +212,14 @@ 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))
}
}
return p, nil
}