annotate src/mail/ngx_mail_pop3_handler.c @ 3450:4f9dd6d22acd

delete surplus code
author Igor Sysoev <igor@sysoev.ru>
date Fri, 12 Feb 2010 09:48:04 +0000
parents a59b26eee816
children dd1570b6f237
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 423
diff changeset
1
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 423
diff changeset
2 /*
444
42d11f017717 nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents: 441
diff changeset
3 * Copyright (C) Igor Sysoev
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 423
diff changeset
4 */
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 423
diff changeset
5
413
de9d4726e28a nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6
de9d4726e28a nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
de9d4726e28a nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
de9d4726e28a nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #include <ngx_event.h>
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
10 #include <ngx_mail.h>
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
11 #include <ngx_mail_pop3_module.h>
417
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
12
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
13
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
14 static ngx_int_t ngx_mail_pop3_user(ngx_mail_session_t *s, ngx_connection_t *c);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
15 static ngx_int_t ngx_mail_pop3_pass(ngx_mail_session_t *s, ngx_connection_t *c);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
16 static ngx_int_t ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c,
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
17 ngx_int_t stls);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
18 static ngx_int_t ngx_mail_pop3_stls(ngx_mail_session_t *s, ngx_connection_t *c);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
19 static ngx_int_t ngx_mail_pop3_apop(ngx_mail_session_t *s, ngx_connection_t *c);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
20 static ngx_int_t ngx_mail_pop3_auth(ngx_mail_session_t *s, ngx_connection_t *c);
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
21
413
de9d4726e28a nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
23 static u_char pop3_greeting[] = "+OK POP3 ready" CRLF;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
24 static u_char pop3_ok[] = "+OK" CRLF;
809
da9c1521319d AUTH PLAIN LOGIN CRAM-MD5
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
25 static u_char pop3_next[] = "+ " CRLF;
da9c1521319d AUTH PLAIN LOGIN CRAM-MD5
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
26 static u_char pop3_username[] = "+ VXNlcm5hbWU6" CRLF;
da9c1521319d AUTH PLAIN LOGIN CRAM-MD5
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
27 static u_char pop3_password[] = "+ UGFzc3dvcmQ6" CRLF;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
28 static u_char pop3_invalid_command[] = "-ERR invalid command" CRLF;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
29
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
30
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
31 void
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
32 ngx_mail_pop3_init_session(ngx_mail_session_t *s, ngx_connection_t *c)
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
33 {
800
Igor Sysoev <igor@sysoev.ru>
parents: 641
diff changeset
34 u_char *p;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
35 ngx_mail_core_srv_conf_t *cscf;
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
36 ngx_mail_pop3_srv_conf_t *pscf;
417
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
37
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
38 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
39 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
40
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
41 if (pscf->auth_methods
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
42 & (NGX_MAIL_AUTH_APOP_ENABLED|NGX_MAIL_AUTH_CRAM_MD5_ENABLED))
800
Igor Sysoev <igor@sysoev.ru>
parents: 641
diff changeset
43 {
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
44 if (ngx_mail_salt(s, c, cscf) != NGX_OK) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
45 ngx_mail_session_internal_server_error(s);
800
Igor Sysoev <igor@sysoev.ru>
parents: 641
diff changeset
46 return;
Igor Sysoev <igor@sysoev.ru>
parents: 641
diff changeset
47 }
Igor Sysoev <igor@sysoev.ru>
parents: 641
diff changeset
48
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1704
diff changeset
49 s->out.data = ngx_pnalloc(c->pool, sizeof(pop3_greeting) + s->salt.len);
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
50 if (s->out.data == NULL) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
51 ngx_mail_session_internal_server_error(s);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
52 return;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
53 }
800
Igor Sysoev <igor@sysoev.ru>
parents: 641
diff changeset
54
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
55 p = ngx_cpymem(s->out.data, pop3_greeting, sizeof(pop3_greeting) - 3);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
56 *p++ = ' ';
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
57 p = ngx_cpymem(p, s->salt.data, s->salt.len);
800
Igor Sysoev <igor@sysoev.ru>
parents: 641
diff changeset
58
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
59 s->out.len = p - s->out.data;
800
Igor Sysoev <igor@sysoev.ru>
parents: 641
diff changeset
60
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
61 } else {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
62 s->out.len = sizeof(pop3_greeting) - 1;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
63 s->out.data = pop3_greeting;
800
Igor Sysoev <igor@sysoev.ru>
parents: 641
diff changeset
64 }
Igor Sysoev <igor@sysoev.ru>
parents: 641
diff changeset
65
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
66 c->read->handler = ngx_mail_pop3_init_protocol;
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
67
1486
0e7074ef7303 style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents: 1482
diff changeset
68 ngx_add_timer(c->read, cscf->timeout);
1480
a231e37a19ab move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents: 1479
diff changeset
69
2388
722b5aff05ae use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents: 2049
diff changeset
70 if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
1480
a231e37a19ab move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents: 1479
diff changeset
71 ngx_mail_close_connection(c);
a231e37a19ab move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents: 1479
diff changeset
72 }
a231e37a19ab move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents: 1479
diff changeset
73
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
74 ngx_mail_send(c->write);
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
75 }
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
76
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
77
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
78 void
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
79 ngx_mail_pop3_init_protocol(ngx_event_t *rev)
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
80 {
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
81 ngx_connection_t *c;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
82 ngx_mail_session_t *s;
417
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
83
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
84 c = rev->data;
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
85
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
86 c->log->action = "in auth state";
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
87
423
fda5987b188d nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents: 422
diff changeset
88 if (rev->timedout) {
fda5987b188d nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents: 422
diff changeset
89 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 569
diff changeset
90 c->timedout = 1;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
91 ngx_mail_close_connection(c);
423
fda5987b188d nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents: 422
diff changeset
92 return;
fda5987b188d nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents: 422
diff changeset
93 }
420
33a8253115b4 nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents: 419
diff changeset
94
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
95 s = c->data;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
96
419
47709bff4468 nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents: 418
diff changeset
97 if (s->buffer == NULL) {
583
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
98 if (ngx_array_init(&s->args, c->pool, 2, sizeof(ngx_str_t))
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
99 == NGX_ERROR)
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
100 {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
101 ngx_mail_session_internal_server_error(s);
583
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
102 return;
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
103 }
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
104
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
105 s->buffer = ngx_create_temp_buf(c->pool, 128);
583
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
106 if (s->buffer == NULL) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
107 ngx_mail_session_internal_server_error(s);
583
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
108 return;
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
109 }
419
47709bff4468 nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents: 418
diff changeset
110 }
47709bff4468 nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents: 418
diff changeset
111
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
112 s->mail_state = ngx_pop3_start;
1477
59e1caf2be94 style fix and optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1476
diff changeset
113 c->read->handler = ngx_mail_pop3_auth_state;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
114
1477
59e1caf2be94 style fix and optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1476
diff changeset
115 ngx_mail_pop3_auth_state(rev);
420
33a8253115b4 nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents: 419
diff changeset
116 }
33a8253115b4 nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents: 419
diff changeset
117
33a8253115b4 nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents: 419
diff changeset
118
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
119 void
1477
59e1caf2be94 style fix and optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1476
diff changeset
120 ngx_mail_pop3_auth_state(ngx_event_t *rev)
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
121 {
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
122 ngx_int_t rc;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
123 ngx_connection_t *c;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
124 ngx_mail_session_t *s;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
125
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
126 c = rev->data;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
127 s = c->data;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
128
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
129 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "pop3 auth state");
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
130
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
131 if (rev->timedout) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
132 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 569
diff changeset
133 c->timedout = 1;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
134 ngx_mail_close_connection(c);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
135 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
136 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
137
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
138 if (s->out.len) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
139 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "pop3 send handler busy");
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
140 s->blocked = 1;
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
141 return;
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
142 }
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
143
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
144 s->blocked = 0;
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
145
1482
4606dce4f416 optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1480
diff changeset
146 rc = ngx_mail_read_command(s, c);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
147
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
148 if (rc == NGX_AGAIN || rc == NGX_ERROR) {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
149 return;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
150 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
151
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
152 s->out.len = sizeof(pop3_ok) - 1;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
153 s->out.data = pop3_ok;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
154
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
155 if (rc == NGX_OK) {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
156 switch (s->mail_state) {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
157
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
158 case ngx_pop3_start:
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
159
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
160 switch (s->command) {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
161
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
162 case NGX_POP3_USER:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
163 rc = ngx_mail_pop3_user(s, c);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
164 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
165
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
166 case NGX_POP3_CAPA:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
167 rc = ngx_mail_pop3_capa(s, c, 1);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
168 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
169
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
170 case NGX_POP3_APOP:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
171 rc = ngx_mail_pop3_apop(s, c);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
172 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
173
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
174 case NGX_POP3_AUTH:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
175 rc = ngx_mail_pop3_auth(s, c);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
176 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
177
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
178 case NGX_POP3_QUIT:
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
179 s->quit = 1;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
180 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
181
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
182 case NGX_POP3_NOOP:
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
183 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
184
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
185 case NGX_POP3_STLS:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
186 rc = ngx_mail_pop3_stls(s, c);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
187 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
188
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
189 default:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
190 rc = NGX_MAIL_PARSE_INVALID_COMMAND;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
191 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
192 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
193
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
194 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
195
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
196 case ngx_pop3_user:
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
197
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
198 switch (s->command) {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
199
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
200 case NGX_POP3_PASS:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
201 rc = ngx_mail_pop3_pass(s, c);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
202 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
203
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
204 case NGX_POP3_CAPA:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
205 rc = ngx_mail_pop3_capa(s, c, 0);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
206 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
207
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
208 case NGX_POP3_QUIT:
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
209 s->quit = 1;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
210 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
211
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
212 case NGX_POP3_NOOP:
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
213 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
214
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
215 default:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
216 rc = NGX_MAIL_PARSE_INVALID_COMMAND;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
217 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
218 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
219
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
220 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
221
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
222 /* suppress warinings */
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
223 case ngx_pop3_passwd:
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
224 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
225
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
226 case ngx_pop3_auth_login_username:
2495
a59b26eee816 compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents: 2388
diff changeset
227 rc = ngx_mail_auth_login_username(s, c, 0);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
228
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
229 s->out.len = sizeof(pop3_password) - 1;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
230 s->out.data = pop3_password;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
231 s->mail_state = ngx_pop3_auth_login_password;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
232 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
233
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
234 case ngx_pop3_auth_login_password:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
235 rc = ngx_mail_auth_login_password(s, c);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
236 break;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
237
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
238 case ngx_pop3_auth_plain:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
239 rc = ngx_mail_auth_plain(s, c, 0);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
240 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
241
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
242 case ngx_pop3_auth_cram_md5:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
243 rc = ngx_mail_auth_cram_md5(s, c);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
244 break;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
245 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
246 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
247
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
248 switch (rc) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
249
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
250 case NGX_DONE:
1482
4606dce4f416 optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1480
diff changeset
251 ngx_mail_auth(s, c);
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
252 return;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
253
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
254 case NGX_ERROR:
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
255 ngx_mail_session_internal_server_error(s);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
256 return;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
257
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
258 case NGX_MAIL_PARSE_INVALID_COMMAND:
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
259 s->mail_state = ngx_pop3_start;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
260 s->state = 0;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
261
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
262 s->out.len = sizeof(pop3_invalid_command) - 1;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
263 s->out.data = pop3_invalid_command;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
264
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
265 /* fall through */
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
266
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
267 case NGX_OK:
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
268
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
269 s->args.nelts = 0;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
270 s->buffer->pos = s->buffer->start;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
271 s->buffer->last = s->buffer->start;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
272
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
273 if (s->state) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
274 s->arg_start = s->buffer->start;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
275 }
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
276
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
277 ngx_mail_send(c->write);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
278 }
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
279 }
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
280
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
281 static ngx_int_t
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
282 ngx_mail_pop3_user(ngx_mail_session_t *s, ngx_connection_t *c)
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
283 {
1704
e584e946e198 move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents: 1487
diff changeset
284 ngx_str_t *arg;
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
285
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
286 #if (NGX_MAIL_SSL)
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
287 if (ngx_mail_starttls_only(s, c)) {
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
288 return NGX_MAIL_PARSE_INVALID_COMMAND;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
289 }
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
290 #endif
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
291
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
292 if (s->args.nelts != 1) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
293 return NGX_MAIL_PARSE_INVALID_COMMAND;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
294 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
295
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
296 arg = s->args.elts;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
297 s->login.len = arg[0].len;
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1704
diff changeset
298 s->login.data = ngx_pnalloc(c->pool, s->login.len);
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
299 if (s->login.data == NULL) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
300 return NGX_ERROR;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
301 }
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
302
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
303 ngx_memcpy(s->login.data, arg[0].data, s->login.len);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
304
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
305 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
306 "pop3 login: \"%V\"", &s->login);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
307
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
308 s->mail_state = ngx_pop3_user;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
309
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
310 return NGX_OK;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
311 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
312
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
313
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
314 static ngx_int_t
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
315 ngx_mail_pop3_pass(ngx_mail_session_t *s, ngx_connection_t *c)
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
316 {
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
317 ngx_str_t *arg;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1111
diff changeset
318
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
319 if (s->args.nelts != 1) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
320 return NGX_MAIL_PARSE_INVALID_COMMAND;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
321 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
322
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
323 arg = s->args.elts;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
324 s->passwd.len = arg[0].len;
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1704
diff changeset
325 s->passwd.data = ngx_pnalloc(c->pool, s->passwd.len);
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
326 if (s->passwd.data == NULL) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
327 return NGX_ERROR;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
328 }
1323
c4b2c893989d IMAP AUTHENTICATE
Igor Sysoev <igor@sysoev.ru>
parents: 1322
diff changeset
329
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
330 ngx_memcpy(s->passwd.data, arg[0].data, s->passwd.len);
1323
c4b2c893989d IMAP AUTHENTICATE
Igor Sysoev <igor@sysoev.ru>
parents: 1322
diff changeset
331
c4b2c893989d IMAP AUTHENTICATE
Igor Sysoev <igor@sysoev.ru>
parents: 1322
diff changeset
332 #if (NGX_DEBUG_MAIL_PASSWD)
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
333 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
334 "pop3 passwd: \"%V\"", &s->passwd);
1323
c4b2c893989d IMAP AUTHENTICATE
Igor Sysoev <igor@sysoev.ru>
parents: 1322
diff changeset
335 #endif
c4b2c893989d IMAP AUTHENTICATE
Igor Sysoev <igor@sysoev.ru>
parents: 1322
diff changeset
336
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
337 return NGX_DONE;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
338 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
339
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
340
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
341 static ngx_int_t
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
342 ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c, ngx_int_t stls)
420
33a8253115b4 nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents: 419
diff changeset
343 {
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
344 ngx_mail_pop3_srv_conf_t *pscf;
420
33a8253115b4 nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents: 419
diff changeset
345
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
346 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module);
809
da9c1521319d AUTH PLAIN LOGIN CRAM-MD5
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
347
1322
27f2299e0d80 SMTP STARTTLS
Igor Sysoev <igor@sysoev.ru>
parents: 1286
diff changeset
348 #if (NGX_MAIL_SSL)
27f2299e0d80 SMTP STARTTLS
Igor Sysoev <igor@sysoev.ru>
parents: 1286
diff changeset
349
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
350 if (stls && c->ssl == NULL) {
1704
e584e946e198 move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents: 1487
diff changeset
351 ngx_mail_ssl_conf_t *sslcf;
e584e946e198 move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents: 1487
diff changeset
352
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
353 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
1322
27f2299e0d80 SMTP STARTTLS
Igor Sysoev <igor@sysoev.ru>
parents: 1286
diff changeset
354
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
355 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) {
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
356 s->out = pscf->starttls_capability;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
357 return NGX_OK;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
358 }
809
da9c1521319d AUTH PLAIN LOGIN CRAM-MD5
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
359
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
360 if (sslcf->starttls == NGX_MAIL_STARTTLS_ONLY) {
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
361 s->out = pscf->starttls_only_capability;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
362 return NGX_OK;
421
01456a419cf9 nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 420
diff changeset
363 }
01456a419cf9 nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 420
diff changeset
364 }
420
33a8253115b4 nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents: 419
diff changeset
365
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
366 #endif
420
33a8253115b4 nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents: 419
diff changeset
367
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
368 s->out = pscf->capability;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
369 return NGX_OK;
417
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
370 }
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
371
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
372
894
4f7dca9c37f0 workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents: 884
diff changeset
373 static ngx_int_t
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
374 ngx_mail_pop3_stls(ngx_mail_session_t *s, ngx_connection_t *c)
894
4f7dca9c37f0 workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents: 884
diff changeset
375 {
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
376 #if (NGX_MAIL_SSL)
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
377 ngx_mail_ssl_conf_t *sslcf;
894
4f7dca9c37f0 workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents: 884
diff changeset
378
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
379 if (c->ssl == NULL) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
380 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
381 if (sslcf->starttls) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
382 c->read->handler = ngx_mail_starttls_handler;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
383 return NGX_OK;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
384 }
894
4f7dca9c37f0 workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents: 884
diff changeset
385 }
4f7dca9c37f0 workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents: 884
diff changeset
386
4f7dca9c37f0 workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents: 884
diff changeset
387 #endif
4f7dca9c37f0 workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents: 884
diff changeset
388
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
389 return NGX_MAIL_PARSE_INVALID_COMMAND;
855
b006f30d6a2f count s->login_attempt for POP3, minimize code
Igor Sysoev <igor@sysoev.ru>
parents: 851
diff changeset
390 }
b006f30d6a2f count s->login_attempt for POP3, minimize code
Igor Sysoev <igor@sysoev.ru>
parents: 851
diff changeset
391
b006f30d6a2f count s->login_attempt for POP3, minimize code
Igor Sysoev <igor@sysoev.ru>
parents: 851
diff changeset
392
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
393 static ngx_int_t
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
394 ngx_mail_pop3_apop(ngx_mail_session_t *s, ngx_connection_t *c)
420
33a8253115b4 nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents: 419
diff changeset
395 {
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
396 ngx_str_t *arg;
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
397 ngx_mail_pop3_srv_conf_t *pscf;
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
398
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
399 #if (NGX_MAIL_SSL)
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
400 if (ngx_mail_starttls_only(s, c)) {
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
401 return NGX_MAIL_PARSE_INVALID_COMMAND;
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
402 }
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
403 #endif
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
404
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
405 if (s->args.nelts != 2) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
406 return NGX_MAIL_PARSE_INVALID_COMMAND;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
407 }
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
408
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
409 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module);
1472
32450a2bbdf4 decrement active connection counter in mail proxy
Igor Sysoev <igor@sysoev.ru>
parents: 1323
diff changeset
410
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
411 if (!(pscf->auth_methods & NGX_MAIL_AUTH_APOP_ENABLED)) {
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
412 return NGX_MAIL_PARSE_INVALID_COMMAND;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
413 }
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
414
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
415 arg = s->args.elts;
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
416
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
417 s->login.len = arg[0].len;
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1704
diff changeset
418 s->login.data = ngx_pnalloc(c->pool, s->login.len);
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
419 if (s->login.data == NULL) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
420 return NGX_ERROR;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
421 }
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
422
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
423 ngx_memcpy(s->login.data, arg[0].data, s->login.len);
479
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
424
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
425 s->passwd.len = arg[1].len;
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1704
diff changeset
426 s->passwd.data = ngx_pnalloc(c->pool, s->passwd.len);
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
427 if (s->passwd.data == NULL) {
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
428 return NGX_ERROR;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
429 }
479
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
430
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
431 ngx_memcpy(s->passwd.data, arg[1].data, s->passwd.len);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
432
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
433 ngx_log_debug2(NGX_LOG_DEBUG_MAIL, c->log, 0,
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
434 "pop3 apop: \"%V\" \"%V\"", &s->login, &s->passwd);
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
435
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
436 s->auth_method = NGX_MAIL_AUTH_APOP;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
437
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
438 return NGX_DONE;
417
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
439 }
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
440
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 529
diff changeset
441
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
442 static ngx_int_t
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
443 ngx_mail_pop3_auth(ngx_mail_session_t *s, ngx_connection_t *c)
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
444 {
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
445 ngx_int_t rc;
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
446 ngx_mail_pop3_srv_conf_t *pscf;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
447
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
448 #if (NGX_MAIL_SSL)
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
449 if (ngx_mail_starttls_only(s, c)) {
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
450 return NGX_MAIL_PARSE_INVALID_COMMAND;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
451 }
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
452 #endif
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
453
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
454 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module);
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
455
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
456 if (s->args.nelts == 0) {
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
457 s->out = pscf->auth_capability;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
458 s->state = 0;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
459
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
460 return NGX_OK;
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
461 }
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 569
diff changeset
462
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
463 rc = ngx_mail_auth_parse(s, c);
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
464
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
465 switch (rc) {
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
466
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
467 case NGX_MAIL_AUTH_LOGIN:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
468
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
469 s->out.len = sizeof(pop3_username) - 1;
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
470 s->out.data = pop3_username;
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
471 s->mail_state = ngx_pop3_auth_login_username;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
472
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
473 return NGX_OK;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
474
2495
a59b26eee816 compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents: 2388
diff changeset
475 case NGX_MAIL_AUTH_LOGIN_USERNAME:
a59b26eee816 compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents: 2388
diff changeset
476
a59b26eee816 compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents: 2388
diff changeset
477 s->out.len = sizeof(pop3_password) - 1;
a59b26eee816 compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents: 2388
diff changeset
478 s->out.data = pop3_password;
a59b26eee816 compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents: 2388
diff changeset
479 s->mail_state = ngx_pop3_auth_login_password;
a59b26eee816 compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents: 2388
diff changeset
480
a59b26eee816 compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents: 2388
diff changeset
481 return ngx_mail_auth_login_username(s, c, 1);
a59b26eee816 compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents: 2388
diff changeset
482
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
483 case NGX_MAIL_AUTH_PLAIN:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
484
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
485 s->out.len = sizeof(pop3_next) - 1;
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
486 s->out.data = pop3_next;
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
487 s->mail_state = ngx_pop3_auth_plain;
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
488
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
489 return NGX_OK;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
490
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
491 case NGX_MAIL_AUTH_CRAM_MD5:
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
492
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1486
diff changeset
493 if (!(pscf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) {
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
494 return NGX_MAIL_PARSE_INVALID_COMMAND;
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
495 }
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
496
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
497 if (ngx_mail_auth_cram_md5_salt(s, c, "+ ", 2) == NGX_OK) {
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
498 s->mail_state = ngx_pop3_auth_cram_md5;
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
499 return NGX_OK;
1476
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
500 }
67578e966dcc split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents: 1472
diff changeset
501
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
502 return NGX_ERROR;
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
503 }
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
504
1479
2647950e047f optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
505 return rc;
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
506 }