From 9122bc1096f3231c5f6b8ffc0d7ad3e700f18af1 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 27 Apr 2020 12:34:45 +0200 Subject: [PATCH] ntdll: Avoid using wine_get_user_name() from libwine. Signed-off-by: Alexandre Julliard --- dlls/ntdll/env.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c index efb5270a2cc..ff0c8fbe906 100644 --- a/dlls/ntdll/env.c +++ b/dlls/ntdll/env.c @@ -27,6 +27,9 @@ #ifdef HAVE_SYS_STAT_H # include #endif +#ifdef HAVE_PWD_H +# include +#endif #ifdef HAVE_UNISTD_H # include #endif @@ -386,15 +389,27 @@ static void set_wow64_environment( WCHAR **env ) UNICODE_STRING valW = { 0, sizeof(buf), buf }; OBJECT_ATTRIBUTES attr; UNICODE_STRING nameW; - const char *p, *name; + const char *p; + const char *home = getenv( "HOME" ); + const char *name = getenv( "USER" ); WCHAR *val; HANDLE hkey; DWORD i; + if (!home || !name) + { + struct passwd *pwd = getpwuid( getuid() ); + if (pwd) + { + if (!home) home = pwd->pw_dir; + if (!name) name = pwd->pw_name; + } + } + /* set the Wine paths */ set_wine_path_variable( env, winedatadirW, wine_get_data_dir() ); - set_wine_path_variable( env, winehomedirW, getenv("HOME") ); + set_wine_path_variable( env, winehomedirW, home ); set_wine_path_variable( env, winebuilddirW, wine_get_build_dir() ); set_wine_path_variable( env, wineconfigdirW, config_dir ); for (i = 0; (p = wine_dll_enum_load_path( i )); i++) @@ -407,7 +422,7 @@ static void set_wow64_environment( WCHAR **env ) /* set user name */ - name = wine_get_user_name(); + if (!name) name = "wine"; if ((p = strrchr( name, '/' ))) name = p + 1; if ((p = strrchr( name, '\\' ))) name = p + 1; ntdll_umbstowcs( name, strlen(name) + 1, buf, ARRAY_SIZE(buf) );