From 1f374c8b2a610f3a7483bd4047dfbfa928c50a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 11 May 2015 09:12:38 +0200 Subject: [PATCH] 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. --- src/system/libroot/os/find_directory.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/system/libroot/os/find_directory.cpp b/src/system/libroot/os/find_directory.cpp index 2e3ef620da..0821b7dbab 100644 --- a/src/system/libroot/os/find_directory.cpp +++ b/src/system/libroot/os/find_directory.cpp @@ -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;