X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fos_execd%2Fconfig.c;fp=src%2Fos_execd%2Fconfig.c;h=7b7af86fb376bbf9075315cfcc53364bf787bcec;hp=1705887dd78a69e64b7ab99ee82544a02bd01409;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b diff --git a/src/os_execd/config.c b/src/os_execd/config.c old mode 100755 new mode 100644 index 1705887..7b7af86 --- a/src/os_execd/config.c +++ b/src/os_execd/config.c @@ -1,6 +1,3 @@ -/* @(#) $Id: ./src/os_execd/config.c, 2011/09/08 dcid Exp $ - */ - /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * @@ -10,22 +7,18 @@ * Foundation */ - #include "shared.h" #include "execd.h" -/* ExecdConfig v0.1, 2006/03/24 - * Read the config file - */ -int ExecdConfig(char * cfgfile) +/* Read the config file */ +int ExecdConfig(const char *cfgfile) { - extern int repeated_offenders_timeout[]; - #ifdef WIN32 +#ifdef WIN32 int is_disabled = 1; - #else +#else int is_disabled = 0; - #endif +#endif const char *(xmlf[]) = {"ossec_config", "active-response", "disabled", NULL}; const char *(blocks[]) = {"ossec_config", "active-response", "repeated_offenders", NULL}; char *disable_entry; @@ -34,78 +27,67 @@ int ExecdConfig(char * cfgfile) OS_XML xml; - - /* Reading XML file */ - if(OS_ReadXML(cfgfile,&xml) < 0) - { + /* Read XML file */ + if (OS_ReadXML(cfgfile, &xml) < 0) { ErrorExit(XML_ERROR, ARGV0, cfgfile, xml.err, xml.err_line); } - /* We do not validate the xml in here. It is done by other processes */ + /* We do not validate the xml in here. It is done by other processes. */ disable_entry = OS_GetOneContentforElement(&xml, xmlf); - if(disable_entry) - { - if(strcmp(disable_entry, "yes") == 0) - { + if (disable_entry) { + if (strcmp(disable_entry, "yes") == 0) { is_disabled = 1; - } - else if(strcmp(disable_entry, "no") == 0) - { + } else if (strcmp(disable_entry, "no") == 0) { is_disabled = 0; - } - else - { + } else { merror(XML_VALUEERR, ARGV0, - "disabled", - disable_entry); - return(-1); + "disabled", + disable_entry); + return (-1); } } repeated_t = OS_GetOneContentforElement(&xml, blocks); - if(repeated_t) - { + if (repeated_t) { int i = 0; int j = 0; repeated_a = OS_StrBreak(',', repeated_t, 5); - if(!repeated_a) - { + if (!repeated_a) { merror(XML_VALUEERR, ARGV0, - "repeated_offenders", - disable_entry); - return(-1); + "repeated_offenders", + disable_entry); + return (-1); } - while(repeated_a[i] != NULL) - { + while (repeated_a[i] != NULL) { char *tmpt = repeated_a[i]; - while(*tmpt != '\0') - { - if(*tmpt == ' ' || *tmpt == '\t') - tmpt++; - else - break; + while (*tmpt != '\0') { + if (*tmpt == ' ' || *tmpt == '\t') { + tmpt++; + } else { + break; + } } - if(*tmpt == '\0') - { + if (*tmpt == '\0') { i++; continue; } repeated_offenders_timeout[j] = atoi(tmpt); verbose("%s: INFO: Adding offenders timeout: %d (for #%d)", - ARGV0, repeated_offenders_timeout[j], j+1); + ARGV0, repeated_offenders_timeout[j], j + 1); j++; repeated_offenders_timeout[j] = 0; - if(j >= 6) break; + if (j >= 6) { + break; + } i++; } } - OS_ClearXML(&xml); - return(is_disabled); + + return (is_disabled); } -/* EOF */