Skip to content

Commit

Permalink
Merge pull request #567 from cgwalters/chdir-after-chroot
Browse files Browse the repository at this point in the history
user-group: Add chdir("/") after chroot()
  • Loading branch information
arithx authored Jun 28, 2018
2 parents 3c7dbd3 + 85e6b62 commit f41d15d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/exec/util/user_group_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ static int user_lookup_fn(lookup_ctxt_t *ctxt) {
goto out_err;
}

if (chdir("/") == -1) {
goto out_err;
}

if(getpwnam_r(ctxt->name, &p, buf, sizeof(buf), &pptr) != 0 || !pptr) {
goto out_err;
}
Expand Down Expand Up @@ -90,6 +94,10 @@ static int group_lookup_fn(lookup_ctxt_t *ctxt) {
goto out_err;
}

if (chdir("/") == -1) {
goto out_err;
}

if(getgrnam_r(ctxt->name, &g, buf, sizeof(buf), &gptr) != 0 || !gptr) {
goto out_err;
}
Expand Down

0 comments on commit f41d15d

Please sign in to comment.