Author: weiden
Date: Sun Jun 10 14:45:38 2007
New Revision: 27106
URL:
http://svn.reactos.org/svn/reactos?rev=27106&view=rev
Log:
Display the owner of the security descriptor
Modified:
trunk/reactos/dll/win32/aclui/aclui.c
trunk/reactos/dll/win32/aclui/aclui_En.rc
trunk/reactos/dll/win32/aclui/precomp.h
trunk/reactos/dll/win32/aclui/resource.h
trunk/reactos/dll/win32/aclui/sidcache.c
Modified: trunk/reactos/dll/win32/aclui/aclui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/aclui/aclui.c?re…
==============================================================================
--- trunk/reactos/dll/win32/aclui/aclui.c (original)
+++ trunk/reactos/dll/win32/aclui/aclui.c Sun Jun 10 14:45:38 2007
@@ -90,6 +90,9 @@
DestroySidCacheMgr(sp->SidCacheMgr);
+ if (sp->OwnerSid != NULL)
+ LocalFree((HLOCAL)sp->OwnerSid);
+
HeapFree(GetProcessHeap(),
0,
sp);
@@ -309,34 +312,44 @@
}
static LPWSTR
+GetDisplayStringFromSidRequestResult(IN PSIDREQRESULT SidReqResult)
+{
+ LPWSTR lpDisplayString = NULL;
+
+ if (SidReqResult->SidNameUse == SidTypeUser ||
+ SidReqResult->SidNameUse == SidTypeGroup)
+ {
+ LoadAndFormatString(hDllInstance,
+ IDS_USERDOMAINFORMAT,
+ &lpDisplayString,
+ SidReqResult->AccountName,
+ SidReqResult->DomainName,
+ SidReqResult->AccountName);
+ }
+ else
+ {
+ LoadAndFormatString(hDllInstance,
+ IDS_USERFORMAT,
+ &lpDisplayString,
+ SidReqResult->AccountName);
+ }
+
+ return lpDisplayString;
+}
+
+static LPWSTR
GetPrincipalDisplayString(IN PPRINCIPAL_LISTITEM PrincipalListItem)
{
LPWSTR lpDisplayString = NULL;
if (PrincipalListItem->SidReqResult != NULL)
{
- if (PrincipalListItem->SidReqResult->SidNameUse == SidTypeUser ||
- PrincipalListItem->SidReqResult->SidNameUse == SidTypeGroup)
- {
- LoadAndFormatString(hDllInstance,
- IDS_USERDOMAINFORMAT,
- &lpDisplayString,
- PrincipalListItem->SidReqResult->AccountName,
- PrincipalListItem->SidReqResult->DomainName,
- PrincipalListItem->SidReqResult->AccountName);
- }
- else
- {
- LoadAndFormatString(hDllInstance,
- IDS_USERFORMAT,
- &lpDisplayString,
- PrincipalListItem->SidReqResult->AccountName);
- }
+ lpDisplayString =
GetDisplayStringFromSidRequestResult(PrincipalListItem->SidReqResult);
}
else
{
- ConvertSidToStringSid((PSID)(PrincipalListItem + 1),
- &lpDisplayString);
+ ConvertSidToStringSidW((PSID)(PrincipalListItem + 1),
+ &lpDisplayString);
}
return lpDisplayString;
@@ -491,8 +504,11 @@
ReloadPrincipalsList(IN PSECURITY_PAGE sp)
{
PSECURITY_DESCRIPTOR SecurityDescriptor;
- BOOL DaclPresent, DaclDefaulted;
+ BOOL DaclPresent, DaclDefaulted, OwnerDefaulted;
PACL Dacl = NULL;
+ PSID OwnerSid = NULL;
+ LPTSTR OwnerSidString;
+ DWORD SidLen;
HRESULT hRet;
/* delete the cached ACL */
@@ -501,11 +517,67 @@
/* query the ACL */
hRet = sp->psi->lpVtbl->GetSecurity(sp->psi,
- DACL_SECURITY_INFORMATION,
+ DACL_SECURITY_INFORMATION |
OWNER_SECURITY_INFORMATION,
&SecurityDescriptor,
FALSE);
if (SUCCEEDED(hRet) && SecurityDescriptor != NULL)
{
+ if (GetSecurityDescriptorOwner(SecurityDescriptor,
+ &OwnerSid,
+ &OwnerDefaulted))
+ {
+ sp->OwnerDefaulted = OwnerDefaulted;
+ if (sp->OwnerSid != NULL)
+ {
+ LocalFree((HLOCAL)sp->OwnerSid);
+ sp->OwnerSid = NULL;
+ }
+
+ SidLen = GetLengthSid(OwnerSid);
+ if (SidLen == 0)
+ goto ClearOwner;
+
+ sp->OwnerSid = (PSID)LocalAlloc(LMEM_FIXED,
+ SidLen);
+ if (sp->OwnerSid != NULL)
+ {
+ if (CopySid(SidLen,
+ sp->OwnerSid,
+ OwnerSid))
+ {
+ /* Lookup the SID now */
+ if (!LookupSidCache(sp->SidCacheMgr,
+ sp->OwnerSid,
+ SidLookupCompletion,
+ sp))
+ {
+ /* Lookup was deferred */
+ if (ConvertSidToStringSid(sp->OwnerSid,
+ &OwnerSidString))
+ {
+ SetDlgItemText(sp->hWnd,
+ IDC_OWNER,
+ OwnerSidString);
+ LocalFree((HLOCAL)OwnerSidString);
+ }
+ else
+ goto ClearOwner;
+ }
+ }
+ else
+ goto ClearOwner;
+ }
+ else
+ goto ClearOwner;
+ }
+ else
+ {
+ClearOwner:
+ SetDlgItemText(sp->hWnd,
+ IDC_OWNER,
+ NULL);
+ }
+
if (GetSecurityDescriptorDacl(SecurityDescriptor,
&DaclPresent,
&Dacl,
@@ -605,6 +677,29 @@
IN PSIDLOOKUPNOTIFYINFO LookupInfo)
{
PPRINCIPAL_LISTITEM CurItem;
+ LPWSTR DisplayName;
+
+ if (sp->OwnerSid != NULL &&
+ EqualSid(sp->OwnerSid,
+ LookupInfo->Sid))
+ {
+ if (LookupInfo->SidRequestResult != NULL)
+ DisplayName =
GetDisplayStringFromSidRequestResult(LookupInfo->SidRequestResult);
+ else if (!ConvertSidToStringSidW(LookupInfo->Sid,
+ &DisplayName))
+ {
+ DisplayName = NULL;
+ }
+
+ if (DisplayName != NULL)
+ {
+ SetDlgItemTextW(sp->hWnd,
+ IDC_OWNER,
+ DisplayName);
+
+ LocalFree((HLOCAL)DisplayName);
+ }
+ }
for (CurItem = sp->PrincipalsListHead;
CurItem != NULL;
@@ -1422,6 +1517,9 @@
return NULL;
}
+ ZeroMemory(sPage,
+ sizeof(*sPage));
+
sPage->psi = psi;
sPage->ObjectInfo = ObjectInfo;
sPage->ServerName = SystemName;
Modified: trunk/reactos/dll/win32/aclui/aclui_En.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/aclui/aclui_En.r…
==============================================================================
--- trunk/reactos/dll/win32/aclui/aclui_En.rc (original)
+++ trunk/reactos/dll/win32/aclui/aclui_En.rc Sun Jun 10 14:45:38 2007
@@ -5,8 +5,10 @@
CAPTION "Security"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
- LTEXT "&Group or user names:", -1, 7, 7, 105, 8
- CONTROL "", IDC_PRINCIPALS, "SysListView32", LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_NOCOLUMNHEADER |
LVS_NOSORTHEADER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 7, 17, 213, 66,
WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE
+ LTEXT "&Group or user names:", -1, 7, 21, 105, 8
+ CONTROL "", IDC_PRINCIPALS, "SysListView32", LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_NOCOLUMNHEADER |
LVS_NOSORTHEADER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 7, 31, 213, 52,
WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE
+ LTEXT "&Owner:", -1, 7, 7, 49, 8
+ EDITTEXT IDC_OWNER, 63, 4, 156, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_READONLY
PUSHBUTTON "A&dd...", IDC_ADD_PRINCIPAL, 116, 87, 50, 14
PUSHBUTTON "&Remove", IDC_REMOVE_PRINCIPAL, 170, 87, 50, 14
LTEXT "", IDC_LABEL_PERMISSIONS_FOR, 7, 107, 105, 8, SS_LEFT | SS_NOPREFIX
Modified: trunk/reactos/dll/win32/aclui/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/aclui/precomp.h?…
==============================================================================
--- trunk/reactos/dll/win32/aclui/precomp.h (original)
+++ trunk/reactos/dll/win32/aclui/precomp.h Sun Jun 10 14:45:38 2007
@@ -50,6 +50,9 @@
HWND hWndPrincipalsList;
PPRINCIPAL_LISTITEM PrincipalsListHead;
+ PSID OwnerSid;
+ BOOL OwnerDefaulted;
+
INT ControlsMargin;
INT SpecialPermCheckIndex;
Modified: trunk/reactos/dll/win32/aclui/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/aclui/resource.h…
==============================================================================
--- trunk/reactos/dll/win32/aclui/resource.h (original)
+++ trunk/reactos/dll/win32/aclui/resource.h Sun Jun 10 14:45:38 2007
@@ -12,6 +12,7 @@
#define IDC_ADVANCED 1007
#define IDC_LABEL_ADVANCED 1008
#define IDC_LABEL_PERMISSIONS_FOR 1009
+#define IDC_OWNER 1010
#define IDS_PSP_TITLE 1001
#define IDS_UNKNOWN 1002
Modified: trunk/reactos/dll/win32/aclui/sidcache.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/aclui/sidcache.c…
==============================================================================
--- trunk/reactos/dll/win32/aclui/sidcache.c (original)
+++ trunk/reactos/dll/win32/aclui/sidcache.c Sun Jun 10 14:45:38 2007
@@ -36,7 +36,7 @@
typedef struct _SIDCACHEMGR
{
- LONG RefCount;
+ volatile LONG RefCount;
LSA_HANDLE LsaHandle;
CRITICAL_SECTION Lock;
LIST_ENTRY QueueListHead;
@@ -109,12 +109,6 @@
static VOID
CleanupSidCacheMgr(IN PSIDCACHEMGR scm)
{
- /* make sure the lookup thread runs down */
- SetEvent(scm->LookupEvent);
- WaitForSingleObject(scm->LookupThread,
- INFINITE);
-
-
LsaClose(scm->LsaHandle);
CloseHandle(scm->LookupEvent);
CloseHandle(scm->LookupThread);
@@ -164,14 +158,7 @@
static VOID
DereferenceSidCacheMgr(IN PSIDCACHEMGR scm)
{
- if (InterlockedDecrement(&scm->RefCount) == 0)
- {
- CleanupSidCacheMgr(scm);
-
- HeapFree(scm->Heap,
- 0,
- scm);
- }
+ InterlockedDecrement(&scm->RefCount);
}
@@ -456,7 +443,17 @@
static DWORD WINAPI
LookupThreadProc(IN LPVOID lpParameter)
{
+ HMODULE hModule;
PSIDCACHEMGR scm = (PSIDCACHEMGR)lpParameter;
+
+ /* Reference the dll to avoid problems in case of accidental
+ FreeLibrary calls... */
+ if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ (LPCWSTR)hDllInstance,
+ &hModule))
+ {
+ hModule = NULL;
+ }
while (scm->RefCount != 0)
{
@@ -564,6 +561,19 @@
FreeQueueEntry(scm,
QueueEntry);
}
+ }
+
+ CleanupSidCacheMgr(scm);
+
+ HeapFree(scm->Heap,
+ 0,
+ scm);
+
+ if (hModule != NULL)
+ {
+ /* dereference the library and exit */
+ FreeLibraryAndExitThread(hModule,
+ 0);
}
return 0;