-/* @(#) $Id: win_execd.c,v 1.4 2009/06/24 17:06:30 dcid Exp $ */
+/* @(#) $Id: ./src/os_execd/win_execd.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
- * License (version 3) as published by the FSF - Free Software
+ * License (version 2) as published by the FSF - Free Software
* Foundation
*/
#ifdef ARGV0
#undef ARGV0
#endif
-
+
#define ARGV0 "ossec-execd"
-
+
/* Timeout list */
OSList *timeout_list;
OSListNode *timeout_node;
-
+
/* Exit if test_config */
if(test_config)
return(0);
-
-
+
+
/* Active response disabled */
if(c == 1)
{
verbose(EXEC_DISABLED, ARGV0);
return(0);
}
-
+
/* Creating list for timeout */
timeout_list = OSList_Create();
{
ErrorExit(LIST_ERROR, ARGV0);
}
-
-
+
+
/* Start up message */
verbose(STARTUP_MSG, ARGV0, getpid());
-
+
return(1);
}
list_entry = (timeout_data *)timeout_node->data;
/* Timeouted */
- if((curr_time - list_entry->time_of_addition) >
+ if((curr_time - list_entry->time_of_addition) >
list_entry->time_to_block)
{
ExecCmd_Win32(list_entry->command[0]);
char *cmd_user;
char *cmd_ip;
char buffer[OS_MAXSTR + 1];
-
+
timeout_data *timeout_entry;
}
*tmp_msg = '\0';
tmp_msg++;
-
+
/* Getting the command to execute (valid name) */
command = GetCommandbyName(name, &timeout_value);
/* Adding initial variables to the timeout cmd */
- snprintf(buffer, OS_MAXSTR, "\"%s\" %s \"%s\" \"%s\" \"%s\"",
- command, DELETE_ENTRY, cmd_user, cmd_ip, tmp_msg);
+ snprintf(buffer, OS_MAXSTR, "\"%s\" %s \"%s\" \"%s\" \"%s\"",
+ command, DELETE_ENTRY, cmd_user, cmd_ip, tmp_msg);
os_strdup(buffer, timeout_args[0]);
timeout_args[1] = NULL;
-
+
/* Getting size for the strncmp */
{
if(buffer[i] == ' ')
j++;
-
+
i++;
if(j == 4)
break;
}
-
+
/* Check this command was already executed. */
timeout_node = OSList_GetFirstNode(timeout_list);
/* If it wasn't added before, do it now */
if(!added_before)
{
- snprintf(buffer, OS_MAXSTR, "\"%s\" %s \"%s\" \"%s\" \"%s\"", command,
+ snprintf(buffer, OS_MAXSTR, "\"%s\" %s \"%s\" \"%s\" \"%s\"", command,
ADD_ENTRY, cmd_user, cmd_ip, tmp_msg);
/* executing command */
{
merror(LIST_ADD_ERROR, ARGV0);
FreeTimeoutEntry(timeout_entry);
- }
+ }
}
/* If no timeout, we still need to free it in here */