Mercurial > hgrepos > hgweb.cgi > imapext
comparison src/ipopd/ipop3d.c @ 4:d741b3ecc917 draft
imapext-2007f
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 30 Oct 2014 00:03:05 +0900 |
parents | 2366b362676d |
children |
comparison
equal
deleted
inserted
replaced
3:2366b362676d | 4:d741b3ecc917 |
---|---|
94 void kodint (); | 94 void kodint (); |
95 void hupint (); | 95 void hupint (); |
96 void trmint (); | 96 void trmint (); |
97 int pass_login (char *t,int argc,char *argv[]); | 97 int pass_login (char *t,int argc,char *argv[]); |
98 char *apop_login (char *chal,char *user,char *md5,int argc,char *argv[]); | 98 char *apop_login (char *chal,char *user,char *md5,int argc,char *argv[]); |
99 #ifdef QMAIL | |
100 char* conv_virtualdomain(char *account); | |
101 #endif | |
99 char *responder (void *challenge,unsigned long clen,unsigned long *rlen); | 102 char *responder (void *challenge,unsigned long clen,unsigned long *rlen); |
100 int mbxopen (char *mailbox); | 103 int mbxopen (char *mailbox); |
101 long blat (char *text,long lines,unsigned long size,STRING *st); | 104 long blat (char *text,long lines,unsigned long size,STRING *st); |
102 void rset (); | 105 void rset (); |
103 | 106 |
126 } | 129 } |
127 { /* set up MD5 challenge */ | 130 { /* set up MD5 challenge */ |
128 AUTHENTICATOR *auth = mail_lookup_auth (1); | 131 AUTHENTICATOR *auth = mail_lookup_auth (1); |
129 while (auth && compare_cstring (auth->name,"CRAM-MD5")) auth = auth->next; | 132 while (auth && compare_cstring (auth->name,"CRAM-MD5")) auth = auth->next; |
130 /* build challenge -- less than 128 chars */ | 133 /* build challenge -- less than 128 chars */ |
134 #ifndef QMAIL | |
135 if (!(auth->flags & AU_DISABLE)) | |
136 #else | |
131 if (auth && auth->server && !(auth->flags & AU_DISABLE)) | 137 if (auth && auth->server && !(auth->flags & AU_DISABLE)) |
138 #endif | |
132 sprintf (challenge,"<%lx.%lx@%.64s>",(unsigned long) getpid (), | 139 sprintf (challenge,"<%lx.%lx@%.64s>",(unsigned long) getpid (), |
133 (unsigned long) time (0),tcp_serverhost ()); | 140 (unsigned long) time (0),tcp_serverhost ()); |
134 else challenge[0] = '\0'; /* no MD5 authentication */ | 141 else challenge[0] = '\0'; /* no MD5 authentication */ |
135 } | 142 } |
136 /* There are reports of POP3 clients which get upset if anything appears | 143 /* There are reports of POP3 clients which get upset if anything appears |
256 if (user) fs_give ((void **) &user); | 263 if (user) fs_give ((void **) &user); |
257 if (pass) fs_give ((void **) &pass); | 264 if (pass) fs_give ((void **) &pass); |
258 /* get user name */ | 265 /* get user name */ |
259 if (!(t && *t && (s = strtok (t," ")) && (t = strtok(NIL,"\012")))) | 266 if (!(t && *t && (s = strtok (t," ")) && (t = strtok(NIL,"\012")))) |
260 PSOUT ("-ERR Missing APOP argument\015\012"); | 267 PSOUT ("-ERR Missing APOP argument\015\012"); |
261 else if (!(user = apop_login (challenge,s,t,argc,argv))) | 268 #ifdef QMAIL |
262 PSOUT ("-ERR Bad APOP\015\012"); | 269 else if (!(user = apop_login (challenge,conv_virtualdomain(s),t,argc,argv))) { |
263 else if ((state = mbxopen ("INBOX")) == TRANSACTION) | 270 #else /* !QMAIL */ |
264 syslog (LOG_INFO,"APOP user=%.80s host=%.80s nmsgs=%lu/%lu", | 271 else if (!(user = apop_login (challenge,s,t,argc,argv))) { |
272 #endif /* QMAIL */ | |
273 PSOUT ("-ERR Bad APOP (Maybe your password is expired)\015\012"); | |
274 user = cpystr (s); | |
275 syslog (LOG_INFO,"APOP login failure user=%.80s host=%.80s", | |
276 user,tcp_clienthost ()); | |
277 } else if ((state = mbxopen ("INBOX")) == TRANSACTION) | |
278 syslog (LOG_INFO,"APOP user=%.80s host=%.80s nmsgs=%ld/%ld", | |
265 user,tcp_clienthost (),nmsgs,stream->nmsgs); | 279 user,tcp_clienthost (),nmsgs,stream->nmsgs); |
266 else syslog (LOG_INFO,"APOP user=%.80s host=%.80s no mailbox", | 280 else syslog (LOG_INFO,"APOP user=%.80s host=%.80s no mailbox", |
267 user,tcp_clienthost ()); | 281 user,tcp_clienthost ()); |
268 } | 282 } |
269 else PSOUT ("-ERR Not supported\015\012"); | 283 else PSOUT ("-ERR Not supported\015\012"); |
277 PSOUT (t); | 291 PSOUT (t); |
278 CRLF; | 292 CRLF; |
279 } | 293 } |
280 else PSOUT ("+OK STLS completed\015\012"); | 294 else PSOUT ("+OK STLS completed\015\012"); |
281 } | 295 } |
296 #ifndef RESTRICT_POP | |
282 else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) && | 297 else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) && |
283 !strcmp (s,"USER")) { | 298 !strcmp (s,"USER")) { |
299 #else /* !RESTRICT_POP */ | |
300 else if (!strcmp (s,"USER")) { | |
301 if (getenv("INTRANET") == NIL) { | |
302 PSOUT("-ERR Sorry, we don't allow POP3 from your network. Use APOP instead.\015\012"); | |
303 user = cpystr(t); | |
304 syslog (LOG_INFO,"Plain POP3 is restricted user=%.80s host=%.80s", | |
305 user,tcp_clienthost ()); | |
306 memset(user, '\0', strlen(user)); | |
307 break; | |
308 } | |
309 #endif | |
284 if (host) fs_give ((void **) &host); | 310 if (host) fs_give ((void **) &host); |
285 if (user) fs_give ((void **) &user); | 311 if (user) fs_give ((void **) &user); |
286 if (pass) fs_give ((void **) &pass); | 312 if (pass) fs_give ((void **) &pass); |
287 if (t && *t) { /* if user name given */ | 313 if (t && *t) { /* if user name given */ |
288 /* skip leading whitespace (bogus clients!) */ | 314 /* skip leading whitespace (bogus clients!) */ |
292 *s++ = '\0'; /* tie off host name */ | 318 *s++ = '\0'; /* tie off host name */ |
293 host = cpystr (t);/* copy host name */ | 319 host = cpystr (t);/* copy host name */ |
294 user = cpystr (s);/* copy user name */ | 320 user = cpystr (s);/* copy user name */ |
295 } | 321 } |
296 /* local user name */ | 322 /* local user name */ |
323 #ifdef QMAIL | |
324 else user = conv_virtualdomain(cpystr (t)); | |
325 #else | |
297 else user = cpystr (t); | 326 else user = cpystr (t); |
327 #endif | |
298 PSOUT ("+OK User name accepted, password please\015\012"); | 328 PSOUT ("+OK User name accepted, password please\015\012"); |
299 } | 329 } |
300 else PSOUT ("-ERR Missing username argument\015\012"); | 330 else PSOUT ("-ERR Missing username argument\015\012"); |
301 } | 331 } |
302 else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) && | 332 else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) && |