projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- add fortify to lintian
[ossec-hids.git]
/
src
/
win32
/
win_service.c
diff --git
a/src/win32/win_service.c
b/src/win32/win_service.c
index
d17d7b8
..
1989c4e
100755
(executable)
--- a/
src/win32/win_service.c
+++ b/
src/win32/win_service.c
@@
-1,4
+1,5
@@
-/* @(#) $Id$ */
+/* @(#) $Id: ./src/win32/win_service.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
@@
-8,7
+9,7
@@
* License (version 2) as published by the FSF - Free Software
* Foundation.
*
* License (version 2) as published by the FSF - Free Software
* Foundation.
*
- * License details at the LICENSE file included with OSSEC or
+ * License details at the LICENSE file included with OSSEC or
* online at: http://www.ossec.net/en/licensing.html
*/
* online at: http://www.ossec.net/en/licensing.html
*/
@@
-24,8
+25,8
@@
#endif
static LPTSTR g_lpszServiceName = "OssecSvc";
#endif
static LPTSTR g_lpszServiceName = "OssecSvc";
-static LPTSTR g_lpszServiceDisplayName = "OSSEC Hids";
-static LPTSTR g_lpszServiceDescription = "OSSEC Hids Windows Agent";
+static LPTSTR g_lpszServiceDisplayName = "OSSEC HIDS";
+static LPTSTR g_lpszServiceDescription = "OSSEC HIDS Windows Agent";
static SERVICE_STATUS ossecServiceStatus;
static SERVICE_STATUS_HANDLE ossecServiceStatusHandle;
static SERVICE_STATUS ossecServiceStatus;
static SERVICE_STATUS_HANDLE ossecServiceStatusHandle;
@@
-62,7
+63,7
@@
int os_start_service()
rc = -1;
}
}
rc = -1;
}
}
-
+
CloseServiceHandle(schService);
}
CloseServiceHandle(schService);
}
@@
-89,13
+90,13
@@
int os_stop_service()
if(schService)
{
SERVICE_STATUS lpServiceStatus;
if(schService)
{
SERVICE_STATUS lpServiceStatus;
-
- if(ControlService(schService,
+
+ if(ControlService(schService,
SERVICE_CONTROL_STOP, &lpServiceStatus))
{
rc = 1;
}
SERVICE_CONTROL_STOP, &lpServiceStatus))
{
rc = 1;
}
-
+
CloseServiceHandle(schService);
}
CloseServiceHandle(schService);
}
@@
-123,7
+124,7
@@
int CheckServiceRunning()
{
/* Checking status */
SERVICE_STATUS lpServiceStatus;
{
/* Checking status */
SERVICE_STATUS lpServiceStatus;
-
+
if(QueryServiceStatus(schService, &lpServiceStatus))
{
if(lpServiceStatus.dwCurrentState == SERVICE_RUNNING)
if(QueryServiceStatus(schService, &lpServiceStatus))
{
if(lpServiceStatus.dwCurrentState == SERVICE_RUNNING)
@@
-133,14
+134,14
@@
int CheckServiceRunning()
}
CloseServiceHandle(schService);
}
}
CloseServiceHandle(schService);
}
-
+
CloseServiceHandle(schSCManager);
}
return(rc);
}
CloseServiceHandle(schSCManager);
}
return(rc);
}
-
+
/* int InstallService()
* Install the OSSEC HIDS agent service.
*/
/* int InstallService()
* Install the OSSEC HIDS agent service.
*/
@@
-151,17
+152,17
@@
int InstallService(char *path)
SC_HANDLE schSCManager, schService;
LPCTSTR lpszBinaryPathName = NULL;
SERVICE_DESCRIPTION sdBuf;
SC_HANDLE schSCManager, schService;
LPCTSTR lpszBinaryPathName = NULL;
SERVICE_DESCRIPTION sdBuf;
-
+
/* Cleaning up some variables */
buffer[MAX_PATH] = '\0';
/* Cleaning up some variables */
buffer[MAX_PATH] = '\0';
-
-
+
+
/* Executable path -- it must be called with the
* full path
*/
lpszBinaryPathName = path;
/* Executable path -- it must be called with the
* full path
*/
lpszBinaryPathName = path;
-
+
/* Opening the services database */
schSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
/* Opening the services database */
schSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
@@
-171,7
+172,7
@@
int InstallService(char *path)
}
/* Creating the service */
}
/* Creating the service */
- schService = CreateService(schSCManager,
+ schService = CreateService(schSCManager,
g_lpszServiceName,
g_lpszServiceDisplayName,
SERVICE_ALL_ACCESS,
g_lpszServiceName,
g_lpszServiceDisplayName,
SERVICE_ALL_ACCESS,
@@
-180,7
+181,7
@@
int InstallService(char *path)
SERVICE_ERROR_NORMAL,
lpszBinaryPathName,
NULL, NULL, NULL, NULL, NULL);
SERVICE_ERROR_NORMAL,
lpszBinaryPathName,
NULL, NULL, NULL, NULL, NULL);
-
+
if (schService == NULL)
{
goto install_error;
if (schService == NULL)
{
goto install_error;
@@
-192,7
+193,7
@@
int InstallService(char *path)
{
goto install_error;
}
{
goto install_error;
}
-
+
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
@@
-204,7
+205,7
@@
int InstallService(char *path)
{
char local_msg[1025];
LPVOID lpMsgBuf;
{
char local_msg[1025];
LPVOID lpMsgBuf;
-
+
memset(local_msg, 0, 1025);
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
memset(local_msg, 0, 1025);
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
@@
-227,11
+228,11
@@
int InstallService(char *path)
/* int UninstallService()
* Uninstall the OSSEC HIDS agent service.
*/
/* int UninstallService()
* Uninstall the OSSEC HIDS agent service.
*/
-int UninstallService()
+int UninstallService()
{
SC_HANDLE schSCManager, schService;
{
SC_HANDLE schSCManager, schService;
-
+
/* Removing from the services database */
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (schSCManager)
/* Removing from the services database */
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (schSCManager)
@@
-256,7
+257,7
@@
int UninstallService()
fprintf(stderr, " [%s] Error removing from "
"the Services database.\n", ARGV0);
fprintf(stderr, " [%s] Error removing from "
"the Services database.\n", ARGV0);
-
+
return(0);
}
return(0);
}
@@
-284,7
+285,7
@@
VOID WINAPI OssecServiceCtrlHandler(DWORD dwOpcode)
}
return;
}
}
return;
}
-
+
/** void WinSetError()
* Sets the error code in the services
/** void WinSetError()
* Sets the error code in the services
@@
-294,11
+295,11
@@
void WinSetError()
OssecServiceCtrlHandler(SERVICE_CONTROL_STOP);
}
OssecServiceCtrlHandler(SERVICE_CONTROL_STOP);
}
-
+
/** int os_WinMain(int argc, char **argv)
* Initializes OSSEC dispatcher
*/
/** int os_WinMain(int argc, char **argv)
* Initializes OSSEC dispatcher
*/
-int os_WinMain(int argc, char **argv)
+int os_WinMain(int argc, char **argv)
{
SERVICE_TABLE_ENTRY steDispatchTable[] =
{
{
SERVICE_TABLE_ENTRY steDispatchTable[] =
{
@@
-329,8
+330,8
@@
void WINAPI OssecServiceStart (DWORD argc, LPTSTR *argv)
ossecServiceStatus.dwCheckPoint = 0;
ossecServiceStatus.dwWaitHint = 0;
ossecServiceStatus.dwCheckPoint = 0;
ossecServiceStatus.dwWaitHint = 0;
- ossecServiceStatusHandle =
- RegisterServiceCtrlHandler(g_lpszServiceName,
+ ossecServiceStatusHandle =
+ RegisterServiceCtrlHandler(g_lpszServiceName,
OssecServiceCtrlHandler);
if (ossecServiceStatusHandle == (SERVICE_STATUS_HANDLE)0)
OssecServiceCtrlHandler);
if (ossecServiceStatusHandle == (SERVICE_STATUS_HANDLE)0)