Imported Upstream version 2.5.1
[ossec-hids.git] / src / os_execd / config.c
1 /* @(#) $Id$ */
2
3 /* Copyright (C) 2009 Trend Micro Inc.
4  * All right reserved.
5  *
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 2) as published by the FSF - Free Software
9  * Foundation
10  */
11
12
13 #include "shared.h" 
14
15
16 /* ExecdConfig v0.1, 2006/03/24
17  * Read the config file
18  */
19 int ExecdConfig(char * cfgfile)
20 {
21     #ifdef WIN32
22     int is_disabled = 1;
23     #else
24     int is_disabled = 0;
25     #endif
26     char *(xmlf[]) = {"ossec_config", "active-response", "disabled", NULL};
27     char *disable_entry;
28
29     OS_XML xml;
30
31
32     /* Reading XML file */
33     if(OS_ReadXML(cfgfile,&xml) < 0)
34     {
35         ErrorExit(XML_ERROR, ARGV0, cfgfile, xml.err, xml.err_line);
36     }
37
38     /* We do not validate the xml in here. It is done by other processes */
39     disable_entry = OS_GetOneContentforElement(&xml, xmlf);
40     if(disable_entry)
41     {
42         if(strcmp(disable_entry, "yes") == 0)
43         {
44             is_disabled = 1;
45         }
46         else if(strcmp(disable_entry, "no") == 0)
47         {
48             is_disabled = 0;
49         }
50         else
51         {
52             merror(XML_VALUEERR, ARGV0,
53                     "disabled", 
54                     disable_entry); 
55             return(-1);
56         }
57     }
58     
59     OS_ClearXML(&xml);
60     return(is_disabled);
61 }
62
63 /* EOF */