]> git.armaanb.net Git - opendoas.git/blobdiff - doas.c
Add closefrom(2) from openssh-portable
[opendoas.git] / doas.c
diff --git a/doas.c b/doas.c
index 869155973b3944235fd5304a428372d024ad794e..d4d87cb7c930780effa5931cf944089cf4c3b083 100644 (file)
--- a/doas.c
+++ b/doas.c
@@ -46,8 +46,11 @@ version(void)
 static void __dead
 usage(void)
 {
-       fprintf(stderr, "usage: doas [-nsv] [-a style] [-C config] [-u user]"
-           " command [args]\n");
+       fprintf(stderr, "usage: doas [-nsv] "
+#ifdef HAVE_BSD_AUTH_H
+           "[-a style] "
+#endif
+           "[-C config] [-u user] command [args]\n");
        exit(1);
 }
 
@@ -249,7 +252,7 @@ main(int argc, char **argv)
        if (pledge("stdio rpath getpw tty recvfd proc exec id", NULL) == -1)
                err(1, "pledge");
 
-       /* closefrom(STDERR_FILENO + 1); */
+       closefrom(STDERR_FILENO + 1);
 
        uid = getuid();
 
@@ -311,9 +314,11 @@ main(int argc, char **argv)
 
        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;