libroot: hardcode find_directory() to /home/boot for root.
* This is a work-around to allow the registrar, and the launch_daemon to call find_directory() without worries.
This commit is contained in:
parent
bea38cb711
commit
1f374c8b2a
|
@ -231,11 +231,18 @@ get_user_home_path(char* buffer, size_t bufferSize)
|
||||||
const char* home = NULL;
|
const char* home = NULL;
|
||||||
#ifndef _KERNEL_MODE
|
#ifndef _KERNEL_MODE
|
||||||
#ifdef USE_PWENTS
|
#ifdef USE_PWENTS
|
||||||
|
uid_t user = geteuid();
|
||||||
|
if (user == 0) {
|
||||||
|
// TODO: this is a work-around as the launch_daemon, and the registrar
|
||||||
|
// must not call getpwuid_r().
|
||||||
|
return strlcpy(buffer, kUserDirectory, bufferSize);
|
||||||
|
}
|
||||||
|
|
||||||
struct passwd pwBuffer;
|
struct passwd pwBuffer;
|
||||||
char pwStringBuffer[MAX_PASSWD_BUFFER_SIZE];
|
char pwStringBuffer[MAX_PASSWD_BUFFER_SIZE];
|
||||||
struct passwd* pw;
|
struct passwd* pw;
|
||||||
|
|
||||||
if (getpwuid_r(geteuid(), &pwBuffer, pwStringBuffer,
|
if (getpwuid_r(user, &pwBuffer, pwStringBuffer,
|
||||||
sizeof(pwStringBuffer), &pw) == 0
|
sizeof(pwStringBuffer), &pw) == 0
|
||||||
&& pw != NULL) {
|
&& pw != NULL) {
|
||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
|
|
Loading…
Reference in New Issue