nginxtra 1.6.3.9 → 1.8.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nginxtra +1 -1
  3. data/bin/nginxtra_rails +1 -1
  4. data/lib/nginxtra/version.rb +1 -1
  5. data/vendor/nginx/CHANGES +358 -14
  6. data/vendor/nginx/CHANGES.ru +372 -18
  7. data/vendor/nginx/LICENSE +2 -2
  8. data/vendor/nginx/auto/cc/clang +5 -0
  9. data/vendor/nginx/auto/cc/gcc +5 -0
  10. data/vendor/nginx/auto/lib/google-perftools/conf +1 -1
  11. data/vendor/nginx/auto/lib/openssl/make +0 -5
  12. data/vendor/nginx/auto/lib/perl/conf +9 -1
  13. data/vendor/nginx/auto/make +1 -1
  14. data/vendor/nginx/auto/modules +11 -0
  15. data/vendor/nginx/auto/options +10 -2
  16. data/vendor/nginx/auto/os/darwin +0 -1
  17. data/vendor/nginx/auto/os/freebsd +6 -23
  18. data/vendor/nginx/auto/sources +16 -14
  19. data/vendor/nginx/auto/summary +3 -24
  20. data/vendor/nginx/auto/threads +20 -0
  21. data/vendor/nginx/auto/types/sizeof +2 -12
  22. data/vendor/nginx/auto/unix +50 -6
  23. data/vendor/nginx/configure +5 -0
  24. data/vendor/nginx/contrib/vim/syntax/nginx.vim +183 -50
  25. data/vendor/nginx/src/core/nginx.c +21 -9
  26. data/vendor/nginx/src/core/nginx.h +8 -2
  27. data/vendor/nginx/src/core/ngx_buf.c +88 -0
  28. data/vendor/nginx/src/core/ngx_buf.h +15 -1
  29. data/vendor/nginx/src/core/ngx_conf_file.c +4 -1
  30. data/vendor/nginx/src/core/ngx_connection.c +25 -66
  31. data/vendor/nginx/src/core/ngx_connection.h +1 -3
  32. data/vendor/nginx/src/core/ngx_core.h +11 -3
  33. data/vendor/nginx/src/core/ngx_crypt.c +1 -1
  34. data/vendor/nginx/src/core/ngx_cycle.c +7 -1
  35. data/vendor/nginx/src/core/ngx_cycle.h +6 -2
  36. data/vendor/nginx/src/core/ngx_file.c +13 -5
  37. data/vendor/nginx/src/core/ngx_file.h +6 -0
  38. data/vendor/nginx/src/core/ngx_log.c +215 -21
  39. data/vendor/nginx/src/core/ngx_log.h +9 -1
  40. data/vendor/nginx/src/core/ngx_output_chain.c +104 -15
  41. data/vendor/nginx/src/core/ngx_palloc.c +3 -7
  42. data/vendor/nginx/src/core/ngx_rbtree.c +2 -4
  43. data/vendor/nginx/src/core/ngx_rbtree.h +2 -4
  44. data/vendor/nginx/src/core/ngx_regex.c +14 -6
  45. data/vendor/nginx/src/core/ngx_resolver.c +16 -23
  46. data/vendor/nginx/src/core/ngx_resolver.h +8 -7
  47. data/vendor/nginx/src/core/ngx_shmtx.c +1 -1
  48. data/vendor/nginx/src/core/ngx_slab.c +89 -2
  49. data/vendor/nginx/src/core/ngx_slab.h +3 -0
  50. data/vendor/nginx/src/core/ngx_string.c +58 -2
  51. data/vendor/nginx/src/core/ngx_string.h +1 -0
  52. data/vendor/nginx/src/core/ngx_syslog.c +374 -0
  53. data/vendor/nginx/src/core/ngx_syslog.h +30 -0
  54. data/vendor/nginx/src/core/ngx_thread_pool.c +630 -0
  55. data/vendor/nginx/src/core/ngx_thread_pool.h +36 -0
  56. data/vendor/nginx/src/core/ngx_times.c +19 -2
  57. data/vendor/nginx/src/core/ngx_times.h +1 -0
  58. data/vendor/nginx/src/event/modules/ngx_aio_module.c +1 -1
  59. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +9 -24
  60. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +152 -28
  61. data/vendor/nginx/src/event/modules/ngx_eventport_module.c +43 -25
  62. data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +86 -156
  63. data/vendor/nginx/src/event/modules/ngx_poll_module.c +21 -37
  64. data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +15 -27
  65. data/vendor/nginx/src/event/modules/ngx_select_module.c +10 -12
  66. data/vendor/nginx/src/event/modules/ngx_win32_select_module.c +7 -9
  67. data/vendor/nginx/src/event/ngx_event.c +5 -33
  68. data/vendor/nginx/src/event/ngx_event.h +15 -50
  69. data/vendor/nginx/src/event/ngx_event_accept.c +11 -10
  70. data/vendor/nginx/src/event/ngx_event_connect.c +0 -11
  71. data/vendor/nginx/src/event/ngx_event_connect.h +1 -4
  72. data/vendor/nginx/src/event/ngx_event_openssl.c +622 -38
  73. data/vendor/nginx/src/event/ngx_event_openssl.h +20 -2
  74. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +5 -1
  75. data/vendor/nginx/src/event/ngx_event_pipe.c +45 -19
  76. data/vendor/nginx/src/event/ngx_event_pipe.h +3 -0
  77. data/vendor/nginx/src/event/ngx_event_posted.c +7 -145
  78. data/vendor/nginx/src/event/ngx_event_posted.h +12 -39
  79. data/vendor/nginx/src/event/ngx_event_timer.c +50 -70
  80. data/vendor/nginx/src/event/ngx_event_timer.h +2 -14
  81. data/vendor/nginx/src/http/modules/ngx_http_addition_filter_module.c +1 -1
  82. data/vendor/nginx/src/http/modules/ngx_http_autoindex_module.c +416 -71
  83. data/vendor/nginx/src/http/modules/ngx_http_charset_filter_module.c +19 -15
  84. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +16 -4
  85. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +601 -134
  86. data/vendor/nginx/src/http/modules/ngx_http_geo_module.c +1 -1
  87. data/vendor/nginx/src/http/modules/ngx_http_geoip_module.c +9 -3
  88. data/vendor/nginx/src/http/modules/ngx_http_gunzip_filter_module.c +9 -3
  89. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +9 -3
  90. data/vendor/nginx/src/http/modules/ngx_http_gzip_static_module.c +0 -2
  91. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +197 -91
  92. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +1 -0
  93. data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +65 -162
  94. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +53 -67
  95. data/vendor/nginx/src/http/modules/ngx_http_log_module.c +128 -23
  96. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +25 -6
  97. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +1 -1
  98. data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +39 -13
  99. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +697 -141
  100. data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +5 -1
  101. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +282 -125
  102. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +4 -1
  103. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +44 -1
  104. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.h +2 -0
  105. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +10 -8
  106. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +18 -3
  107. data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +641 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +1 -1
  109. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +3 -21
  110. data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +0 -5
  111. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +449 -125
  112. data/vendor/nginx/src/http/modules/ngx_http_xslt_filter_module.c +4 -2
  113. data/vendor/nginx/src/http/modules/perl/ngx_http_perl_module.c +2 -1
  114. data/vendor/nginx/src/http/ngx_http.c +10 -5
  115. data/vendor/nginx/src/http/ngx_http.h +4 -4
  116. data/vendor/nginx/src/http/ngx_http_cache.h +26 -1
  117. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +109 -68
  118. data/vendor/nginx/src/http/ngx_http_core_module.c +191 -46
  119. data/vendor/nginx/src/http/ngx_http_core_module.h +16 -4
  120. data/vendor/nginx/src/http/ngx_http_file_cache.c +584 -67
  121. data/vendor/nginx/src/http/ngx_http_parse.c +55 -4
  122. data/vendor/nginx/src/http/ngx_http_request.c +14 -6
  123. data/vendor/nginx/src/http/ngx_http_request.h +12 -4
  124. data/vendor/nginx/src/http/ngx_http_request_body.c +114 -28
  125. data/vendor/nginx/src/http/ngx_http_spdy.c +383 -229
  126. data/vendor/nginx/src/http/ngx_http_spdy.h +8 -5
  127. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +12 -4
  128. data/vendor/nginx/src/http/ngx_http_special_response.c +2 -2
  129. data/vendor/nginx/src/http/ngx_http_upstream.c +808 -132
  130. data/vendor/nginx/src/http/ngx_http_upstream.h +33 -3
  131. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +72 -65
  132. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +1 -2
  133. data/vendor/nginx/src/http/ngx_http_variables.c +47 -3
  134. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +15 -6
  135. data/vendor/nginx/src/mail/ngx_mail.c +2 -3
  136. data/vendor/nginx/src/mail/ngx_mail.h +2 -0
  137. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +140 -11
  138. data/vendor/nginx/src/mail/ngx_mail_core_module.c +3 -3
  139. data/vendor/nginx/src/mail/ngx_mail_handler.c +79 -2
  140. data/vendor/nginx/src/mail/ngx_mail_imap_module.c +3 -1
  141. data/vendor/nginx/src/mail/ngx_mail_pop3_module.c +3 -1
  142. data/vendor/nginx/src/mail/ngx_mail_smtp_module.c +3 -1
  143. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +125 -1
  144. data/vendor/nginx/src/mail/ngx_mail_ssl_module.h +8 -0
  145. data/vendor/nginx/src/misc/ngx_cpp_test_module.cpp +1 -1
  146. data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +1 -1
  147. data/vendor/nginx/src/os/unix/ngx_channel.c +0 -7
  148. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +0 -3
  149. data/vendor/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +44 -208
  150. data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +25 -17
  151. data/vendor/nginx/src/os/unix/ngx_files.c +109 -0
  152. data/vendor/nginx/src/os/unix/ngx_files.h +6 -0
  153. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +0 -6
  154. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +78 -206
  155. data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +25 -14
  156. data/vendor/nginx/src/os/unix/ngx_linux_config.h +4 -1
  157. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +235 -194
  158. data/vendor/nginx/src/os/unix/ngx_os.h +25 -3
  159. data/vendor/nginx/src/os/unix/ngx_posix_init.c +4 -2
  160. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +13 -195
  161. data/vendor/nginx/src/os/unix/ngx_process_cycle.h +0 -1
  162. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +27 -108
  163. data/vendor/nginx/src/os/unix/ngx_setproctitle.h +2 -2
  164. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +12 -67
  165. data/vendor/nginx/src/os/unix/ngx_thread.h +26 -83
  166. data/vendor/nginx/src/os/unix/ngx_thread_cond.c +87 -0
  167. data/vendor/nginx/src/os/unix/ngx_thread_id.c +70 -0
  168. data/vendor/nginx/src/os/unix/ngx_thread_mutex.c +174 -0
  169. data/vendor/nginx/src/os/unix/ngx_user.c +2 -20
  170. data/vendor/nginx/src/os/unix/ngx_writev_chain.c +129 -98
  171. metadata +16 -17
  172. data/vendor/nginx/auto/lib/zlib/patch.zlib.h +0 -10
  173. data/vendor/nginx/src/event/ngx_event_busy_lock.c +0 -286
  174. data/vendor/nginx/src/event/ngx_event_busy_lock.h +0 -65
  175. data/vendor/nginx/src/event/ngx_event_mutex.c +0 -70
  176. data/vendor/nginx/src/http/ngx_http_busy_lock.c +0 -307
  177. data/vendor/nginx/src/http/ngx_http_busy_lock.h +0 -54
  178. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +0 -756
  179. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +0 -122
  180. data/vendor/nginx/src/os/unix/ngx_pthread_thread.c +0 -278
  181. data/vendor/nginx/src/os/unix/rfork_thread.S +0 -73
@@ -52,7 +52,9 @@ static ngx_mail_protocol_t ngx_mail_imap_protocol = {
52
52
  ngx_mail_imap_parse_command,
53
53
  ngx_mail_imap_auth_state,
54
54
 
55
- ngx_string("* BAD internal server error" CRLF)
55
+ ngx_string("* BAD internal server error" CRLF),
56
+ ngx_string("* BYE SSL certificate error" CRLF),
57
+ ngx_string("* BYE No required SSL certificate" CRLF)
56
58
  };
57
59
 
58
60
 
@@ -58,7 +58,9 @@ static ngx_mail_protocol_t ngx_mail_pop3_protocol = {
58
58
  ngx_mail_pop3_parse_command,
59
59
  ngx_mail_pop3_auth_state,
60
60
 
61
- ngx_string("-ERR internal server error" CRLF)
61
+ ngx_string("-ERR internal server error" CRLF),
62
+ ngx_string("-ERR SSL certificate error" CRLF),
63
+ ngx_string("-ERR No required SSL certificate" CRLF)
62
64
  };
63
65
 
64
66
 
@@ -45,7 +45,9 @@ static ngx_mail_protocol_t ngx_mail_smtp_protocol = {
45
45
  ngx_mail_smtp_parse_command,
46
46
  ngx_mail_smtp_auth_state,
47
47
 
48
- ngx_string("451 4.3.2 Internal server error" CRLF)
48
+ ngx_string("451 4.3.2 Internal server error" CRLF),
49
+ ngx_string("421 4.7.1 SSL certificate error" CRLF),
50
+ ngx_string("421 4.7.1 No required SSL certificate" CRLF)
49
51
  };
50
52
 
51
53
 
@@ -21,6 +21,8 @@ static char *ngx_mail_ssl_enable(ngx_conf_t *cf, ngx_command_t *cmd,
21
21
  void *conf);
22
22
  static char *ngx_mail_ssl_starttls(ngx_conf_t *cf, ngx_command_t *cmd,
23
23
  void *conf);
24
+ static char *ngx_mail_ssl_password_file(ngx_conf_t *cf, ngx_command_t *cmd,
25
+ void *conf);
24
26
  static char *ngx_mail_ssl_session_cache(ngx_conf_t *cf, ngx_command_t *cmd,
25
27
  void *conf);
26
28
 
@@ -44,6 +46,15 @@ static ngx_conf_bitmask_t ngx_mail_ssl_protocols[] = {
44
46
  };
45
47
 
46
48
 
49
+ static ngx_conf_enum_t ngx_mail_ssl_verify[] = {
50
+ { ngx_string("off"), 0 },
51
+ { ngx_string("on"), 1 },
52
+ { ngx_string("optional"), 2 },
53
+ { ngx_string("optional_no_ca"), 3 },
54
+ { ngx_null_string, 0 }
55
+ };
56
+
57
+
47
58
  static ngx_command_t ngx_mail_ssl_commands[] = {
48
59
 
49
60
  { ngx_string("ssl"),
@@ -74,6 +85,13 @@ static ngx_command_t ngx_mail_ssl_commands[] = {
74
85
  offsetof(ngx_mail_ssl_conf_t, certificate_key),
75
86
  NULL },
76
87
 
88
+ { ngx_string("ssl_password_file"),
89
+ NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
90
+ ngx_mail_ssl_password_file,
91
+ NGX_MAIL_SRV_CONF_OFFSET,
92
+ 0,
93
+ NULL },
94
+
77
95
  { ngx_string("ssl_dhparam"),
78
96
  NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
79
97
  ngx_conf_set_str_slot,
@@ -137,6 +155,41 @@ static ngx_command_t ngx_mail_ssl_commands[] = {
137
155
  offsetof(ngx_mail_ssl_conf_t, session_timeout),
138
156
  NULL },
139
157
 
158
+ { ngx_string("ssl_verify_client"),
159
+ NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
160
+ ngx_conf_set_enum_slot,
161
+ NGX_MAIL_SRV_CONF_OFFSET,
162
+ offsetof(ngx_mail_ssl_conf_t, verify),
163
+ &ngx_mail_ssl_verify },
164
+
165
+ { ngx_string("ssl_verify_depth"),
166
+ NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
167
+ ngx_conf_set_num_slot,
168
+ NGX_MAIL_SRV_CONF_OFFSET,
169
+ offsetof(ngx_mail_ssl_conf_t, verify_depth),
170
+ NULL },
171
+
172
+ { ngx_string("ssl_client_certificate"),
173
+ NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
174
+ ngx_conf_set_str_slot,
175
+ NGX_MAIL_SRV_CONF_OFFSET,
176
+ offsetof(ngx_mail_ssl_conf_t, client_certificate),
177
+ NULL },
178
+
179
+ { ngx_string("ssl_trusted_certificate"),
180
+ NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
181
+ ngx_conf_set_str_slot,
182
+ NGX_MAIL_SRV_CONF_OFFSET,
183
+ offsetof(ngx_mail_ssl_conf_t, trusted_certificate),
184
+ NULL },
185
+
186
+ { ngx_string("ssl_crl"),
187
+ NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
188
+ ngx_conf_set_str_slot,
189
+ NGX_MAIL_SRV_CONF_OFFSET,
190
+ offsetof(ngx_mail_ssl_conf_t, crl),
191
+ NULL },
192
+
140
193
  ngx_null_command
141
194
  };
142
195
 
@@ -189,13 +242,19 @@ ngx_mail_ssl_create_conf(ngx_conf_t *cf)
189
242
  * scf->certificate_key = { 0, NULL };
190
243
  * scf->dhparam = { 0, NULL };
191
244
  * scf->ecdh_curve = { 0, NULL };
245
+ * scf->client_certificate = { 0, NULL };
246
+ * scf->trusted_certificate = { 0, NULL };
247
+ * scf->crl = { 0, NULL };
192
248
  * scf->ciphers = { 0, NULL };
193
249
  * scf->shm_zone = NULL;
194
250
  */
195
251
 
196
252
  scf->enable = NGX_CONF_UNSET;
197
253
  scf->starttls = NGX_CONF_UNSET_UINT;
254
+ scf->passwords = NGX_CONF_UNSET_PTR;
198
255
  scf->prefer_server_ciphers = NGX_CONF_UNSET;
256
+ scf->verify = NGX_CONF_UNSET_UINT;
257
+ scf->verify_depth = NGX_CONF_UNSET_UINT;
199
258
  scf->builtin_session_cache = NGX_CONF_UNSET;
200
259
  scf->session_timeout = NGX_CONF_UNSET;
201
260
  scf->session_tickets = NGX_CONF_UNSET;
@@ -228,14 +287,25 @@ ngx_mail_ssl_merge_conf(ngx_conf_t *cf, void *parent, void *child)
228
287
  (NGX_CONF_BITMASK_SET|NGX_SSL_SSLv3|NGX_SSL_TLSv1
229
288
  |NGX_SSL_TLSv1_1|NGX_SSL_TLSv1_2));
230
289
 
290
+ ngx_conf_merge_uint_value(conf->verify, prev->verify, 0);
291
+ ngx_conf_merge_uint_value(conf->verify_depth, prev->verify_depth, 1);
292
+
231
293
  ngx_conf_merge_str_value(conf->certificate, prev->certificate, "");
232
294
  ngx_conf_merge_str_value(conf->certificate_key, prev->certificate_key, "");
233
295
 
296
+ ngx_conf_merge_ptr_value(conf->passwords, prev->passwords, NULL);
297
+
234
298
  ngx_conf_merge_str_value(conf->dhparam, prev->dhparam, "");
235
299
 
236
300
  ngx_conf_merge_str_value(conf->ecdh_curve, prev->ecdh_curve,
237
301
  NGX_DEFAULT_ECDH_CURVE);
238
302
 
303
+ ngx_conf_merge_str_value(conf->client_certificate,
304
+ prev->client_certificate, "");
305
+ ngx_conf_merge_str_value(conf->trusted_certificate,
306
+ prev->trusted_certificate, "");
307
+ ngx_conf_merge_str_value(conf->crl, prev->crl, "");
308
+
239
309
  ngx_conf_merge_str_value(conf->ciphers, prev->ciphers, NGX_DEFAULT_CIPHERS);
240
310
 
241
311
 
@@ -302,12 +372,41 @@ ngx_mail_ssl_merge_conf(ngx_conf_t *cf, void *parent, void *child)
302
372
  cln->data = &conf->ssl;
303
373
 
304
374
  if (ngx_ssl_certificate(cf, &conf->ssl, &conf->certificate,
305
- &conf->certificate_key)
375
+ &conf->certificate_key, conf->passwords)
306
376
  != NGX_OK)
307
377
  {
308
378
  return NGX_CONF_ERROR;
309
379
  }
310
380
 
381
+ if (conf->verify) {
382
+
383
+ if (conf->client_certificate.len == 0 && conf->verify != 3) {
384
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
385
+ "no ssl_client_certificate for ssl_client_verify");
386
+ return NGX_CONF_ERROR;
387
+ }
388
+
389
+ if (ngx_ssl_client_certificate(cf, &conf->ssl,
390
+ &conf->client_certificate,
391
+ conf->verify_depth)
392
+ != NGX_OK)
393
+ {
394
+ return NGX_CONF_ERROR;
395
+ }
396
+
397
+ if (ngx_ssl_trusted_certificate(cf, &conf->ssl,
398
+ &conf->trusted_certificate,
399
+ conf->verify_depth)
400
+ != NGX_OK)
401
+ {
402
+ return NGX_CONF_ERROR;
403
+ }
404
+
405
+ if (ngx_ssl_crl(cf, &conf->ssl, &conf->crl) != NGX_OK) {
406
+ return NGX_CONF_ERROR;
407
+ }
408
+ }
409
+
311
410
  if (SSL_CTX_set_cipher_list(conf->ssl.ctx,
312
411
  (const char *) conf->ciphers.data)
313
412
  == 0)
@@ -322,7 +421,9 @@ ngx_mail_ssl_merge_conf(ngx_conf_t *cf, void *parent, void *child)
322
421
  SSL_CTX_set_options(conf->ssl.ctx, SSL_OP_CIPHER_SERVER_PREFERENCE);
323
422
  }
324
423
 
424
+ #ifndef LIBRESSL_VERSION_NUMBER
325
425
  SSL_CTX_set_tmp_rsa_callback(conf->ssl.ctx, ngx_ssl_rsa512_key_callback);
426
+ #endif
326
427
 
327
428
  if (ngx_ssl_dhparam(cf, &conf->ssl, &conf->dhparam) != NGX_OK) {
328
429
  return NGX_CONF_ERROR;
@@ -421,6 +522,29 @@ ngx_mail_ssl_starttls(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
421
522
  }
422
523
 
423
524
 
525
+ static char *
526
+ ngx_mail_ssl_password_file(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
527
+ {
528
+ ngx_mail_ssl_conf_t *scf = conf;
529
+
530
+ ngx_str_t *value;
531
+
532
+ if (scf->passwords != NGX_CONF_UNSET_PTR) {
533
+ return "is duplicate";
534
+ }
535
+
536
+ value = cf->args->elts;
537
+
538
+ scf->passwords = ngx_ssl_read_password_file(cf, &value[1]);
539
+
540
+ if (scf->passwords == NULL) {
541
+ return NGX_CONF_ERROR;
542
+ }
543
+
544
+ return NGX_CONF_OK;
545
+ }
546
+
547
+
424
548
  static char *
425
549
  ngx_mail_ssl_session_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
426
550
  {
@@ -28,6 +28,9 @@ typedef struct {
28
28
  ngx_uint_t starttls;
29
29
  ngx_uint_t protocols;
30
30
 
31
+ ngx_uint_t verify;
32
+ ngx_uint_t verify_depth;
33
+
31
34
  ssize_t builtin_session_cache;
32
35
 
33
36
  time_t session_timeout;
@@ -36,9 +39,14 @@ typedef struct {
36
39
  ngx_str_t certificate_key;
37
40
  ngx_str_t dhparam;
38
41
  ngx_str_t ecdh_curve;
42
+ ngx_str_t client_certificate;
43
+ ngx_str_t trusted_certificate;
44
+ ngx_str_t crl;
39
45
 
40
46
  ngx_str_t ciphers;
41
47
 
48
+ ngx_array_t *passwords;
49
+
42
50
  ngx_shm_zone_t *shm_zone;
43
51
 
44
52
  ngx_flag_t session_tickets;
@@ -1,5 +1,5 @@
1
1
 
2
- // stub module to test header files' C++ compatibilty
2
+ // stub module to test header files' C++ compatibility
3
3
 
4
4
  extern "C" {
5
5
  #include <ngx_config.h>
@@ -11,7 +11,7 @@
11
11
 
12
12
 
13
13
  ssize_t
14
- ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
14
+ ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit)
15
15
  {
16
16
  int n;
17
17
  u_char *buf, *prev;
@@ -216,13 +216,6 @@ ngx_add_channel_event(ngx_cycle_t *cycle, ngx_fd_t fd, ngx_int_t event,
216
216
  rev->log = cycle->log;
217
217
  wev->log = cycle->log;
218
218
 
219
- #if (NGX_THREADS)
220
- rev->lock = &c->lock;
221
- wev->lock = &c->lock;
222
- rev->own_lock = &c->lock;
223
- wev->own_lock = &c->lock;
224
- #endif
225
-
226
219
  rev->channel = 1;
227
220
  wev->channel = 1;
228
221
 
@@ -9,9 +9,6 @@
9
9
  #define _NGX_DARWIN_CONFIG_H_INCLUDED_
10
10
 
11
11
 
12
- #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_0
13
-
14
-
15
12
  #include <sys/types.h>
16
13
  #include <sys/time.h>
17
14
  #include <unistd.h>
@@ -13,7 +13,7 @@
13
13
  /*
14
14
  * It seems that Darwin 9.4 (Mac OS X 1.5) sendfile() has the same
15
15
  * old bug as early FreeBSD sendfile() syscall:
16
- * http://www.freebsd.org/cgi/query-pr.cgi?pr=33771
16
+ * http://bugs.freebsd.org/33771
17
17
  *
18
18
  * Besides sendfile() has another bug: if one calls sendfile()
19
19
  * with both a header and a trailer, then sendfile() ignores a file part
@@ -27,30 +27,22 @@
27
27
  */
28
28
 
29
29
 
30
- #if (IOV_MAX > 64)
31
- #define NGX_HEADERS 64
32
- #define NGX_TRAILERS 64
33
- #else
34
- #define NGX_HEADERS IOV_MAX
35
- #define NGX_TRAILERS IOV_MAX
36
- #endif
37
-
38
-
39
30
  ngx_chain_t *
40
31
  ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
41
32
  {
42
33
  int rc;
43
- u_char *prev;
44
- off_t size, send, prev_send, aligned, sent, fprev;
45
- off_t header_size, file_size;
46
- ngx_uint_t eintr, complete;
34
+ off_t send, prev_send, sent;
35
+ off_t file_size;
36
+ ssize_t n;
37
+ ngx_uint_t eintr;
47
38
  ngx_err_t err;
48
39
  ngx_buf_t *file;
49
- ngx_array_t header, trailer;
50
40
  ngx_event_t *wev;
51
41
  ngx_chain_t *cl;
42
+ ngx_iovec_t header, trailer;
52
43
  struct sf_hdtr hdtr;
53
- struct iovec *iov, headers[NGX_HEADERS], trailers[NGX_TRAILERS];
44
+ struct iovec headers[NGX_IOVS_PREALLOCATE];
45
+ struct iovec trailers[NGX_IOVS_PREALLOCATE];
54
46
 
55
47
  wev = c->write;
56
48
 
@@ -77,166 +69,68 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
77
69
 
78
70
  send = 0;
79
71
 
80
- header.elts = headers;
81
- header.size = sizeof(struct iovec);
82
- header.nalloc = NGX_HEADERS;
83
- header.pool = c->pool;
72
+ header.iovs = headers;
73
+ header.nalloc = NGX_IOVS_PREALLOCATE;
84
74
 
85
- trailer.elts = trailers;
86
- trailer.size = sizeof(struct iovec);
87
- trailer.nalloc = NGX_TRAILERS;
88
- trailer.pool = c->pool;
75
+ trailer.iovs = trailers;
76
+ trailer.nalloc = NGX_IOVS_PREALLOCATE;
89
77
 
90
78
  for ( ;; ) {
91
- file = NULL;
92
- file_size = 0;
93
- header_size = 0;
94
79
  eintr = 0;
95
- complete = 0;
96
80
  prev_send = send;
97
81
 
98
- header.nelts = 0;
99
- trailer.nelts = 0;
100
-
101
82
  /* create the header iovec and coalesce the neighbouring bufs */
102
83
 
103
- prev = NULL;
104
- iov = NULL;
105
-
106
- for (cl = in; cl && send < limit; cl = cl->next) {
107
-
108
- if (ngx_buf_special(cl->buf)) {
109
- continue;
110
- }
111
-
112
- if (!ngx_buf_in_memory_only(cl->buf)) {
113
- break;
114
- }
115
-
116
- size = cl->buf->last - cl->buf->pos;
117
-
118
- if (send + size > limit) {
119
- size = limit - send;
120
- }
121
-
122
- if (prev == cl->buf->pos) {
123
- iov->iov_len += (size_t) size;
124
-
125
- } else {
126
- if (header.nelts >= IOV_MAX) {
127
- break;
128
- }
129
-
130
- iov = ngx_array_push(&header);
131
- if (iov == NULL) {
132
- return NGX_CHAIN_ERROR;
133
- }
134
-
135
- iov->iov_base = (void *) cl->buf->pos;
136
- iov->iov_len = (size_t) size;
137
- }
84
+ cl = ngx_output_chain_to_iovec(&header, in, limit - send, c->log);
138
85
 
139
- prev = cl->buf->pos + (size_t) size;
140
- header_size += size;
141
- send += size;
86
+ if (cl == NGX_CHAIN_ERROR) {
87
+ return NGX_CHAIN_ERROR;
142
88
  }
143
89
 
90
+ send += header.size;
144
91
 
145
92
  if (cl && cl->buf->in_file && send < limit) {
146
93
  file = cl->buf;
147
94
 
148
95
  /* coalesce the neighbouring file bufs */
149
96
 
150
- do {
151
- size = cl->buf->file_last - cl->buf->file_pos;
152
-
153
- if (send + size > limit) {
154
- size = limit - send;
155
-
156
- aligned = (cl->buf->file_pos + size + ngx_pagesize - 1)
157
- & ~((off_t) ngx_pagesize - 1);
97
+ file_size = ngx_chain_coalesce_file(&cl, limit - send);
158
98
 
159
- if (aligned <= cl->buf->file_last) {
160
- size = aligned - cl->buf->file_pos;
161
- }
162
- }
163
-
164
- file_size += size;
165
- send += size;
166
- fprev = cl->buf->file_pos + size;
167
- cl = cl->next;
99
+ send += file_size;
168
100
 
169
- } while (cl
170
- && cl->buf->in_file
171
- && send < limit
172
- && file->file->fd == cl->buf->file->fd
173
- && fprev == cl->buf->file_pos);
174
- }
101
+ if (header.count == 0) {
175
102
 
176
- if (file && header.nelts == 0) {
177
-
178
- /* create the trailer iovec and coalesce the neighbouring bufs */
179
-
180
- prev = NULL;
181
- iov = NULL;
182
-
183
- while (cl && send < limit) {
184
-
185
- if (ngx_buf_special(cl->buf)) {
186
- cl = cl->next;
187
- continue;
188
- }
189
-
190
- if (!ngx_buf_in_memory_only(cl->buf)) {
191
- break;
192
- }
193
-
194
- size = cl->buf->last - cl->buf->pos;
103
+ /*
104
+ * create the trailer iovec and coalesce the neighbouring bufs
105
+ */
195
106
 
196
- if (send + size > limit) {
197
- size = limit - send;
107
+ cl = ngx_output_chain_to_iovec(&trailer, cl, limit - send,
108
+ c->log);
109
+ if (cl == NGX_CHAIN_ERROR) {
110
+ return NGX_CHAIN_ERROR;
198
111
  }
199
112
 
200
- if (prev == cl->buf->pos) {
201
- iov->iov_len += (size_t) size;
202
-
203
- } else {
204
- if (trailer.nelts >= IOV_MAX) {
205
- break;
206
- }
207
-
208
- iov = ngx_array_push(&trailer);
209
- if (iov == NULL) {
210
- return NGX_CHAIN_ERROR;
211
- }
212
-
213
- iov->iov_base = (void *) cl->buf->pos;
214
- iov->iov_len = (size_t) size;
215
- }
113
+ send += trailer.size;
216
114
 
217
- prev = cl->buf->pos + (size_t) size;
218
- send += size;
219
- cl = cl->next;
115
+ } else {
116
+ trailer.count = 0;
220
117
  }
221
- }
222
-
223
- if (file) {
224
118
 
225
119
  /*
226
120
  * sendfile() returns EINVAL if sf_hdtr's count is 0,
227
121
  * but corresponding pointer is not NULL
228
122
  */
229
123
 
230
- hdtr.headers = header.nelts ? (struct iovec *) header.elts: NULL;
231
- hdtr.hdr_cnt = header.nelts;
232
- hdtr.trailers = trailer.nelts ? (struct iovec *) trailer.elts: NULL;
233
- hdtr.trl_cnt = trailer.nelts;
124
+ hdtr.headers = header.count ? header.iovs : NULL;
125
+ hdtr.hdr_cnt = header.count;
126
+ hdtr.trailers = trailer.count ? trailer.iovs : NULL;
127
+ hdtr.trl_cnt = trailer.count;
234
128
 
235
- sent = header_size + file_size;
129
+ sent = header.size + file_size;
236
130
 
237
131
  ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
238
- "sendfile: @%O %O h:%O",
239
- file->file_pos, sent, header_size);
132
+ "sendfile: @%O %O h:%uz",
133
+ file->file_pos, sent, header.size);
240
134
 
241
135
  rc = sendfile(file->file->fd, c->fd, file->file_pos,
242
136
  &sent, &hdtr, 0);
@@ -279,86 +173,28 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
279
173
 
280
174
  ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
281
175
  "sendfile: %d, @%O %O:%O",
282
- rc, file->file_pos, sent, file_size + header_size);
176
+ rc, file->file_pos, sent, file_size + header.size);
283
177
 
284
178
  } else {
285
- rc = writev(c->fd, header.elts, header.nelts);
286
-
287
- ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
288
- "writev: %d of %uz", rc, send);
289
-
290
- if (rc == -1) {
291
- err = ngx_errno;
292
-
293
- switch (err) {
294
- case NGX_EAGAIN:
295
- break;
296
-
297
- case NGX_EINTR:
298
- eintr = 1;
299
- break;
300
-
301
- default:
302
- wev->error = 1;
303
- ngx_connection_error(c, err, "writev() failed");
304
- return NGX_CHAIN_ERROR;
305
- }
179
+ n = ngx_writev(c, &header);
306
180
 
307
- ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
308
- "writev() not ready");
181
+ if (n == NGX_ERROR) {
182
+ return NGX_CHAIN_ERROR;
309
183
  }
310
184
 
311
- sent = rc > 0 ? rc : 0;
312
- }
313
-
314
- if (send - prev_send == sent) {
315
- complete = 1;
185
+ sent = (n == NGX_AGAIN) ? 0 : n;
316
186
  }
317
187
 
318
188
  c->sent += sent;
319
189
 
320
- for ( /* void */ ; in; in = in->next) {
321
-
322
- if (ngx_buf_special(in->buf)) {
323
- continue;
324
- }
325
-
326
- if (sent == 0) {
327
- break;
328
- }
329
-
330
- size = ngx_buf_size(in->buf);
331
-
332
- if (sent >= size) {
333
- sent -= size;
334
-
335
- if (ngx_buf_in_memory(in->buf)) {
336
- in->buf->pos = in->buf->last;
337
- }
338
-
339
- if (in->buf->in_file) {
340
- in->buf->file_pos = in->buf->file_last;
341
- }
342
-
343
- continue;
344
- }
345
-
346
- if (ngx_buf_in_memory(in->buf)) {
347
- in->buf->pos += (size_t) sent;
348
- }
349
-
350
- if (in->buf->in_file) {
351
- in->buf->file_pos += sent;
352
- }
353
-
354
- break;
355
- }
190
+ in = ngx_chain_update_sent(in, sent);
356
191
 
357
192
  if (eintr) {
193
+ send = prev_send + sent;
358
194
  continue;
359
195
  }
360
196
 
361
- if (!complete) {
197
+ if (send - prev_send != sent) {
362
198
  wev->ready = 0;
363
199
  return in;
364
200
  }