Subject: | FileSecurity::Set does not handle LookupAccountName correctly |
internally , FileSecurity::Set calls LookupAccountName.
user names passed in the hash map to set the ACL are parsed
(splitted at '\' character)
for instance foo\bar is splitted into 'foo' and 'bar'
during the call of LookupAccountName , foo is then used as 'server'
parameter. This is wrong as 'foo' may not be all the times
the name of a server (of a host)
see FileSecurity.c:524
FileSecurity::Set then fail with error like
<-----
foo\bar
Error handling error: 1722, LookupAccountName at bla.pl
<-----
User names passed in the hash map are checked and valid on the system.
Using a small win32 program to call LookupAccountName, everything works
fine on same user names.
FileSecurity::Set should pass user names directly as "lpAccountName"
parameter of LookupAccountName as they are received.
see
++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++ following code should be replaced +++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++
/* Retrieve the SID */
cbSID = 1024 ;
cchDomainName = 80 ;
if ( lpszTemp = strchr( lpszAccount, '\\' ) ) {
lpszServer = lpszAccount ;
*lpszTemp = '\0' ;
lpszAccount = lpszTemp + 1 ;
} else {
lpszServer = NULL ;
}
if ( lpszServer != NULL ) {
for ( i = 0; szLocalLookup[i] != NULL; i++ ) {
if ( stricmp( szLocalLookup[i], lpszServer ) == 0 ) {
lpszServer = NULL ;
break ;
}
}
}
bResult = LookupAccountNameA((LPCSTR) lpszServer,
(LPCSTR) lpszAccount,
pSID,
&cbSID,
lpszDomain,
&cchDomainName,
psnuType);
++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++ replaced by +++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++
lpszServer = NULL;
cbSID = 0;
pSID = NULL;
cchDomainName = 0;
lpszDomain = NULL;
bResult = LookupAccountNameA((LPCSTR) lpszServer,
(LPCSTR) lpszAccount,
pSID,
&cbSID,
lpszDomain,
&cchDomainName,
psnuType);
lpszDomain = HeapAlloc(GetProcessHeap(),0,cchDomainName);
...
pSID = HeapAlloc(GetProcessHeap(),0,cbSID);
...
bResult = LookupAccountNameA((LPCSTR) lpszServer,
(LPCSTR) lpszAccount,
pSID,
&cbSID,
lpszDomain,
&cchDomainName,
psnuType);
lpszAccount is the user name as found in the hash map.