diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-12-27 08:43:29 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-12-27 12:40:55 +0100 |
commit | 85c06cf5d785035fce01f3bf91984b2b7bf7d025 (patch) | |
tree | 103e6ef1743bfbfe7101acf3e02f5829f1386bf6 /sal | |
parent | f8e29707df8ebb6acf33ac4e32033252953bc7ef (diff) |
sal_osl_security: Windows: Handle cases with same hostname and username
... as seen in
[build CUT] sal_osl_security
#Initializing ...
#
#logonUser function need root/Administrator account to test.
#You can test by login with root/Administrator, and execute:
#testshl2 -forward "username password" ../../../wntmsci9/bin/Security.dll
# where username and password are forwarded account info.
#if no text forwarded, this function will be skipped.
#
#Retrieved system information is below:
Computer Name: SOMENAME
Current User Name: Somename
Current User Home Directory:file:///C:/Users/Somename/Documents
Current Config Directory: file:///C:/Users/Somename/AppData/Roaming
Current UserID: S-1-5-21-1234567890-123456789-123456789
Current User is: NOT Administrator.
#
#Initialization Done.
osl_Security::ctors::ctors_001 finished in: 0ms
osl_Security::UserProfile::loadUserProfile finished in: 0ms
osl_Security::UserProfile::unloadUserProfile finished in: 0ms
osl_Security::getHandle::getHandle_001 finished in: 0ms
osl_Security::loginUserOnFileServer::loginUserOnFileServer_001 finished in: 3ms
osl_Security::getConfigDir::getConfigDir_001 finished in: 1ms
C:/cygwin/home/Somename/lode/dev/core/sal/qa/osl/security/osl_Security.cxx:139:osl_Security::getUserIdent::getUserIdent_001
equality assertion failed
- Expected: S-1-5-21-1234567890-123456789-123456789
- Actual : S-1-5-21-1234567890-123456789-123456789-1001
- strUserID: S-1-5-21-1234567890-123456789-123456789, strID: S-1-5-21-1234567890-123456789-123456789-1001, bRes: true
osl_Security::getUserIdent::getUserIdent_001 finished in: 0ms
osl_Security::getUserName::getUserName_001 finished in: 1ms
osl_Security::isAdministrator::isAdministrator_001 finished in: 0ms
C:/cygwin/home/Somename/lode/dev/core/sal/qa/osl/security/osl_Security.cxx(139) : error : Assertion
Test name: osl_Security::getUserIdent::getUserIdent_001
equality assertion failed
- Expected: S-1-5-21-1234567890-123456789-123456789
- Actual : S-1-5-21-1234567890-123456789-123456789-1001
- strUserID: S-1-5-21-1234567890-123456789-123456789, strID: S-1-5-21-1234567890-123456789-123456789-1001, bRes: true
Failures !!!
Run: 9 Failure total: 1 Failures: 1 Errors: 0
The problem here is that passing a string equal to hostname (case-insensitive)
to LookupAccountNameW without domain qualifier returns data for local system
domain, not for user with the same name. So let's try again, this time with
fully-qualified user name including local domain part.
Change-Id: I15f69c01dddf15782bd11a6ed6678f0a02d79786
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85859
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/qa/osl/security/osl_Security.cxx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx index bc00d27a21e7..c7f2dd71bc01 100644 --- a/sal/qa/osl/security/osl_Security.cxx +++ b/sal/qa/osl/security/osl_Security.cxx @@ -415,7 +415,8 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, SID_NAME_USE eSidType; DWORD dwErrorCode = 0; - LPCWSTR wszAccName = o3tl::toW(strUserName.getStr( )); + OUString sLookupUserName = strUserName; + LPCWSTR wszAccName = o3tl::toW(sLookupUserName.getStr( )); // Create buffers for the SID and the domain name. PSID pSid = static_cast<PSID>(new BYTE[dwSidBufferSize]); @@ -440,6 +441,17 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, &eSidType )) { + if (eSidType == SID_NAME_USE::SidTypeDomain) + { + // LookupAccountNameW returned SID of a domain; likely the hostname is the same as + // username (case-insensitive): something like "JOHNSMITH\JohnSmith", so looking up + // for "JohnSmith" without doman returns domain itself. Try getting the SID of the + // user using fully qualified name (the case of user of another domain having name + // identical this hostname is not handled). + sLookupUserName = o3tl::toU(wszDomainName) + OUStringLiteral("\\") + strUserName; + wszAccName = o3tl::toW(sLookupUserName.getStr()); + continue; + } if (IsValidSid( pSid) == FALSE) wprintf(L"# The SID for %s is invalid.\n", wszAccName); break; |