1 /* @(#) $Id: setup-syscheck.c,v 1.5 2009/06/24 18:53:10 dcid Exp $ */
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
13 #include "setup-shared.h"
14 #include "os_xml/os_xml.h"
15 #include "os_xml/os_xml_writer.h"
17 #define OSSEC_CONFIG_TMP ".tmp.ossec.conf"
21 int main(int argc, char **argv)
24 char *(xml_syscheck_status[])={"ossec_config","syscheck","disabled", NULL};
28 printf("%s: Invalid syntax.\n", argv[0]);
29 printf("Try: '%s <dir> [enable|disable]'\n\n", argv[0]);
33 /* Checking for directory. */
34 if(chdir(argv[1]) != 0)
36 printf("%s: Invalid directory: '%s'.\n", argv[0], argv[1]);
41 /* Checking if ossec was installed already */
42 if(!fileexist(OSSECCONF))
44 printf("%s: OSSEC not installed yet. Exiting.\n", argv[0]);
49 /* Checking status. */
50 if(strcmp(argv[2], "enable") == 0)
60 /* Writing to the XML. */
61 if(OS_WriteXML(OSSECCONF, OSSEC_CONFIG_TMP, xml_syscheck_status,
62 NULL, "no", status, 0) != 0)
64 printf("%s: Error writing to the Config file. Exiting.\n", argv[0]);
68 /* Renaming config files */
70 rename(OSSECCONF, OSSECLAST);
71 rename(OSSEC_CONFIG_TMP, OSSECCONF);