Fix environment vars after setuid
This commit is contained in:
parent
d74db187ef
commit
43146158aa
6
main.c
6
main.c
@ -566,7 +566,11 @@ int change_user_group () {
|
|||||||
if (setuid (pw->pw_uid) < 0) {
|
if (setuid (pw->pw_uid) < 0) {
|
||||||
fprintf (stderr, "change_user_group: failed to assume identity of user %s\n", username);
|
fprintf (stderr, "change_user_group: failed to assume identity of user %s\n", username);
|
||||||
return -1;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user