[dev] [st][PATCH] Set correct value of variable SHELL

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Thu, 7 Aug 2014 11:25:38 +0200

SHELL must contain the value of the SHELL of the user. execsh()
was reading this variable from the environment of the user, and
in case of being NULL it was setting SHELL with the value of
/etc/passwd, but in this case it was executing the default
shell specified in config.h.
---
 st.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/st.c b/st.c
index e0aae9d..d2929d0 100644
--- a/st.c
+++ b/st.c
_AT_@ -1142,7 +1142,7 @@ die(const char *errstr, ...) {
 void
 execsh(void) {
 	char **args;
-	char *envshell = getenv("SHELL");
+	char *envshell;
 	const struct passwd *pass = getpwuid(getuid());
 	char buf[sizeof(long) * 8 + 1];
 
_AT_@ -1156,7 +1156,6 @@ execsh(void) {
 		setenv("SHELL", pass->pw_shell, 0);
 		setenv("HOME", pass->pw_dir, 0);
 	}
-
 	snprintf(buf, sizeof(buf), "%lu", xw.win);
 	setenv("WINDOWID", buf, 1);
 
_AT_@ -1167,7 +1166,8 @@ execsh(void) {
 	signal(SIGTERM, SIG_DFL);
 	signal(SIGALRM, SIG_DFL);
 
-	DEFAULT(envshell, shell);
+	if ((envshell = getenv("SHELL")) == NULL)
+		setenv("SHELL", envshell = shell, 1);
 	setenv("TERM", termname, 1);
 	args = opt_cmd ? opt_cmd : (char *[]){envshell, "-i", NULL};
 	execvp(args[0], args);
-- 
2.0.1
Received on Thu Aug 07 2014 - 11:25:38 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 07 2014 - 11:36:06 CEST