]> diplodocus.org Git - nmh/blobdiff - uip/whom.c
lock_file.c: close(2) file descriptor on failure, avoiding leak.
[nmh] / uip / whom.c
index d1feb9fed2408247828e37e5fa1f2ae7feebb2f9..145190b7c6baffaf654bff73bff427bbfed0820f 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * whom.c -- report to whom a message would be sent
+/* whom.c -- report to whom a message would be sent
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +8,8 @@
 #include <h/mh.h>
 #include <h/utils.h>
 #include <h/signals.h>
+#include "sbr/m_maildir.h"
+#include "sbr/m_mktemp.h"
 
 #ifndef CYRUS_SASL
 # define SASLminc(a) (a)
@@ -58,7 +58,7 @@ int
 main (int argc, char **argv)
 {
     pid_t child_id = OK;
-    int i, status, isdf = 0;
+    int status, isdf = 0;
     int distsw = 0, vecp = 0;
     char *cp, *dfolder = NULL, *dmsg = NULL;
     char *msg = NULL, **ap, **argp, backup[BUFSIZ];
@@ -74,6 +74,12 @@ main (int argc, char **argv)
     vec[vecp++] = "-library";
     vec[vecp++] = getcpy (m_maildir (""));
 
+    if ((cp = context_find ("credentials"))) {
+       /* post doesn't read context so need to pass credentials. */
+       vec[vecp++] = "-credentials";
+       vec[vecp++] = cp;
+    }
+
     /* Don't need to feed fileproc or mhlproc to post because
        it doesn't use them when used for whom. */
 
@@ -143,8 +149,7 @@ main (int argc, char **argv)
        }
        if (msg)
            adios (NULL, "only one draft at a time!");
-       else
-           vec[vecp++] = msg = cp;
+        vec[vecp++] = msg = cp;
     }
 
     /* allow Aliasfile: profile entry */
@@ -175,10 +180,8 @@ main (int argc, char **argv)
 
     closefds (3);
 
-    if (distsw) {
-       for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
-           sleep (5);
-    }
+    if (distsw)
+       child_id = fork();
 
     switch (distsw ? child_id : OK) {
        case NOTOK: