diff options
Diffstat (limited to 'imap/src/c-client')
-rw-r--r-- | imap/src/c-client/imap4r1.c | 2 | ||||
-rw-r--r-- | imap/src/c-client/mail.c | 35 | ||||
-rw-r--r-- | imap/src/c-client/mail.h | 9 | ||||
-rw-r--r-- | imap/src/c-client/nntp.c | 5 | ||||
-rw-r--r-- | imap/src/c-client/pop3.c | 3 |
5 files changed, 51 insertions, 3 deletions
diff --git a/imap/src/c-client/imap4r1.c b/imap/src/c-client/imap4r1.c index 1409b37d..96d1fa19 100644 --- a/imap/src/c-client/imap4r1.c +++ b/imap/src/c-client/imap4r1.c @@ -1156,6 +1156,7 @@ long imap_auth (MAILSTREAM *stream,NETMBX *mb,char *tmp,char *usr) } /* no error if protocol-initiated cancel */ lsterr = cpystr (reply->text); + delete_password(mb, usr); } } while (LOCAL->netstream && !LOCAL->byeseen && trial && @@ -1207,6 +1208,7 @@ long imap_login (MAILSTREAM *stream,NETMBX *mb,char *pwd,char *usr) if (imap_OK (stream,reply = imap_send (stream,"LOGIN",args))) ret = LONGT; /* success */ else { + delete_password(mb, usr); mm_log (reply->text,WARN); if (!LOCAL->referral && (trial == imap_maxlogintrials)) mm_log ("Too many login failures",ERROR); diff --git a/imap/src/c-client/mail.c b/imap/src/c-client/mail.c index d80a01f6..8fd55265 100644 --- a/imap/src/c-client/mail.c +++ b/imap/src/c-client/mail.c @@ -52,6 +52,8 @@ static mailcache_t mailcache = mm_cache; static rfc822out_t mail822out = NIL; /* RFC-822 output generator (new style) */ static rfc822outfull_t mail822outfull = NIL; + /* Erase password (client side) */ +static deletepwd_t erase_password = NIL; /* SMTP verbose callback */ static smtpverbose_t mailsmtpverbose = mm_dlog; /* proxy copy routine */ @@ -544,6 +546,11 @@ void *mail_parameters (MAILSTREAM *stream,long function,void *value) case GET_SENDCOMMAND: ret = (void *) mailsendcommand; break; + case SET_ERASEPASSWORD: + erase_password = (deletepwd_t) value; + case GET_ERASEPASSWORD: + ret = (void *) erase_password; + break; case SET_SERVICENAME: servicename = (char *) value; @@ -991,7 +998,7 @@ long mail_create (MAILSTREAM *stream,char *mailbox) MAILSTREAM *ts; char *s,*t,tmp[MAILTMPLEN]; size_t i; - DRIVER *d; + DRIVER *d, *md; /* never allow names with newlines */ if (s = strpbrk (mailbox,"\015\012")) { MM_LOG ("Can't create mailbox with such a name",ERROR); @@ -1015,6 +1022,8 @@ long mail_create (MAILSTREAM *stream,char *mailbox) return NIL; } + /* Hack, we should do this better, but it works */ + for (md = maildrivers; md && strcmp (md->name, "md"); md = md->next); /* see if special driver hack */ if ((mailbox[0] == '#') && ((mailbox[1] == 'd') || (mailbox[1] == 'D')) && ((mailbox[2] == 'r') || (mailbox[2] == 'R')) && @@ -1045,6 +1054,13 @@ long mail_create (MAILSTREAM *stream,char *mailbox) (((*mailbox == '{') || (*mailbox == '#')) && (stream = mail_open (NIL,mailbox,OP_PROTOTYPE | OP_SILENT)))) d = stream->dtb; + else if(mailbox[0] == '#' + && (mailbox[1] == 'm' || mailbox[1] == 'M') + && (mailbox[2] == 'd' || mailbox[2] == 'D' + || mailbox[2] == 'c' || mailbox[2] == 'C') + && mailbox[3] == '/' + && mailbox[4] != '\0') + return (*md->create)(stream, mailbox); else if ((*mailbox != '{') && (ts = default_proto (NIL))) d = ts->dtb; else { /* failed utterly */ sprintf (tmp,"Can't create mailbox %.80s: indeterminate format",mailbox); @@ -3352,13 +3368,13 @@ unsigned long mail_filter (char *text,unsigned long len,STRINGLIST *lines, long flags) { STRINGLIST *hdrs; - int notfound; + int notfound, fix = text[len - 1] == '\0'; unsigned long i; char c,*s,*e,*t,tmp[MAILTMPLEN]; char *src = text; char *dst = src; char *end = text + len; - text[len] = '\012'; /* guard against running off buffer */ + text[fix ? len - 1 : len] = '\012'; /* guard against running off buffer */ while (src < end) { /* process header */ /* slurp header line name */ for (s = src,e = s + MAILTMPLEN - 1,e = (e < end ? e : end),t = tmp; @@ -3397,6 +3413,10 @@ unsigned long mail_filter (char *text,unsigned long len,STRINGLIST *lines, } } *dst = '\0'; /* tie off destination */ + if(fix){ + text[len] = '\012'; + text[len-1] = '\0'; + } return dst - text; } @@ -6121,6 +6141,15 @@ unsigned int mail_lookup_auth_name (char *mechanism,long flags) return i; return 0; } +/* Client side callback warning to delete wrong password + * + */ +void delete_password(NETMBX *mb, char *user) +{ + deletepwd_t ep = mail_parameters(NULL, GET_ERASEPASSWORD, NULL); + if (ep) (ep)(mb, user); +} + /* Standard TCP/IP network driver */ diff --git a/imap/src/c-client/mail.h b/imap/src/c-client/mail.h index 174993e1..0af362e6 100644 --- a/imap/src/c-client/mail.h +++ b/imap/src/c-client/mail.h @@ -177,6 +177,8 @@ #define SET_EXTERNALAUTHID (long) 230 #define GET_SSLCAPATH (long) 231 #define SET_SSLCAPATH (long) 232 +#define GET_ERASEPASSWORD (long) 233 +#define SET_ERASEPASSWORD (long) 234 /* 3xx: TCP/IP */ #define GET_OPENTIMEOUT (long) 300 @@ -353,6 +355,10 @@ #define SET_SCANCONTENTS (long) 573 #define GET_MHALLOWINBOX (long) 574 #define SET_MHALLOWINBOX (long) 575 +#define GET_COURIERSTYLE (long) 576 +#define SET_COURIERSTYLE (long) 577 +#define SET_MDINBOXPATH (long) 578 +#define GET_MDINBOXPATH (long) 579 /* Driver flags */ @@ -1326,6 +1332,7 @@ typedef ADDRESS *(*parsephrase_t) (char *phrase,char *end,char *host); typedef void *(*blocknotify_t) (int reason,void *data); typedef long (*kinit_t) (char *host,char *reason); typedef void (*sendcommand_t) (MAILSTREAM *stream,char *cmd,long flags); +typedef void (*deletepwd_t) (NETMBX *mb,char *user); typedef char *(*newsrcquery_t) (MAILSTREAM *stream,char *mulname,char *name); typedef void (*getacl_t) (MAILSTREAM *stream,char *mailbox,ACLLIST *acl); typedef void (*listrights_t) (MAILSTREAM *stream,char *mailbox,char *id, @@ -1605,6 +1612,8 @@ long mm_diskerror (MAILSTREAM *stream,long errcode,long serious); void mm_fatal (char *string); void *mm_cache (MAILSTREAM *stream,unsigned long msgno,long op); +void delete_password (NETMBX *mb, char *user); + extern STRINGDRIVER mail_string; void mail_versioncheck (char *version); void mail_link (DRIVER *driver); diff --git a/imap/src/c-client/nntp.c b/imap/src/c-client/nntp.c index fe90edba..8fbcb9b7 100644 --- a/imap/src/c-client/nntp.c +++ b/imap/src/c-client/nntp.c @@ -2031,6 +2031,7 @@ long nntp_send_auth_work (SENDSTREAM *stream,NETMBX *mb,char *pwd,long flags) sprintf (tmp,"Retrying using %s authentication after %.80s", at->name,lsterr); mm_log (tmp,NIL); + delete_password(mb, mb ? mb->user : NULL); fs_give ((void **) &lsterr); } trial = 0; /* initial trial count */ @@ -2039,6 +2040,7 @@ long nntp_send_auth_work (SENDSTREAM *stream,NETMBX *mb,char *pwd,long flags) if (lsterr) { sprintf (tmp,"Retrying %s authentication after %.80s",at->name,lsterr); mm_log (tmp,WARN); + delete_password(mb, mb ? mb->user : NULL); fs_give ((void **) &lsterr); } stream->saslcancel = NIL; @@ -2064,6 +2066,7 @@ long nntp_send_auth_work (SENDSTREAM *stream,NETMBX *mb,char *pwd,long flags) sprintf (tmp,"Can not authenticate to NNTP server: %.80s",lsterr); mm_log (tmp,ERROR); } + delete_password(mb, mb ? mb->user : NULL); fs_give ((void **) &lsterr); } else if (mb->secflag) /* no SASL, can't do /secure */ @@ -2092,6 +2095,8 @@ long nntp_send_auth_work (SENDSTREAM *stream,NETMBX *mb,char *pwd,long flags) stream->sensitive = T; /* hide this command */ if (nntp_send_work (stream,"AUTHINFO PASS",pwd) == NNTPAUTHED) ret = LONGT; /* password OK */ + else + delete_password(mb, mb ? mb->user : NULL); stream->sensitive = NIL; /* unhide */ if (ret) break; /* OK if successful */ default: /* authentication failed */ diff --git a/imap/src/c-client/pop3.c b/imap/src/c-client/pop3.c index 58a9ceb6..1b411546 100644 --- a/imap/src/c-client/pop3.c +++ b/imap/src/c-client/pop3.c @@ -615,6 +615,7 @@ long pop3_auth (MAILSTREAM *stream,NETMBX *mb,char *pwd,char *usr) sprintf (pwd,"Retrying using %.80s authentication after %.80s", at->name,t); mm_log (pwd,NIL); + delete_password(mb, usr); fs_give ((void **) &t); } trial = 0; /* initial trial count */ @@ -622,6 +623,7 @@ long pop3_auth (MAILSTREAM *stream,NETMBX *mb,char *pwd,char *usr) if (t) { sprintf (pwd,"Retrying %s authentication after %.80s",at->name,t); mm_log (pwd,WARN); + delete_password(mb, usr); fs_give ((void **) &t); } LOCAL->saslcancel = NIL; @@ -667,6 +669,7 @@ long pop3_auth (MAILSTREAM *stream,NETMBX *mb,char *pwd,char *usr) LOCAL->sensitive=NIL; /* unhide */ } if (!ret) { /* failure */ + delete_password(mb, usr); mm_log (LOCAL->reply,WARN); if (trial == pop3_maxlogintrials) mm_log ("Too many login failures",ERROR); |