X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fanalysisd%2Factive-response.c;fp=src%2Fanalysisd%2Factive-response.c;h=1613e267a18095447cb00f44accb069dc7d55fa4;hp=f6f24147a87f45f1b03a8f99eb514910c45f9154;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b diff --git a/src/analysisd/active-response.c b/src/analysisd/active-response.c old mode 100755 new mode 100644 index f6f2414..1613e26 --- a/src/analysisd/active-response.c +++ b/src/analysisd/active-response.c @@ -1,6 +1,3 @@ -/* @(#) $Id: ./src/analysisd/active-response.c, 2011/09/08 dcid Exp $ - */ - /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * @@ -10,63 +7,56 @@ * Foundation */ - #include "shared.h" #include "active-response.h" +/* Active response commands */ +static OSList *ar_commands; +OSList *active_responses; -/** void AR_Init() - * Initializing active response. - */ +/* Initialize active response */ void AR_Init() { ar_commands = OSList_Create(); active_responses = OSList_Create(); ar_flag = 0; - if(!ar_commands || !active_responses) - { + if (!ar_commands || !active_responses) { ErrorExit(LIST_ERROR, ARGV0); } } - -/** int AR_ReadConfig(int test_config, char *cfgfile) - * Reads active response configuration and write them +/* Read active response configuration and write it * to the appropriate lists. */ -int AR_ReadConfig(int test_config, char *cfgfile) +int AR_ReadConfig(const char *cfgfile) { FILE *fp; int modules = 0; - modules|= CAR; + modules |= CAR; - - /* Cleaning ar file */ + /* Clean ar file */ fp = fopen(DEFAULTARPATH, "w"); - if(!fp) - { - merror(FOPEN_ERROR, ARGV0, DEFAULTARPATH); - return(OS_INVALID); + if (!fp) { + merror(FOPEN_ERROR, ARGV0, DEFAULTARPATH, errno, strerror(errno)); + return (OS_INVALID); } fprintf(fp, "restart-ossec0 - restart-ossec.sh - 0\n"); fprintf(fp, "restart-ossec0 - restart-ossec.cmd - 0\n"); fclose(fp); - - /* Setting right permission */ - chmod(DEFAULTARPATH, 0440); - - - /* Reading configuration */ - if(ReadConfig(modules, cfgfile, ar_commands, active_responses) < 0) - { - return(OS_INVALID); + /* Set right permission */ + if (chmod(DEFAULTARPATH, 0440) == -1) { + merror(CHMOD_ERROR, ARGV0, DEFAULTARPATH, errno, strerror(errno)); + return (OS_INVALID); } + /* Read configuration */ + if (ReadConfig(modules, cfgfile, ar_commands, active_responses) < 0) { + return (OS_INVALID); + } - return(0); + return (0); } -/* EOF */