annotate src/mail/ngx_mail_pop3_handler.c @ 326:f70f2f565fe0 NGINX_0_5_33

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