Mercurial > hg > nginx-quic
annotate src/mail/ngx_mail_smtp_handler.c @ 8531:41f4bd4c51f1
Disabled control characters and space in header names.
Control characters (0x00-0x1f, 0x7f), space, and colon were never allowed in
header names. The only somewhat valid use is header continuation which nginx
never supported and which is explicitly obsolete by RFC 7230.
Previously, such headers were considered invalid and were ignored by default
(as per ignore_invalid_headers directive). With this change, such headers
are unconditionally rejected.
It is expected to make nginx more resilient to various attacks, in particular,
with ignore_invalid_headers switched off (which is inherently unsecure, though
nevertheless sometimes used in the wild).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 28 Jun 2021 18:01:18 +0300 |
parents | da0a85e91587 |
children |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
6 |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_event.h> |
1136 | 11 #include <ngx_mail.h> |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
12 #include <ngx_mail_smtp_module.h> |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
13 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
14 |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
15 static void ngx_mail_smtp_resolve_addr_handler(ngx_resolver_ctx_t *ctx); |
2488
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
16 static void ngx_mail_smtp_resolve_name(ngx_event_t *rev); |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
17 static void ngx_mail_smtp_resolve_name_handler(ngx_resolver_ctx_t *ctx); |
7546
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
18 static void ngx_mail_smtp_block_reading(ngx_event_t *rev); |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
19 static void ngx_mail_smtp_greeting(ngx_mail_session_t *s, ngx_connection_t *c); |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
20 static void ngx_mail_smtp_invalid_pipelining(ngx_event_t *rev); |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
21 static ngx_int_t ngx_mail_smtp_create_buffer(ngx_mail_session_t *s, |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
22 ngx_connection_t *c); |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
23 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
24 static ngx_int_t ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
25 static ngx_int_t ngx_mail_smtp_auth(ngx_mail_session_t *s, ngx_connection_t *c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
26 static ngx_int_t ngx_mail_smtp_mail(ngx_mail_session_t *s, ngx_connection_t *c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
27 static ngx_int_t ngx_mail_smtp_starttls(ngx_mail_session_t *s, |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
28 ngx_connection_t *c); |
2309 | 29 static ngx_int_t ngx_mail_smtp_rset(ngx_mail_session_t *s, ngx_connection_t *c); |
30 static ngx_int_t ngx_mail_smtp_rcpt(ngx_mail_session_t *s, ngx_connection_t *c); | |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
32 static ngx_int_t ngx_mail_smtp_discard_command(ngx_mail_session_t *s, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
33 ngx_connection_t *c, char *err); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
34 static void ngx_mail_smtp_log_rejected_command(ngx_mail_session_t *s, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
35 ngx_connection_t *c, char *err); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
36 |
527 | 37 |
1136 | 38 static u_char smtp_ok[] = "250 2.0.0 OK" CRLF; |
39 static u_char smtp_bye[] = "221 2.0.0 Bye" CRLF; | |
1762 | 40 static u_char smtp_starttls[] = "220 2.0.0 Start TLS" CRLF; |
1136 | 41 static u_char smtp_next[] = "334 " CRLF; |
42 static u_char smtp_username[] = "334 VXNlcm5hbWU6" CRLF; | |
43 static u_char smtp_password[] = "334 UGFzc3dvcmQ6" CRLF; | |
44 static u_char smtp_invalid_command[] = "500 5.5.1 Invalid command" CRLF; | |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
45 static u_char smtp_invalid_pipelining[] = |
6474 | 46 "503 5.5.0 Improper use of SMTP command pipelining" CRLF; |
1136 | 47 static u_char smtp_invalid_argument[] = "501 5.5.4 Invalid argument" CRLF; |
48 static u_char smtp_auth_required[] = "530 5.7.1 Authentication required" CRLF; | |
2309 | 49 static u_char smtp_bad_sequence[] = "503 5.5.1 Bad sequence of commands" CRLF; |
1136 | 50 |
521 | 51 |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
52 static ngx_str_t smtp_unavailable = ngx_string("[UNAVAILABLE]"); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
53 static ngx_str_t smtp_tempunavail = ngx_string("[TEMPUNAVAIL]"); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
54 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
55 |
521 | 56 void |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
57 ngx_mail_smtp_init_session(ngx_mail_session_t *s, ngx_connection_t *c) |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 { |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
59 ngx_resolver_ctx_t *ctx; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
60 ngx_mail_core_srv_conf_t *cscf; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
61 |
1896
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
62 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
63 |
1896
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
64 if (cscf->resolver == NULL) { |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
65 s->host = smtp_unavailable; |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
66 ngx_mail_smtp_greeting(s, c); |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
67 return; |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
68 } |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
69 |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
70 #if (NGX_HAVE_UNIX_DOMAIN) |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
71 if (c->sockaddr->sa_family == AF_UNIX) { |
2855
a96a8c916b0c
mail proxy listen IPv6 support
Igor Sysoev <igor@sysoev.ru>
parents:
2495
diff
changeset
|
72 s->host = smtp_tempunavail; |
a96a8c916b0c
mail proxy listen IPv6 support
Igor Sysoev <igor@sysoev.ru>
parents:
2495
diff
changeset
|
73 ngx_mail_smtp_greeting(s, c); |
a96a8c916b0c
mail proxy listen IPv6 support
Igor Sysoev <igor@sysoev.ru>
parents:
2495
diff
changeset
|
74 return; |
a96a8c916b0c
mail proxy listen IPv6 support
Igor Sysoev <igor@sysoev.ru>
parents:
2495
diff
changeset
|
75 } |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
76 #endif |
2855
a96a8c916b0c
mail proxy listen IPv6 support
Igor Sysoev <igor@sysoev.ru>
parents:
2495
diff
changeset
|
77 |
1896
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
78 c->log->action = "in resolving client address"; |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
79 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
80 ctx = ngx_resolve_start(cscf->resolver, NULL); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
81 if (ctx == NULL) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
82 ngx_mail_close_connection(c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
83 return; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
84 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
85 |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
86 ctx->addr.sockaddr = c->sockaddr; |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
87 ctx->addr.socklen = c->socklen; |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
88 ctx->handler = ngx_mail_smtp_resolve_addr_handler; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
89 ctx->data = s; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
90 ctx->timeout = cscf->resolver_timeout; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
91 |
7546
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
92 s->resolver_ctx = ctx; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
93 c->read->handler = ngx_mail_smtp_block_reading; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
94 |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
95 if (ngx_resolve_addr(ctx) != NGX_OK) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
96 ngx_mail_close_connection(c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
97 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
98 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
99 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
100 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
101 static void |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
102 ngx_mail_smtp_resolve_addr_handler(ngx_resolver_ctx_t *ctx) |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
103 { |
2488
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
104 ngx_connection_t *c; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
105 ngx_mail_session_t *s; |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
106 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
107 s = ctx->data; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
108 c = s->connection; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
109 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
110 if (ctx->state) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
111 ngx_log_error(NGX_LOG_ERR, c->log, 0, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
112 "%V could not be resolved (%i: %s)", |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
113 &c->addr_text, ctx->state, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
114 ngx_resolver_strerror(ctx->state)); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
115 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
116 if (ctx->state == NGX_RESOLVE_NXDOMAIN) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
117 s->host = smtp_unavailable; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
118 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
119 } else { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
120 s->host = smtp_tempunavail; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
121 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
122 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
123 ngx_resolve_addr_done(ctx); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
124 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
125 ngx_mail_smtp_greeting(s, s->connection); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
126 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
127 return; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
128 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
129 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
130 c->log->action = "in resolving client hostname"; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
131 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
132 s->host.data = ngx_pstrdup(c->pool, &ctx->name); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
133 if (s->host.data == NULL) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
134 ngx_resolve_addr_done(ctx); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
135 ngx_mail_close_connection(c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
136 return; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
137 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
138 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
139 s->host.len = ctx->name.len; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
140 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
141 ngx_resolve_addr_done(ctx); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
142 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
143 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
144 "address resolved: %V", &s->host); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
145 |
2488
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
146 c->read->handler = ngx_mail_smtp_resolve_name; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
147 |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
148 ngx_post_event(c->read, &ngx_posted_events); |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
149 } |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
150 |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
151 |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
152 static void |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
153 ngx_mail_smtp_resolve_name(ngx_event_t *rev) |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
154 { |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
155 ngx_connection_t *c; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
156 ngx_mail_session_t *s; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
157 ngx_resolver_ctx_t *ctx; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
158 ngx_mail_core_srv_conf_t *cscf; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
159 |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
160 c = rev->data; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
161 s = c->data; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
162 |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
163 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
164 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
165 ctx = ngx_resolve_start(cscf->resolver, NULL); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
166 if (ctx == NULL) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
167 ngx_mail_close_connection(c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
168 return; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
169 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
170 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
171 ctx->name = s->host; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
172 ctx->handler = ngx_mail_smtp_resolve_name_handler; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
173 ctx->data = s; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
174 ctx->timeout = cscf->resolver_timeout; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
175 |
7546
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
176 s->resolver_ctx = ctx; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
177 c->read->handler = ngx_mail_smtp_block_reading; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
178 |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
179 if (ngx_resolve_name(ctx) != NGX_OK) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
180 ngx_mail_close_connection(c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
181 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
182 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
183 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
184 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
185 static void |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
186 ngx_mail_smtp_resolve_name_handler(ngx_resolver_ctx_t *ctx) |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
187 { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
188 ngx_uint_t i; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
189 ngx_connection_t *c; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
190 ngx_mail_session_t *s; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
191 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
192 s = ctx->data; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
193 c = s->connection; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
194 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
195 if (ctx->state) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
196 ngx_log_error(NGX_LOG_ERR, c->log, 0, |
3299
0b6277a58a2d
*) fix resolving an empty name ("."),
Igor Sysoev <igor@sysoev.ru>
parents:
3298
diff
changeset
|
197 "\"%V\" could not be resolved (%i: %s)", |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
198 &ctx->name, ctx->state, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
199 ngx_resolver_strerror(ctx->state)); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
200 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
201 if (ctx->state == NGX_RESOLVE_NXDOMAIN) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
202 s->host = smtp_unavailable; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
203 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
204 } else { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
205 s->host = smtp_tempunavail; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
206 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
207 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
208 } else { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
209 |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
210 #if (NGX_DEBUG) |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
211 { |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
212 u_char text[NGX_SOCKADDR_STRLEN]; |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
213 ngx_str_t addr; |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
214 |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
215 addr.data = text; |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
216 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
217 for (i = 0; i < ctx->naddrs; i++) { |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
218 addr.len = ngx_sock_ntop(ctx->addrs[i].sockaddr, |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
219 ctx->addrs[i].socklen, |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
220 text, NGX_SOCKADDR_STRLEN, 0); |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
221 |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
222 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
223 "name was resolved to %V", &addr); |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
224 } |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
225 } |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
226 #endif |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
227 |
5475
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
228 for (i = 0; i < ctx->naddrs; i++) { |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
229 if (ngx_cmp_sockaddr(ctx->addrs[i].sockaddr, ctx->addrs[i].socklen, |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
230 c->sockaddr, c->socklen, 0) |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
231 == NGX_OK) |
07dd5bd222ac
Changed resolver API to use ngx_addr_t.
Ruslan Ermilov <ru@nginx.com>
parents:
5398
diff
changeset
|
232 { |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
233 goto found; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
234 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
235 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
236 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
237 s->host = smtp_unavailable; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
238 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
239 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
240 found: |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
241 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
242 ngx_resolve_name_done(ctx); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
243 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
244 ngx_mail_smtp_greeting(s, c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
245 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
246 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
247 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
248 static void |
7546
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
249 ngx_mail_smtp_block_reading(ngx_event_t *rev) |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
250 { |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
251 ngx_connection_t *c; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
252 ngx_mail_session_t *s; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
253 ngx_resolver_ctx_t *ctx; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
254 |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
255 c = rev->data; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
256 s = c->data; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
257 |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
258 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "smtp reading blocked"); |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
259 |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
260 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
261 |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
262 if (s->resolver_ctx) { |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
263 ctx = s->resolver_ctx; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
264 |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
265 if (ctx->handler == ngx_mail_smtp_resolve_addr_handler) { |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
266 ngx_resolve_addr_done(ctx); |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
267 |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
268 } else if (ctx->handler == ngx_mail_smtp_resolve_name_handler) { |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
269 ngx_resolve_name_done(ctx); |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
270 } |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
271 |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
272 s->resolver_ctx = NULL; |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
273 } |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
274 |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
275 ngx_mail_close_connection(c); |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
276 } |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
277 } |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
278 |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
279 |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
280 static void |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
281 ngx_mail_smtp_greeting(ngx_mail_session_t *s, ngx_connection_t *c) |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
282 { |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
283 ngx_msec_t timeout; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
284 ngx_mail_core_srv_conf_t *cscf; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
285 ngx_mail_smtp_srv_conf_t *sscf; |
641 | 286 |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
287 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
288 "smtp greeting for \"%V\"", &s->host); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
289 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
290 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
291 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); |
541 | 292 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
293 timeout = sscf->greeting_delay ? sscf->greeting_delay : cscf->timeout; |
1486
0e7074ef7303
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1485
diff
changeset
|
294 ngx_add_timer(c->read, timeout); |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
295 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2309
diff
changeset
|
296 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
297 ngx_mail_close_connection(c); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
298 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
299 |
7546
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
300 if (c->read->ready) { |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
301 ngx_post_event(c->read, &ngx_posted_events); |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
302 } |
fcd92ad76b7b
Mail: fixed duplicate resolving.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6869
diff
changeset
|
303 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
304 if (sscf->greeting_delay) { |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
305 c->read->handler = ngx_mail_smtp_invalid_pipelining; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
306 return; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
307 } |
1480
a231e37a19ab
move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents:
1479
diff
changeset
|
308 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
309 c->read->handler = ngx_mail_smtp_init_protocol; |
583 | 310 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
311 s->out = sscf->greeting; |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
312 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
313 ngx_mail_send(c->write); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
314 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
315 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
316 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
317 static void |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
318 ngx_mail_smtp_invalid_pipelining(ngx_event_t *rev) |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
319 { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
320 ngx_connection_t *c; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
321 ngx_mail_session_t *s; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
322 ngx_mail_core_srv_conf_t *cscf; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
323 ngx_mail_smtp_srv_conf_t *sscf; |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
324 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
325 c = rev->data; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
326 s = c->data; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
327 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
328 c->log->action = "in delay pipelining state"; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
329 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
330 if (rev->timedout) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
331 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
332 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "delay greeting"); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
333 |
1484 | 334 rev->timedout = 0; |
335 | |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
336 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
1480
a231e37a19ab
move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents:
1479
diff
changeset
|
337 |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
338 c->read->handler = ngx_mail_smtp_init_protocol; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
339 |
1486
0e7074ef7303
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1485
diff
changeset
|
340 ngx_add_timer(c->read, cscf->timeout); |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
341 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2309
diff
changeset
|
342 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
343 ngx_mail_close_connection(c); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
344 return; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
345 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
346 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
347 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
348 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
349 s->out = sscf->greeting; |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
350 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
351 } else { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
352 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
353 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "invalid pipelining"); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
354 |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
355 if (s->buffer == NULL) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
356 if (ngx_mail_smtp_create_buffer(s, c) != NGX_OK) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
357 return; |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
358 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
359 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
360 |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
361 if (ngx_mail_smtp_discard_command(s, c, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
362 "client was rejected before greeting: \"%V\"") |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
363 != NGX_OK) |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
364 { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
365 return; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
366 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
367 |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
368 ngx_str_set(&s->out, smtp_invalid_pipelining); |
5396
42f874c0b970
Mail: added session close on smtp_greeting_delay violation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
369 s->quit = 1; |
1480
a231e37a19ab
move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents:
1479
diff
changeset
|
370 } |
539 | 371 |
1136 | 372 ngx_mail_send(c->write); |
539 | 373 } |
374 | |
375 | |
376 void | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
377 ngx_mail_smtp_init_protocol(ngx_event_t *rev) |
539 | 378 { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
379 ngx_connection_t *c; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
380 ngx_mail_session_t *s; |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
381 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
382 c = rev->data; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
383 |
541 | 384 c->log->action = "in auth state"; |
385 | |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
386 if (rev->timedout) { |
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
387 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
577 | 388 c->timedout = 1; |
1136 | 389 ngx_mail_close_connection(c); |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
390 return; |
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
391 } |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
392 |
539 | 393 s = c->data; |
521 | 394 |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
395 if (s->buffer == NULL) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
396 if (ngx_mail_smtp_create_buffer(s, c) != NGX_OK) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
397 return; |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
398 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
399 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
400 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
401 s->mail_state = ngx_smtp_start; |
1477 | 402 c->read->handler = ngx_mail_smtp_auth_state; |
1136 | 403 |
1477 | 404 ngx_mail_smtp_auth_state(rev); |
521 | 405 } |
406 | |
407 | |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
408 static ngx_int_t |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
409 ngx_mail_smtp_create_buffer(ngx_mail_session_t *s, ngx_connection_t *c) |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
410 { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
411 ngx_mail_smtp_srv_conf_t *sscf; |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
412 |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
413 if (ngx_array_init(&s->args, c->pool, 2, sizeof(ngx_str_t)) == NGX_ERROR) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
414 ngx_mail_session_internal_server_error(s); |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
415 return NGX_ERROR; |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
416 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
417 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
418 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
419 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
420 s->buffer = ngx_create_temp_buf(c->pool, sscf->client_buffer_size); |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
421 if (s->buffer == NULL) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
422 ngx_mail_session_internal_server_error(s); |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
423 return NGX_ERROR; |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
424 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
425 |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
426 return NGX_OK; |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
427 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
428 |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
429 |
527 | 430 void |
1477 | 431 ngx_mail_smtp_auth_state(ngx_event_t *rev) |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
432 { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
433 ngx_int_t rc; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
434 ngx_connection_t *c; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
435 ngx_mail_session_t *s; |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
436 |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
437 c = rev->data; |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
438 s = c->data; |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
439 |
1136 | 440 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "smtp auth state"); |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
441 |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
442 if (rev->timedout) { |
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
443 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
577 | 444 c->timedout = 1; |
1136 | 445 ngx_mail_close_connection(c); |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
446 return; |
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
447 } |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
448 |
539 | 449 if (s->out.len) { |
1136 | 450 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "smtp send handler busy"); |
539 | 451 s->blocked = 1; |
8338
ab6257dac2a8
Mail: added missing event handling after blocking events.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7546
diff
changeset
|
452 |
ab6257dac2a8
Mail: added missing event handling after blocking events.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7546
diff
changeset
|
453 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
ab6257dac2a8
Mail: added missing event handling after blocking events.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7546
diff
changeset
|
454 ngx_mail_close_connection(c); |
ab6257dac2a8
Mail: added missing event handling after blocking events.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7546
diff
changeset
|
455 return; |
ab6257dac2a8
Mail: added missing event handling after blocking events.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7546
diff
changeset
|
456 } |
ab6257dac2a8
Mail: added missing event handling after blocking events.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7546
diff
changeset
|
457 |
539 | 458 return; |
459 } | |
460 | |
461 s->blocked = 0; | |
462 | |
1482 | 463 rc = ngx_mail_read_command(s, c); |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
464 |
8339
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
465 if (rc == NGX_AGAIN) { |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
466 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
467 ngx_mail_session_internal_server_error(s); |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
468 return; |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
469 } |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
470 |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
471 return; |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
472 } |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
473 |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
474 if (rc == NGX_ERROR) { |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
475 return; |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
476 } |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
477 |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
478 ngx_str_set(&s->out, smtp_ok); |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
479 |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
480 if (rc == NGX_OK) { |
1136 | 481 switch (s->mail_state) { |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
482 |
1136 | 483 case ngx_smtp_start: |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
484 |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
485 switch (s->command) { |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
486 |
1136 | 487 case NGX_SMTP_HELO: |
488 case NGX_SMTP_EHLO: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
489 rc = ngx_mail_smtp_helo(s, c); |
809 | 490 break; |
491 | |
1136 | 492 case NGX_SMTP_AUTH: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
493 rc = ngx_mail_smtp_auth(s, c); |
800 | 494 break; |
495 | |
1136 | 496 case NGX_SMTP_QUIT: |
539 | 497 s->quit = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
498 ngx_str_set(&s->out, smtp_bye); |
527 | 499 break; |
500 | |
1136 | 501 case NGX_SMTP_MAIL: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
502 rc = ngx_mail_smtp_mail(s, c); |
583 | 503 break; |
504 | |
2309 | 505 case NGX_SMTP_RCPT: |
506 rc = ngx_mail_smtp_rcpt(s, c); | |
507 break; | |
508 | |
509 case NGX_SMTP_RSET: | |
510 rc = ngx_mail_smtp_rset(s, c); | |
511 break; | |
512 | |
1136 | 513 case NGX_SMTP_NOOP: |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
514 break; |
1322 | 515 |
516 case NGX_SMTP_STARTTLS: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
517 rc = ngx_mail_smtp_starttls(s, c); |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
518 ngx_str_set(&s->out, smtp_starttls); |
1322 | 519 break; |
520 | |
521 default: | |
522 rc = NGX_MAIL_PARSE_INVALID_COMMAND; | |
523 break; | |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
524 } |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
525 |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
526 break; |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
527 |
1136 | 528 case ngx_smtp_auth_login_username: |
2495
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
529 rc = ngx_mail_auth_login_username(s, c, 0); |
809 | 530 |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
531 ngx_str_set(&s->out, smtp_password); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
532 s->mail_state = ngx_smtp_auth_login_password; |
809 | 533 break; |
534 | |
1136 | 535 case ngx_smtp_auth_login_password: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
536 rc = ngx_mail_auth_login_password(s, c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
537 break; |
809 | 538 |
1136 | 539 case ngx_smtp_auth_plain: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
540 rc = ngx_mail_auth_plain(s, c, 0); |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
541 break; |
809 | 542 |
1136 | 543 case ngx_smtp_auth_cram_md5: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
544 rc = ngx_mail_auth_cram_md5(s, c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
545 break; |
6774
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
546 |
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
547 case ngx_smtp_auth_external: |
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
548 rc = ngx_mail_auth_external(s, c, 0); |
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
549 break; |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
550 } |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
551 } |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
552 |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
553 if (s->buffer->pos < s->buffer->last) { |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
554 s->blocked = 1; |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
555 } |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
556 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
557 switch (rc) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
558 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
559 case NGX_DONE: |
1482 | 560 ngx_mail_auth(s, c); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
561 return; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
562 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
563 case NGX_ERROR: |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
564 ngx_mail_session_internal_server_error(s); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
565 return; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
566 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
567 case NGX_MAIL_PARSE_INVALID_COMMAND: |
1136 | 568 s->mail_state = ngx_smtp_start; |
1486
0e7074ef7303
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1485
diff
changeset
|
569 s->state = 0; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
570 ngx_str_set(&s->out, smtp_invalid_command); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
571 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
572 /* fall through */ |
539 | 573 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
574 case NGX_OK: |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
575 s->args.nelts = 0; |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
576 |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
577 if (s->buffer->pos == s->buffer->last) { |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
578 s->buffer->pos = s->buffer->start; |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
579 s->buffer->last = s->buffer->start; |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
580 } |
810 | 581 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
582 if (s->state) { |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
583 s->arg_start = s->buffer->pos; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
584 } |
539 | 585 |
8339
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
586 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
587 ngx_mail_session_internal_server_error(s); |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
588 return; |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
589 } |
da0a85e91587
Mail: added missing event handling after reading data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8338
diff
changeset
|
590 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
591 ngx_mail_send(c->write); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
592 } |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
593 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
594 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
595 |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
596 static ngx_int_t |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
597 ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c) |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
598 { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
599 ngx_str_t *arg; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
600 ngx_mail_smtp_srv_conf_t *sscf; |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
601 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
602 if (s->args.nelts != 1) { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
603 ngx_str_set(&s->out, smtp_invalid_argument); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
604 s->state = 0; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
605 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
606 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
607 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
608 arg = s->args.elts; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
609 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
610 s->smtp_helo.len = arg[0].len; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
611 |
2049 | 612 s->smtp_helo.data = ngx_pnalloc(c->pool, arg[0].len); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
613 if (s->smtp_helo.data == NULL) { |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
614 return NGX_ERROR; |
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
615 } |
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
616 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
617 ngx_memcpy(s->smtp_helo.data, arg[0].data, arg[0].len); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
618 |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
619 ngx_str_null(&s->smtp_from); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
620 ngx_str_null(&s->smtp_to); |
2309 | 621 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
622 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
623 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
624 if (s->command == NGX_SMTP_HELO) { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
625 s->out = sscf->server_name; |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
626 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
627 } else { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
628 s->esmtp = 1; |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
629 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
630 #if (NGX_MAIL_SSL) |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
631 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
632 if (c->ssl == NULL) { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1493
diff
changeset
|
633 ngx_mail_ssl_conf_t *sslcf; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1493
diff
changeset
|
634 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
635 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
636 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
637 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
638 s->out = sscf->starttls_capability; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
639 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
640 } |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
641 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
642 if (sslcf->starttls == NGX_MAIL_STARTTLS_ONLY) { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
643 s->out = sscf->starttls_only_capability; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
644 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
645 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
646 } |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
647 #endif |
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
648 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
649 s->out = sscf->capability; |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
650 } |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
651 |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
652 return NGX_OK; |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
653 } |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
654 |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
655 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
656 static ngx_int_t |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
657 ngx_mail_smtp_auth(ngx_mail_session_t *s, ngx_connection_t *c) |
525 | 658 { |
1479 | 659 ngx_int_t rc; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
660 ngx_mail_core_srv_conf_t *cscf; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
661 ngx_mail_smtp_srv_conf_t *sscf; |
525 | 662 |
1479 | 663 #if (NGX_MAIL_SSL) |
664 if (ngx_mail_starttls_only(s, c)) { | |
665 return NGX_MAIL_PARSE_INVALID_COMMAND; | |
539 | 666 } |
667 #endif | |
668 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
669 if (s->args.nelts == 0) { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
670 ngx_str_set(&s->out, smtp_invalid_argument); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
671 s->state = 0; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
672 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
673 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
674 |
6869
b2915d99ee8d
Mail: make it possible to disable SASL EXTERNAL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6774
diff
changeset
|
675 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); |
b2915d99ee8d
Mail: make it possible to disable SASL EXTERNAL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6774
diff
changeset
|
676 |
1479 | 677 rc = ngx_mail_auth_parse(s, c); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
678 |
1479 | 679 switch (rc) { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
680 |
1479 | 681 case NGX_MAIL_AUTH_LOGIN: |
1472
32450a2bbdf4
decrement active connection counter in mail proxy
Igor Sysoev <igor@sysoev.ru>
parents:
1323
diff
changeset
|
682 |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
683 ngx_str_set(&s->out, smtp_username); |
1479 | 684 s->mail_state = ngx_smtp_auth_login_username; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
685 |
1479 | 686 return NGX_OK; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
687 |
2495
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
688 case NGX_MAIL_AUTH_LOGIN_USERNAME: |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
689 |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
690 ngx_str_set(&s->out, smtp_password); |
2495
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
691 s->mail_state = ngx_smtp_auth_login_password; |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
692 |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
693 return ngx_mail_auth_login_username(s, c, 1); |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
694 |
1479 | 695 case NGX_MAIL_AUTH_PLAIN: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
696 |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
697 ngx_str_set(&s->out, smtp_next); |
1479 | 698 s->mail_state = ngx_smtp_auth_plain; |
543 | 699 |
1479 | 700 return NGX_OK; |
701 | |
702 case NGX_MAIL_AUTH_CRAM_MD5: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
703 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
704 if (!(sscf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
705 return NGX_MAIL_PARSE_INVALID_COMMAND; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
706 } |
479 | 707 |
1485
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
708 if (s->salt.data == NULL) { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
709 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
710 |
1485
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
711 if (ngx_mail_salt(s, c, cscf) != NGX_OK) { |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
712 return NGX_ERROR; |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
713 } |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
714 } |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
715 |
1479 | 716 if (ngx_mail_auth_cram_md5_salt(s, c, "334 ", 4) == NGX_OK) { |
717 s->mail_state = ngx_smtp_auth_cram_md5; | |
718 return NGX_OK; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
719 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
720 |
1479 | 721 return NGX_ERROR; |
6774
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
722 |
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
723 case NGX_MAIL_AUTH_EXTERNAL: |
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
724 |
6869
b2915d99ee8d
Mail: make it possible to disable SASL EXTERNAL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6774
diff
changeset
|
725 if (!(sscf->auth_methods & NGX_MAIL_AUTH_EXTERNAL_ENABLED)) { |
b2915d99ee8d
Mail: make it possible to disable SASL EXTERNAL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6774
diff
changeset
|
726 return NGX_MAIL_PARSE_INVALID_COMMAND; |
b2915d99ee8d
Mail: make it possible to disable SASL EXTERNAL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6774
diff
changeset
|
727 } |
b2915d99ee8d
Mail: make it possible to disable SASL EXTERNAL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6774
diff
changeset
|
728 |
6774
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
729 ngx_str_set(&s->out, smtp_username); |
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
730 s->mail_state = ngx_smtp_auth_external; |
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
731 |
bcb107bb89cd
Mail: support SASL EXTERNAL (RFC 4422).
Rob N ★ <robn@fastmail.com>
parents:
6474
diff
changeset
|
732 return NGX_OK; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
733 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
734 |
1479 | 735 return rc; |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
736 } |
539 | 737 |
738 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
739 static ngx_int_t |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
740 ngx_mail_smtp_mail(ngx_mail_session_t *s, ngx_connection_t *c) |
541 | 741 { |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
742 ngx_str_t *arg, cmd; |
2309 | 743 ngx_mail_smtp_srv_conf_t *sscf; |
744 | |
745 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); | |
746 | |
747 if (!(sscf->auth_methods & NGX_MAIL_AUTH_NONE_ENABLED)) { | |
748 ngx_mail_smtp_log_rejected_command(s, c, "client was rejected: \"%V\""); | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
749 ngx_str_set(&s->out, smtp_auth_required); |
2309 | 750 return NGX_OK; |
751 } | |
752 | |
753 /* auth none */ | |
754 | |
755 if (s->smtp_from.len) { | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
756 ngx_str_set(&s->out, smtp_bad_sequence); |
2309 | 757 return NGX_OK; |
758 } | |
759 | |
5703
7deb01451486
Mail: added a check for the number of arguments in MAIL/RCPT.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5477
diff
changeset
|
760 if (s->args.nelts == 0) { |
7deb01451486
Mail: added a check for the number of arguments in MAIL/RCPT.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5477
diff
changeset
|
761 ngx_str_set(&s->out, smtp_invalid_argument); |
7deb01451486
Mail: added a check for the number of arguments in MAIL/RCPT.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5477
diff
changeset
|
762 return NGX_OK; |
7deb01451486
Mail: added a check for the number of arguments in MAIL/RCPT.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5477
diff
changeset
|
763 } |
7deb01451486
Mail: added a check for the number of arguments in MAIL/RCPT.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5477
diff
changeset
|
764 |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
765 arg = s->args.elts; |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
766 arg += s->args.nelts - 1; |
2309 | 767 |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
768 cmd.len = arg->data + arg->len - s->cmd.data; |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
769 cmd.data = s->cmd.data; |
2309 | 770 |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
771 s->smtp_from.len = cmd.len; |
2309 | 772 |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
773 s->smtp_from.data = ngx_pnalloc(c->pool, cmd.len); |
2309 | 774 if (s->smtp_from.data == NULL) { |
775 return NGX_ERROR; | |
776 } | |
777 | |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
778 ngx_memcpy(s->smtp_from.data, cmd.data, cmd.len); |
2309 | 779 |
780 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, | |
781 "smtp mail from:\"%V\"", &s->smtp_from); | |
782 | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
783 ngx_str_set(&s->out, smtp_ok); |
2309 | 784 |
785 return NGX_OK; | |
786 } | |
577 | 787 |
2309 | 788 |
789 static ngx_int_t | |
790 ngx_mail_smtp_rcpt(ngx_mail_session_t *s, ngx_connection_t *c) | |
791 { | |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
792 ngx_str_t *arg, cmd; |
2309 | 793 |
794 if (s->smtp_from.len == 0) { | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
795 ngx_str_set(&s->out, smtp_bad_sequence); |
2309 | 796 return NGX_OK; |
797 } | |
798 | |
5703
7deb01451486
Mail: added a check for the number of arguments in MAIL/RCPT.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5477
diff
changeset
|
799 if (s->args.nelts == 0) { |
7deb01451486
Mail: added a check for the number of arguments in MAIL/RCPT.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5477
diff
changeset
|
800 ngx_str_set(&s->out, smtp_invalid_argument); |
7deb01451486
Mail: added a check for the number of arguments in MAIL/RCPT.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5477
diff
changeset
|
801 return NGX_OK; |
7deb01451486
Mail: added a check for the number of arguments in MAIL/RCPT.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5477
diff
changeset
|
802 } |
7deb01451486
Mail: added a check for the number of arguments in MAIL/RCPT.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5477
diff
changeset
|
803 |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
804 arg = s->args.elts; |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
805 arg += s->args.nelts - 1; |
2309 | 806 |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
807 cmd.len = arg->data + arg->len - s->cmd.data; |
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
808 cmd.data = s->cmd.data; |
2309 | 809 |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
810 s->smtp_to.len = cmd.len; |
2309 | 811 |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
812 s->smtp_to.data = ngx_pnalloc(c->pool, cmd.len); |
2309 | 813 if (s->smtp_to.data == NULL) { |
814 return NGX_ERROR; | |
815 } | |
816 | |
5398
04e43d03e153
Mail: smtp pipelining support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5396
diff
changeset
|
817 ngx_memcpy(s->smtp_to.data, cmd.data, cmd.len); |
2309 | 818 |
819 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, | |
820 "smtp rcpt to:\"%V\"", &s->smtp_to); | |
821 | |
822 s->auth_method = NGX_MAIL_AUTH_NONE; | |
823 | |
824 return NGX_DONE; | |
825 } | |
826 | |
827 | |
828 static ngx_int_t | |
829 ngx_mail_smtp_rset(ngx_mail_session_t *s, ngx_connection_t *c) | |
830 { | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
831 ngx_str_null(&s->smtp_from); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
832 ngx_str_null(&s->smtp_to); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
833 ngx_str_set(&s->out, smtp_ok); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
834 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
835 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
836 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
837 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
838 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
839 static ngx_int_t |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
840 ngx_mail_smtp_starttls(ngx_mail_session_t *s, ngx_connection_t *c) |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
841 { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
842 #if (NGX_MAIL_SSL) |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
843 ngx_mail_ssl_conf_t *sslcf; |
541 | 844 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
845 if (c->ssl == NULL) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
846 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
847 if (sslcf->starttls) { |
541 | 848 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
849 /* |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
850 * RFC3207 requires us to discard any knowledge |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
851 * obtained from client before STARTTLS. |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
852 */ |
541 | 853 |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
854 ngx_str_null(&s->smtp_helo); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
855 ngx_str_null(&s->smtp_from); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3299
diff
changeset
|
856 ngx_str_null(&s->smtp_to); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
857 |
5787
3f5d0af4e40a
Mail: discard pipelined commands after SMTP STARTTLS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5703
diff
changeset
|
858 s->buffer->pos = s->buffer->start; |
3f5d0af4e40a
Mail: discard pipelined commands after SMTP STARTTLS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5703
diff
changeset
|
859 s->buffer->last = s->buffer->start; |
3f5d0af4e40a
Mail: discard pipelined commands after SMTP STARTTLS.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5703
diff
changeset
|
860 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
861 c->read->handler = ngx_mail_starttls_handler; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
862 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
863 } |
541 | 864 } |
865 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
866 #endif |
541 | 867 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
868 return NGX_MAIL_PARSE_INVALID_COMMAND; |
541 | 869 } |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
870 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
871 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
872 static ngx_int_t |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
873 ngx_mail_smtp_discard_command(ngx_mail_session_t *s, ngx_connection_t *c, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
874 char *err) |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
875 { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
876 ssize_t n; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
877 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
878 n = c->recv(c, s->buffer->last, s->buffer->end - s->buffer->last); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
879 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
880 if (n == NGX_ERROR || n == 0) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
881 ngx_mail_close_connection(c); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
882 return NGX_ERROR; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
883 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
884 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
885 if (n > 0) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
886 s->buffer->last += n; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
887 } |
1486
0e7074ef7303
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1485
diff
changeset
|
888 |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
889 if (n == NGX_AGAIN) { |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2309
diff
changeset
|
890 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
891 ngx_mail_session_internal_server_error(s); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
892 return NGX_ERROR; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
893 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
894 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
895 return NGX_AGAIN; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
896 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
897 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
898 ngx_mail_smtp_log_rejected_command(s, c, err); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
899 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
900 s->buffer->pos = s->buffer->start; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
901 s->buffer->last = s->buffer->start; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
902 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
903 return NGX_OK; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
904 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
905 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
906 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
907 static void |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
908 ngx_mail_smtp_log_rejected_command(ngx_mail_session_t *s, ngx_connection_t *c, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
909 char *err) |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
910 { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
911 u_char ch; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
912 ngx_str_t cmd; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
913 ngx_uint_t i; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
914 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
915 if (c->log->log_level < NGX_LOG_INFO) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
916 return; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
917 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
918 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
919 cmd.len = s->buffer->last - s->buffer->start; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
920 cmd.data = s->buffer->start; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
921 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
922 for (i = 0; i < cmd.len; i++) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
923 ch = cmd.data[i]; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
924 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
925 if (ch != CR && ch != LF) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
926 continue; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
927 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
928 |
1493
3c4111e07b58
use "_" instead of " " as new line substitute, do not delete trailing new line
Igor Sysoev <igor@sysoev.ru>
parents:
1487
diff
changeset
|
929 cmd.data[i] = '_'; |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
930 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
931 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
932 cmd.len = i; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
933 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
934 ngx_log_error(NGX_LOG_INFO, c->log, 0, err, &cmd); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
935 } |