diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-09-06 16:09:32 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-09-06 16:09:32 +0000 |
commit | ceb992921cee6f76d1752af2d388ee6a1d71e078 (patch) | |
tree | 2b4916a12d02210134939b7fb388a270e76002fa /src/http/ngx_http_variables.c | |
parent | 5650106a09de8e8d876ed38fbff57b2161d910c4 (diff) | |
download | nginx-ceb992921cee6f76d1752af2d388ee6a1d71e078.tar.gz nginx-ceb992921cee6f76d1752af2d388ee6a1d71e078.zip |
nginx-0.1.44-RELEASE importrelease-0.1.44
*) Feature: the IMAP/POP3 proxy supports SSL.
*) Feature: the "proxy_timeout" directive of the ngx_imap_proxy_module.
*) Feature: the "userid_mark" directive.
*) Feature: the $remote_user variable value is determined independently
of authorization use.
Diffstat (limited to 'src/http/ngx_http_variables.c')
-rw-r--r-- | src/http/ngx_http_variables.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index 3e3f9f7bf..0247298b1 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -32,6 +32,8 @@ static ngx_http_variable_value_t * ngx_http_variable_document_root(ngx_http_request_t *r, uintptr_t data); static ngx_http_variable_value_t * ngx_http_variable_request_filename(ngx_http_request_t *r, uintptr_t data); +static ngx_http_variable_value_t * + ngx_http_variable_remote_user(ngx_http_request_t *r, uintptr_t data); /* @@ -108,8 +110,7 @@ static ngx_http_variable_t ngx_http_core_variables[] = { { ngx_string("request_method"), ngx_http_variable_request, offsetof(ngx_http_request_t, method_name), 0, 0 }, - { ngx_string("remote_user"), ngx_http_variable_request, - offsetof(ngx_http_request_t, headers_in.user), 0, 0 }, + { ngx_string("remote_user"), ngx_http_variable_remote_user, 0, 0, 0 }, { ngx_null_string, NULL, 0, 0, 0 } }; @@ -657,6 +658,34 @@ ngx_http_variable_request_filename(ngx_http_request_t *r, uintptr_t data) } +static ngx_http_variable_value_t * +ngx_http_variable_remote_user(ngx_http_request_t *r, uintptr_t data) +{ + ngx_int_t rc; + ngx_http_variable_value_t *vv; + + rc = ngx_http_auth_basic_user(r); + + if (rc == NGX_DECLINED) { + return NGX_HTTP_VAR_NOT_FOUND; + } + + if (rc == NGX_ERROR) { + return NULL; + } + + vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)); + if (vv == NULL) { + return NULL; + } + + vv->value = 0; + vv->text = r->headers_in.user; + + return vv; +} + + ngx_int_t ngx_http_variables_add_core_vars(ngx_conf_t *cf) { |