X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/dc5d7a6edaba9fe7306e972b926aa4766f6b58ba..9986784343b5e29b4e3160932b4cd2dcfe21f71a:/uip/post.c?ds=inline diff --git a/uip/post.c b/uip/post.c index 8cfcf651..db457ad2 100644 --- a/uip/post.c +++ b/uip/post.c @@ -76,18 +76,19 @@ 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) \ - X("saslmech", SASLminc(-5), SASLMECHSW) \ + X("sasl", SASLminc(4), SASLSW) \ + X("nosasl", SASLminc(6), NOSASLSW) \ + X("saslmaxssf", SASLminc(10), SASLMXSSFSW) \ + X("saslmech", SASLminc(5), SASLMECHSW) \ + X("authservice", SASLminc(0), AUTHSERVICESW) \ X("user", SASLminc(-4), USERSW) \ - X("port server port name/number", 4, PORTSW) \ + X("port server submission port name/number", 4, PORTSW) \ X("tls", TLSminc(-3), TLSSW) \ X("initialtls", TLSminc(-10), INITTLSSW) \ X("notls", TLSminc(-5), NTLSSW) \ X("fileproc", -4, FILEPROCSW) \ X("mhlproc", -3, MHLPROCSW) \ + X("sendmail program", 0, MTSSM) \ X("mts smtp|sendmail/smtp|sendmail/pipe", 2, MTSSW) \ X("credentials legacy|file:filename", 0, CREDENTIALSSW) \ X("messageid localname|random", 2, MESSAGEIDSW) \ @@ -201,8 +202,8 @@ static int sasl=0; /* Use SASL auth for SMTP */ static int saslssf=-1; /* Our maximum SSF for SASL */ 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 char *port="submission"; /* Name of server port for SMTP submission */ +static int tls=-1; /* Use TLS for encryption */ static int fromcount=0; /* Count of addresses on From: header */ static int seensender=0; /* Have we seen a Sender: header? */ @@ -241,7 +242,6 @@ static char *serversw = NULL; static char prefix[] = "----- =_aaaaaaaaaa"; static char *partno = NULL; -static int queued = 0; /* * static prototypes @@ -258,14 +258,14 @@ static void anno (void); static int annoaux (struct mailname *); static void insert_fcc (struct headers *, char *); static void make_bcc_file (int); -static void verify_all_addresses (int, char *); +static void verify_all_addresses (int, char *, const char *); static void chkadr (void); static void sigon (void); static void sigoff (void); static void p_refile (char *); static void fcc (char *, char *); static void die (char *, char *, ...); -static void post (char *, int, int, char *); +static void post (char *, int, int, char *, const char *); static void do_text (char *file, int fd); static void do_an_address (struct mailname *, int); static void do_addresses (int, int); @@ -280,6 +280,7 @@ main (int argc, char **argv) char buf[BUFSIZ], name[NAMESZ]; FILE *in, *out; m_getfld_state_t gstate = 0; + char *xoauth_client_res = NULL; if (nmh_init(argv[0], 0 /* use context_foil() */)) { return 1; } @@ -422,10 +423,6 @@ main (int argc, char **argv) adios (NULL, "missing argument to %s", argp[-2]); continue; - case QUEUESW: - queued++; - continue; - case SASLSW: sasl++; continue; @@ -444,7 +441,16 @@ main (int argc, char **argv) if (!(saslmech = *argp++) || *saslmech == '-') adios (NULL, "missing argument to %s", argp[-2]); continue; - + + case AUTHSERVICESW: +#ifdef OAUTH_SUPPORT + if (!(xoauth_client_res = *argp++) || *xoauth_client_res == '-') + adios (NULL, "missing argument to %s", argp[-2]); +#else + adios (NULL, "not built with OAuth support"); +#endif + continue; + case USERSW: if (!(user = *argp++) || *user == '-') adios (NULL, "missing argument to %s", argp[-2]); @@ -479,6 +485,12 @@ main (int argc, char **argv) mhlproc = cp; continue; + case MTSSM: + if (!(cp = *argp++) || *cp == '-') + adios (NULL, "missing argument to %s", argp[-2]); + sendmail = cp; + continue; + case MTSSW: if (!(cp = *argp++) || *cp == '-') adios (NULL, "missing argument to %s", argp[-2]); @@ -608,10 +620,25 @@ main (int argc, char **argv) envelope = from; } + if (tls == -1) { +#ifdef TLS_SUPPORT + /* + * The user didn't specify any of the tls switches. Try to + * help them by implying -initialtls if they're using port 465 + * (smtps, until IANA revoked that registration in 1998). + */ + tls = ! strcmp (port, "465") || ! strcasecmp (port, "smtps") + ? 2 + : 0; +#else /* ! TLS_SUPPORT */ + tls = 0; +#endif /* ! TLS_SUPPORT */ + } + /* If we are doing a "whom" check */ if (whomsw) { /* This won't work with MTS_SENDMAIL_PIPE. */ - verify_all_addresses (1, envelope); + verify_all_addresses (1, envelope, xoauth_client_res); done (0); } @@ -623,14 +650,14 @@ main (int argc, char **argv) verify_all_addresses with MTS_SENDMAIL_PIPE, but that might require running sendmail as root. Note that spost didn't verify addresses. */ - verify_all_addresses (verbose, envelope); + verify_all_addresses (verbose, envelope, xoauth_client_res); } - post (tmpfil, 0, verbose, envelope); + post (tmpfil, 0, verbose, envelope, xoauth_client_res); } - post (bccfil, 1, verbose, envelope); + post (bccfil, 1, verbose, envelope, xoauth_client_res); (void) m_unlink (bccfil); } else { - post (tmpfil, 0, isatty (1), envelope); + post (tmpfil, 0, isatty (1), envelope, xoauth_client_res); } p_refile (tmpfil); @@ -705,7 +732,7 @@ putfmt (char *name, char *str, FILE *out) if (hdr->flags & HFCC) { if ((cp = strrchr(str, '\n'))) *cp = 0; - for (cp = pp = str; (cp = strchr(pp, ',')); pp = cp) { + for (pp = str; (cp = strchr(pp, ',')); pp = cp) { *cp++ = 0; insert_fcc (hdr, pp); } @@ -1477,7 +1504,8 @@ do_addresses (int bccque, int talk) */ static void -post (char *file, int bccque, int talk, char *envelope) +post (char *file, int bccque, int talk, char *envelope, + const char *xoauth_client_res) { int fd; int retval, i; @@ -1526,9 +1554,9 @@ 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)) || - rp_isbad (retval = sm_winit (envelope))) + verbose, snoop, sasl, saslssf, + saslmech, user, xoauth_client_res, tls)) + || rp_isbad (retval = sm_winit (envelope))) die (NULL, "problem initializing server; %s", rp_string (retval)); do_addresses (bccque, talk && verbose); @@ -1557,7 +1585,7 @@ post (char *file, int bccque, int talk, char *envelope) /* Address Verification */ static void -verify_all_addresses (int talk, char *envelope) +verify_all_addresses (int talk, char *envelope, const char *xoauth_client_res) { int retval; struct mailname *lp; @@ -1566,8 +1594,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, xoauth_client_res, tls)) || rp_isbad (retval = sm_winit (envelope))) die (NULL, "problem initializing server; %s", rp_string (retval));