Introduction
Introduction Statistics Contact Development Disclaimer Help
su: check $SHELL for validity - ubase - suckless linux base utils
git clone git://git.suckless.org/ubase
Log
Files
Refs
README
LICENSE
---
commit e9bcdcc341d74f0abaa171703ac031b55e9020c0
parent cf9e26d7fa2d13ede8ce2830819e311fc0dd83b9
Author: neeshy <[email protected]>
Date: Mon, 12 Feb 2024 21:41:02 -0500
su: check $SHELL for validity
If $SHELL isn't defined in the environment, the call to execve will
fail when -p is specified. Fallback to the user's login shell if $SHELL
is invalid.
Diffstat:
M su.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/su.c b/su.c
@@ -28,7 +28,7 @@ int
main(int argc, char *argv[])
{
char *usr = "root", *pass;
- char *shell, *term;
+ char *shell, *envshell, *term;
struct passwd *pw;
char *newargv[3];
uid_t uid;
@@ -89,7 +89,9 @@ main(int argc, char *argv[])
newargv[2] = NULL;
} else {
if (pflag) {
- shell = getenv("SHELL");
+ envshell = getenv("SHELL");
+ if (envshell && envshell[0] != '\0')
+ shell = envshell;
} else {
setenv("HOME", pw->pw_dir, 1);
setenv("SHELL", shell, 1);
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.