Mercurial > hgrepos > hgweb.cgi > imapext
diff src/ipopd/ipop3d.c @ 1:28a55bc1110c imapext-2007-1
[mq]: imapext
author | yuuji@gentei.org |
---|---|
date | Mon, 14 Sep 2009 19:23:11 +0900 |
parents | ada5e610ab86 |
children | 2366b362676d |
line wrap: on
line diff
--- a/src/ipopd/ipop3d.c Mon Sep 14 15:17:45 2009 +0900 +++ b/src/ipopd/ipop3d.c Mon Sep 14 19:23:11 2009 +0900 @@ -96,6 +96,9 @@ void trmint (); int pass_login (char *t,int argc,char *argv[]); char *apop_login (char *chal,char *user,char *md5,int argc,char *argv[]); +#ifdef QMAIL +char* conv_virtualdomain(char *account); +#endif char *responder (void *challenge,unsigned long clen,unsigned long *rlen); int mbxopen (char *mailbox); long blat (char *text,long lines,unsigned long size,STRING *st); @@ -128,7 +131,11 @@ AUTHENTICATOR *auth = mail_lookup_auth (1); while (auth && compare_cstring (auth->name,"CRAM-MD5")) auth = auth->next; /* build challenge -- less than 128 chars */ +#ifndef QMAIL + if (!(auth->flags & AU_DISABLE)) +#else if (auth && auth->server && !(auth->flags & AU_DISABLE)) +#endif sprintf (challenge,"<%lx.%lx@%.64s>",(unsigned long) getpid (), (unsigned long) time (0),tcp_serverhost ()); else challenge[0] = '\0'; /* no MD5 authentication */ @@ -258,10 +265,17 @@ /* get user name */ if (!(t && *t && (s = strtok (t," ")) && (t = strtok(NIL,"\012")))) PSOUT ("-ERR Missing APOP argument\015\012"); - else if (!(user = apop_login (challenge,s,t,argc,argv))) - PSOUT ("-ERR Bad APOP\015\012"); - else if ((state = mbxopen ("INBOX")) == TRANSACTION) - syslog (LOG_INFO,"APOP user=%.80s host=%.80s nmsgs=%lu/%lu", + #ifdef QMAIL + else if (!(user = apop_login (challenge,conv_virtualdomain(s),t,argc,argv))) { + #else /* !QMAIL */ + else if (!(user = apop_login (challenge,s,t,argc,argv))) { + #endif /* QMAIL */ + PSOUT ("-ERR Bad APOP (Maybe your password is expired)\015\012"); + user = cpystr (s); + syslog (LOG_INFO,"APOP login failure user=%.80s host=%.80s", + user,tcp_clienthost ()); + } else if ((state = mbxopen ("INBOX")) == TRANSACTION) + syslog (LOG_INFO,"APOP user=%.80s host=%.80s nmsgs=%ld/%ld", user,tcp_clienthost (),nmsgs,stream->nmsgs); else syslog (LOG_INFO,"APOP user=%.80s host=%.80s no mailbox", user,tcp_clienthost ()); @@ -279,8 +293,20 @@ } else PSOUT ("+OK STLS completed\015\012"); } +#ifndef RESTRICT_POP else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) && !strcmp (s,"USER")) { +#else /* !RESTRICT_POP */ + else if (!strcmp (s,"USER")) { + if (getenv("INTRANET") == NIL) { + PSOUT("-ERR Sorry, we don't allow POP3 from your network. Use APOP instead.\015\012"); + user = cpystr(t); + syslog (LOG_INFO,"Plain POP3 is restricted user=%.80s host=%.80s", + user,tcp_clienthost ()); + memset(user, '\0', strlen(user)); + break; + } +#endif if (host) fs_give ((void **) &host); if (user) fs_give ((void **) &user); if (pass) fs_give ((void **) &pass); @@ -294,7 +320,11 @@ user = cpystr (s);/* copy user name */ } /* local user name */ +#ifdef QMAIL + else user = conv_virtualdomain(cpystr (t)); +#else else user = cpystr (t); +#endif PSOUT ("+OK User name accepted, password please\015\012"); } else PSOUT ("-ERR Missing username argument\015\012");