]> git.armaanb.net Git - opendoas.git/commitdiff
The string with path to shell could be taken directly from struct passwd. At some...
authorzhuk <zhuk>
Mon, 18 Jul 2016 16:46:30 +0000 (16:46 +0000)
committerDuncaen <mail@duncano.de>
Thu, 1 Sep 2016 17:28:43 +0000 (19:28 +0200)
  $ doas doas -su _sndio
  doas: mpty: command not found

The fix is easy: just strdup() the pw_shell field value.

okay tedu@, tweaks from & okay natano@

doas.c

diff --git a/doas.c b/doas.c
index 869155973b3944235fd5304a428372d024ad794e..fa0eafb4970ccff8a5bad147ef910b7aa3984c45 100644 (file)
--- a/doas.c
+++ b/doas.c
@@ -311,9 +311,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;