]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/message.c
Final changes
[bacula/bacula] / bacula / src / lib / message.c
index 436743fa00916bf159035444b091f56b458bc789..98c03a86b5ea74c4903f4b66502839dbea80a0be 100755 (executable)
@@ -61,6 +61,9 @@ char catalog_db[] = "Internal";
 #endif
 #endif
 
+char *host_os = HOST_OS;
+char *distname = DISTNAME;
+char *distver = DISTVER;
 
 /* Forward referenced functions */
 
@@ -155,12 +158,29 @@ void
 init_msg(JCR *jcr, MSGS *msg)
 {
    DEST *d, *dnew, *temp_chain = NULL;
+   int i, fd;
+
+   /*
+    * Make sure we have fd's 0, 1, 2 open
+    *  If we don't do this one of our sockets may open
+    *  there and if we then use stdout, it could
+    *  send total garbage to our socket.
+    *
+    */
+   fd = open("/dev/null", O_RDONLY, 0644);
+   if (fd > 2) {
+      close(fd);
+   } else {
+      for(i=1; fd + i <= 2; i++) {
+        dup2(fd, fd+i);
+      }
+   }
+
 
    /*
     * If msg is NULL, initialize global chain for STDOUT and syslog
     */
    if (msg == NULL) {
-      int i;
       daemon_msgs = (MSGS *)malloc(sizeof(MSGS));
       memset(daemon_msgs, 0, sizeof(MSGS));
       for (i=1; i<=M_MAX; i++) {
@@ -420,7 +440,7 @@ void close_msg(JCR *jcr)
            }
            
            if (!(bpipe=open_mail_pipe(jcr, &cmd, d))) {
-               Dmsg0(000, "open mail pipe failed.\n");
+               Pmsg0(000, "open mail pipe failed.\n");
               goto rem_temp_file;
            }
             Dmsg0(150, "Opened mail pipe\n");
@@ -431,7 +451,7 @@ void close_msg(JCR *jcr)
               fputs(line, bpipe->wfd);
            }
            if (!close_wpipe(bpipe)) {       /* close write pipe sending mail */
-               Dmsg1(000, "close error: ERR=%s\n", strerror(errno));
+               Pmsg1(000, "close error: ERR=%s\n", strerror(errno));
            }
 
            /*
@@ -794,8 +814,6 @@ t_msg(char *file, int line, int level, char *fmt,...)
     va_list   arg_ptr;
     int       details = TRUE;
 
-    return;
-
     if (level < 0) {
        details = FALSE;
        level = -level;