mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 20:03:12 +00:00
[SERVICES]
RSetServiceObjectSecurity: Modify and store a service security descriptor. svn path=/trunk/; revision=71686
This commit is contained in:
parent
90c41c110a
commit
def1d69426
1 changed files with 23 additions and 22 deletions
|
@ -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,32 +1522,35 @@ 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 */
|
||||||
|
if (bDatabaseLocked == TRUE)
|
||||||
ScmUnlockDatabase();
|
ScmUnlockDatabase();
|
||||||
|
|
||||||
|
if (hToken != NULL)
|
||||||
|
NtClose(hToken);
|
||||||
|
|
||||||
DPRINT("RSetServiceObjectSecurity() done (Error %lu)\n", dwError);
|
DPRINT("RSetServiceObjectSecurity() done (Error %lu)\n", dwError);
|
||||||
|
|
||||||
return dwError;
|
return dwError;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue