mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
Display the owner of the security descriptor
svn path=/trunk/; revision=27106
This commit is contained in:
parent
8b79ad2052
commit
9705ebf7f4
5 changed files with 152 additions and 38 deletions
|
@ -90,6 +90,9 @@ DestroySecurityPage(IN PSECURITY_PAGE sp)
|
|||
|
||||
DestroySidCacheMgr(sp->SidCacheMgr);
|
||||
|
||||
if (sp->OwnerSid != NULL)
|
||||
LocalFree((HLOCAL)sp->OwnerSid);
|
||||
|
||||
HeapFree(GetProcessHeap(),
|
||||
0,
|
||||
sp);
|
||||
|
@ -308,6 +311,32 @@ AddPrincipalToList(IN PSECURITY_PAGE sp,
|
|||
return PrincipalListItem;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -315,28 +344,12 @@ GetPrincipalDisplayString(IN PPRINCIPAL_LISTITEM PrincipalListItem)
|
|||
|
||||
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 @@ static VOID
|
|||
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 @@ ReloadPrincipalsList(IN PSECURITY_PAGE sp)
|
|||
|
||||
/* 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 @@ UpdatePrincipalInfo(IN PSECURITY_PAGE sp,
|
|||
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 @@ CreateSecurityPage(IN LPSECURITYINFO psi)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMemory(sPage,
|
||||
sizeof(*sPage));
|
||||
|
||||
sPage->psi = psi;
|
||||
sPage->ObjectInfo = ObjectInfo;
|
||||
sPage->ServerName = SystemName;
|
||||
|
|
|
@ -5,8 +5,10 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_CAPTION
|
|||
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
|
||||
|
|
|
@ -50,6 +50,9 @@ typedef struct _SECURITY_PAGE
|
|||
HWND hWndPrincipalsList;
|
||||
PPRINCIPAL_LISTITEM PrincipalsListHead;
|
||||
|
||||
PSID OwnerSid;
|
||||
BOOL OwnerDefaulted;
|
||||
|
||||
INT ControlsMargin;
|
||||
|
||||
INT SpecialPermCheckIndex;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 @@ FreeCacheEntry(IN PSIDCACHEMGR scm,
|
|||
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 @@ ReferenceSidCacheMgr(IN HANDLE SidCacheMgr)
|
|||
static VOID
|
||||
DereferenceSidCacheMgr(IN PSIDCACHEMGR scm)
|
||||
{
|
||||
if (InterlockedDecrement(&scm->RefCount) == 0)
|
||||
{
|
||||
CleanupSidCacheMgr(scm);
|
||||
|
||||
HeapFree(scm->Heap,
|
||||
0,
|
||||
scm);
|
||||
}
|
||||
InterlockedDecrement(&scm->RefCount);
|
||||
}
|
||||
|
||||
|
||||
|
@ -456,8 +443,18 @@ CacheLookupResults(IN PSIDCACHEMGR scm,
|
|||
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)
|
||||
{
|
||||
PSIDQUEUEENTRY QueueEntry = NULL;
|
||||
|
@ -566,6 +563,19 @@ LookupThreadProc(IN LPVOID lpParameter)
|
|||
}
|
||||
}
|
||||
|
||||
CleanupSidCacheMgr(scm);
|
||||
|
||||
HeapFree(scm->Heap,
|
||||
0,
|
||||
scm);
|
||||
|
||||
if (hModule != NULL)
|
||||
{
|
||||
/* dereference the library and exit */
|
||||
FreeLibraryAndExitThread(hModule,
|
||||
0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue