novi upstream verzije 2.8.3
[ossec-hids.git] / src / monitord / main.c
index a491529..e3f4d5d 100755 (executable)
@@ -1,4 +1,5 @@
-/* @(#) $Id$ */
+/* @(#) $Id: ./src/monitord/main.c, 2011/09/08 dcid Exp $
+ */
 
 /* Copyright (C) 2009 Trend Micro Inc.
  * All rights reserved.
@@ -30,7 +31,7 @@ int main(int argc, char **argv)
 
     /* Setting the name */
     OS_SetName(ARGV0);
-        
+
 
     while((c = getopt(argc, argv, "Vdhtfu:g:D:c:")) != -1){
         switch(c){
@@ -60,13 +61,14 @@ int main(int argc, char **argv)
                 if(!optarg)
                     ErrorExit("%s: -D needs an argument",ARGV0);
                 dir=optarg;
+                break;
             case 'c':
                 if(!optarg)
                     ErrorExit("%s: -c needs an argument",ARGV0);
                 cfg = optarg;
                 break;
             case 't':
-                test_config = 1;    
+                test_config = 1;
                 break;
             default:
                 help(ARGV0);
@@ -99,6 +101,7 @@ int main(int argc, char **argv)
     mond.agents = NULL;
     mond.smtpserver = NULL;
     mond.emailfrom = NULL;
+    mond.emailidsname = NULL;
 
 
     c = 0;
@@ -114,8 +117,9 @@ int main(int argc, char **argv)
         OS_XML xml;
         char *tmpsmtp;
 
-        char *(xml_smtp[])={"ossec_config", "global", "smtp_server", NULL};
-        char *(xml_from[])={"ossec_config", "global", "email_from", NULL};
+        const char *(xml_smtp[])={"ossec_config", "global", "smtp_server", NULL};
+        const char *(xml_from[])={"ossec_config", "global", "email_from", NULL};
+        const char *(xml_idsname[])={"ossec_config", "global", "email_idsname", NULL};
 
         if(OS_ReadXML(cfg, &xml) < 0)
         {
@@ -124,6 +128,7 @@ int main(int argc, char **argv)
 
         tmpsmtp = OS_GetOneContentforElement(&xml,xml_smtp);
         mond.emailfrom = OS_GetOneContentforElement(&xml,xml_from);
+        mond.emailidsname = OS_GetOneContentforElement(&xml,xml_idsname);
 
         if(tmpsmtp && mond.emailfrom)
         {
@@ -154,20 +159,20 @@ int main(int argc, char **argv)
     if(test_config)
         exit(0);
 
-        
-    if (!run_foreground) 
+
+    if (!run_foreground)
     {
         /* Going on daemon mode */
         nowDaemon();
         goDaemon();
     }
 
-    
-    /* Privilege separation */ 
+
+    /* Privilege separation */
     if(Privsep_SetGroup(gid) < 0)
         ErrorExit(SETGID_ERROR,ARGV0,group);
 
-    
+
     /* chrooting */
     if(Privsep_Chroot(dir) < 0)
         ErrorExit(CHROOT_ERROR,ARGV0,dir);
@@ -175,8 +180,8 @@ int main(int argc, char **argv)
     nowChroot();
 
 
-    
-    /* Changing user */        
+
+    /* Changing user */
     if(Privsep_SetUser(uid) < 0)
         ErrorExit(SETUID_ERROR,ARGV0,user);
 
@@ -188,18 +193,18 @@ int main(int argc, char **argv)
     /* Signal manipulation */
     StartSIG(ARGV0);
 
-    
+
 
     /* Creating PID files */
     if(CreatePID(ARGV0, getpid()) < 0)
         ErrorExit(PID_ERROR,ARGV0);
 
-    
+
     /* Start up message */
     verbose(STARTUP_MSG, ARGV0, (int)getpid());
-    
 
-    /* the real daemon now */  
+
+    /* the real daemon now */
     Monitord();
     exit(0);
 }