[SERVICES]

RSetServiceObjectSecurity: Modify and store a service security descriptor.

svn path=/trunk/; revision=71686
This commit is contained in:
Eric Kohl 2016-06-27 22:35:54 +00:00
parent 90c41c110a
commit def1d69426

View file

@ -1441,9 +1441,10 @@ DWORD RSetServiceObjectSecurity(
PSERVICE_HANDLE hSvc; PSERVICE_HANDLE hSvc;
PSERVICE lpService; PSERVICE lpService;
ULONG DesiredAccess = 0; ULONG DesiredAccess = 0;
/* HANDLE hToken = NULL; */ HANDLE hToken = NULL;
HKEY hServiceKey; HKEY hServiceKey = NULL;
/* NTSTATUS Status; */ BOOL bDatabaseLocked = FALSE;
NTSTATUS Status;
DWORD dwError; DWORD dwError;
DPRINT("RSetServiceObjectSecurity() called\n"); DPRINT("RSetServiceObjectSecurity() called\n");
@ -1483,14 +1484,14 @@ DWORD RSetServiceObjectSecurity(
if (!RtlAreAllAccessesGranted(hSvc->Handle.DesiredAccess, if (!RtlAreAllAccessesGranted(hSvc->Handle.DesiredAccess,
DesiredAccess)) DesiredAccess))
{ {
DPRINT("Insufficient access rights! 0x%lx\n", hSvc->Handle.DesiredAccess); DPRINT1("Insufficient access rights! 0x%lx\n", hSvc->Handle.DesiredAccess);
return ERROR_ACCESS_DENIED; return ERROR_ACCESS_DENIED;
} }
lpService = hSvc->ServiceEntry; lpService = hSvc->ServiceEntry;
if (lpService == NULL) if (lpService == NULL)
{ {
DPRINT("lpService == NULL!\n"); DPRINT1("lpService == NULL!\n");
return ERROR_INVALID_HANDLE; return ERROR_INVALID_HANDLE;
} }
@ -1510,13 +1511,10 @@ DWORD RSetServiceObjectSecurity(
RpcRevertToSelf(); RpcRevertToSelf();
#endif #endif
/* Lock the service database exclusive */ /* Build the new security descriptor */
ScmLockDatabaseExclusive();
#if 0
Status = RtlSetSecurityObject(dwSecurityInformation, Status = RtlSetSecurityObject(dwSecurityInformation,
(PSECURITY_DESCRIPTOR)lpSecurityDescriptor, (PSECURITY_DESCRIPTOR)lpSecurityDescriptor,
&lpService->lpSecurityDescriptor, &lpService->pSecurityDescriptor,
&ScmServiceMapping, &ScmServiceMapping,
hToken); hToken);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -1524,31 +1522,34 @@ DWORD RSetServiceObjectSecurity(
dwError = RtlNtStatusToDosError(Status); dwError = RtlNtStatusToDosError(Status);
goto Done; goto Done;
} }
#endif
/* Lock the service database exclusive */
ScmLockDatabaseExclusive();
bDatabaseLocked = TRUE;
/* Open the service key */
dwError = ScmOpenServiceKey(lpService->lpServiceName, dwError = ScmOpenServiceKey(lpService->lpServiceName,
READ_CONTROL | KEY_CREATE_SUB_KEY | KEY_SET_VALUE, READ_CONTROL | KEY_CREATE_SUB_KEY | KEY_SET_VALUE,
&hServiceKey); &hServiceKey);
if (dwError != ERROR_SUCCESS) if (dwError != ERROR_SUCCESS)
goto Done; goto Done;
UNIMPLEMENTED; /* Store the new security descriptor */
dwError = ERROR_SUCCESS; dwError = ScmWriteSecurityDescriptor(hServiceKey,
// dwError = ScmWriteSecurityDescriptor(hServiceKey, lpService->pSecurityDescriptor);
// lpService->lpSecurityDescriptor);
RegFlushKey(hServiceKey); RegFlushKey(hServiceKey);
RegCloseKey(hServiceKey);
Done: Done:
if (hServiceKey != NULL)
#if 0 RegCloseKey(hServiceKey);
if (hToken != NULL)
NtClose(hToken);
#endif
/* Unlock service database */ /* Unlock service database */
ScmUnlockDatabase(); if (bDatabaseLocked == TRUE)
ScmUnlockDatabase();
if (hToken != NULL)
NtClose(hToken);
DPRINT("RSetServiceObjectSecurity() done (Error %lu)\n", dwError); DPRINT("RSetServiceObjectSecurity() done (Error %lu)\n", dwError);