Module: wine Branch: master Commit: 9122bc1096f3231c5f6b8ffc0d7ad3e700f18af1 URL: https://source.winehq.org/git/wine.git/?a=commit;h=9122bc1096f3231c5f6b8ffc0...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Apr 27 12:34:45 2020 +0200
ntdll: Avoid using wine_get_user_name() from libwine.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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 efb5270a2c..ff0c8fbe90 100644 --- a/dlls/ntdll/env.c +++ b/dlls/ntdll/env.c @@ -27,6 +27,9 @@ #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif +#ifdef HAVE_PWD_H +# include <pwd.h> +#endif #ifdef HAVE_UNISTD_H # include <unistd.h> #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) );