logo

skeud

Simple and portable utilities to deal with user accounts (su, login)
commit: bad8fe03edbade65b8d3f0824d74d013452547bd
parent ef20f83ba2ab372efadde76b116d262fc573d0ca
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun,  9 Oct 2022 04:09:41 +0200

su,login: Always set USER, LOGNAME, IFS environment variables

Diffstat:

Mlogin.c3+++
Msu.c11+++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/login.c b/login.c @@ -193,7 +193,10 @@ main(int argc, char *argv[]) pwent = NULL; } + setenv("USER", username, 1); + setenv("LOGNAME", username, 1); setenv("SHELL", shell, 1); + setenv("IFS", " \t\n", 1); errno = 0; /* flawfinder: ignore CWE-78 */ diff --git a/su.c b/su.c @@ -200,6 +200,17 @@ main(int argc, char *argv[]) shell = "/bin/sh"; } + if(username != NULL) + { + setenv("USER", username, 1); + setenv("LOGNAME", username, 1); + } + else + { + setenv("USER", "root", 1); + setenv("LOGNAME", "root", 1); + } + setenv("SHELL", shell, 1); setenv("IFS", " \t\n", 1);