Mercurial > hg > nginx-vendor-0-7
diff src/http/modules/ngx_http_auth_basic_module.c @ 452:fc5ebf0e5f98 NGINX_0_7_38
nginx 0.7.38
*) Feature: authentication failures logging.
*) Bugfix: name/password in auth_basic_user_file were ignored after odd
number of empty lines.
Thanks to Alexander Zagrebin.
*) Bugfix: a segmentation fault occurred in a master process, if long
path was used in unix domain socket; the bug had appeared in 0.7.36.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 23 Feb 2009 00:00:00 +0300 |
parents | 984bb0b1399b |
children | bb941a2996a6 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_auth_basic_module.c +++ b/src/http/modules/ngx_http_auth_basic_module.c @@ -126,6 +126,10 @@ ngx_http_auth_basic_handler(ngx_http_req rc = ngx_http_auth_basic_user(r); if (rc == NGX_DECLINED) { + + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "no user/password was provided for basic authentication"); + return ngx_http_auth_basic_set_realm(r, &alcf->realm); } @@ -172,9 +176,16 @@ ngx_http_auth_basic_handler(ngx_http_req switch (state) { case sw_login: - if (login == 0 && buf[i] == '#') { - state = sw_skip; - break; + if (login == 0) { + + if (buf[i] == '#' || buf[i] == CR) { + state = sw_skip; + break; + } + + if (buf[i] == LF) { + break; + } } if (buf[i] != r->headers_in.user.data[login]) { @@ -242,6 +253,10 @@ ngx_http_auth_basic_handler(ngx_http_req return ngx_http_auth_basic_crypt_handler(r, NULL, &pwd, &alcf->realm); } + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "user \"%V\" was not found in \"%V\"", + &r->headers_in.user, &alcf->user_file); + return ngx_http_auth_basic_set_realm(r, &alcf->realm); } @@ -257,8 +272,8 @@ ngx_http_auth_basic_crypt_handler(ngx_ht &encrypted); ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "rc: %d user: \"%V\" salt: \"%s\"", - rc, &r->headers_in.user, passwd->data); + "rc: %d user: \"%V\" salt: \"%s\"", + rc, &r->headers_in.user, passwd->data); if (rc == NGX_OK) { if (ngx_strcmp(encrypted, passwd->data) == 0) { @@ -268,6 +283,10 @@ ngx_http_auth_basic_crypt_handler(ngx_ht ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "encrypted: \"%s\"", encrypted); + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "user \"%V\": password mismatch", + &r->headers_in.user); + return ngx_http_auth_basic_set_realm(r, realm); }