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:
Axel Dörfler 2015-05-11 09:12:38 +02:00
parent bea38cb711
commit 1f374c8b2a
1 changed files with 8 additions and 1 deletions

View File

@ -231,11 +231,18 @@ get_user_home_path(char* buffer, size_t bufferSize)
const char* home = NULL;
#ifndef _KERNEL_MODE
#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;
char pwStringBuffer[MAX_PASSWD_BUFFER_SIZE];
struct passwd* pw;
if (getpwuid_r(geteuid(), &pwBuffer, pwStringBuffer,
if (getpwuid_r(user, &pwBuffer, pwStringBuffer,
sizeof(pwStringBuffer), &pw) == 0
&& pw != NULL) {
home = pw->pw_dir;