File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 77#include <sys/types.h>
88#include <sys/wait.h>
99#include <syslog.h>
10+ #include <string.h>
1011#include <unistd.h>
1112#include <signal.h>
1213#include <spawn.h>
2122#include "rc.h"
2223#include "rc_exec.h"
2324
25+ static bool valid_shell (const char * shell ) {
26+ FILE * fp = fopen (RC_SYSCONFDIR "/shells" , "r" );
27+ bool ret = false;
28+ char * line = NULL ;
29+ size_t size ;
30+
31+ if (!fp )
32+ return true;
33+
34+ while (xgetline (& line , & size , fp ) != -1 ) {
35+ if (line [0 ] == '#' )
36+ continue ;
37+ if (strcmp (line , shell ) == 0 ) {
38+ ret = true;
39+ break ;
40+ }
41+ }
42+
43+ free (line );
44+ return ret ;
45+ }
46+
2447static bool spawn_openrc (const struct passwd * user , bool start ) {
2548 char * argv0 ;
2649 const char * argv [] = {
@@ -32,7 +55,7 @@ static bool spawn_openrc(const struct passwd *user, bool start) {
3255
3356 /* shell might be a multicall binary, e.g busybox.
3457 * so setting argv[0] to "-" might not work */
35- xasprintf (& argv0 , "-%s" , user -> pw_shell );
58+ xasprintf (& argv0 , "-%s" , valid_shell ( user -> pw_shell ) ? user -> pw_shell : "/bin/sh" );
3659 argv [0 ] = argv0 ;
3760 args = exec_init (argv );
3861 args .cmd = user -> pw_shell ;
You can’t perform that action at this time.
0 commit comments