1 /* @(#) $Id: syscheck-baseline.c,v 1.2 2009/06/24 18:53:09 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
11 * License details at the LICENSE file included with OSSEC or
12 * online at: http://www.ossec.net/en/licensing.html
20 /* Help information for syscheck-baseline.
22 void sb_help(char *argv0)
24 /* -s sleep between files.
26 * -D workdir (where ossec is installed to read internal_options.conf)
28 * -i input_file (only used with compare)
34 /* void read_internal()
35 * Reads syscheck internal options.
37 void read_internal(no_stop)
42 syscheck.sleep_after = 9999;
46 syscheck.tsleep = getDefine_Int("syscheck","sleep",1,64);
47 syscheck.sleep_after = getDefine_Int("syscheck","sleep_after",1,128);
57 int main(int argc, char **argv)
62 char *cfg = DEFAULTCPATH;
64 char *output_f = NULL;
67 /* Zeroing the structure */
68 syscheck.workdir = NULL;
71 /* Setting the name */
75 while((c = getopt(argc, argv, "VtdshD:c:i:o:")) != -1)
93 ErrorExit("%s: -i needs an argument",ARGV0);
98 ErrorExit("%s: -o needs an argument",ARGV0);
103 ErrorExit("%s: -D needs an argument",ARGV0);
104 syscheck.workdir = optarg;
108 ErrorExit("%s: -c needs an argument",ARGV0);
121 /* Checking if the configuration is present */
122 if(File_DateofChange(cfg) < 0)
123 ErrorExit(NO_CONFIG, ARGV0, cfg);
126 /* Read syscheck config */
127 if((r = Read_Syscheck_Config(cfg)) < 0)
129 ErrorExit(CONFIG_ERROR, ARGV0, cfg);
131 else if((r == 1) || (syscheck.disabled == 1))
133 syscheck.dir[0] = NULL;
136 merror("%s: WARN: Syscheck disabled.", ARGV0);
141 /* Reading internal options */
142 read_internal(no_stop);
145 /* Exit if testing config */
150 /* Setting default values */
151 if(syscheck.workdir == NULL)
152 syscheck.workdir = DEFAULTDIR;
155 /* Creating a temporary fp */
156 syscheck.db = (char *)calloc(1024,sizeof(char));
157 if(syscheck.db == NULL)
158 ErrorExit(MEM_ERROR,ARGV0);
160 snprintf(syscheck.db,1023, output_f);
163 /* Printing options */
166 while(syscheck.registry[r] != NULL)
168 verbose("%s: INFO: Monitoring registry entry: '%s'.",
169 ARGV0, syscheck.registry[r]);
175 while(syscheck.dir[r] != NULL)
177 verbose("%s: INFO: Monitoring directory: '%s'.",
178 ARGV0, syscheck.dir[r]);
182 /* Start the signal handling */
186 /* Start up message */
187 verbose(STARTUP_MSG, ARGV0, getpid());
190 /* Create local database */