X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/4eb3c86131807ffa6d36047df51ddad3b5d67a48..23816efd3e8e294e8f1c1ce811ac3a1cd15d334e:/uip/post.c diff --git a/uip/post.c b/uip/post.c index 27f7ad83..246f5670 100644 --- a/uip/post.c +++ b/uip/post.c @@ -6,6 +6,8 @@ */ #include "h/mh.h" +#include "sbr/dtime.h" +#include "sbr/m_getfld.h" #include "sbr/getarguments.h" #include "sbr/concat.h" #include "sbr/smatch.h" @@ -239,7 +241,7 @@ static short fccind = 0; /* index into fccfold[] */ static short outputlinelen = OUTPUTLINELEN; static int pfd = NOTOK; /* fd to write annotation list to */ -static bool recipients; /* how many people will get a copy */ +static bool recipients; /* how many people will get a copy */ static int unkadr = 0; /* how many of those were unknown */ static int badadr = 0; /* number of bad addrs */ static bool badmsg; /* message has bad semantics */ @@ -259,7 +261,7 @@ static char *user=NULL; /* Authenticate as this user */ static char *port="submission"; /* Name of server port for SMTP submission */ static int tlsflag=0; /* Flags to control TLS settings */ static int fromcount=0; /* Count of addresses on From: header */ -static bool seensender; /* Have we seen a Sender: header? */ +static bool seensender; /* Have we seen a Sender: header? */ static unsigned msgflags = 0; /* what we've seen */ @@ -316,7 +318,7 @@ static int annoaux (struct mailname *); static void insert_fcc (struct headers *, char *); static void make_bcc_file (int); static void verify_all_addresses (int, int, char *, int, char *); -static void chkadr (void) PURE; +static void chkadr (void); static void sigon (void); static void sigoff (void); static void p_refile (char *); @@ -699,11 +701,11 @@ main (int argc, char **argv) */ if (msgflags & MEFM) { - envelope = efrom; + envelope = efrom; } else if (seensender) { - envelope = sender; + envelope = sender; } else { - envelope = from; + envelope = from; } if (tls == -1) { @@ -758,7 +760,12 @@ main (int argc, char **argv) /* If we are doing a "whom" check */ if (whomsw) { - /* This won't work with MTS_SENDMAIL_PIPE. */ + /* Note that this will call sendmail directly using SMTP, just like + sendmail/smtp, even if the sendmail/pipe mts is specified. + It doesn't use sendmail -bv, which spost(8) used to do, because: + Notice: -bv may give misleading output for non-privileged user + and because -bv works differently with postfix. + And see the BUGS section of the whom(1) man page re. -check. */ verify_all_addresses (1, eai, envelope, oauth_flag, auth_svc); done (0); } @@ -767,10 +774,9 @@ main (int argc, char **argv) make_bcc_file (dashstuff); if (msgflags & MVIS) { if (sm_mts != MTS_SENDMAIL_PIPE) { - /* It would be nice to have support to call - verify_all_addresses with MTS_SENDMAIL_PIPE, but - that might require running sendmail as root. Note - that spost didn't verify addresses. */ + /* Addresses aren't verified here with sendmail/pipe because + spost didn't. They could be because verify_all_address() + uses SMTP, see above. */ verify_all_addresses (verbose, eai, envelope, oauth_flag, auth_svc); } @@ -786,7 +792,7 @@ main (int argc, char **argv) (void) m_unlink (tmpfil); if (verbose) { - if (partno) + if (partno) printf ("Partial Message #%s Processed\n", partno); else puts("Message Processed"); @@ -866,6 +872,12 @@ putfmt (char *name, char *str, int *eai, FILE *out) badmsg = true; return; } + if (hdr->flags & HDCC && sm_mts == MTS_SENDMAIL_PIPE) + { + inform("Dcc header is not supported with sendmail/pipe"); + badmsg = true; + return; + } msgflags |= (hdr->set & ~(MVIS | MINV)); if (hdr->flags & HSUB) @@ -1018,8 +1030,7 @@ putfmt (char *name, char *str, int *eai, FILE *out) aliases and put them in Bcc:, but then they'd have the Blind-Carbon-Copy indication. */ - die( "blind lists not compatible with" - " sendmail/pipe"); + die("blind lists not compatible with sendmail/pipe"); } grp = true; @@ -1162,9 +1173,9 @@ finish_headers (FILE *out) */ if (fromcount > 1 && !seensender) { - if (efrom[0] == '\0') { + if (efrom[0] == '\0') { inform("Envelope-From cannot be blank when there " - "is multiple From: addresses\nand no Sender: " + "is multiple From: addresses\nand no Sender: " "header"); badmsg = true; } else { @@ -1212,9 +1223,9 @@ finish_headers (FILE *out) */ if (fromcount > 1 && !seensender) { - if (efrom[0] == '\0') { + if (efrom[0] == '\0') { inform("Envelope-From cannot be blank when there " - "is multiple Resent-From: addresses and no " + "is multiple Resent-From: addresses and no " "Resent-Sender: header"); badmsg = true; } else { @@ -1260,8 +1271,7 @@ putadr (char *name, char *aka, struct mailname *mp, FILE *out, if (mp->m_mbox == NULL || ((flags & HTRY) && !insert (mp))) return 0; - if (sm_mts != MTS_SENDMAIL_PIPE && - ((flags & (HBCC | HDCC | HEFM)) || mp->m_ingrp)) + if ((flags & (HBCC | HDCC | HEFM)) || mp->m_ingrp) return 1; if (!nameoutput) { @@ -1493,7 +1503,33 @@ make_bcc_file (int dashstuff) fprintf (out, "Message-ID: %s\n", message_id (tclock, 0)); if (subject) fprintf (out, "Subject: %s", subject); - fprintf (out, "BCC:\n"); + + /* for sendmail/pipe, insert all bcc recipients here so that the email can be routed based on the bcc: header */ + if (sm_mts == MTS_SENDMAIL_PIPE) + { + char *allbcc = NULL; + struct mailname *lp; + + for (lp = localaddrs.m_next; lp; lp = lp->m_next) + if (lp->m_bcc) + allbcc = allbcc? add(concat(", ", lp->m_mbox, NULL), allbcc) + : mh_xstrdup(lp->m_mbox); + for (lp = netaddrs.m_next; lp; lp = lp->m_next) + if (lp->m_bcc) + allbcc = allbcc? add( + concat(", ", lp->m_mbox, "@", lp->m_host, NULL), + allbcc) + : concat(lp->m_mbox, "@", lp->m_host, NULL); + if (allbcc) + { + fprintf (out, "BCC: %s\n",allbcc); + free(allbcc); + } + } + else + { + fprintf (out, "BCC:\n"); + } /* * Use MIME encapsulation for Bcc messages @@ -1851,7 +1887,7 @@ do_an_address (struct mailname *lp, int talk) snprintf (addr, sizeof(addr), "%s!%s", lp->m_host, lp->m_mbox); break; - default: /* let SendMail decide if the host is bad */ + default: /* let SendMail decide if the host is bad */ mbox = lp->m_mbox; host = lp->m_host; snprintf (addr, sizeof(addr), "%s at %s", mbox, host);