]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/mail-sendmail.c
Improve the hidden/undocumented 'modes' trace criteria, and document it'
[irc/evilnet/x3.git] / src / mail-sendmail.c
index bae492661eddc39de0680c3b13658da11d98ff16..4c255ff9f22fd1f308f8ee7c6a860f7fa54844c2 100644 (file)
@@ -5,7 +5,7 @@
  *
  * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -68,9 +68,11 @@ send_flowed_text(FILE *where, const char *para)
 void
 mail_send(struct userNode *from, struct handle_info *to, const char *subject, const char *body, int first_time)
 {
+    struct sigaction sv;
     pid_t child;
     int infds[2], outfds[2];
-    const char *fromaddr, *str;
+    const char *fromaddr;
+    const char *str;
 
     /* Grab some config items first. */
     str = conf_get_data("mail/enable", RECDB_QSTRING);
@@ -92,6 +94,11 @@ mail_send(struct userNode *from, struct handle_info *to, const char *subject, co
     } else if (child > 0) {
         return;
     }
+    /* Reset the SIGCHLD signal handler to the default. */
+    memset(&sv, 0, sizeof(sv));
+    sigemptyset(&sv.sa_mask);
+    sv.sa_handler = SIG_DFL;
+    sigaction(SIGCHLD, &sv, NULL);
     /* We're in a child now; must _exit() to die properly. */
     if (pipe(infds) < 0) {
         log_module(MAIN_LOG, LOG_ERROR, "sendmail() child to %s couldn't pipe(infds): %s (%d)", to->email_addr, strerror(errno), errno);
@@ -116,15 +123,6 @@ mail_send(struct userNode *from, struct handle_info *to, const char *subject, co
         close(infds[0]);
         close(outfds[1]);
 
-        /* Do we have any "extra" headers to send? */
-        extras = conf_get_data("mail/extra_headers", RECDB_STRING_LIST);
-        if (extras) {
-            for (nn=0; nn<extras->used; nn++) {
-                fputs(extras->list[nn], out);
-                fputs("\n", out);
-            }
-        }
-
         /* Content type?  (format=flowed is a standard for plain text
          * that lets the receiver reconstruct paragraphs, defined in
          * RFC 2646.  See comment above send_flowed_text() for more.)
@@ -138,6 +136,15 @@ mail_send(struct userNode *from, struct handle_info *to, const char *subject, co
         fprintf(out, "To: \"%s\" <%s>\n", to->handle, to->email_addr);
         fprintf(out, "Subject: %s\n", subject);
 
+        /* Do we have any "extra" headers to send? */
+        extras = conf_get_data("mail/extra_headers", RECDB_STRING_LIST);
+        if (extras) {
+            for (nn=0; nn<extras->used; nn++) {
+                fputs(extras->list[nn], out);
+                fputs("\n", out);
+            }
+        }
+
         /* Send mail body */
         fputs("\n", out); /* terminate headers */
         extras = conf_get_data((first_time?"mail/body_prefix_first":"mail/body_prefix"), RECDB_STRING_LIST);