X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fpost.c;h=419b86c4a1fff3f0555820f171616fa6851fff14;hb=220dcd2dda3136cefd20951e34e963f37f8e2132;hp=e3b6229dd0071946d346a5c8837f22da2dc69ae2;hpb=38615191e71744b066425e0c44412b62dbe49cc2;p=mmh diff --git a/uip/post.c b/uip/post.c index e3b6229..419b86c 100644 --- a/uip/post.c +++ b/uip/post.c @@ -2,8 +2,6 @@ /* * post.c -- enter messages into the mail transport system * - * $Id$ - * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. @@ -46,6 +44,12 @@ # define SASLminc(a) 0 #endif /* CYRUS_SASL */ +#ifndef TLS_SUPPORT +# define TLSminc(a) (a) +#else /* TLS_SUPPORT */ +# define TLSminc(a) 0 +#endif /* TLS_SUPPORT */ + #define FCCS 10 /* max number of fccs allowed */ #define uptolow(c) ((isalpha(c) && isupper (c)) ? tolower (c) : c) @@ -138,6 +142,14 @@ static struct swit switches[] = { { "saslmech", SASLminc(-5) }, #define USERSW 39 { "user", SASLminc(-4) }, +#define PORTSW 40 + { "port server port name/number", 4 }, +#define TLSSW 41 + { "tls", TLSminc(-3) }, +#define FILEPROCSW 42 + { "fileproc", -4 }, +#define MHLPROCSW 43 + { "mhlproc", -3 }, { NULL, 0 } }; @@ -236,6 +248,8 @@ static int nameoutput=0; /* putadr() has output header name */ static int sasl=0; /* Use SASL auth for SMTP */ static char *saslmech=NULL; /* Force use of particular SASL mech */ static char *user=NULL; /* Authenticate as this user */ +static char *port="smtp"; /* Name of server port for SMTP */ +static int tls=0; /* Use TLS for encryption */ static unsigned msgflags = 0; /* what we've seen */ @@ -518,6 +532,27 @@ main (int argc, char **argv) if (!(user = *argp++) || *user == '-') adios (NULL, "missing argument to %s", argp[-2]); continue; + + case PORTSW: + if (!(port = *argp++) || *port == '-') + adios (NULL, "missing argument to %s", argp[-2]); + continue; + + case TLSSW: + tls++; + continue; + + case FILEPROCSW: + if (!(cp = *argp++) || *cp == '-') + adios (NULL, "missing argument to %s", argp[-2]); + fileproc = cp; + continue; + + case MHLPROCSW: + if (!(cp = *argp++) || *cp == '-') + adios (NULL, "missing argument to %s", argp[-2]); + mhlproc = cp; + continue; } } if (msg) @@ -546,13 +581,14 @@ main (int argc, char **argv) if ((out = fopen (fill_in ? fill_in : "/dev/null", "w")) == NULL) adios ("/dev/null", "unable to open"); } else { - strncpy (tmpfil, m_scratch ("", m_maildir (invo_name)), - sizeof(tmpfil)); - if ((out = fopen (tmpfil, "w")) == NULL) { - strncpy (tmpfil, m_tmpfil (invo_name), sizeof(tmpfil)); - if ((out = fopen (tmpfil, "w")) == NULL) - adios (tmpfil, "unable to create"); - } + 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"); + } + } + strncpy(tmpfil, cp, sizeof(tmpfil)); chmod (tmpfil, 0600); } } @@ -654,7 +690,7 @@ putfmt (char *name, char *str, FILE *out) int count, grp, i, keep; char *cp, *pp, *qp; char namep[BUFSIZ]; - struct mailname *mp, *np; + struct mailname *mp = NULL, *np = NULL; struct headers *hdr; while (*str == ' ' || *str == '\t') @@ -1158,11 +1194,12 @@ make_bcc_file (int dashstuff) pid_t child_id; char *vec[6]; FILE *out; + char *tfile = NULL; - strncpy (bccfil, m_tmpfil ("bccs"), sizeof(bccfil)); - if ((out = fopen (bccfil, "w")) == NULL) - adios (bccfil, "unable to create"); + tfile = m_mktemp2(NULL, "bccs", NULL, &out); + if (tfile == NULL) adios("bcc", "unable to create temporary file"); chmod (bccfil, 0600); + strncpy (bccfil, tfile, sizeof(bccfil)); fprintf (out, "Date: %s\n", dtime (&tclock, 0)); if (msgid) @@ -1288,16 +1325,13 @@ make_bcc_file (int dashstuff) static int find_prefix (void) { - int len, result; + int result = OK; unsigned char buffer[BUFSIZ]; FILE *in; if ((in = fopen (tmpfil, "r")) == NULL) adios (tmpfil, "unable to re-open"); - len = strlen (prefix); - - result = OK; while (fgets (buffer, sizeof(buffer) - 1, in)) if (buffer[0] == '-' && buffer[1] == '-') { unsigned char *cp; @@ -1403,9 +1437,9 @@ post (char *file, int bccque, int talk) sigon (); - if (rp_isbad (retval = sm_init (clientsw, serversw, watch, verbose, + if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch, verbose, snoop, onex, queued, sasl, saslmech, - user)) + user, tls)) || rp_isbad (retval = sm_winit (smtpmode, from))) die (NULL, "problem initializing server; %s", rp_string (retval)); @@ -1442,8 +1476,9 @@ verify_all_addresses (int talk) sigon (); if (!whomsw || checksw) - if (rp_isbad (retval = sm_init (clientsw, serversw, watch, verbose, snoop, 0, - queued, sasl, saslmech, user)) + if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch, + verbose, snoop, 0, queued, sasl, + saslmech, user, tls)) || rp_isbad (retval = sm_winit (smtpmode, from))) die (NULL, "problem initializing server; %s", rp_string (retval));