comparison src/http/modules/ngx_http_secure_link_module.c @ 7831:bdd4d89370a7

Changed complex value slots to use NGX_CONF_UNSET_PTR. With this change, it is now possible to use ngx_conf_merge_ptr_value() to merge complex values. This change follows much earlier changes in ngx_conf_merge_ptr_value() and ngx_conf_set_str_array_slot() in 1452:cd586e963db0 (0.6.10) and 1701:40d004d95d88 (0.6.22), and the change in ngx_conf_set_keyval_slot() (7728:485dba3e2a01, 1.19.4). To preserve compatibility with existing 3rd party modules, both NULL and NGX_CONF_UNSET_PTR are accepted for now.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 06 May 2021 02:22:03 +0300
parents c7d4017c8876
children
comparison
equal deleted inserted replaced
7830:f2ff291bbdac 7831:bdd4d89370a7
300 } 300 }
301 301
302 /* 302 /*
303 * set by ngx_pcalloc(): 303 * set by ngx_pcalloc():
304 * 304 *
305 * conf->variable = NULL;
306 * conf->md5 = NULL;
307 * conf->secret = { 0, NULL }; 305 * conf->secret = { 0, NULL };
308 */ 306 */
309 307
308 conf->variable = NGX_CONF_UNSET_PTR;
309 conf->md5 = NGX_CONF_UNSET_PTR;
310
310 return conf; 311 return conf;
311 } 312 }
312 313
313 314
314 static char * 315 static char *
316 { 317 {
317 ngx_http_secure_link_conf_t *prev = parent; 318 ngx_http_secure_link_conf_t *prev = parent;
318 ngx_http_secure_link_conf_t *conf = child; 319 ngx_http_secure_link_conf_t *conf = child;
319 320
320 if (conf->secret.data) { 321 if (conf->secret.data) {
322 ngx_conf_init_ptr_value(conf->variable, NULL);
323 ngx_conf_init_ptr_value(conf->md5, NULL);
324
321 if (conf->variable || conf->md5) { 325 if (conf->variable || conf->md5) {
322 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 326 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
323 "\"secure_link_secret\" cannot be mixed with " 327 "\"secure_link_secret\" cannot be mixed with "
324 "\"secure_link\" and \"secure_link_md5\""); 328 "\"secure_link\" and \"secure_link_md5\"");
325 return NGX_CONF_ERROR; 329 return NGX_CONF_ERROR;
326 } 330 }
327 331
328 return NGX_CONF_OK; 332 return NGX_CONF_OK;
329 } 333 }
330 334
331 if (conf->variable == NULL) { 335 ngx_conf_merge_ptr_value(conf->variable, prev->variable, NULL);
332 conf->variable = prev->variable; 336 ngx_conf_merge_ptr_value(conf->md5, prev->md5, NULL);
333 }
334
335 if (conf->md5 == NULL) {
336 conf->md5 = prev->md5;
337 }
338 337
339 if (conf->variable == NULL && conf->md5 == NULL) { 338 if (conf->variable == NULL && conf->md5 == NULL) {
340 conf->secret = prev->secret; 339 conf->secret = prev->secret;
341 } 340 }
342 341