From 78b646b0de3114319294b2973bf925e1d4deddff Mon Sep 17 00:00:00 2001 From: Brian Katyl Date: Fri, 26 Mar 2021 18:13:19 -0600 Subject: [PATCH] Adds support for system account lookup (#478) --- contrib/win32/win32compat/pwd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/win32/win32compat/pwd.c b/contrib/win32/win32compat/pwd.c index 9c9a385b4..5d866a246 100644 --- a/contrib/win32/win32compat/pwd.c +++ b/contrib/win32/win32compat/pwd.c @@ -252,9 +252,13 @@ get_passwd(const wchar_t * user_utf16, PSID sid) goto cleanup; } - /* If standard local user name, just use name without decoration */ - if ((_wcsicmp(domain_name, computer_name) == 0) && (_wcsicmp(computer_name, user_name) != 0)) + /* if standard local user name or system account, just use name without decoration */ + const SID_IDENTIFIER_AUTHORITY nt_authority = SECURITY_NT_AUTHORITY; + if (((_wcsicmp(domain_name, computer_name) == 0) && (_wcsicmp(computer_name, user_name) != 0)) || + ((memcmp(&nt_authority, GetSidIdentifierAuthority((PSID)binary_sid), sizeof(SID_IDENTIFIER_AUTHORITY)) == 0) && + (((SID*)binary_sid)->SubAuthority[0] == SECURITY_LOCAL_SYSTEM_RID))) { wcscpy_s(user_resolved, ARRAYSIZE(user_resolved), user_name); + } /* put any other format in sam compatible format */ else