This merge request implements the third name format ("[NameDisplay](https://learn.microsoft.com/en-us/windows/win32/api/secext/ne-secext-extende...)") of the GetUserNameExW method.
-- v3: secur32: GetUserNameExW(3) is supposed to return ERROR_MORE_DATA if the buffer is too small, not ERROR_INSUFFICIENT_BUFFER secur32/tests: Add GetUserNameExW(3) specific test cases
From: Egor Poleshko somedevfox@gmail.com
--- dlls/ntdll/unix/env.c | 1 + dlls/ntdll/unix/loader.c | 11 ++++++----- dlls/ntdll/unix/unix_private.h | 1 + dlls/secur32/secur32.c | 14 +++++++++++++- 4 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 36949b905fb..4edd740774a 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -1099,6 +1099,7 @@ static void add_dynamic_environment( WCHAR **env, SIZE_T *pos, SIZE_T *size ) add_system_dll_path_var( env, pos, size ); append_envA( env, pos, size, "WINELOADER", wineloader ); append_envA( env, pos, size, "WINEUSERNAME", user_name ); + append_envA( env, pos, size, "WINEDISPLAYUSERNAME", display_user_name); append_envA( env, pos, size, "WINEDLLOVERRIDES", overrides ); if (unix_cp.CodePage != CP_UTF8) { diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 19fbfb2b68c..dbf60ccd8b2 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -160,6 +160,7 @@ const char *config_dir = NULL; const char **dll_paths = NULL; const char **system_dll_paths = NULL; const char *user_name = NULL; +const char *display_user_name = NULL; SECTION_IMAGE_INFORMATION main_image_info = { NULL };
/* adjust an array of pointers to make them into RVAs */ @@ -410,17 +411,17 @@ static void set_system_dll_path(void) system_dll_paths[count] = NULL; }
- static void set_home_dir(void) { + struct passwd *pwd = getpwuid( getuid() ); const char *home = getenv( "HOME" ); const char *name = getenv( "USER" ); + const char *display_name = (pwd == NULL) ? "Wine" : pwd->pw_gecos; const char *p;
- if (!home || !name) + if(!home || !name) { - struct passwd *pwd = getpwuid( getuid() ); - if (pwd) + if(pwd) { if (!home) home = pwd->pw_dir; if (!name) name = pwd->pw_name; @@ -431,9 +432,9 @@ static void set_home_dir(void) if ((p = strrchr( name, '\' ))) name = p + 1; home_dir = strdup( home ); user_name = strdup( name ); + display_user_name = strdup( display_name ); }
- static void set_config_dir(void) { char *p, *dir; diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 6cd88a5acc0..26601224619 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -161,6 +161,7 @@ extern const char *data_dir; extern const char *build_dir; extern const char *config_dir; extern const char *user_name; +extern const char *display_user_name; extern const char **dll_paths; extern const char **system_dll_paths; extern pthread_key_t teb_key; diff --git a/dlls/secur32/secur32.c b/dlls/secur32/secur32.c index f757ea6d34f..ce253e7a647 100644 --- a/dlls/secur32/secur32.c +++ b/dlls/secur32/secur32.c @@ -1158,9 +1158,21 @@ BOOLEAN WINAPI GetUserNameExW( return FALSE; }
+ case NameDisplay: + { + DWORD len = GetEnvironmentVariableW( L"WINEDISPLAYUSERNAME", lpNameBuffer, *nSize ); + BOOL ret; + + if (!len) return FALSE; + if ((ret = (len < *nSize))) len++; + else SetLastError( ERROR_INSUFFICIENT_BUFFER ); + *nSize = len; + + return ret; + } + case NameUnknown: case NameFullyQualifiedDN: - case NameDisplay: case NameUniqueId: case NameCanonical: case NameUserPrincipal:
From: Egor Poleshko somedevfox@gmail.com
--- dlls/secur32/tests/Makefile.in | 2 +- dlls/secur32/tests/secur32.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/dlls/secur32/tests/Makefile.in b/dlls/secur32/tests/Makefile.in index caeac7e47e1..67732294ec4 100644 --- a/dlls/secur32/tests/Makefile.in +++ b/dlls/secur32/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = secur32.dll -IMPORTS = secur32 crypt32 advapi32 ws2_32 +IMPORTS = secur32 crypt32 advapi32 ws2_32 netapi32
SOURCES = \ main.c \ diff --git a/dlls/secur32/tests/secur32.c b/dlls/secur32/tests/secur32.c index dd6eea095bf..45ced684fee 100644 --- a/dlls/secur32/tests/secur32.c +++ b/dlls/secur32/tests/secur32.c @@ -31,6 +31,7 @@ #include <winsock2.h> #include <ntsecapi.h> #include <winternl.h> +#include <lmaccess.h>
#include "wine/test.h"
@@ -245,6 +246,23 @@ static void testGetUserNameExW(void) ok(! rc && GetLastError() == ERROR_MORE_DATA, "Expected fail with ERROR_MORE_DATA, got %d with %lu\n", rc, GetLastError()); ok(1 < size, "Expected size to be set to required size\n"); ok(nameW[0] == (WCHAR) 0xff, "Expected unchanged buffer\n"); + + size = 255; + LPCWSTR domainNameW = NULL; + NET_API_STATUS domainNameRc = NetGetDCName(NULL, NULL, (LPBYTE *) &domainNameW); + rc = pGetUserNameExW(NameDisplay, nameW, &size); + if(domainNameRc != 0) + ok(GetLastError() == ERROR_NONE_MAPPED, "Expected fail with ERROR_NONE_MAPPED, got %d\n", GetLastError()); + size = 0; + rc = pGetUserNameExW(NameDisplay, nameW, &size); + ok(! rc && GetLastError() == ERROR_MORE_DATA, "Expected fail with ERROR_MORE_DATA, got %d with %lu\n", rc, GetLastError()); + ok(size != 0, "Expected size to be set to required size\n"); + size = 1; + nameW[0] = 0xff; + rc = pGetUserNameExW(NameDisplay, nameW, &size); + ok(! rc && GetLastError() == ERROR_MORE_DATA, "Expected fail with ERROR_MORE_DATA, got %d with %lu\n", rc, GetLastError()); + ok(1 < size, "Expected size to be set to required size\n"); + ok(nameW[0] == (WCHAR) 0xff, "Expected unchanged buffer\n"); }
static void test_InitSecurityInterface(void)
From: Egor Poleshko somedevfox@gmail.com
--- dlls/secur32/secur32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/secur32/secur32.c b/dlls/secur32/secur32.c index ce253e7a647..a0703c555fc 100644 --- a/dlls/secur32/secur32.c +++ b/dlls/secur32/secur32.c @@ -1165,7 +1165,7 @@ BOOLEAN WINAPI GetUserNameExW(
if (!len) return FALSE; if ((ret = (len < *nSize))) len++; - else SetLastError( ERROR_INSUFFICIENT_BUFFER ); + else SetLastError( ERROR_MORE_DATA ); *nSize = len;
return ret;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147019
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w7u_adm (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w7u_el (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w8 (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w8adm (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w864 (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w1064v1507 (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w1064v1809 (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w1064_tsign (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w10pro64 (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w10pro64_en_AE_u8 (32 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w11pro64 (32 bit report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 0
=== w7pro64 (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w864 (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w1064v1507 (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w1064v1809 (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w1064_2qxl (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w1064_adm (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w1064_tsign (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w10pro64 (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w10pro64_ar (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w10pro64_ja (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w10pro64_zh_CN (64 bit report) ===
secur32: secur32.c:258: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:259: Test failed: Expected size to be set to required size secur32.c:263: Test failed: Expected fail with ERROR_MORE_DATA, got 0 with 1332 secur32.c:264: Test failed: Expected size to be set to required size
=== w11pro64_amd (64 bit report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 0
=== debian11 (32 bit report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 234
=== debian11 (32 bit ar:MA report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 234
=== debian11 (32 bit de report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 234
=== debian11 (32 bit fr report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 234
=== debian11 (32 bit he:IL report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 234
=== debian11 (32 bit hi:IN report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 234
=== debian11 (32 bit ja:JP report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 234
=== debian11 (32 bit zh:CN report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 234
=== debian11b (32 bit WoW report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 234
=== debian11b (64 bit WoW report) ===
secur32: secur32.c:255: Test failed: Expected fail with ERROR_NONE_MAPPED, got 234
This merge request was closed by Egor Poleshko.