]> git.armaanb.net Git - opendoas.git/blobdiff - doas.c
correctly reset path for rules without specific command
[opendoas.git] / doas.c
diff --git a/doas.c b/doas.c
index a184650ba38ea9b4f8c781fd791a869efee32dc1..d312b2471a6332a833829cd9148532a52a49e33f 100644 (file)
--- a/doas.c
+++ b/doas.c
@@ -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");
@@ -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)