diff options
author | Eduardo Chappa <chappa@washington.edu> | 2019-02-15 09:25:43 -0700 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2019-02-15 09:25:43 -0700 |
commit | 7da08008606c282cd08440d2f9310cc718c62946 (patch) | |
tree | b9b3b7f7908a10266c263e8d4cbc889f1c0a3053 | |
parent | 8ee1778a57c78b88e203ba20291d61d3e7cd0507 (diff) | |
download | alpine-7da08008606c282cd08440d2f9310cc718c62946.tar.xz |
* Add /auth=XYZ to the way to define a server. This allows users to
select the method to authenticate to an IMAP, SMTP or POP3 server.
Examples are /auth=plain, or /auth=gssapi, etc.
-rw-r--r-- | imap/src/c-client/mail.c | 2 | ||||
-rw-r--r-- | imap/src/c-client/mail.h | 2 | ||||
-rw-r--r-- | imap/src/c-client/pop3.c | 19 | ||||
-rw-r--r-- | imap/src/c-client/smtp.c | 17 |
4 files changed, 36 insertions, 4 deletions
diff --git a/imap/src/c-client/mail.c b/imap/src/c-client/mail.c index 8ac8ba63..ae828751 100644 --- a/imap/src/c-client/mail.c +++ b/imap/src/c-client/mail.c @@ -806,6 +806,8 @@ long mail_valid_net_parse_work (char *name,NETMBX *mb,char *service) strcpy (mb->user,v); else if (!compare_cstring (s,"authuser") && (i < NETMAXUSER) && !*mb->authuser) strcpy (mb->authuser,v); + else if (!compare_cstring (s,"auth") && (i < NETMAXAUTH) && + !*mb->auth) strcpy (mb->auth,v); else return NIL; } diff --git a/imap/src/c-client/mail.h b/imap/src/c-client/mail.h index e5755e54..73f6521c 100644 --- a/imap/src/c-client/mail.h +++ b/imap/src/c-client/mail.h @@ -680,10 +680,12 @@ STRINGLIST { #define NETMAXUSER 65 #define NETMAXMBX (MAILTMPLEN/4) #define NETMAXSRV 21 +#define NETMAXAUTH 16 typedef struct net_mailbox { char host[NETMAXHOST]; /* host name (may be canonicalized) */ char orighost[NETMAXHOST]; /* host name before canonicalization */ char user[NETMAXUSER]; /* user name */ + char auth[NETMAXAUTH]; /* authenticator name (PLAIN, etc.) */ char authuser[NETMAXUSER]; /* authentication user name */ char mailbox[NETMAXMBX]; /* mailbox name */ char service[NETMAXSRV]; /* service name */ diff --git a/imap/src/c-client/pop3.c b/imap/src/c-client/pop3.c index 46c050ee..80f1858d 100644 --- a/imap/src/c-client/pop3.c +++ b/imap/src/c-client/pop3.c @@ -553,9 +553,9 @@ long pop3_capa (MAILSTREAM *stream,long flags) long pop3_auth (MAILSTREAM *stream,NETMBX *mb,char *pwd,char *usr) { - unsigned long i,trial,auths = 0; + unsigned long i,trial,auths = 0, authsaved; char *t; - AUTHENTICATOR *at; + AUTHENTICATOR *at, *atsaved; long ret = NIL; long flags = (stream->secure ? AU_SECURE : NIL) | (mb->authuser[0] ? AU_AUTHUSER : NIL); @@ -612,6 +612,15 @@ long pop3_auth (MAILSTREAM *stream,NETMBX *mb,char *pwd,char *usr) } for (t = NIL, LOCAL->saslcancel = NIL; !ret && LOCAL->netstream && auths && (at = mail_lookup_auth (find_rightmost_bit (&auths)+1)); ) { + if(mb && *mb->auth){ + if(!compare_cstring(at->name, mb->auth)) + atsaved = at; + else{ + authsaved = auths; + continue; + } + } + if (t) { /* previous authenticator failed? */ sprintf (pwd,"Retrying using %.80s authentication after %.80s", at->name,t); @@ -649,6 +658,12 @@ long pop3_auth (MAILSTREAM *stream,NETMBX *mb,char *pwd,char *usr) } fs_give ((void **) &t); } + if(mb && *mb->auth){ + if(!authsaved) sprintf (pwd,"Client does not support AUTH=%.80s authenticator",mb->auth); + else if (!atsaved) sprintf (pwd,"POP server does not support AUTH=%.80s authenticator",mb->auth); + if (!authsaved || !atsaved) mm_log (pwd,ERROR); + } + } else if (stream->secure) diff --git a/imap/src/c-client/smtp.c b/imap/src/c-client/smtp.c index d614ef97..d1c9a7cb 100644 --- a/imap/src/c-client/smtp.c +++ b/imap/src/c-client/smtp.c @@ -281,14 +281,22 @@ SENDSTREAM *smtp_open_full (NETDRIVER *dv,char **hostlist,char *service, long smtp_auth (SENDSTREAM *stream,NETMBX *mb,char *tmp) { - unsigned long trial,auths; + unsigned long trial,auths, authsaved; char *lsterr = NIL; char usr[MAILTMPLEN]; - AUTHENTICATOR *at; + AUTHENTICATOR *at, *atsaved; long ret = NIL; for (auths = ESMTP.auth, stream->saslcancel = NIL; !ret && stream->netstream && auths && (at = mail_lookup_auth (find_rightmost_bit (&auths) + 1)); ) { + if(mb && *mb->auth){ + if(!compare_cstring(at->name, mb->auth)) + atsaved = at; + else{ + authsaved = auths; + continue; + } + } if (lsterr) { /* previous authenticator failed? */ sprintf (tmp,"Retrying using %s authentication after %.80s", at->name,lsterr); @@ -330,6 +338,11 @@ long smtp_auth (SENDSTREAM *stream,NETMBX *mb,char *tmp) } fs_give ((void **) &lsterr); } + if(mb && *mb->auth){ + if(!authsaved) sprintf (tmp, "Client does not support AUTH=%.80s authenticator",mb->auth); + else if (!atsaved) sprintf (tmp,"SMTP server does not support AUTH=%.80s authenticator",mb->auth); + if (!authsaved || !atsaved) mm_log (tmp,ERROR); + } return ret; /* authentication failed */ } |