Mercurial > hg > nginx-quic
annotate src/mail/ngx_mail_pop3_handler.c @ 1851:056347360e14 stable-0.5
r1755, r1756, r1757 merge:
*) SSL_shutdown() never returns -1, on error it returns 0.
This fixes incidental "bad write retry" errors.
*) cleaning stale global SSL error
*) remove SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER, we never need it
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 08 Jan 2008 17:30:39 +0000 |
parents | ed9cd1702f7a |
children |
rev | line source |
---|---|
1621
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2 /* |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
4 */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
5 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_mail.h> |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 #include <ngx_mail_pop3_module.h> |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 static ngx_int_t ngx_mail_pop3_user(ngx_mail_session_t *s, ngx_connection_t *c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 static ngx_int_t ngx_mail_pop3_pass(ngx_mail_session_t *s, ngx_connection_t *c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
16 static ngx_int_t ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
17 ngx_int_t stls); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
18 static ngx_int_t ngx_mail_pop3_stls(ngx_mail_session_t *s, ngx_connection_t *c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 static ngx_int_t ngx_mail_pop3_apop(ngx_mail_session_t *s, ngx_connection_t *c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 static ngx_int_t ngx_mail_pop3_auth(ngx_mail_session_t *s, ngx_connection_t *c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
23 static u_char pop3_greeting[] = "+OK POP3 ready" CRLF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
24 static u_char pop3_ok[] = "+OK" CRLF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
25 static u_char pop3_next[] = "+ " CRLF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
26 static u_char pop3_username[] = "+ VXNlcm5hbWU6" CRLF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 static u_char pop3_password[] = "+ UGFzc3dvcmQ6" CRLF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 static u_char pop3_invalid_command[] = "-ERR invalid command" CRLF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 void |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 ngx_mail_pop3_init_session(ngx_mail_session_t *s, ngx_connection_t *c) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 u_char *p; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 ngx_mail_core_srv_conf_t *cscf; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 ngx_mail_pop3_srv_conf_t *pscf; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
39 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
40 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 if (pscf->auth_methods |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 & (NGX_MAIL_AUTH_APOP_ENABLED|NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 if (ngx_mail_salt(s, c, cscf) != NGX_OK) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
45 ngx_mail_session_internal_server_error(s); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 return; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
48 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 s->out.data = ngx_palloc(c->pool, sizeof(pop3_greeting) + s->salt.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
50 if (s->out.data == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
51 ngx_mail_session_internal_server_error(s); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
52 return; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
53 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
55 p = ngx_cpymem(s->out.data, pop3_greeting, sizeof(pop3_greeting) - 3); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 *p++ = ' '; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
57 p = ngx_cpymem(p, s->salt.data, s->salt.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
59 s->out.len = p - s->out.data; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
61 } else { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
62 s->out.len = sizeof(pop3_greeting) - 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
63 s->out.data = pop3_greeting; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
64 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
65 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
66 c->read->handler = ngx_mail_pop3_init_protocol; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
67 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 ngx_add_timer(c->read, cscf->timeout); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
70 if (ngx_handle_read_event(c->read, 0) == NGX_ERROR) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
71 ngx_mail_close_connection(c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
72 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
73 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
74 ngx_mail_send(c->write); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
75 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
76 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
77 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
78 void |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
79 ngx_mail_pop3_init_protocol(ngx_event_t *rev) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
80 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
81 ngx_connection_t *c; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
82 ngx_mail_session_t *s; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
83 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
84 c = rev->data; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
85 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 c->log->action = "in auth state"; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
87 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
88 if (rev->timedout) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
89 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
90 c->timedout = 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
91 ngx_mail_close_connection(c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
92 return; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
93 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
94 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
95 s = c->data; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
96 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 if (s->buffer == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
98 if (ngx_array_init(&s->args, c->pool, 2, sizeof(ngx_str_t)) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
99 == NGX_ERROR) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
100 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
101 ngx_mail_session_internal_server_error(s); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
102 return; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
104 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
105 s->buffer = ngx_create_temp_buf(c->pool, 128); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
106 if (s->buffer == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
107 ngx_mail_session_internal_server_error(s); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 return; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
109 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
110 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
111 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
112 s->mail_state = ngx_pop3_start; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
113 c->read->handler = ngx_mail_pop3_auth_state; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
114 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
115 ngx_mail_pop3_auth_state(rev); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
116 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
117 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
118 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
119 void |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
120 ngx_mail_pop3_auth_state(ngx_event_t *rev) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
121 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 ngx_int_t rc; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
123 ngx_connection_t *c; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
124 ngx_mail_session_t *s; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 c = rev->data; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 s = c->data; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
128 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
129 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "pop3 auth state"); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
130 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
131 if (rev->timedout) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
132 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
133 c->timedout = 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
134 ngx_mail_close_connection(c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
135 return; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
136 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
137 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
138 if (s->out.len) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
139 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "pop3 send handler busy"); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
140 s->blocked = 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
141 return; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
144 s->blocked = 0; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
145 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
146 rc = ngx_mail_read_command(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
147 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 if (rc == NGX_AGAIN || rc == NGX_ERROR) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
149 return; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
150 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
151 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
152 s->out.len = sizeof(pop3_ok) - 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
153 s->out.data = pop3_ok; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
155 if (rc == NGX_OK) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 switch (s->mail_state) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 case ngx_pop3_start: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
159 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
160 switch (s->command) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
161 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 case NGX_POP3_USER: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
163 rc = ngx_mail_pop3_user(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
164 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
165 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 case NGX_POP3_CAPA: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 rc = ngx_mail_pop3_capa(s, c, 1); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
169 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
170 case NGX_POP3_APOP: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 rc = ngx_mail_pop3_apop(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
173 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
174 case NGX_POP3_AUTH: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
175 rc = ngx_mail_pop3_auth(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
176 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
177 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 case NGX_POP3_QUIT: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 s->quit = 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
181 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
182 case NGX_POP3_NOOP: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
183 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
184 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
185 case NGX_POP3_STLS: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
186 rc = ngx_mail_pop3_stls(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
188 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
189 default: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
190 rc = NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
191 s->mail_state = ngx_pop3_start; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
192 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
193 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
197 case ngx_pop3_user: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
198 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
199 switch (s->command) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 case NGX_POP3_PASS: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
202 rc = ngx_mail_pop3_pass(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
203 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
204 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
205 case NGX_POP3_CAPA: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
206 rc = ngx_mail_pop3_capa(s, c, 0); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
207 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
208 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 case NGX_POP3_QUIT: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
210 s->quit = 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
211 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
212 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
213 case NGX_POP3_NOOP: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
214 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
215 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 default: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 rc = NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
218 s->mail_state = ngx_pop3_start; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
219 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
220 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
222 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
223 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
224 /* suppress warinings */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
225 case ngx_pop3_passwd: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
226 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
228 case ngx_pop3_auth_login_username: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
229 rc = ngx_mail_auth_login_username(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
230 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 s->out.len = sizeof(pop3_password) - 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
232 s->out.data = pop3_password; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
233 s->mail_state = ngx_pop3_auth_login_password; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
234 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
235 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
236 case ngx_pop3_auth_login_password: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
237 rc = ngx_mail_auth_login_password(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
238 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
239 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
240 case ngx_pop3_auth_plain: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
241 rc = ngx_mail_auth_plain(s, c, 0); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
242 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
243 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
244 case ngx_pop3_auth_cram_md5: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
245 rc = ngx_mail_auth_cram_md5(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
246 break; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
247 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
248 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
249 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 switch (rc) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
251 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
252 case NGX_DONE: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
253 ngx_mail_auth(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
254 return; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
255 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
256 case NGX_ERROR: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
257 ngx_mail_session_internal_server_error(s); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
258 return; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
259 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
260 case NGX_MAIL_PARSE_INVALID_COMMAND: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
261 s->mail_state = ngx_pop3_start; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
262 s->state = 0; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
263 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
264 s->out.len = sizeof(pop3_invalid_command) - 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
265 s->out.data = pop3_invalid_command; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
266 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
267 /* fall through */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
268 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
269 case NGX_OK: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
270 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
271 s->args.nelts = 0; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
272 s->buffer->pos = s->buffer->start; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
273 s->buffer->last = s->buffer->start; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
274 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
275 if (s->state) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
276 s->arg_start = s->buffer->start; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
277 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
278 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
279 ngx_mail_send(c->write); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
280 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
281 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
282 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
283 static ngx_int_t |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
284 ngx_mail_pop3_user(ngx_mail_session_t *s, ngx_connection_t *c) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
285 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
286 ngx_str_t *arg; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
287 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
288 #if (NGX_MAIL_SSL) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
289 if (ngx_mail_starttls_only(s, c)) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
290 return NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
291 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
292 #endif |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
293 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
294 if (s->args.nelts != 1) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
295 return NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
296 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
297 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
298 arg = s->args.elts; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
299 s->login.len = arg[0].len; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
300 s->login.data = ngx_palloc(c->pool, s->login.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
301 if (s->login.data == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
302 return NGX_ERROR; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
303 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
304 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
305 ngx_memcpy(s->login.data, arg[0].data, s->login.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
306 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
307 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
308 "pop3 login: \"%V\"", &s->login); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
309 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
310 s->mail_state = ngx_pop3_user; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
311 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
312 return NGX_OK; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
313 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
314 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
315 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
316 static ngx_int_t |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
317 ngx_mail_pop3_pass(ngx_mail_session_t *s, ngx_connection_t *c) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
318 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
319 ngx_str_t *arg; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
320 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
321 if (s->args.nelts != 1) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
322 return NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
323 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
324 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
325 arg = s->args.elts; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
326 s->passwd.len = arg[0].len; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
327 s->passwd.data = ngx_palloc(c->pool, s->passwd.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
328 if (s->passwd.data == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
329 return NGX_ERROR; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
330 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
331 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
332 ngx_memcpy(s->passwd.data, arg[0].data, s->passwd.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
333 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
334 #if (NGX_DEBUG_MAIL_PASSWD) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
335 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
336 "pop3 passwd: \"%V\"", &s->passwd); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
337 #endif |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
338 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
339 return NGX_DONE; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
340 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
341 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
342 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
343 static ngx_int_t |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
344 ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c, ngx_int_t stls) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
345 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
346 ngx_mail_pop3_srv_conf_t *pscf; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
347 #if (NGX_MAIL_SSL) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
348 ngx_mail_ssl_conf_t *sslcf; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
349 #endif |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
350 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
351 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
352 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
353 #if (NGX_MAIL_SSL) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
354 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
355 if (stls && c->ssl == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
356 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
357 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
358 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
359 s->out = pscf->starttls_capability; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
360 return NGX_OK; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
361 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
362 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
363 if (sslcf->starttls == NGX_MAIL_STARTTLS_ONLY) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
364 s->out = pscf->starttls_only_capability; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
365 return NGX_OK; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
366 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
367 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
368 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
369 #endif |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
370 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
371 s->out = pscf->capability; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
372 return NGX_OK; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
373 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
374 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
375 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
376 static ngx_int_t |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
377 ngx_mail_pop3_stls(ngx_mail_session_t *s, ngx_connection_t *c) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
378 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
379 #if (NGX_MAIL_SSL) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
380 ngx_mail_ssl_conf_t *sslcf; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
381 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
382 if (c->ssl == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
383 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
384 if (sslcf->starttls) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
385 c->read->handler = ngx_mail_starttls_handler; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
386 return NGX_OK; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
387 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
388 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
389 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
390 #endif |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
391 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
392 return NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
393 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
394 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
395 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
396 static ngx_int_t |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
397 ngx_mail_pop3_apop(ngx_mail_session_t *s, ngx_connection_t *c) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
398 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
399 ngx_str_t *arg; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
400 ngx_mail_pop3_srv_conf_t *pscf; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
401 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
402 #if (NGX_MAIL_SSL) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
403 if (ngx_mail_starttls_only(s, c)) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
404 return NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
405 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
406 #endif |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
407 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
408 if (s->args.nelts != 2) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
409 return NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
410 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
411 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
412 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
413 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
414 if (!(pscf->auth_methods & NGX_MAIL_AUTH_APOP_ENABLED)) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
415 return NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
416 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
417 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
418 arg = s->args.elts; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
419 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
420 s->login.len = arg[0].len; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
421 s->login.data = ngx_palloc(c->pool, s->login.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
422 if (s->login.data == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
423 return NGX_ERROR; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
424 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
425 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
426 ngx_memcpy(s->login.data, arg[0].data, s->login.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
427 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
428 s->passwd.len = arg[1].len; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
429 s->passwd.data = ngx_palloc(c->pool, s->passwd.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
430 if (s->passwd.data == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
431 return NGX_ERROR; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
432 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
433 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
434 ngx_memcpy(s->passwd.data, arg[1].data, s->passwd.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
435 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
436 ngx_log_debug2(NGX_LOG_DEBUG_MAIL, c->log, 0, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
437 "pop3 apop: \"%V\" \"%V\"", &s->login, &s->passwd); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
438 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
439 s->auth_method = NGX_MAIL_AUTH_APOP; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
440 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
441 return NGX_DONE; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
442 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
443 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
444 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
445 static ngx_int_t |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
446 ngx_mail_pop3_auth(ngx_mail_session_t *s, ngx_connection_t *c) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
447 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
448 ngx_int_t rc; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
449 ngx_mail_pop3_srv_conf_t *pscf; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
450 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
451 #if (NGX_MAIL_SSL) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
452 if (ngx_mail_starttls_only(s, c)) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
453 return NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
454 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
455 #endif |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
456 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
457 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
458 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
459 if (s->args.nelts == 0) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
460 s->out = pscf->auth_capability; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
461 s->state = 0; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
462 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
463 return NGX_OK; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
464 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
465 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
466 rc = ngx_mail_auth_parse(s, c); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
467 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
468 switch (rc) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
469 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
470 case NGX_MAIL_AUTH_LOGIN: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
471 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
472 s->out.len = sizeof(pop3_username) - 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
473 s->out.data = pop3_username; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
474 s->mail_state = ngx_pop3_auth_login_username; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
475 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
476 return NGX_OK; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
477 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
478 case NGX_MAIL_AUTH_PLAIN: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
479 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
480 s->out.len = sizeof(pop3_next) - 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
481 s->out.data = pop3_next; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
482 s->mail_state = ngx_pop3_auth_plain; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
483 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
484 return NGX_OK; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
485 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
486 case NGX_MAIL_AUTH_CRAM_MD5: |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
487 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
488 if (!(pscf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
489 return NGX_MAIL_PARSE_INVALID_COMMAND; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
490 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
491 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
492 if (ngx_mail_auth_cram_md5_salt(s, c, "+ ", 2) == NGX_OK) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
493 s->mail_state = ngx_pop3_auth_cram_md5; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
494 return NGX_OK; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
495 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
496 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
497 return NGX_ERROR; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
498 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
499 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
500 return rc; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
501 } |