setprogname("doas");
- if (pledge("stdio rpath getpw tty proc exec id", NULL) == -1)
+ if (pledge("stdio rpath getpw tty recvfd proc exec id", NULL) == -1)
err(1, "pledge");
/* closefrom(STDERR_FILENO + 1); */
if (sflag) {
sh = getenv("SHELL");
- if (sh == NULL || *sh == '\0')
- shargv[0] = pw->pw_shell;
- else
+ if (sh == NULL || *sh == '\0') {
+ shargv[0] = strdup(pw->pw_shell);
+ if (shargv[0] == NULL)
+ err(1, NULL);
+ } else
shargv[0] = sh;
argv = shargv;
argc = 1;