X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fanalysisd%2Factive-response.c;h=1613e267a18095447cb00f44accb069dc7d55fa4;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hp=5827ad94da852be8f1daba96041e66124cd0f795;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/analysisd/active-response.c b/src/analysisd/active-response.c old mode 100755 new mode 100644 index 5827ad9..1613e26 --- a/src/analysisd/active-response.c +++ b/src/analysisd/active-response.c @@ -1,71 +1,62 @@ -/* @(#) $Id: active-response.c,v 1.26 2009/06/24 17:06:21 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 */ - #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, 0444); - - - /* 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 */