comparison src/ipopd/ipop3d.c @ 3:2366b362676d draft

imap-2007f
author HIROSE Yuuji <yuuji@gentei.org>
date Thu, 30 Oct 2014 00:00:57 +0900
parents 28a55bc1110c
children d741b3ecc917
comparison
equal deleted inserted replaced
2:fc6002700ecd 3:2366b362676d
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
102 char *responder (void *challenge,unsigned long clen,unsigned long *rlen); 99 char *responder (void *challenge,unsigned long clen,unsigned long *rlen);
103 int mbxopen (char *mailbox); 100 int mbxopen (char *mailbox);
104 long blat (char *text,long lines,unsigned long size,STRING *st); 101 long blat (char *text,long lines,unsigned long size,STRING *st);
105 void rset (); 102 void rset ();
106 103
129 } 126 }
130 { /* set up MD5 challenge */ 127 { /* set up MD5 challenge */
131 AUTHENTICATOR *auth = mail_lookup_auth (1); 128 AUTHENTICATOR *auth = mail_lookup_auth (1);
132 while (auth && compare_cstring (auth->name,"CRAM-MD5")) auth = auth->next; 129 while (auth && compare_cstring (auth->name,"CRAM-MD5")) auth = auth->next;
133 /* build challenge -- less than 128 chars */ 130 /* build challenge -- less than 128 chars */
134 #ifndef QMAIL
135 if (!(auth->flags & AU_DISABLE))
136 #else
137 if (auth && auth->server && !(auth->flags & AU_DISABLE)) 131 if (auth && auth->server && !(auth->flags & AU_DISABLE))
138 #endif
139 sprintf (challenge,"<%lx.%lx@%.64s>",(unsigned long) getpid (), 132 sprintf (challenge,"<%lx.%lx@%.64s>",(unsigned long) getpid (),
140 (unsigned long) time (0),tcp_serverhost ()); 133 (unsigned long) time (0),tcp_serverhost ());
141 else challenge[0] = '\0'; /* no MD5 authentication */ 134 else challenge[0] = '\0'; /* no MD5 authentication */
142 } 135 }
143 /* There are reports of POP3 clients which get upset if anything appears 136 /* There are reports of POP3 clients which get upset if anything appears
263 if (user) fs_give ((void **) &user); 256 if (user) fs_give ((void **) &user);
264 if (pass) fs_give ((void **) &pass); 257 if (pass) fs_give ((void **) &pass);
265 /* get user name */ 258 /* get user name */
266 if (!(t && *t && (s = strtok (t," ")) && (t = strtok(NIL,"\012")))) 259 if (!(t && *t && (s = strtok (t," ")) && (t = strtok(NIL,"\012"))))
267 PSOUT ("-ERR Missing APOP argument\015\012"); 260 PSOUT ("-ERR Missing APOP argument\015\012");
268 #ifdef QMAIL 261 else if (!(user = apop_login (challenge,s,t,argc,argv)))
269 else if (!(user = apop_login (challenge,conv_virtualdomain(s),t,argc,argv))) { 262 PSOUT ("-ERR Bad APOP\015\012");
270 #else /* !QMAIL */ 263 else if ((state = mbxopen ("INBOX")) == TRANSACTION)
271 else if (!(user = apop_login (challenge,s,t,argc,argv))) { 264 syslog (LOG_INFO,"APOP user=%.80s host=%.80s nmsgs=%lu/%lu",
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",
279 user,tcp_clienthost (),nmsgs,stream->nmsgs); 265 user,tcp_clienthost (),nmsgs,stream->nmsgs);
280 else syslog (LOG_INFO,"APOP user=%.80s host=%.80s no mailbox", 266 else syslog (LOG_INFO,"APOP user=%.80s host=%.80s no mailbox",
281 user,tcp_clienthost ()); 267 user,tcp_clienthost ());
282 } 268 }
283 else PSOUT ("-ERR Not supported\015\012"); 269 else PSOUT ("-ERR Not supported\015\012");
291 PSOUT (t); 277 PSOUT (t);
292 CRLF; 278 CRLF;
293 } 279 }
294 else PSOUT ("+OK STLS completed\015\012"); 280 else PSOUT ("+OK STLS completed\015\012");
295 } 281 }
296 #ifndef RESTRICT_POP
297 else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) && 282 else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) &&
298 !strcmp (s,"USER")) { 283 !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
310 if (host) fs_give ((void **) &host); 284 if (host) fs_give ((void **) &host);
311 if (user) fs_give ((void **) &user); 285 if (user) fs_give ((void **) &user);
312 if (pass) fs_give ((void **) &pass); 286 if (pass) fs_give ((void **) &pass);
313 if (t && *t) { /* if user name given */ 287 if (t && *t) { /* if user name given */
314 /* skip leading whitespace (bogus clients!) */ 288 /* skip leading whitespace (bogus clients!) */
318 *s++ = '\0'; /* tie off host name */ 292 *s++ = '\0'; /* tie off host name */
319 host = cpystr (t);/* copy host name */ 293 host = cpystr (t);/* copy host name */
320 user = cpystr (s);/* copy user name */ 294 user = cpystr (s);/* copy user name */
321 } 295 }
322 /* local user name */ 296 /* local user name */
323 #ifdef QMAIL
324 else user = conv_virtualdomain(cpystr (t));
325 #else
326 else user = cpystr (t); 297 else user = cpystr (t);
327 #endif
328 PSOUT ("+OK User name accepted, password please\015\012"); 298 PSOUT ("+OK User name accepted, password please\015\012");
329 } 299 }
330 else PSOUT ("-ERR Missing username argument\015\012"); 300 else PSOUT ("-ERR Missing username argument\015\012");
331 } 301 }
332 else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) && 302 else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) &&

yatex.org