Commit 94812b12 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

userenv: Fix setting ALLUSERSPROFILE and ProgramData in CreateEnvironmentBlock.

This syncs the code with dlls/ntdll/unix/env.c add_registry_environment. It fixes ALLUSERSPROFILE and ProgramData environment variables value in services.
parent 9b400f3f
...@@ -78,7 +78,7 @@ static void test_create_env(void) ...@@ -78,7 +78,7 @@ static void test_create_env(void)
BOOL r, is_wow64 = FALSE; BOOL r, is_wow64 = FALSE;
HANDLE htok; HANDLE htok;
WCHAR * env[4]; WCHAR * env[4];
char * st, systemroot[100], programdata[100]; char * st, systemroot[100], programdata[100], allusersprofile[100];
int i, j; int i, j;
static const struct profile_item common_vars[] = { static const struct profile_item common_vars[] = {
...@@ -186,7 +186,7 @@ static void test_create_env(void) ...@@ -186,7 +186,7 @@ static void test_create_env(void)
} }
/* Test for common environment variables (post NT4) */ /* Test for common environment variables (post NT4) */
if (!GetEnvironmentVariableA("ALLUSERSPROFILE", NULL, 0)) if (!GetEnvironmentVariableA("ALLUSERSPROFILE", allusersprofile, sizeof(allusersprofile)))
{ {
win_skip("Some environment variables are not present on NT4\n"); win_skip("Some environment variables are not present on NT4\n");
} }
...@@ -198,6 +198,9 @@ static void test_create_env(void) ...@@ -198,6 +198,9 @@ static void test_create_env(void)
{ {
r = get_env(env[j], common_post_nt4_vars[i].name, &st); r = get_env(env[j], common_post_nt4_vars[i].name, &st);
expect_env(TRUE, r, common_post_nt4_vars[i].name); expect_env(TRUE, r, common_post_nt4_vars[i].name);
if (!strcmp(common_post_nt4_vars[i].name, "ALLUSERSPROFILE") ||
!strcmp(common_post_nt4_vars[i].name, "ProgramData"))
ok(!strcmp(st + strlen(common_post_nt4_vars[i].name) + 1, allusersprofile), "%s\n", st);
if (r) HeapFree(GetProcessHeap(), 0, st); if (r) HeapFree(GetProcessHeap(), 0, st);
} }
} }
......
...@@ -242,7 +242,7 @@ BOOL WINAPI CreateEnvironmentBlock( LPVOID* lpEnvironment, ...@@ -242,7 +242,7 @@ BOOL WINAPI CreateEnvironmentBlock( LPVOID* lpEnvironment,
profiles_dir[len] = '\0'; profiles_dir[len] = '\0';
} }
if (get_reg_value(env, hkey, L"Public", buf, UNICODE_STRING_MAX_CHARS)) if (get_reg_value(env, hkey, L"ProgramData", buf, UNICODE_STRING_MAX_CHARS))
{ {
set_env_var(&env, L"ALLUSERSPROFILE", buf); set_env_var(&env, L"ALLUSERSPROFILE", buf);
set_env_var(&env, L"ProgramData", buf); set_env_var(&env, L"ProgramData", buf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment