dom0: Allow UID as parameter to qfile-dom0-unpacker
This commit is contained in:
parent
4f10835d83
commit
79d593e191
@ -19,15 +19,20 @@
|
||||
int prepare_creds_return_uid(char *username)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
// First try name
|
||||
pwd = getpwnam(username);
|
||||
if (!pwd) {
|
||||
perror("getpwnam");
|
||||
// Then try UID
|
||||
pwd = getpwuid(atoi(username));
|
||||
if (!pwd) {
|
||||
perror("getpwuid");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
setenv("HOME", pwd->pw_dir, 1);
|
||||
setenv("USER", username, 1);
|
||||
setenv("USER", pwd->pw_name, 1);
|
||||
setgid(pwd->pw_gid);
|
||||
initgroups(username, pwd->pw_gid);
|
||||
initgroups(pwd->pw_name, pwd->pw_gid);
|
||||
setfsuid(pwd->pw_uid);
|
||||
return pwd->pw_uid;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user