diff --git a/src/startup/darling.c b/src/startup/darling.c index 95b2126f7..101ba2580 100644 --- a/src/startup/darling.c +++ b/src/startup/darling.c @@ -44,6 +44,7 @@ along with Darling. If not, see . #include #include #include +#include #include "../shellspawn/shellspawn.h" #include "darling.h" #include "darling-config.h" @@ -1318,7 +1319,16 @@ void setupUserHome(void) mkdir(buf, 0777); const char* home = getenv("HOME"); - const char* login = getlogin(); + + const char* login = NULL; + struct passwd* pw = getpwuid(getuid()); + + if (pw != NULL) + login = pw->pw_name; + + if (!login) + login = getlogin(); + if (!login) { fprintf(stderr, "Cannot determine your user name\n");