X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fmonitord%2Fmain.c;h=a4915296b3efbd1def4b7cd5d8e6d9506d144667;hp=0eee48bda820a27d64bb0c11bd8ca67d0806c3ce;hb=301048b51990573e58a30dc4a5bb4ec285cad554;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a diff --git a/src/monitord/main.c b/src/monitord/main.c index 0eee48b..a491529 100755 --- a/src/monitord/main.c +++ b/src/monitord/main.c @@ -1,17 +1,19 @@ -/* @(#) $Id: main.c,v 1.9 2009/11/18 19:07:40 dcid Exp $ */ +/* @(#) $Id$ */ /* Copyright (C) 2009 Trend Micro Inc. * All rights reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 3) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation */ #include "shared.h" +#include "config/config.h" #include "monitord.h" +#include "os_net/os_net.h" int main(int argc, char **argv) @@ -95,6 +97,57 @@ int main(int argc, char **argv) mond.monitor_agents = getDefine_Int("monitord","monitor_agents",0,1); mond.agents = NULL; + mond.smtpserver = NULL; + mond.emailfrom = NULL; + + + c = 0; + c|= CREPORTS; + if(ReadConfig(c, cfg, &mond, NULL) < 0) + { + ErrorExit(CONFIG_ERROR, ARGV0, cfg); + } + + /* If we have any reports configured, read smtp/emailfrom */ + if(mond.reports) + { + OS_XML xml; + char *tmpsmtp; + + char *(xml_smtp[])={"ossec_config", "global", "smtp_server", NULL}; + char *(xml_from[])={"ossec_config", "global", "email_from", NULL}; + + if(OS_ReadXML(cfg, &xml) < 0) + { + ErrorExit(CONFIG_ERROR, ARGV0, cfg); + } + + tmpsmtp = OS_GetOneContentforElement(&xml,xml_smtp); + mond.emailfrom = OS_GetOneContentforElement(&xml,xml_from); + + if(tmpsmtp && mond.emailfrom) + { + mond.smtpserver = OS_GetHost(tmpsmtp, 5); + if(!mond.smtpserver) + { + merror(INVALID_SMTP, ARGV0, tmpsmtp); + if(mond.emailfrom) free(mond.emailfrom); + mond.emailfrom = NULL; + merror("%s: Invalid SMTP server. Disabling email reports.", ARGV0); + } + } + else + { + if(tmpsmtp) free(tmpsmtp); + if(mond.emailfrom) free(mond.emailfrom); + + mond.emailfrom = NULL; + + merror("%s: SMTP server or 'email from' missing. Disabling email reports.", ARGV0); + } + + OS_ClearXML(&xml); + } /* Exit here if test config is set */