1 /* @(#) $Id: ./src/syscheckd/syscheck-baseline.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
12 * License details at the LICENSE file included with OSSEC or
13 * online at: http://www.ossec.net/en/licensing.html
21 /* Help information for syscheck-baseline.
23 void sb_help(char *argv0)
25 /* -s sleep between files.
27 * -D workdir (where ossec is installed to read internal_options.conf)
29 * -i input_file (only used with compare)
35 /* void read_internal()
36 * Reads syscheck internal options.
38 void read_internal(no_stop)
43 syscheck.sleep_after = 9999;
47 syscheck.tsleep = getDefine_Int("syscheck","sleep",1,64);
48 syscheck.sleep_after = getDefine_Int("syscheck","sleep_after",1,128);
58 int main(int argc, char **argv)
63 char *cfg = DEFAULTCPATH;
65 char *output_f = NULL;
68 /* Zeroing the structure */
69 syscheck.workdir = NULL;
72 /* Setting the name */
76 while((c = getopt(argc, argv, "VtdshD:c:i:o:")) != -1)
94 ErrorExit("%s: -i needs an argument",ARGV0);
99 ErrorExit("%s: -o needs an argument",ARGV0);
104 ErrorExit("%s: -D needs an argument",ARGV0);
105 syscheck.workdir = optarg;
109 ErrorExit("%s: -c needs an argument",ARGV0);
122 /* Checking if the configuration is present */
123 if(File_DateofChange(cfg) < 0)
124 ErrorExit(NO_CONFIG, ARGV0, cfg);
127 /* Read syscheck config */
128 if((r = Read_Syscheck_Config(cfg)) < 0)
130 ErrorExit(CONFIG_ERROR, ARGV0, cfg);
132 else if((r == 1) || (syscheck.disabled == 1))
134 syscheck.dir[0] = NULL;
137 merror("%s: WARN: Syscheck disabled.", ARGV0);
142 /* Reading internal options */
143 read_internal(no_stop);
146 /* Exit if testing config */
151 /* Setting default values */
152 if(syscheck.workdir == NULL)
153 syscheck.workdir = DEFAULTDIR;
156 /* Creating a temporary fp */
157 syscheck.db = (char *)calloc(1024,sizeof(char));
158 if(syscheck.db == NULL)
159 ErrorExit(MEM_ERROR,ARGV0);
161 snprintf(syscheck.db,1023, output_f);
164 /* Printing options */
167 while(syscheck.registry[r] != NULL)
169 verbose("%s: INFO: Monitoring registry entry: '%s'.",
170 ARGV0, syscheck.registry[r]);
176 while(syscheck.dir[r] != NULL)
178 verbose("%s: INFO: Monitoring directory: '%s'.",
179 ARGV0, syscheck.dir[r]);
183 /* Start the signal handling */
187 /* Start up message */
188 verbose(STARTUP_MSG, ARGV0, getpid());
191 /* Create local database */