aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhuk <zhuk>2016-07-18 16:46:30 +0000
committerDuncaen <mail@duncano.de>2016-09-01 19:28:43 +0200
commit24c98415f578823a1132be03279f18189d41c241 (patch)
treeca168a02f09dba412d3484705d123d211d888d83
parent6ec218cb321404af01a1bec505f782e98c5ec7a3 (diff)
downloadopendoas-24c98415f578823a1132be03279f18189d41c241.tar.gz
The string with path to shell could be taken directly from struct passwd. At some point later the data it points to is overridden by getpwuid() call, resulting in garbage. The problem could be easily demonstreated by double doas call:
$ 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@
-rw-r--r--doas.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/doas.c b/doas.c
index 8691559..fa0eafb 100644
--- 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;