From 2d028f891035189c5c790aeae8895fb1e6af116f Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Sat, 29 Dec 2007 16:38:23 +0000 Subject: [PATCH] satisfy all|any --- src/http/modules/ngx_http_access_module.c | 2 +- src/http/ngx_http_core_module.c | 29 +++++++++++++++++++---- src/http/ngx_http_core_module.h | 7 +++++- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/http/modules/ngx_http_access_module.c b/src/http/modules/ngx_http_access_module.c index 44a2fbd89..264423beb 100644 --- a/src/http/modules/ngx_http_access_module.c +++ b/src/http/modules/ngx_http_access_module.c @@ -116,7 +116,7 @@ ngx_http_access_handler(ngx_http_request_t *r) if (rule[i].deny) { clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - if (!clcf->satisfy_any) { + if (clcf->satisfy == NGX_HTTP_SATISFY_ALL) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "access forbidden by rule"); } diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 81d27d824..4f43ead43 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -93,6 +93,10 @@ static ngx_conf_deprecated_t ngx_conf_deprecated_open_file_cache_retest = { ngx_conf_deprecated, "open_file_cache_retest", "open_file_cache_valid" }; +static ngx_conf_deprecated_t ngx_conf_deprecated_satisfy_any = { + ngx_conf_deprecated, "satisfy_any", "satisfy" +}; + static ngx_conf_enum_t ngx_http_core_request_body_in_file[] = { { ngx_string("off"), NGX_HTTP_REQUEST_BODY_FILE_OFF }, @@ -102,6 +106,13 @@ static ngx_conf_enum_t ngx_http_core_request_body_in_file[] = { }; +static ngx_conf_enum_t ngx_http_core_satisfy[] = { + { ngx_string("all"), NGX_HTTP_SATISFY_ALL }, + { ngx_string("any"), NGX_HTTP_SATISFY_ANY }, + { ngx_null_string, 0 } +}; + + #if (NGX_HTTP_GZIP) static ngx_conf_enum_t ngx_http_gzip_http_version[] = { @@ -404,12 +415,19 @@ static ngx_command_t ngx_http_core_commands[] = { 0, NULL }, + { ngx_string("satisfy"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_enum_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_core_loc_conf_t, satisfy), + &ngx_http_core_satisfy }, + { ngx_string("satisfy_any"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, ngx_conf_set_flag_slot, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_core_loc_conf_t, satisfy_any), - NULL }, + offsetof(ngx_http_core_loc_conf_t, satisfy), + &ngx_conf_deprecated_satisfy_any }, { ngx_string("internal"), NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS, @@ -918,7 +936,7 @@ ngx_http_core_access_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph) clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - if (clcf->satisfy_any == 0) { + if (clcf->satisfy == NGX_HTTP_SATISFY_ALL) { if (rc == NGX_OK) { r->phase_handler++; @@ -2674,7 +2692,7 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf) lcf->client_max_body_size = NGX_CONF_UNSET; lcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE; lcf->client_body_timeout = NGX_CONF_UNSET_MSEC; - lcf->satisfy_any = NGX_CONF_UNSET; + lcf->satisfy = NGX_CONF_UNSET; lcf->internal = NGX_CONF_UNSET; lcf->client_body_in_file_only = NGX_CONF_UNSET; lcf->sendfile = NGX_CONF_UNSET; @@ -2859,7 +2877,8 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) ngx_conf_merge_msec_value(conf->client_body_timeout, prev->client_body_timeout, 60000); - ngx_conf_merge_value(conf->satisfy_any, prev->satisfy_any, 0); + ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy, + NGX_HTTP_SATISFY_ALL); ngx_conf_merge_value(conf->internal, prev->internal, 0); ngx_conf_merge_value(conf->client_body_in_file_only, prev->client_body_in_file_only, 0); diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 796ae48e8..e11d82941 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -24,6 +24,10 @@ #define NGX_HTTP_GZIP_PROXIED_ANY 0x0200 +#define NGX_HTTP_SATISFY_ALL 0 +#define NGX_HTTP_SATISFY_ANY 1 + + typedef struct { unsigned default_server:1; unsigned bind:1; @@ -286,7 +290,8 @@ struct ngx_http_core_loc_conf_s { time_t keepalive_header; /* keepalive_timeout */ - ngx_flag_t satisfy_any; /* satisfy_any */ + ngx_uint_t satisfy; /* satisfy */ + ngx_flag_t internal; /* internal */ ngx_flag_t client_body_in_file_only; /* client_body_in_file_only */ ngx_flag_t sendfile; /* sendfile */