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)", __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);
123 ErrorExit("%s: -c needs an argument",ARGV0);
137 /*Check if the user/group given are valid */
138 uid = Privsep_GetUser(user);
139 gid = Privsep_GetGroup(group);
140 if((uid < 0)||(gid < 0))
141 ErrorExit(USER_ERROR,ARGV0,user,group);
145 debug1(FOUND_USER, ARGV0);
148 /* Reading configuration file */
149 if(GlobalConf(cfg) < 0)
151 ErrorExit(CONFIG_ERROR,ARGV0, cfg);
154 debug1(READ_CONFIG, ARGV0);
156 /* Setting the group */
157 if(Privsep_SetGroup(gid) < 0)
158 ErrorExit(SETGID_ERROR,ARGV0,group);
161 if(Privsep_Chroot(dir) < 0)
162 ErrorExit(CHROOT_ERROR,ARGV0,dir);
168 /* Createing the lists for use in rules */
169 Lists_OP_CreateLists();
171 /* Reading the lists */
174 listfiles = Config.lists;
175 while(listfiles && *listfiles)
177 if(Lists_OP_LoadList(*listfiles) < 0)
178 ErrorExit(LISTS_ERROR, ARGV0, *listfiles);
186 Lists_OP_MakeAll(force);