Skip to content

Commit

Permalink
cmd: use utils.{c,h} helpers in lxc-usernsexec
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Aug 19, 2018
1 parent c881c81 commit 197c929
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/lxc/cmd/lxc_usernsexec.c
Expand Up @@ -104,23 +104,13 @@ static int do_child(void *vargv)
char **argv = (char **)vargv;

/* Assume we want to become root */
ret = setgid(0);
if (ret < 0) {
CMD_SYSERROR("Failed to set gid to");
return -1;
}

ret = setuid(0);
if (ret < 0) {
CMD_SYSERROR("Failed to set uid to 0");
ret = lxc_switch_uid_gid(0, 0);
if (ret < 0)
return -1;
}

ret = setgroups(0, NULL);
if (ret < 0) {
CMD_SYSERROR("Failed to clear supplementary groups");
ret = lxc_setgroups(0, NULL);
if (ret < 0)
return -1;
}

ret = unshare(CLONE_NEWNS);
if (ret < 0) {
Expand Down

0 comments on commit 197c929

Please sign in to comment.