Mercurial > hg > nginx-quic
annotate src/mail/ngx_mail_imap_handler.c @ 3263:00d436dbf826
delete unused field c->local_socklen
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 01 Nov 2009 19:29:49 +0000 |
parents | a59b26eee816 |
children | dd1570b6f237 |
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 | 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_imap_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_imap_login(ngx_mail_session_t *s, |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
15 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_imap_authenticate(ngx_mail_session_t *s, |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
17 ngx_connection_t *c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
18 static ngx_int_t ngx_mail_imap_capability(ngx_mail_session_t *s, |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
19 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_imap_starttls(ngx_mail_session_t *s, |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
21 ngx_connection_t *c); |
539 | 22 |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
23 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
24 static u_char imap_greeting[] = "* OK IMAP4 ready" CRLF; |
543 | 25 static u_char imap_star[] = "* "; |
529 | 26 static u_char imap_ok[] = "OK completed" CRLF; |
527 | 27 static u_char imap_next[] = "+ OK" CRLF; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
28 static u_char imap_plain_next[] = "+ " CRLF; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
29 static u_char imap_username[] = "+ VXNlcm5hbWU6" CRLF; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
30 static u_char imap_password[] = "+ UGFzc3dvcmQ6" CRLF; |
527 | 31 static u_char imap_bye[] = "* BYE" CRLF; |
32 static u_char imap_invalid_command[] = "BAD invalid command" CRLF; | |
33 | |
521 | 34 |
35 void | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
36 ngx_mail_imap_init_session(ngx_mail_session_t *s, ngx_connection_t *c) |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
38 ngx_mail_core_srv_conf_t *cscf; |
641 | 39 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
40 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
541 | 41 |
1480
a231e37a19ab
move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents:
1479
diff
changeset
|
42 s->out.len = sizeof(imap_greeting) - 1; |
a231e37a19ab
move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents:
1479
diff
changeset
|
43 s->out.data = imap_greeting; |
a231e37a19ab
move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents:
1479
diff
changeset
|
44 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
45 c->read->handler = ngx_mail_imap_init_protocol; |
583 | 46 |
1486
0e7074ef7303
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1485
diff
changeset
|
47 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
|
48 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
49 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
|
50 ngx_mail_close_connection(c); |
a231e37a19ab
move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents:
1479
diff
changeset
|
51 } |
539 | 52 |
1136 | 53 ngx_mail_send(c->write); |
539 | 54 } |
55 | |
56 | |
57 void | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
58 ngx_mail_imap_init_protocol(ngx_event_t *rev) |
539 | 59 { |
521 | 60 ngx_connection_t *c; |
1136 | 61 ngx_mail_session_t *s; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
62 ngx_mail_imap_srv_conf_t *iscf; |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
63 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
64 c = rev->data; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
65 |
541 | 66 c->log->action = "in auth state"; |
67 | |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
68 if (rev->timedout) { |
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
69 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
577 | 70 c->timedout = 1; |
1136 | 71 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
|
72 return; |
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
73 } |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
74 |
539 | 75 s = c->data; |
521 | 76 |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
77 if (s->buffer == NULL) { |
583 | 78 if (ngx_array_init(&s->args, c->pool, 2, sizeof(ngx_str_t)) |
79 == NGX_ERROR) | |
80 { | |
1136 | 81 ngx_mail_session_internal_server_error(s); |
583 | 82 return; |
83 } | |
84 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
85 iscf = ngx_mail_get_module_srv_conf(s, ngx_mail_imap_module); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
86 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
87 s->buffer = ngx_create_temp_buf(c->pool, iscf->client_buffer_size); |
583 | 88 if (s->buffer == NULL) { |
1136 | 89 ngx_mail_session_internal_server_error(s); |
583 | 90 return; |
91 } | |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
92 } |
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
418
diff
changeset
|
93 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
94 s->mail_state = ngx_imap_start; |
1477 | 95 c->read->handler = ngx_mail_imap_auth_state; |
1136 | 96 |
1477 | 97 ngx_mail_imap_auth_state(rev); |
1136 | 98 } |
99 | |
100 | |
101 void | |
1477 | 102 ngx_mail_imap_auth_state(ngx_event_t *rev) |
1136 | 103 { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
104 u_char *p, *dst, *src, *end; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
105 ngx_str_t *arg; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
106 ngx_int_t rc; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
107 ngx_uint_t tag, i; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
108 ngx_connection_t *c; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
109 ngx_mail_session_t *s; |
1136 | 110 |
111 c = rev->data; | |
112 s = c->data; | |
113 | |
114 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "imap auth state"); | |
115 | |
116 if (rev->timedout) { | |
117 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); | |
118 c->timedout = 1; | |
119 ngx_mail_close_connection(c); | |
120 return; | |
121 } | |
122 | |
123 if (s->out.len) { | |
124 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "imap send handler busy"); | |
125 s->blocked = 1; | |
126 return; | |
127 } | |
128 | |
129 s->blocked = 0; | |
130 | |
1482 | 131 rc = ngx_mail_read_command(s, c); |
527 | 132 |
133 if (rc == NGX_AGAIN || rc == NGX_ERROR) { | |
134 return; | |
135 } | |
136 | |
137 tag = 1; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
138 s->text.len = 0; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
139 s->out.len = sizeof(imap_ok) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
140 s->out.data = imap_ok; |
527 | 141 |
142 if (rc == NGX_OK) { | |
143 | |
1136 | 144 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, "imap auth command: %i", |
527 | 145 s->command); |
146 | |
543 | 147 if (s->backslash) { |
148 | |
149 arg = s->args.elts; | |
150 | |
151 for (i = 0; i < s->args.nelts; i++) { | |
152 dst = arg[i].data; | |
153 end = dst + arg[i].len; | |
154 | |
155 for (src = dst; src < end; dst++) { | |
156 *dst = *src; | |
157 if (*src++ == '\\') { | |
158 *dst = *src++; | |
159 } | |
160 } | |
161 | |
162 arg[i].len = dst - arg[i].data; | |
163 } | |
164 | |
165 s->backslash = 0; | |
166 } | |
167 | |
1323 | 168 switch (s->mail_state) { |
169 | |
170 case ngx_imap_start: | |
171 | |
172 switch (s->command) { | |
173 | |
174 case NGX_IMAP_LOGIN: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
175 rc = ngx_mail_imap_login(s, c); |
1323 | 176 break; |
177 | |
178 case NGX_IMAP_AUTHENTICATE: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
179 rc = ngx_mail_imap_authenticate(s, c); |
1479 | 180 tag = (rc != NGX_OK); |
1323 | 181 break; |
182 | |
183 case NGX_IMAP_CAPABILITY: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
184 rc = ngx_mail_imap_capability(s, c); |
1323 | 185 break; |
186 | |
187 case NGX_IMAP_LOGOUT: | |
188 s->quit = 1; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
189 s->text.len = sizeof(imap_bye) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
190 s->text.data = imap_bye; |
1323 | 191 break; |
192 | |
193 case NGX_IMAP_NOOP: | |
194 break; | |
195 | |
196 case NGX_IMAP_STARTTLS: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
197 rc = ngx_mail_imap_starttls(s, c); |
1323 | 198 break; |
199 | |
200 default: | |
201 rc = NGX_MAIL_PARSE_INVALID_COMMAND; | |
202 break; | |
203 } | |
204 | |
205 break; | |
206 | |
207 case ngx_imap_auth_login_username: | |
2495
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
208 rc = ngx_mail_auth_login_username(s, c, 0); |
1323 | 209 |
210 tag = 0; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
211 s->out.len = sizeof(imap_password) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
212 s->out.data = imap_password; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
213 s->mail_state = ngx_imap_auth_login_password; |
1323 | 214 |
215 break; | |
216 | |
217 case ngx_imap_auth_login_password: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
218 rc = ngx_mail_auth_login_password(s, c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
219 break; |
1323 | 220 |
221 case ngx_imap_auth_plain: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
222 rc = ngx_mail_auth_plain(s, c, 0); |
527 | 223 break; |
224 | |
1323 | 225 case ngx_imap_auth_cram_md5: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
226 rc = ngx_mail_auth_cram_md5(s, c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
227 break; |
527 | 228 } |
229 | |
230 } else if (rc == NGX_IMAP_NEXT) { | |
231 tag = 0; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
232 s->out.len = sizeof(imap_next) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
233 s->out.data = imap_next; |
527 | 234 } |
235 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
236 switch (rc) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
237 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
238 case NGX_DONE: |
1482 | 239 ngx_mail_auth(s, c); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
240 return; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
241 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
242 case NGX_ERROR: |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
243 ngx_mail_session_internal_server_error(s); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
244 return; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
245 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
246 case NGX_MAIL_PARSE_INVALID_COMMAND: |
1323 | 247 s->state = 0; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
248 s->out.len = sizeof(imap_invalid_command) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
249 s->out.data = imap_invalid_command; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
250 s->mail_state = ngx_imap_start; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
251 break; |
527 | 252 } |
253 | |
254 if (tag) { | |
543 | 255 if (s->tag.len == 0) { |
256 s->tag.len = sizeof(imap_star) - 1; | |
257 s->tag.data = (u_char *) imap_star; | |
258 } | |
259 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
260 if (s->tagged_line.len < s->tag.len + s->text.len + s->out.len) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
261 s->tagged_line.len = s->tag.len + s->text.len + s->out.len; |
2049 | 262 s->tagged_line.data = ngx_pnalloc(c->pool, s->tagged_line.len); |
539 | 263 if (s->tagged_line.data == NULL) { |
1136 | 264 ngx_mail_close_connection(c); |
527 | 265 return; |
266 } | |
267 } | |
268 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
269 p = s->tagged_line.data; |
539 | 270 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
271 if (s->text.len) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
272 p = ngx_cpymem(p, s->text.data, s->text.len); |
527 | 273 } |
274 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
275 p = ngx_cpymem(p, s->tag.data, s->tag.len); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
276 ngx_memcpy(p, s->out.data, s->out.len); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
277 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
278 s->out.len = s->text.len + s->tag.len + s->out.len; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
279 s->out.data = s->tagged_line.data; |
527 | 280 } |
281 | |
539 | 282 if (rc != NGX_IMAP_NEXT) { |
283 s->args.nelts = 0; | |
1323 | 284 |
285 if (s->state) { | |
286 /* preserve tag */ | |
287 s->arg_start = s->buffer->start + s->tag.len; | |
288 s->buffer->pos = s->arg_start; | |
289 s->buffer->last = s->arg_start; | |
290 | |
291 } else { | |
292 s->buffer->pos = s->buffer->start; | |
293 s->buffer->last = s->buffer->start; | |
294 s->tag.len = 0; | |
295 } | |
527 | 296 } |
297 | |
1136 | 298 ngx_mail_send(c->write); |
521 | 299 } |
300 | |
301 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
302 static ngx_int_t |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
303 ngx_mail_imap_login(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
|
304 { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1487
diff
changeset
|
305 ngx_str_t *arg; |
1479 | 306 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
307 #if (NGX_MAIL_SSL) |
1479 | 308 if (ngx_mail_starttls_only(s, c)) { |
309 return NGX_MAIL_PARSE_INVALID_COMMAND; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
310 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
311 #endif |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
312 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
313 arg = s->args.elts; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
314 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
315 if (s->args.nelts != 2 || arg[0].len == 0) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
316 return NGX_MAIL_PARSE_INVALID_COMMAND; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
317 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
318 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
319 s->login.len = arg[0].len; |
2049 | 320 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
|
321 if (s->login.data == NULL) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
322 return NGX_ERROR; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
323 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
324 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
325 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
|
326 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
327 s->passwd.len = arg[1].len; |
2049 | 328 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
|
329 if (s->passwd.data == NULL) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
330 return NGX_ERROR; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
331 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
332 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
333 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
|
334 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
335 #if (NGX_DEBUG_MAIL_PASSWD) |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
336 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
|
337 "imap login:\"%V\" passwd:\"%V\"", |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
338 &s->login, &s->passwd); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
339 #else |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
340 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
|
341 "imap login:\"%V\"", &s->login); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
342 #endif |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
343 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
344 return NGX_DONE; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
345 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
346 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
347 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
348 static ngx_int_t |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
349 ngx_mail_imap_authenticate(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
|
350 { |
1479 | 351 ngx_int_t rc; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
352 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
|
353 ngx_mail_imap_srv_conf_t *iscf; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
354 |
1479 | 355 #if (NGX_MAIL_SSL) |
356 if (ngx_mail_starttls_only(s, c)) { | |
357 return NGX_MAIL_PARSE_INVALID_COMMAND; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
358 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
359 #endif |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
360 |
1479 | 361 rc = ngx_mail_auth_parse(s, c); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
362 |
1479 | 363 switch (rc) { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
364 |
1479 | 365 case NGX_MAIL_AUTH_LOGIN: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
366 |
1479 | 367 s->out.len = sizeof(imap_username) - 1; |
368 s->out.data = imap_username; | |
369 s->mail_state = ngx_imap_auth_login_username; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
370 |
1479 | 371 return NGX_OK; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
372 |
2495
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
373 case NGX_MAIL_AUTH_LOGIN_USERNAME: |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
374 |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
375 s->out.len = sizeof(imap_password) - 1; |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
376 s->out.data = imap_password; |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
377 s->mail_state = ngx_imap_auth_login_password; |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
378 |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
379 return ngx_mail_auth_login_username(s, c, 1); |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
380 |
1479 | 381 case NGX_MAIL_AUTH_PLAIN: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
382 |
1479 | 383 s->out.len = sizeof(imap_plain_next) - 1; |
384 s->out.data = imap_plain_next; | |
385 s->mail_state = ngx_imap_auth_plain; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
386 |
1479 | 387 return NGX_OK; |
388 | |
389 case NGX_MAIL_AUTH_CRAM_MD5: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
390 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
391 iscf = ngx_mail_get_module_srv_conf(s, ngx_mail_imap_module); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
392 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
393 if (!(iscf->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
|
394 return NGX_MAIL_PARSE_INVALID_COMMAND; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
395 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
396 |
1485
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
397 if (s->salt.data == NULL) { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
398 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
399 |
1485
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
400 if (ngx_mail_salt(s, c, cscf) != NGX_OK) { |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
401 return NGX_ERROR; |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
402 } |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
403 } |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
404 |
1479 | 405 if (ngx_mail_auth_cram_md5_salt(s, c, "+ ", 2) == NGX_OK) { |
406 s->mail_state = ngx_imap_auth_cram_md5; | |
407 return NGX_OK; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
408 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
409 |
1479 | 410 return NGX_ERROR; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
411 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
412 |
1479 | 413 return rc; |
1476
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 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
416 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
417 static ngx_int_t |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
418 ngx_mail_imap_capability(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
|
419 { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
420 ngx_mail_imap_srv_conf_t *iscf; |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
421 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
422 iscf = ngx_mail_get_module_srv_conf(s, ngx_mail_imap_module); |
809 | 423 |
1322 | 424 #if (NGX_MAIL_SSL) |
425 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
426 if (c->ssl == NULL) { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1487
diff
changeset
|
427 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
|
428 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
429 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); |
809 | 430 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
431 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
|
432 s->text = iscf->starttls_capability; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
433 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
434 } |
1136 | 435 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
436 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
|
437 s->text = iscf->starttls_only_capability; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
438 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
439 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
440 } |
1322 | 441 #endif |
442 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
443 s->text = iscf->capability; |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
444 |
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
445 return NGX_OK; |
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
446 } |
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
447 |
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
448 |
521 | 449 static ngx_int_t |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
450 ngx_mail_imap_starttls(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
|
451 { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
452 #if (NGX_MAIL_SSL) |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
453 ngx_mail_ssl_conf_t *sslcf; |
1136 | 454 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
455 if (c->ssl == NULL) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
456 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
|
457 if (sslcf->starttls) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
458 c->read->handler = ngx_mail_starttls_handler; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
459 return NGX_OK; |
539 | 460 } |
461 } | |
462 | |
463 #endif | |
464 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
465 return NGX_MAIL_PARSE_INVALID_COMMAND; |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
466 } |