1 /* @(#) $Id: ./src/analysisd/makelists.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2010 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
18 * Available at http://www.ossec.net
23 * Responsible for correlation and log decoding.
27 #define ARGV0 "ossec-testrule"
34 #include "active-response.h"
38 #include "lists_make.h"
40 #include "eventinfo.h"
41 #include "analysisd.h"
47 /** External functions prototypes (only called here) **/
50 int GlobalConf(char * cfgfile);
54 void Lists_OP_CreateLists();
56 void makelist_help(const char *prog)
59 print_out("%s %s - %s (%s)", __ossec_name, __version, __author, __contact);
60 print_out("%s", __site);
62 print_out(" %s: -[Vhdt] [-u user] [-g group] [-c config] [-D dir]", prog);
63 print_out(" -V Version and license message");
64 print_out(" -h This help message");
65 print_out(" -d Execute in debug mode");
66 print_out(" -f Force rebuild of all databases");
67 print_out(" -u <user> Run as 'user'");
68 print_out(" -g <group> Run as 'group'");
69 print_out(" -c <config> Read the 'config' file");
70 print_out(" -D <dir> Chroot to 'dir'");
75 /** int main(int argc, char **argv)
77 int main(int argc, char **argv)
80 char *dir = DEFAULTDIR;
82 char *group = GROUPGLOBAL;
86 char *cfg = DEFAULTCPATH;
88 /* Setting the name */
94 memset(prev_month, '\0', 4);
96 while((c = getopt(argc, argv, "Vdhfu:g:D:c:")) != -1){
102 makelist_help(ARGV0);
109 ErrorExit("%s: -u needs an argument",ARGV0);
114 ErrorExit("%s: -g needs an argument",ARGV0);
119 ErrorExit("%s: -D needs an argument",ARGV0);
124 ErrorExit("%s: -c needs an argument",ARGV0);
138 /*Check if the user/group given are valid */
139 uid = Privsep_GetUser(user);
140 gid = Privsep_GetGroup(group);
141 if((uid < 0)||(gid < 0))
142 ErrorExit(USER_ERROR,ARGV0,user,group);
146 debug1(FOUND_USER, ARGV0);
149 /* Reading configuration file */
150 if(GlobalConf(cfg) < 0)
152 ErrorExit(CONFIG_ERROR,ARGV0, cfg);
155 debug1(READ_CONFIG, ARGV0);
157 /* Setting the group */
158 if(Privsep_SetGroup(gid) < 0)
159 ErrorExit(SETGID_ERROR,ARGV0,group);
162 if(Privsep_Chroot(dir) < 0)
163 ErrorExit(CHROOT_ERROR,ARGV0,dir);
169 /* Createing the lists for use in rules */
170 Lists_OP_CreateLists();
172 /* Reading the lists */
175 listfiles = Config.lists;
176 while(listfiles && *listfiles)
178 if(Lists_OP_LoadList(*listfiles) < 0)
179 ErrorExit(LISTS_ERROR, ARGV0, *listfiles);
187 Lists_OP_MakeAll(force);