Skip to content

Commit

Permalink
correctly reset path for rules without specific command
Browse files Browse the repository at this point in the history
This is a fixup for commit 01c658f
where the behaviour was changed to not inherit the PATH variable
by default.
  • Loading branch information
Duncaen committed Jan 28, 2021
1 parent 01ac841 commit d5acd52
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doas.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ main(int argc, char **argv)

#ifdef HAVE_LOGIN_CAP_H
if (setusercontext(NULL, targpw, target, LOGIN_SETGROUP |
LOGIN_SETPATH |
LOGIN_SETPRIORITY | LOGIN_SETRESOURCES | LOGIN_SETUMASK |
LOGIN_SETUSER) != 0)
errx(1, "failed to set user context for target");
Expand All @@ -396,6 +397,8 @@ main(int argc, char **argv)
err(1, "initgroups");
if (setresuid(target, target, target) != 0)
err(1, "setresuid");
if (setenv("PATH", safepath, 1) == -1)
err(1, "failed to set PATH '%s'", safepath);
#endif

if (getcwd(cwdpath, sizeof(cwdpath)) == NULL)
Expand Down

0 comments on commit d5acd52

Please sign in to comment.