From 77c8f8abbb4034e409be2e71a22c1caaf1ce5f03 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sun, 26 Apr 2009 17:57:06 +0000 Subject: Use /bin/bash or user shell in /etc/passwd if none set before /bin/sh. --- src/rc/rc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rc/rc.c b/src/rc/rc.c index 56d6d580..0336264c 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -53,6 +53,7 @@ const char rc_copyright[] = "Copyright (c) 2007-2008 Roy Marples"; #include #include #include +#include #include #include #include @@ -315,6 +316,7 @@ static void open_shell(void) { const char *shell; + struct passwd *pw; #ifdef __linux__ const char *sys = rc_sys(); @@ -330,8 +332,17 @@ open_shell(void) #endif shell = rc_conf_value("rc_shell"); - if (shell == NULL) - shell = "/bin/sh"; + /* No shell set, so obey env, then passwd, then default to /bin/sh */ + if (shell == NULL) { + shell = getenv("SHELL"); + if (shell == NULL) { + pw = getpwuid(getuid()); + if (pw) + shell = pw->pw_shell; + if (shell == NULL) + shell = "/bin/sh"; + } + } run_program(shell); } -- cgit v1.2.3