Fix environment vars after setuid

This commit is contained in:
gfleury 2014-12-21 21:03:47 -02:00
parent d74db187ef
commit 43146158aa

6
main.c
View File

@ -566,7 +566,11 @@ int change_user_group () {
if (setuid (pw->pw_uid) < 0) {
fprintf (stderr, "change_user_group: failed to assume identity of user %s\n", username);
return -1;
}
} else {
pw = getpwuid(getuid());
setenv("USER", pw->pw_name, 1);
setenv("HOME", pw->pw_dir, 1);
setenv("SHELL", pw->pw_shell, 1);
}
return 0;
}