X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Futil%2Fverify-agent-conf.c;h=f76745e8202e1dcdd2f02e97da6de805c4a7ff85;hp=ee684d0f8c790a1bc18094931afe59dd26e13e23;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hpb=301048b51990573e58a30dc4a5bb4ec285cad554 diff --git a/src/util/verify-agent-conf.c b/src/util/verify-agent-conf.c index ee684d0..f76745e 100755 --- a/src/util/verify-agent-conf.c +++ b/src/util/verify-agent-conf.c @@ -1,4 +1,5 @@ -/* @(#) $Id$ */ +/* @(#) $Id: ./src/util/verify-agent-conf.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2010 Trend Micro Inc. * All right reserved. @@ -20,27 +21,81 @@ #define ARGV0 "verify-agent-conf" +/** help **/ +void helpmsg() +{ + printf("\nOSSEC HIDS %s: Verify agent.conf syntax for errors.\n", ARGV0); + printf("Usage: %s [-f ]\n\n", ARGV0); + printf("Available options:\n"); + printf("\t-h This help message.\n"); + printf("\t-f Full file name and path to config file to be tested.\n"); + printf("\t If this option is not specified the following default\n"); + printf("\t will be used.\n"); + printf(" "); + printf("\t Validation is successful, if no errors are shown.\n"); + exit(1); +} + /* main: v0.3: 2005/04/04 */ int main(int argc, char **argv) { + char* ar=AGENTCONFIG; + int c=0; int modules = 0; logreader_config log_config; /* Setting the name */ OS_SetName(ARGV0); - + + + /* printf ("Agrc [%d], Argv [%s]\n", argc, *argv); */ + + /* user arguments */ + if(argc > 1) + { + while((c = getopt(argc, argv, "Vdhf:")) != -1) + { + switch(c){ + case 'V': + print_version(); + break; + case 'h': + helpmsg(); + break; + case 'd': + nowDebug(); + break; + case 'f': + if(!optarg) + { + merror("%s: -f needs an argument",ARGV0); + helpmsg(); + } + ar = optarg; + break; + default: + helpmsg(); + break; + } + + } + } + + + + printf("\n%s: Verifying [%s].\n\n", ARGV0, ar); modules|= CLOCALFILE; modules|= CAGENT_CONFIG; log_config.config = NULL; - if(ReadConfig(modules, AGENTCONFIG, &log_config, NULL) < 0) + if(ReadConfig(modules, ar, &log_config, NULL) < 0) { return(OS_INVALID); } - logff = log_config.config; + logff = log_config.config; return(0);