]> diplodocus.org Git - nmh/blobdiff - uip/post.c
Newer versions of Automake want to include the test-driver script,
[nmh] / uip / post.c
index 16121359ee711178ea1bb08d50b55dafd199f129..db457ad2517355366dbf0086b8e0d55bede1853b 100644 (file)
     X("server host", 6, SERVSW) /* specify alternate SMTP server */ \
     X("snoop", -5, SNOOPSW) /* snoop the SMTP transaction */ \
     X("partno", -6, PARTSW) \
     X("server host", 6, SERVSW) /* specify alternate SMTP server */ \
     X("snoop", -5, SNOOPSW) /* snoop the SMTP transaction */ \
     X("partno", -6, PARTSW) \
-    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 submission port name/number", 4, PORTSW) \
     X("tls", TLSminc(-3), TLSSW) \
     X("user", SASLminc(-4), USERSW) \
     X("port server submission port name/number", 4, PORTSW) \
     X("tls", TLSminc(-3), TLSSW) \
@@ -87,6 +88,7 @@
     X("notls", TLSminc(-5), NTLSSW) \
     X("fileproc", -4, FILEPROCSW) \
     X("mhlproc", -3, MHLPROCSW) \
     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) \
     X("mts smtp|sendmail/smtp|sendmail/pipe", 2, MTSSW) \
     X("credentials legacy|file:filename", 0, CREDENTIALSSW) \
     X("messageid localname|random", 2, MESSAGEIDSW) \
@@ -256,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 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 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);
 static void do_text (char *file, int fd);
 static void do_an_address (struct mailname *, int);
 static void do_addresses (int, int);
@@ -278,6 +280,7 @@ main (int argc, char **argv)
     char buf[BUFSIZ], name[NAMESZ];
     FILE *in, *out;
     m_getfld_state_t gstate = 0;
     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; }
 
 
     if (nmh_init(argv[0], 0 /* use context_foil() */)) { return 1; }
 
@@ -438,7 +441,16 @@ main (int argc, char **argv)
                    if (!(saslmech = *argp++) || *saslmech == '-')
                        adios (NULL, "missing argument to %s", argp[-2]);
                    continue;
                    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]);
                case USERSW:
                    if (!(user = *argp++) || *user == '-')
                        adios (NULL, "missing argument to %s", argp[-2]);
@@ -473,6 +485,12 @@ main (int argc, char **argv)
                    mhlproc = cp;
                    continue;
 
                    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]);
                case MTSSW:
                    if (!(cp = *argp++) || *cp == '-')
                        adios (NULL, "missing argument to %s", argp[-2]);
@@ -620,7 +638,7 @@ main (int argc, char **argv)
     /* If we are doing a "whom" check */
     if (whomsw) {
        /* This won't work with MTS_SENDMAIL_PIPE. */
     /* 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);
     }
 
        done (0);
     }
 
@@ -632,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 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 {
        (void) m_unlink (bccfil);
     } else {
-       post (tmpfil, 0, isatty (1), envelope);
+       post (tmpfil, 0, isatty (1), envelope, xoauth_client_res);
     }
 
     p_refile (tmpfil);
     }
 
     p_refile (tmpfil);
@@ -714,7 +732,7 @@ putfmt (char *name, char *str, FILE *out)
     if (hdr->flags & HFCC) {
        if ((cp = strrchr(str, '\n')))
            *cp = 0;
     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);
        }
            *cp++ = 0;
            insert_fcc (hdr, pp);
        }
@@ -1486,7 +1504,8 @@ do_addresses (int bccque, int talk)
  */
 
 static void
  */
 
 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;
 {
     int fd;
     int        retval, i;
@@ -1536,8 +1555,8 @@ post (char *file, int bccque, int talk, char *envelope)
     } else {
         if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch,
                                         verbose, snoop, sasl, saslssf,
     } else {
         if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch,
                                         verbose, snoop, sasl, saslssf,
-                                       saslmech, user, tls))  ||
-            rp_isbad (retval = sm_winit (envelope)))
+                                       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);
            die (NULL, "problem initializing server; %s", rp_string (retval));
 
         do_addresses (bccque, talk && verbose);
@@ -1566,7 +1585,7 @@ post (char *file, int bccque, int talk, char *envelope)
 /* Address Verification */
 
 static void
 /* 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;
 {
     int retval;
     struct mailname *lp;
@@ -1576,7 +1595,7 @@ verify_all_addresses (int talk, char *envelope)
     if (!whomsw || checksw)
        if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch,
                                        verbose, snoop, sasl, saslssf,
     if (!whomsw || checksw)
        if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch,
                                        verbose, snoop, sasl, saslssf,
-                                       saslmech, user, tls))
+                                       saslmech, user, xoauth_client_res, tls))
                || rp_isbad (retval = sm_winit (envelope)))
            die (NULL, "problem initializing server; %s", rp_string (retval));
 
                || rp_isbad (retval = sm_winit (envelope)))
            die (NULL, "problem initializing server; %s", rp_string (retval));