X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/af429a902add614e35cd76d15172a4ccb70a3be1..0860f098b5a13f4e8bedb2d2da9d2df94717b4a5:/uip/post.c?ds=inline diff --git a/uip/post.c b/uip/post.c index 69f5b821..b940ac3a 100644 --- a/uip/post.c +++ b/uip/post.c @@ -76,7 +76,6 @@ X("server host", 6, SERVSW) /* specify alternate SMTP server */ \ X("snoop", -5, SNOOPSW) /* snoop the SMTP transaction */ \ X("partno", -6, PARTSW) \ - X("queued", -6, QUEUESW) \ X("sasl", SASLminc(-4), SASLSW) \ X("nosasl", SASLminc(-6), NOSASLSW) \ X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \ @@ -223,7 +222,6 @@ static char from[BUFSIZ]; /* my network address */ static char sender[BUFSIZ]; /* my Sender: header */ static char efrom[BUFSIZ]; /* my Envelope-From: header */ static char fullfrom[BUFSIZ]; /* full contents of From header */ -static char signature[BUFSIZ]; /* my signature */ static char *filter = NULL; /* the filter for BCC'ing */ static char *subject = NULL; /* the subject field for BCC'ing */ static char *fccfold[FCCS]; /* foldernames for FCC'ing */ @@ -239,12 +237,9 @@ static int snoop = 0; static char *clientsw = NULL; static char *serversw = NULL; -extern struct smtp sm_reply; - static char prefix[] = "----- =_aaaaaaaaaa"; static char *partno = NULL; -static int queued = 0; /* * static prototypes @@ -284,14 +279,7 @@ main (int argc, char **argv) FILE *in, *out; m_getfld_state_t gstate = 0; -#ifdef LOCALE - setlocale(LC_ALL, ""); -#endif - invo_name = r1bindex (argv[0], '/'); - - /* foil search of user profile/context */ - if (context_foil (NULL) == -1) - done (1); + if (nmh_init(argv[0], 0 /* use context_foil() */)) { return 1; } mts_init (invo_name); arguments = getarguments (invo_name, argc, argv, 0); @@ -432,10 +420,6 @@ main (int argc, char **argv) adios (NULL, "missing argument to %s", argp[-2]); continue; - case QUEUESW: - queued++; - continue; - case SASLSW: sasl++; continue; @@ -496,17 +480,9 @@ main (int argc, char **argv) continue; case CREDENTIALSSW: { - /* post doesn't read the profile, so insert credentials - entry the hard way. */ - struct node *np = (struct node *) mh_xmalloc (sizeof *np); - if (!(cp = *argp++) || *cp == '-') adios (NULL, "missing argument to %s", argp[-2]); - np->n_name = "credentials"; - np->n_field = cp; - np->n_context = 0; - np->n_next = m_defs; - m_defs = np; + add_profile_entry ("credentials", cp); continue; } @@ -544,15 +520,12 @@ main (int argc, char **argv) if ((out = fopen ("/dev/null", "w")) == NULL) adios ("/dev/null", "unable to open"); } else { - char *cp = m_mktemp(m_maildir(invo_name), NULL, &out); - if (cp == NULL) { - cp = m_mktemp2(NULL, invo_name, NULL, &out); - if (cp == NULL) { - adios ("post", "unable to create temporary file"); - } - } + char *cp = m_mktemp2(NULL, invo_name, NULL, &out); + if (cp == NULL) { + adios(NULL, "unable to create temporary file in %s", + get_temp_dir()); + } strncpy(tmpfil, cp, sizeof(tmpfil)); - chmod (tmpfil, 0600); } } @@ -649,17 +622,21 @@ main (int argc, char **argv) post (tmpfil, 0, verbose, envelope); } post (bccfil, 1, verbose, envelope); - unlink (bccfil); + (void) m_unlink (bccfil); } else { post (tmpfil, 0, isatty (1), envelope); } p_refile (tmpfil); - unlink (tmpfil); + (void) m_unlink (tmpfil); + + if (verbose) { + if (partno) + printf ("Partial Message #%s Processed\n", partno); + else + printf ("Message Processed\n"); + } - if (verbose) - printf (partno ? "Partial Message #%s Processed\n" : "Message Processed\n", - partno); done (0); return 1; } @@ -674,7 +651,7 @@ putfmt (char *name, char *str, FILE *out) { int count, grp, i, keep; char *cp, *pp, *qp; - char namep[BUFSIZ]; + char namep[BUFSIZ], error[BUFSIZ]; struct mailname *mp = NULL, *np = NULL; struct headers *hdr; @@ -737,18 +714,20 @@ putfmt (char *name, char *str, FILE *out) tmpaddrs.m_next = NULL; for (count = 0; (cp = getname (str)); count++) - if ((mp = getm (cp, NULL, 0, AD_HOST, NULL))) { + if ((mp = getm (cp, NULL, 0, error, sizeof(error)))) { if (tmpaddrs.m_next) np->m_next = mp; else tmpaddrs.m_next = mp; np = mp; } - else + else { + admonish(cp, "%s", error); if (hdr->flags & HTRY) badadr++; else badmsg++; + } if (count < 1) { if (hdr->flags & HNIL) @@ -789,7 +768,8 @@ putfmt (char *name, char *str, FILE *out) if (np->m_gname) putgrp (namep, np->m_gname, out, hdr->flags); while ((cp = getname (pp))) { - if (!(mp = getm (cp, NULL, 0, AD_HOST, NULL))) { + if (!(mp = getm (cp, NULL, 0, error, sizeof(error)))) { + admonish(cp, "%s", error); badadr++; continue; } @@ -938,9 +918,6 @@ putfmt (char *name, char *str, FILE *out) static void start_headers (void) { - char *cp, sigbuf[BUFSIZ]; - struct mailname *mp; - time (&tclock); /* @@ -951,21 +928,6 @@ start_headers (void) efrom[0] = '\0'; sender[0] = '\0'; fullfrom[0] = '\0'; - - if ((cp = getfullname ()) && *cp) { - strncpy (sigbuf, cp, sizeof(sigbuf)); - snprintf (signature, sizeof(signature), "%s <%s>", - sigbuf, getlocaladdr()); - if ((cp = getname (signature)) == NULL) - adios (NULL, "getname () failed -- you lose extraordinarily big"); - if ((mp = getm (cp, NULL, 0, AD_HOST, NULL)) == NULL) - adios (NULL, "bad signature '%s'", sigbuf); - mnfree (mp); - while (getname ("")) - continue; - } else { - strncpy (signature, getlocaladdr(), sizeof(signature)); - } } @@ -1302,8 +1264,9 @@ make_bcc_file (int dashstuff) FILE *out; char *tfile = NULL, *program; - tfile = m_mktemp2(NULL, "bccs", NULL, &out); - if (tfile == NULL) adios("bcc", "unable to create temporary file"); + if ((tfile = m_mktemp2(NULL, "bccs", NULL, &out)) == NULL) { + adios(NULL, "unable to create temporary file in %s", get_temp_dir()); + } strncpy (bccfil, tfile, sizeof(bccfil)); fprintf (out, "From: %s\n", fullfrom); @@ -1557,8 +1520,8 @@ post (char *file, int bccque, int talk, char *envelope) } } else { if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch, - verbose, snoop, queued, sasl, - saslssf, saslmech, user, tls)) || + verbose, snoop, sasl, saslssf, + saslmech, user, tls)) || rp_isbad (retval = sm_winit (envelope))) die (NULL, "problem initializing server; %s", rp_string (retval)); @@ -1597,8 +1560,8 @@ verify_all_addresses (int talk, char *envelope) if (!whomsw || checksw) if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch, - verbose, snoop, queued, sasl, - saslssf, saslmech, user, tls)) + verbose, snoop, sasl, saslssf, + saslmech, user, tls)) || rp_isbad (retval = sm_winit (envelope))) die (NULL, "problem initializing server; %s", rp_string (retval)); @@ -1734,9 +1697,9 @@ sigser (int i) { NMH_UNUSED (i); - unlink (tmpfil); + (void) m_unlink (tmpfil); if (msgflags & MINV) - unlink (bccfil); + (void) m_unlink (bccfil); if (!whomsw || checksw) sm_end (NOTOK); @@ -1858,9 +1821,9 @@ die (char *what, char *fmt, ...) { va_list ap; - unlink (tmpfil); + (void) m_unlink (tmpfil); if (msgflags & MINV) - unlink (bccfil); + (void) m_unlink (bccfil); if (!whomsw || checksw) sm_end (NOTOK);