Mercurial > hg > nginx-quic
annotate src/mail/ngx_mail_smtp_module.c @ 1621:ed9cd1702f7a stable-0.5
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
r1487, r1488, r1494, r1495, r1499 merge:
*) ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
*) smtp_client_buffer and smtp_greeting_delay
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 07 Nov 2007 14:24:55 +0000 |
parents | |
children |
rev | line source |
---|---|
1621
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2 /* |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
4 */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
5 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_mail.h> |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 #include <ngx_mail_smtp_module.h> |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 static void *ngx_mail_smtp_create_srv_conf(ngx_conf_t *cf); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 static char *ngx_mail_smtp_merge_srv_conf(ngx_conf_t *cf, void *parent, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
16 void *child); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
17 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
18 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 static ngx_conf_bitmask_t ngx_mail_smtp_auth_methods[] = { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 { ngx_string("plain"), NGX_MAIL_AUTH_PLAIN_ENABLED }, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 { ngx_string("login"), NGX_MAIL_AUTH_LOGIN_ENABLED }, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 { ngx_string("cram-md5"), NGX_MAIL_AUTH_CRAM_MD5_ENABLED }, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
23 { ngx_null_string, 0 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
24 }; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
25 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
26 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 static ngx_str_t ngx_mail_smtp_auth_methods_names[] = { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 ngx_string("PLAIN"), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 ngx_string("LOGIN"), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 ngx_null_string, /* APOP */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 ngx_string("CRAM-MD5") |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 }; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 static ngx_mail_protocol_t ngx_mail_smtp_protocol = { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 ngx_string("smtp"), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 { 25, 465, 587, 0 }, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 NGX_MAIL_SMTP_PROTOCOL, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
39 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
40 ngx_mail_smtp_init_session, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 ngx_mail_smtp_init_protocol, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 ngx_mail_smtp_parse_command, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 ngx_mail_smtp_auth_state, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
45 ngx_string("451 4.3.2 Internal server error" CRLF) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 }; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
48 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 static ngx_command_t ngx_mail_smtp_commands[] = { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
50 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
51 { ngx_string("smtp_client_buffer"), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
52 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
53 ngx_conf_set_size_slot, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 NGX_MAIL_SRV_CONF_OFFSET, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
55 offsetof(ngx_mail_smtp_srv_conf_t, client_buffer_size), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 NULL }, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
57 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 { ngx_string("smtp_greeting_delay"), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
59 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 ngx_conf_set_msec_slot, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
61 NGX_MAIL_SRV_CONF_OFFSET, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
62 offsetof(ngx_mail_smtp_srv_conf_t, greeting_delay), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
63 NULL }, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
64 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
65 { ngx_string("smtp_capabilities"), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
66 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
67 ngx_mail_capabilities, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 NGX_MAIL_SRV_CONF_OFFSET, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 offsetof(ngx_mail_smtp_srv_conf_t, capabilities), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
70 NULL }, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
71 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
72 { ngx_string("smtp_auth"), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
73 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
74 ngx_conf_set_bitmask_slot, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
75 NGX_MAIL_SRV_CONF_OFFSET, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
76 offsetof(ngx_mail_smtp_srv_conf_t, auth_methods), |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
77 &ngx_mail_smtp_auth_methods }, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
78 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
79 ngx_null_command |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
80 }; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
81 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
82 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
83 static ngx_mail_module_t ngx_mail_smtp_module_ctx = { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
84 &ngx_mail_smtp_protocol, /* protocol */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
85 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 NULL, /* create main configuration */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
87 NULL, /* init main configuration */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
88 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
89 ngx_mail_smtp_create_srv_conf, /* create server configuration */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
90 ngx_mail_smtp_merge_srv_conf /* merge server configuration */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
91 }; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
92 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
93 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
94 ngx_module_t ngx_mail_smtp_module = { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
95 NGX_MODULE_V1, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
96 &ngx_mail_smtp_module_ctx, /* module context */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 ngx_mail_smtp_commands, /* module directives */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
98 NGX_MAIL_MODULE, /* module type */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
99 NULL, /* init master */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
100 NULL, /* init module */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
101 NULL, /* init process */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
102 NULL, /* init thread */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 NULL, /* exit thread */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
104 NULL, /* exit process */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
105 NULL, /* exit master */ |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
106 NGX_MODULE_V1_PADDING |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
107 }; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
109 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
110 static void * |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
111 ngx_mail_smtp_create_srv_conf(ngx_conf_t *cf) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
112 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
113 ngx_mail_smtp_srv_conf_t *sscf; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
114 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
115 sscf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_smtp_srv_conf_t)); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
116 if (sscf == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
117 return NULL; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
118 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
119 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
120 sscf->client_buffer_size = NGX_CONF_UNSET_SIZE; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
121 sscf->greeting_delay = NGX_CONF_UNSET_MSEC; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
123 if (ngx_array_init(&sscf->capabilities, cf->pool, 4, sizeof(ngx_str_t)) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
124 != NGX_OK) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 return NULL; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
128 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
129 return sscf; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
130 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
131 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
132 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
133 static char * |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
134 ngx_mail_smtp_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
135 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
136 ngx_mail_smtp_srv_conf_t *prev = parent; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
137 ngx_mail_smtp_srv_conf_t *conf = child; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
138 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
139 u_char *p, *auth; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
140 size_t size; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
141 ngx_str_t *c; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 ngx_uint_t i, m; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 ngx_mail_core_srv_conf_t *cscf; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
144 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
145 ngx_conf_merge_size_value(conf->client_buffer_size, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
146 prev->client_buffer_size, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
147 (size_t) ngx_pagesize); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
149 ngx_conf_merge_msec_value(conf->greeting_delay, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
150 prev->greeting_delay, 0); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
151 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
152 ngx_conf_merge_bitmask_value(conf->auth_methods, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
153 prev->auth_methods, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 (NGX_CONF_BITMASK_SET |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
155 |NGX_MAIL_AUTH_PLAIN_ENABLED |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 |NGX_MAIL_AUTH_LOGIN_ENABLED)); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
159 cscf = ngx_mail_conf_get_module_srv_conf(cf, ngx_mail_core_module); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
160 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
161 size = sizeof("220 ESMTP ready" CRLF) - 1 + cscf->server_name.len; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
163 p = ngx_palloc(cf->pool, size); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
164 if (p == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
165 return NGX_CONF_ERROR; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 conf->greeting.len = size; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
169 conf->greeting.data = p; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
170 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 *p++ = '2'; *p++ = '2'; *p++ = '0'; *p++ = ' '; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 p = ngx_cpymem(p, cscf->server_name.data, cscf->server_name.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
173 ngx_memcpy(p, " ESMTP ready" CRLF, sizeof(" ESMTP ready" CRLF) - 1); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
174 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
175 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
176 size = sizeof("250 " CRLF) - 1 + cscf->server_name.len; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
177 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 p = ngx_palloc(cf->pool, size); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 if (p == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 return NGX_CONF_ERROR; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
181 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
182 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
183 conf->server_name.len = size; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
184 conf->server_name.data = p; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
185 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
186 *p++ = '2'; *p++ = '5'; *p++ = '0'; *p++ = ' '; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 p = ngx_cpymem(p, cscf->server_name.data, cscf->server_name.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
188 *p++ = CR; *p = LF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
189 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
190 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
191 if (conf->capabilities.nelts == 0) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
192 conf->capabilities = prev->capabilities; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
193 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 size = sizeof("250-") - 1 + cscf->server_name.len + sizeof(CRLF) - 1 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 + sizeof("250 AUTH") - 1 + sizeof(CRLF) - 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
197 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
198 c = conf->capabilities.elts; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
199 for (i = 0; i < conf->capabilities.nelts; i++) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 size += sizeof("250 ") - 1 + c[i].len + sizeof(CRLF) - 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
202 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
203 for (m = NGX_MAIL_AUTH_PLAIN_ENABLED, i = 0; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
204 m <= NGX_MAIL_AUTH_CRAM_MD5_ENABLED; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
205 m <<= 1, i++) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
206 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
207 if (m & conf->auth_methods) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
208 size += 1 + ngx_mail_smtp_auth_methods_names[i].len; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
210 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
211 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
212 p = ngx_palloc(cf->pool, size); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
213 if (p == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
214 return NGX_CONF_ERROR; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
215 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 conf->capability.len = size; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
218 conf->capability.data = p; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
219 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
220 *p++ = '2'; *p++ = '5'; *p++ = '0'; *p++ = '-'; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 p = ngx_cpymem(p, cscf->server_name.data, cscf->server_name.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
222 *p++ = CR; *p++ = LF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
223 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
224 for (i = 0; i < conf->capabilities.nelts; i++) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
225 *p++ = '2'; *p++ = '5'; *p++ = '0'; *p++ = '-'; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
226 p = ngx_cpymem(p, c[i].data, c[i].len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 *p++ = CR; *p++ = LF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
228 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
229 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
230 auth = p; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
232 *p++ = '2'; *p++ = '5'; *p++ = '0'; *p++ = ' '; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
233 *p++ = 'A'; *p++ = 'U'; *p++ = 'T'; *p++ = 'H'; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
234 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
235 for (m = NGX_MAIL_AUTH_PLAIN_ENABLED, i = 0; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
236 m <= NGX_MAIL_AUTH_CRAM_MD5_ENABLED; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
237 m <<= 1, i++) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
238 { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
239 if (m & conf->auth_methods) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
240 *p++ = ' '; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
241 p = ngx_cpymem(p, ngx_mail_smtp_auth_methods_names[i].data, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
242 ngx_mail_smtp_auth_methods_names[i].len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
243 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
244 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
245 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
246 *p++ = CR; *p = LF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
247 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
248 size += sizeof("250 STARTTLS" CRLF) - 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
249 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 p = ngx_palloc(cf->pool, size); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
251 if (p == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
252 return NGX_CONF_ERROR; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
253 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
254 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
255 conf->starttls_capability.len = size; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
256 conf->starttls_capability.data = p; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
257 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
258 p = ngx_cpymem(p, conf->capability.data, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
259 conf->capability.len); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
260 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
261 p = ngx_cpymem(p, "250 STARTTLS" CRLF, sizeof("250 STARTTLS" CRLF) - 1); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
262 *p++ = CR; *p = LF; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
263 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
264 p = conf->starttls_capability.data |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
265 + (auth - conf->capability.data) + 3; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
266 *p = '-'; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
267 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
268 size = (auth - conf->capability.data) |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
269 + sizeof("250 STARTTLS" CRLF) - 1; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
270 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
271 p = ngx_palloc(cf->pool, size); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
272 if (p == NULL) { |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
273 return NGX_CONF_ERROR; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
274 } |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
275 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
276 conf->starttls_only_capability.len = size; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
277 conf->starttls_only_capability.data = p; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
278 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
279 p = ngx_cpymem(p, conf->capability.data, |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
280 auth - conf->capability.data); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
281 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
282 ngx_memcpy(p, "250 STARTTLS" CRLF, sizeof("250 STARTTLS" CRLF) - 1); |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
283 |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
284 return NGX_CONF_OK; |
ed9cd1702f7a
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
285 } |