1 /* $OSSEC, rootcheck-config.c, v0.1, 2005/09/30, Daniel B. Cid$ */
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
14 #include "rootcheck-config.h"
17 /* Read_Rootcheck: Reads the rootcheck config
19 int Read_Rootcheck(XML_NODE node, void *configp, void *mailp)
26 char *xml_rootkit_files = "rootkit_files";
27 char *xml_rootkit_trojans = "rootkit_trojans";
28 char *xml_winaudit = "windows_audit";
29 char *xml_unixaudit = "system_audit";
30 char *xml_winapps = "windows_apps";
31 char *xml_winmalware = "windows_malware";
32 char *xml_scanall = "scanall";
33 char *xml_readall = "readall";
34 char *xml_time = "frequency";
35 char *xml_disabled = "disabled";
36 char *xml_base_dir = "base_directory";
37 char *xml_ignore = "ignore";
40 rootcheck = (rkconfig *)configp;
46 merror(XML_ELEMNULL, ARGV0);
49 else if(!node[i]->content)
51 merror(XML_VALUENULL, ARGV0, node[i]->element);
55 /* Getting frequency */
56 else if(strcmp(node[i]->element,xml_time) == 0)
58 if(!OS_StrIsNum(node[i]->content))
60 merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content);
64 rootcheck->time = atoi(node[i]->content);
66 /* getting scan all */
67 else if(strcmp(node[i]->element,xml_scanall) == 0)
69 if(strcmp(node[i]->content, "yes") == 0)
70 rootcheck->scanall = 1;
71 else if(strcmp(node[i]->content, "no") == 0)
72 rootcheck->scanall = 0;
75 merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content);
79 else if(strcmp(node[i]->element, xml_disabled) == 0)
81 if(strcmp(node[i]->content, "yes") == 0)
82 rootcheck->disabled = 1;
83 else if(strcmp(node[i]->content, "no") == 0)
84 rootcheck->disabled = 0;
87 merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content);
91 else if(strcmp(node[i]->element,xml_readall) == 0)
93 if(strcmp(node[i]->content, "yes") == 0)
94 rootcheck->readall = 1;
95 else if(strcmp(node[i]->content, "no") == 0)
96 rootcheck->readall = 0;
99 merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content);
103 else if(strcmp(node[i]->element,xml_rootkit_files) == 0)
105 os_strdup(node[i]->content, rootcheck->rootkit_files);
107 else if(strcmp(node[i]->element,xml_rootkit_trojans) == 0)
109 os_strdup(node[i]->content, rootcheck->rootkit_trojans);
111 else if(strcmp(node[i]->element, xml_winaudit) == 0)
113 os_strdup(node[i]->content, rootcheck->winaudit);
115 else if(strcmp(node[i]->element, xml_unixaudit) == 0)
118 while(rootcheck->unixaudit && rootcheck->unixaudit[j])
121 os_realloc(rootcheck->unixaudit, sizeof(char *)*(j+2),
122 rootcheck->unixaudit);
123 rootcheck->unixaudit[j] = NULL;
124 rootcheck->unixaudit[j + 1] = NULL;
126 os_strdup(node[i]->content, rootcheck->unixaudit[j]);
128 else if(strcmp(node[i]->element, xml_ignore) == 0)
131 while(rootcheck->ignore && rootcheck->ignore[j])
134 os_realloc(rootcheck->ignore, sizeof(char *)*(j+2),
136 rootcheck->ignore[j] = NULL;
137 rootcheck->ignore[j + 1] = NULL;
139 os_strdup(node[i]->content, rootcheck->ignore[j]);
141 else if(strcmp(node[i]->element, xml_winmalware) == 0)
143 os_strdup(node[i]->content, rootcheck->winmalware);
145 else if(strcmp(node[i]->element, xml_winapps) == 0)
147 os_strdup(node[i]->content, rootcheck->winapps);
149 else if(strcmp(node[i]->element, xml_base_dir) == 0)
151 os_strdup(node[i]->content, rootcheck->basedir);
155 merror(XML_INVELEM, ARGV0, node[i]->element);