X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;ds=sidebyside;f=src%2Fwin32%2Fadd-localfile.c;h=8cf11e43edd957b7e862f187c40a2641d24d6054;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hp=f62342c668befec7c43b45a387f5631e0b74f44d;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/win32/add-localfile.c b/src/win32/add-localfile.c index f62342c..8cf11e4 100755 --- a/src/win32/add-localfile.c +++ b/src/win32/add-localfile.c @@ -1,14 +1,15 @@ -/* @(#) $Id: add-localfile.c,v 1.13 2009/06/24 18:53:10 dcid Exp $ */ +/* @(#) $Id: ./src/win32/add-localfile.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2009 Trend Micro Inc. * All rights 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 #include @@ -48,7 +49,7 @@ int dogrep(char *file, char *str) /* Clearing memory */ memset(line, '\0', OS_MAXSTR +1); - /* Reading file and looking for str */ + /* Reading file and looking for str */ while(fgets(line, OS_MAXSTR, fp) != NULL) { if(OS_Match(str, line)) @@ -67,13 +68,11 @@ int dogrep(char *file, char *str) /* Check is syscheck is present in the config */ int config_file(char *name, char *file, int quiet) { - int add = 0; - char ffile[256]; FILE *fp; ffile[255] = '\0'; - + /* Checking if the file has a variable format */ if(strchr(file, '%') != NULL) @@ -93,8 +92,8 @@ int config_file(char *name, char *file, int quiet) { strncpy(ffile, file, 255); } - - + + /* Looking for ffile */ if(!fileexist(ffile)) { @@ -104,55 +103,26 @@ int config_file(char *name, char *file, int quiet) } return(-1); } - + if(dogrep(OSSECCONF, file)) { - printf("%s: Log file already configured: '%s'.\n", + printf("%s: Log file already configured: '%s'.\n", name, file); return(0); } - - + + /* Add iis config config */ fp = fopen(OSSECCONF, "a"); if(!fp) { printf("%s: Unable to edit configuration file.\n", name); - return(0); - } - - printf("%s: Adding log file to be monitored: '%s'.\n", name,file); - printf("%s: Continue? (y/n):", name); - while(1) - { - char u_buffer[256]; - memset(u_buffer, '\0', 256); - if((fgets(u_buffer, 254, stdin) != NULL) && - (strlen(u_buffer) < 250)) - { - if((u_buffer[0] == 'y') || (u_buffer[0] == 'Y')) - { - add = 1; - break; - } - else if((u_buffer[0] == 'n') || (u_buffer[0] == 'N')) - { - add = 0; - break; - } - } - printf("%s: Continue? (y/n):", name); - } - - if(add == 0) - { - printf("%s: Action not taken.\n", name); - fclose(fp); return(0); } - - fprintf(fp, "\r\n" - "\r\n" + + printf("%s: Adding log file to be monitored: '%s'.\n", name,file); + fprintf(fp, "\r\n" + "\r\n" "\r\n" "\r\n" " \r\n" @@ -166,14 +136,14 @@ int config_file(char *name, char *file, int quiet) fclose(fp); return(0); - + } /* Setup windows after install */ int main(int argc, char **argv) { int quiet = 0; - + if(argc < 2) { printf("%s: Invalid syntax.\n", argv[0]); @@ -186,7 +156,7 @@ int main(int argc, char **argv) quiet = 1; } - + /* Checking if ossec was installed already */ if(!fileexist(OSSECCONF)) { @@ -197,6 +167,6 @@ int main(int argc, char **argv) { config_file(argv[0], argv[1], quiet); } - + return(0); }