Mercurial > hg > nginx
comparison src/http/modules/ngx_http_secure_link_module.c @ 5017:d89442dab4d1
Secure_link: fixed configuration inheritance.
The "secure_link_secret" directive was always inherited from the outer
configuration level even when "secure_link" and "secure_link_md5" were
specified on the inner level.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Mon, 28 Jan 2013 14:42:07 +0000 |
parents | d620f497c50f |
children | c7d4017c8876 |
comparison
equal
deleted
inserted
replaced
5016:4406168861e8 | 5017:d89442dab4d1 |
---|---|
109 ngx_http_secure_link_conf_t *conf; | 109 ngx_http_secure_link_conf_t *conf; |
110 u_char hash_buf[16], md5_buf[16]; | 110 u_char hash_buf[16], md5_buf[16]; |
111 | 111 |
112 conf = ngx_http_get_module_loc_conf(r, ngx_http_secure_link_module); | 112 conf = ngx_http_get_module_loc_conf(r, ngx_http_secure_link_module); |
113 | 113 |
114 if (conf->secret.len) { | 114 if (conf->secret.data) { |
115 return ngx_http_secure_link_old_variable(r, conf, v, data); | 115 return ngx_http_secure_link_old_variable(r, conf, v, data); |
116 } | 116 } |
117 | 117 |
118 if (conf->variable == NULL || conf->md5 == NULL) { | 118 if (conf->variable == NULL || conf->md5 == NULL) { |
119 goto not_found; | 119 goto not_found; |
316 ngx_http_secure_link_merge_conf(ngx_conf_t *cf, void *parent, void *child) | 316 ngx_http_secure_link_merge_conf(ngx_conf_t *cf, void *parent, void *child) |
317 { | 317 { |
318 ngx_http_secure_link_conf_t *prev = parent; | 318 ngx_http_secure_link_conf_t *prev = parent; |
319 ngx_http_secure_link_conf_t *conf = child; | 319 ngx_http_secure_link_conf_t *conf = child; |
320 | 320 |
321 ngx_conf_merge_str_value(conf->secret, prev->secret, ""); | 321 if (conf->secret.data) { |
322 if (conf->variable || conf->md5) { | |
323 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
324 "\"secure_link_secret\" cannot be mixed with " | |
325 "\"secure_link\" and \"secure_link_md5\""); | |
326 return NGX_CONF_ERROR; | |
327 } | |
328 | |
329 return NGX_CONF_OK; | |
330 } | |
322 | 331 |
323 if (conf->variable == NULL) { | 332 if (conf->variable == NULL) { |
324 conf->variable = prev->variable; | 333 conf->variable = prev->variable; |
325 } | 334 } |
326 | 335 |
327 if (conf->md5 == NULL) { | 336 if (conf->md5 == NULL) { |
328 conf->md5 = prev->md5; | 337 conf->md5 = prev->md5; |
338 } | |
339 | |
340 if (conf->variable == NULL && conf->md5 == NULL) { | |
341 conf->secret = prev->secret; | |
329 } | 342 } |
330 | 343 |
331 return NGX_CONF_OK; | 344 return NGX_CONF_OK; |
332 } | 345 } |
333 | 346 |