logo

skeud

Simple and portable utilities to deal with user accounts (su, login)
commit: 74ae56b5afeea243873567b593f8defc09fff739
parent 93ea6f71157fa3d23d607ba8162b1ff989bea051
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 11 Sep 2023 08:45:46 +0200

su: Always set HOME with fallback to /

Diffstat:

Msu.c11++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/su.c b/su.c @@ -203,14 +203,11 @@ main(int argc, char *argv[]) perror("su: setuid"); } - if(pwent->pw_dir != NULL) + char *home = pwent->pw_dir ? pwent->pw_dir : "/"; + setenv("HOME", home, 1); + if(opt_l) { - setenv("HOME", pwent->pw_dir, 1); - - if(opt_l) - { - if(chdir(pwent->pw_dir) != 0) perror("su: chdir"); - } + if(chdir(pwent->pw_dir) != 0) perror("su: chdir"); } explicit_bzero(pwent, sizeof(pwent));