diff options
author | Dave Olson <olson@cumulusnetworks.com> | 2018-04-15 14:39:26 -0700 |
---|---|---|
committer | Dave Olson <olson@cumulusnetworks.com> | 2018-04-15 14:39:26 -0700 |
commit | 91ae2ae210f9cf530038d071db41e3da574e092d (patch) | |
tree | 3ff40ee2d0fd9cf803e75032f02ec50772f360e1 | |
parent | acc77c4757775bb7689ba769465951a65523db75 (diff) | |
download | libpam-radius-auth-91ae2ae210f9cf530038d071db41e3da574e092d.tar.gz libpam-radius-auth-91ae2ae210f9cf530038d071db41e3da574e092d.zip |
Fixed incredibly stupid radius_shell bug where I forgot about args > 1
Ticket: CM-20606
Reviewed By: nobody
Testing Done: ran my own tests, and the automated radius tests
All the shells need to accept -c someargument, for 'su -c'
non-interactive shell, etc.
Fixed by adjusting args[0], and using execv instead of execl.
Passes regular radius automated tests again.
-rw-r--r-- | src/radius_shell.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/radius_shell.c b/src/radius_shell.c index a94c7f3..5da76dc 100644 --- a/src/radius_shell.c +++ b/src/radius_shell.c @@ -92,6 +92,7 @@ execit: /* * Eventually handle this program being linked or symlinked * and that the shell is one of the shells in /etc/shells + * Expect it to be installed as /sbin/radius/bash, etc. */ shell = strrchr(args[0], '/'); if (!shell) @@ -103,15 +104,22 @@ execit: else check = shell; + /* need to validate shell from basename is valid here */ + + /* should really check this against /etc/shell */ snprintf(execshell, sizeof execshell, "/bin/%s", check); #else check = "bash"; - shell = "-bash"; + if (*args[0] == '-') + shell = "-bash"; + else + shell = "bash"; snprintf(execshell, sizeof execshell, "/bin/%s", check); #endif - execl(execshell, shell, NULL); + args[0] = shell; + execv(execshell, args); fprintf(stderr, "Exec of shell %s failed: %s\n", execshell, strerror(errno)); exit(1); |