From 91ae2ae210f9cf530038d071db41e3da574e092d Mon Sep 17 00:00:00 2001 From: Dave Olson Date: Sun, 15 Apr 2018 14:39:26 -0700 Subject: 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. --- src/radius_shell.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') 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); -- cgit v1.2.3