Added Content-Description header with the filename of the attachment.
[mmh] / uip / send.c
index 51661a5..e39ab80 100644 (file)
@@ -97,6 +97,7 @@ main(int argc, char **argv)
        int msgp = 0, nfiles = 0, distsw = 0, vecp = 1;
        int msgnum, status;
        int in, out;
+       int n;
        char *cp, *maildir = NULL;
        char buf[BUFSIZ], **ap, **argp, **arguments;
        char *msgs[MAXARGS], *vec[MAXARGS];
@@ -273,11 +274,40 @@ main(int argc, char **argv)
                st.st_ino = 0;
        }
        if (pushsw) {
-               push();
+               /* push a fork into the background */
+               pid_t pid;
+
+               switch (pid = fork()) {
+               case -1:
+                       /* fork error */
+                       advise(NULL, "unable to fork, so can't push...");
+                       break;
+
+               default:
+                       /* parent, just exit */
+                       done(0);
+
+               case 0:
+                       /* child, block a few signals and continue */
+                       SIGNAL(SIGHUP, SIG_IGN);
+                       SIGNAL(SIGINT, SIG_IGN);
+                       SIGNAL(SIGQUIT, SIG_IGN);
+                       SIGNAL(SIGTERM, SIG_IGN);
+#ifdef SIGTSTP
+                       SIGNAL(SIGTSTP, SIG_IGN);
+                       SIGNAL(SIGTTIN, SIG_IGN);
+                       SIGNAL(SIGTTOU, SIG_IGN);
+#endif
+                       freopen("/dev/null", "r", stdin);
+                       freopen("/dev/null", "w", stdout);
+                       break;
+               }
        }
        status = 0;
-       vec[0] = mhbasename(postproc);
-       closefds(3);
+       vec[0] = "spost";
+       for (n=3; n<OPEN_MAX; n++) {
+               close(n);
+       }
 
        for (msgnum = 0; msgnum < nfiles; msgnum++) {
                switch (sendsbr(vec, vecp, files[msgnum], &st, 1)) {
@@ -600,9 +630,9 @@ make_mime_composition_file_entry(char *file_name)
                adios(NULL, "unable to access file `%s'", file_name);
        }
 
-       fprintf(composition_file, "#%s; name=\"%s\" <>{attachment}",
-               content_type,
-               (!(cp = strrchr(file_name, '/'))) ? file_name : cp + 1);
+       cp = (!(cp = strrchr(file_name, '/'))) ? file_name : cp + 1;
+       fprintf(composition_file, "#%s; name=\"%s\" <> [%s] {attachment}",
+                       content_type, cp, cp);
 
        fprintf(composition_file, " %s\n", file_name);
 
@@ -611,7 +641,7 @@ make_mime_composition_file_entry(char *file_name)
 
 /*
 ** The back-end of the message sending back-end.
-** Annotate original message, and call `postproc' to send message.
+** Annotate original message, and call `spost' to send message.
 */
 static int
 sendaux(char **vec, int vecp, char *drft, struct stat *st)
@@ -621,7 +651,7 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
        char backup[BUFSIZ];
 
        /*
-       ** fd collects the output of postproc, and is used for the
+       ** fd collects the output of spost, and is used for the
        ** failure notice if we need to send one in alert().
        */
        fd = pushsw ? tmp_fd() : NOTOK;
@@ -650,9 +680,9 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
                        dup2(fd, fileno(stderr));
                        close(fd);
                }
-               execvp(postproc, vec);
+               execvp(*vec, vec);
                fprintf(stderr, "unable to exec ");
-               perror(postproc);
+               perror(*vec);
                _exit(-1);
                break;  /* NOT REACHED */
 
@@ -664,7 +694,7 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
                        }
                } else {
                        /*
-                       ** If postproc failed, and we have good fd (which
+                       ** If spost failed, and we have good fd (which
                        ** means we pushed), then mail error message
                        ** (and possibly the draft) back to the user.
                        */