This makes it possible to override the host value seen by Wine of e.g. XDG_DATA_DIRS by setting WINE_HOST_XDG_DATA_DIRS directly.
From: Alexandre Julliard julliard@winehq.org
To make it clear that this is Wine-specific. --- dlls/appwiz.cpl/addons.c | 2 +- dlls/ntdll/unix/env.c | 8 ++++---- dlls/shell32/recyclebin.c | 2 +- dlls/shell32/shellpath.c | 2 +- programs/winemenubuilder/winemenubuilder.c | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/dlls/appwiz.cpl/addons.c b/dlls/appwiz.cpl/addons.c index aa05994e32f..cf7f4f23c88 100644 --- a/dlls/appwiz.cpl/addons.c +++ b/dlls/appwiz.cpl/addons.c @@ -323,7 +323,7 @@ static WCHAR *get_cache_file_name(BOOL ensure_exists) WCHAR *cache_dir=NULL, *ret; size_t len, size;
- xdg_dir = _wgetenv( L"UNIX_XDG_CACHE_HOME" ); + xdg_dir = _wgetenv( L"WINE_HOST_XDG_CACHE_HOME" ); if (xdg_dir && *xdg_dir) { if (!(cache_dir = HeapAlloc( GetProcessHeap(), 0, wcslen(xdg_dir) * sizeof(WCHAR) + sizeof(L"\\?\unix") ))) return NULL; diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index b82b81eb696..f115d580e3c 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -867,11 +867,11 @@ static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size ) exit(0); } } - else if (is_special_env_var( str )) /* prefix it with UNIX_ */ + else if (is_special_env_var( str )) /* prefix it with WINE_HOST_ */ { - static const WCHAR unixW[] = {'U','N','I','X','_'}; - memcpy( ptr, unixW, sizeof(unixW) ); - ptr += ARRAY_SIZE(unixW); + static const WCHAR hostW[] = {'W','I','N','E','_','H','O','S','T','_'}; + memcpy( ptr, hostW, sizeof(hostW) ); + ptr += ARRAY_SIZE(hostW); }
ptr += ntdll_umbstowcs( str, strlen(str) + 1, ptr, end - ptr ); diff --git a/dlls/shell32/recyclebin.c b/dlls/shell32/recyclebin.c index 0e6e812d3db..fc1b53a7bc9 100644 --- a/dlls/shell32/recyclebin.c +++ b/dlls/shell32/recyclebin.c @@ -104,7 +104,7 @@ static BOOL WINAPI init_trash_dirs( INIT_ONCE *once, void *param, void **context } else { - const WCHAR *data_home = _wgetenv( L"UNIX_XDG_DATA_HOME" ); + const WCHAR *data_home = _wgetenv( L"WINE_HOST_XDG_DATA_HOME" ); const WCHAR *fmt = L"%s/.local/share/Trash"; WCHAR *p;
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 6753ff0d042..f242903ab0c 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -2676,7 +2676,7 @@ static BOOL WINAPI init_xdg_dirs( INIT_ONCE *once, void *param, void **context ) HANDLE file; DWORD len;
- if (!(var = _wgetenv( L"UNIX_XDG_CONFIG_HOME" )) || var[0] != '/') + if (!(var = _wgetenv( L"WINE_HOST_XDG_CONFIG_HOME" )) || var[0] != '/') { if (!(var = _wgetenv( L"WINEHOMEDIR" ))) return TRUE; fmt = L"%s/.config/user-dirs.dirs"; diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 88e56363dd8..99ca50d8242 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -1706,8 +1706,8 @@ static BOOL build_native_mime_types(struct list *mime_types) WCHAR *dirs, *dir, *dos_name, *ctx, *p; BOOL ret;
- if (_wgetenv( L"UNIX_XDG_DATA_DIRS" )) - dirs = xwcsdup( _wgetenv( L"UNIX_XDG_DATA_DIRS" )); + if (_wgetenv( L"WINE_HOST_XDG_DATA_DIRS" )) + dirs = xwcsdup( _wgetenv( L"WINE_HOST_XDG_DATA_DIRS" )); else dirs = xwcsdup( L"/usr/local/share/:/usr/share/" );
@@ -2825,7 +2825,7 @@ static BOOL init_xdg(void)
if (FAILED(hr)) return FALSE;
- if ((p = _wgetenv( L"UNIX_XDG_CONFIG_HOME" ))) + if ((p = _wgetenv( L"WINE_HOST_XDG_CONFIG_HOME" ))) xdg_menu_dir = heap_wprintf( L"\??\unix%s/menus/applications-merged", p ); else xdg_menu_dir = heap_wprintf( L"%s/.config/menus/applications-merged", _wgetenv(L"WINEHOMEDIR") ); @@ -2833,7 +2833,7 @@ static BOOL init_xdg(void) xdg_menu_dir[1] = '\'; /* change ??\ to \?\ */ create_directories(xdg_menu_dir);
- if ((p = _wgetenv( L"UNIX_XDG_DATA_HOME" ))) + if ((p = _wgetenv( L"WINE_HOST_XDG_DATA_HOME" ))) xdg_data_dir = heap_wprintf( L"\??\unix%s", p ); else xdg_data_dir = heap_wprintf( L"%s/.local/share", _wgetenv(L"WINEHOMEDIR") );
From: Alexandre Julliard julliard@winehq.org
--- dlls/ntdll/unix/env.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index f115d580e3c..fdc71e296c2 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -818,6 +818,20 @@ void init_environment(void) }
+/* check if a WINE_HOST_ prefixed variable already exists in the environment */ +static BOOL host_var_exists( const char *name ) +{ + char *end = strchr( name, '=' ); + + if (!end) return FALSE; + for (char **e = environ; *e; e++) + { + if (!STARTS_WITH( *e, "WINE_HOST_" )) continue; + if (!strncmp( *e + 10, name, end + 1 - name )) return TRUE; + } + return FALSE; +} + static const char overrides_help_message[] = "Syntax:\n" " WINEDLLOVERRIDES="entry;entry;entry..."\n" @@ -867,6 +881,7 @@ static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size ) exit(0); } } + else if (host_var_exists( str )) continue; else if (is_special_env_var( str )) /* prefix it with WINE_HOST_ */ { static const WCHAR hostW[] = {'W','I','N','E','_','H','O','S','T','_'};
From: Alexandre Julliard julliard@winehq.org
This makes it possible to override large variables through the registry. --- dlls/ntdll/unix/env.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index fdc71e296c2..5cdbef77caa 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -848,7 +848,7 @@ static const char overrides_help_message[] = * * Return the initial environment. */ -static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size ) +static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size, BOOL skip_unix ) { char **e; WCHAR *env, *ptr, *end; @@ -857,13 +857,6 @@ static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size ) *size = 1; for (e = environ; *e; e++) *size += strlen(*e) + 6;
- if (*size > 30000) /* Windows is limited to 32767, and we need some space for the Wine variables */ - { - ERR( "Unix environment too large, not importing it.\n"); - *size = *pos = 0; - return NULL; - } - env = malloc( *size * sizeof(WCHAR) ); ptr = env; end = env + *size - 1; @@ -881,6 +874,7 @@ static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size ) exit(0); } } + else if (skip_unix) continue; else if (host_var_exists( str )) continue; else if (is_special_env_var( str )) /* prefix it with WINE_HOST_ */ { @@ -1882,7 +1876,7 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params( void **module ) RTL_USER_PROCESS_PARAMETERS *params = NULL; SIZE_T size, env_pos, env_size; WCHAR *dst, *cmdline, *path, *bootstrap; - WCHAR *env = get_initial_environment( &env_pos, &env_size ); + WCHAR *env = get_initial_environment( &env_pos, &env_size, FALSE ); WCHAR *curdir = get_initial_directory(); UNICODE_STRING nt_name; NTSTATUS status; @@ -1906,6 +1900,14 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params( void **module ) is_prefix_bootstrap = !!bootstrap; free( bootstrap ); add_registry_environment( &env, &env_pos, &env_size ); + if (env_pos >= 32767) /* Windows used to have a size limit, and some apps depend on it */ + { + ERR( "Unix environment too large, not importing it.\n"); + free( env ); + env = get_initial_environment( &env_pos, &env_size, TRUE ); + add_dynamic_environment( &env, &env_pos, &env_size ); + add_registry_environment( &env, &env_pos, &env_size ); + } env[env_pos++] = 0;
get_full_path( main_argv[1], curdir, &nt_name );