[SERVICES]

- Silence debug messages.
- Fix typos.
- Add missing database locks.
- RControlService: Return ERROR_INVALID_PARAMETER on illegal control code.

svn path=/trunk/; revision=53850
This commit is contained in:
Eric Kohl 2011-09-25 12:07:52 +00:00
parent c8e41d9f48
commit fc001348ab
2 changed files with 26 additions and 21 deletions

View file

@ -146,7 +146,7 @@ ScmGetServiceImageByImagePath(LPWSTR lpImagePath)
ImageEntry = ImageEntry->Flink; ImageEntry = ImageEntry->Flink;
} }
DPRINT1("Couldn't find a matching image\n"); DPRINT("Couldn't find a matching image\n");
return NULL; return NULL;
@ -1368,7 +1368,7 @@ ScmWaitForServiceConnect(PSERVICE Service)
OVERLAPPED Overlapped = {0, 0, 0, 0, 0}; OVERLAPPED Overlapped = {0, 0, 0, 0, 0};
#endif #endif
DPRINT1("ScmWaitForServiceConnect()\n"); DPRINT("ScmWaitForServiceConnect()\n");
#ifdef USE_ASYNCHRONOUS_IO #ifdef USE_ASYNCHRONOUS_IO
Overlapped.hEvent = (HANDLE)NULL; Overlapped.hEvent = (HANDLE)NULL;
@ -1377,19 +1377,21 @@ ScmWaitForServiceConnect(PSERVICE Service)
&Overlapped); &Overlapped);
if (bResult == FALSE) if (bResult == FALSE)
{ {
DPRINT1("ConnectNamedPipe() returned FALSE\n"); DPRINT("ConnectNamedPipe() returned FALSE\n");
dwError = GetLastError(); dwError = GetLastError();
if (dwError == ERROR_IO_PENDING) if (dwError == ERROR_IO_PENDING)
{ {
DPRINT1("dwError: ERROR_IO_PENDING\n"); DPRINT("dwError: ERROR_IO_PENDING\n");
dwError = WaitForSingleObject(Service->lpImage->hControlPipe, dwError = WaitForSingleObject(Service->lpImage->hControlPipe,
dwPipeTimeout); dwPipeTimeout);
DPRINT1("WaitForSingleObject() returned %lu\n", dwError); DPRINT("WaitForSingleObject() returned %lu\n", dwError);
if (dwError == WAIT_TIMEOUT) if (dwError == WAIT_TIMEOUT)
{ {
DPRINT("WaitForSingleObject() returned WAIT_TIMEOUT\n");
bResult = CancelIo(Service->lpImage->hControlPipe); bResult = CancelIo(Service->lpImage->hControlPipe);
if (bResult == FALSE) if (bResult == FALSE)
{ {
@ -1420,7 +1422,7 @@ ScmWaitForServiceConnect(PSERVICE Service)
} }
} }
DPRINT1("Control pipe connected!\n"); DPRINT("Control pipe connected!\n");
Overlapped.hEvent = (HANDLE) NULL; Overlapped.hEvent = (HANDLE) NULL;
@ -1432,18 +1434,18 @@ ScmWaitForServiceConnect(PSERVICE Service)
&Overlapped); &Overlapped);
if (bResult == FALSE) if (bResult == FALSE)
{ {
DPRINT1("ReadFile() returned FALSE\n"); DPRINT("ReadFile() returned FALSE\n");
dwError = GetLastError(); dwError = GetLastError();
if (dwError == ERROR_IO_PENDING) if (dwError == ERROR_IO_PENDING)
{ {
DPRINT1("dwError: ERROR_IO_PENDING\n"); DPRINT("dwError: ERROR_IO_PENDING\n");
dwError = WaitForSingleObject(Service->lpImage->hControlPipe, dwError = WaitForSingleObject(Service->lpImage->hControlPipe,
dwPipeTimeout); dwPipeTimeout);
if (dwError == WAIT_TIMEOUT) if (dwError == WAIT_TIMEOUT)
{ {
DPRINT1("WaitForSingleObject() returned WAIT_TIMEOUT\n"); DPRINT("WaitForSingleObject() returned WAIT_TIMEOUT\n");
bResult = CancelIo(Service->lpImage->hControlPipe); bResult = CancelIo(Service->lpImage->hControlPipe);
if (bResult == FALSE) if (bResult == FALSE)
@ -1455,9 +1457,9 @@ ScmWaitForServiceConnect(PSERVICE Service)
} }
else if (dwError == ERROR_SUCCESS) else if (dwError == ERROR_SUCCESS)
{ {
DPRINT1("WaitForSingleObject() returned ERROR_SUCCESS\n"); DPRINT("WaitForSingleObject() returned ERROR_SUCCESS\n");
DPRINT1("Process Id: %lu\n", dwProcessId); DPRINT("Process Id: %lu\n", dwProcessId);
bResult = GetOverlappedResult(Service->lpImage->hControlPipe, bResult = GetOverlappedResult(Service->lpImage->hControlPipe,
&Overlapped, &Overlapped,

View file

@ -609,11 +609,7 @@ DWORD RControlService(
if (dwControl >= 128 && dwControl <= 255) if (dwControl >= 128 && dwControl <= 255)
DesiredAccess = SERVICE_USER_DEFINED_CONTROL; DesiredAccess = SERVICE_USER_DEFINED_CONTROL;
else else
DesiredAccess = SERVICE_QUERY_CONFIG | return ERROR_INVALID_PARAMETER;
SERVICE_CHANGE_CONFIG |
SERVICE_QUERY_STATUS |
SERVICE_START |
SERVICE_PAUSE_CONTINUE;
break; break;
} }
@ -862,7 +858,9 @@ DWORD RQueryServiceObjectSecurity(
return ERROR_INVALID_HANDLE; return ERROR_INVALID_HANDLE;
} }
/* FIXME: Lock the service list */ /* Lock the service database */
ScmLockDatabaseShared();
/* hack */ /* hack */
Status = RtlCreateSecurityDescriptor(&ObjectDescriptor, SECURITY_DESCRIPTOR_REVISION); Status = RtlCreateSecurityDescriptor(&ObjectDescriptor, SECURITY_DESCRIPTOR_REVISION);
@ -873,7 +871,8 @@ DWORD RQueryServiceObjectSecurity(
cbBufSize, cbBufSize,
&dwBytesNeeded); &dwBytesNeeded);
/* FIXME: Unlock the service list */ /* Unlock the service database */
ScmUnlockDatabase();
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
@ -975,9 +974,12 @@ DWORD RSetServiceObjectSecurity(
return RtlNtStatusToDosError(Status); return RtlNtStatusToDosError(Status);
RpcRevertToSelf(); RpcRevertToSelf();
#endif
/* FIXME: Lock service database */ /* Lock the service database exclusive */
ScmLockDatabaseExclusive();
#if 0
Status = RtlSetSecurityObject(dwSecurityInformation, Status = RtlSetSecurityObject(dwSecurityInformation,
(PSECURITY_DESCRIPTOR)lpSecurityDescriptor, (PSECURITY_DESCRIPTOR)lpSecurityDescriptor,
&lpService->lpSecurityDescriptor, &lpService->lpSecurityDescriptor,
@ -1011,7 +1013,8 @@ Done:
NtClose(hToken); NtClose(hToken);
#endif #endif
/* FIXME: Unlock service database */ /* Unlock service database */
ScmUnlockDatabase();
DPRINT("RSetServiceObjectSecurity() done (Error %lu)\n", dwError); DPRINT("RSetServiceObjectSecurity() done (Error %lu)\n", dwError);
@ -1053,7 +1056,7 @@ DWORD RQueryServiceStatus(
return ERROR_INVALID_HANDLE; return ERROR_INVALID_HANDLE;
} }
/* Lock the srevice database shared */ /* Lock the service database shared */
ScmLockDatabaseShared(); ScmLockDatabaseShared();
/* Return service status information */ /* Return service status information */