mirror of
https://github.com/nginx/nginx.git
synced 2025-06-08 02:02:38 +08:00
Removed more remnants of the old pthread implementation.
After e284f3ff6831, ngx_crypt() can no longer return NGX_AGAIN.
This commit is contained in:
parent
99cc4c72c7
commit
05e87e19af
@ -14,11 +14,6 @@
|
||||
#define NGX_HTTP_AUTH_BUF_SIZE 2048
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_str_t passwd;
|
||||
} ngx_http_auth_basic_ctx_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_http_complex_value_t *realm;
|
||||
ngx_http_complex_value_t user_file;
|
||||
@ -27,7 +22,7 @@ typedef struct {
|
||||
|
||||
static ngx_int_t ngx_http_auth_basic_handler(ngx_http_request_t *r);
|
||||
static ngx_int_t ngx_http_auth_basic_crypt_handler(ngx_http_request_t *r,
|
||||
ngx_http_auth_basic_ctx_t *ctx, ngx_str_t *passwd, ngx_str_t *realm);
|
||||
ngx_str_t *passwd, ngx_str_t *realm);
|
||||
static ngx_int_t ngx_http_auth_basic_set_realm(ngx_http_request_t *r,
|
||||
ngx_str_t *realm);
|
||||
static void ngx_http_auth_basic_close(ngx_file_t *file);
|
||||
@ -103,7 +98,6 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
|
||||
ngx_str_t pwd, realm, user_file;
|
||||
ngx_uint_t i, level, login, left, passwd;
|
||||
ngx_file_t file;
|
||||
ngx_http_auth_basic_ctx_t *ctx;
|
||||
ngx_http_auth_basic_loc_conf_t *alcf;
|
||||
u_char buf[NGX_HTTP_AUTH_BUF_SIZE];
|
||||
enum {
|
||||
@ -126,13 +120,6 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
||||
ctx = ngx_http_get_module_ctx(r, ngx_http_auth_basic_module);
|
||||
|
||||
if (ctx) {
|
||||
return ngx_http_auth_basic_crypt_handler(r, ctx, &ctx->passwd,
|
||||
&realm);
|
||||
}
|
||||
|
||||
rc = ngx_http_auth_basic_user(r);
|
||||
|
||||
if (rc == NGX_DECLINED) {
|
||||
@ -237,8 +224,7 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
|
||||
pwd.len = i - passwd;
|
||||
pwd.data = &buf[passwd];
|
||||
|
||||
return ngx_http_auth_basic_crypt_handler(r, NULL, &pwd,
|
||||
&realm);
|
||||
return ngx_http_auth_basic_crypt_handler(r, &pwd, &realm);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -276,7 +262,7 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
|
||||
|
||||
ngx_cpystrn(pwd.data, &buf[passwd], pwd.len + 1);
|
||||
|
||||
return ngx_http_auth_basic_crypt_handler(r, NULL, &pwd, &realm);
|
||||
return ngx_http_auth_basic_crypt_handler(r, &pwd, &realm);
|
||||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
@ -288,8 +274,8 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_auth_basic_crypt_handler(ngx_http_request_t *r,
|
||||
ngx_http_auth_basic_ctx_t *ctx, ngx_str_t *passwd, ngx_str_t *realm)
|
||||
ngx_http_auth_basic_crypt_handler(ngx_http_request_t *r, ngx_str_t *passwd,
|
||||
ngx_str_t *realm)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
u_char *encrypted;
|
||||
@ -301,7 +287,10 @@ ngx_http_auth_basic_crypt_handler(ngx_http_request_t *r,
|
||||
"rc: %i user: \"%V\" salt: \"%s\"",
|
||||
rc, &r->headers_in.user, passwd->data);
|
||||
|
||||
if (rc == NGX_OK) {
|
||||
if (rc != NGX_OK) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_strcmp(encrypted, passwd->data) == 0) {
|
||||
return NGX_OK;
|
||||
}
|
||||
@ -316,35 +305,6 @@ ngx_http_auth_basic_crypt_handler(ngx_http_request_t *r,
|
||||
return ngx_http_auth_basic_set_realm(r, realm);
|
||||
}
|
||||
|
||||
if (rc == NGX_ERROR) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
/* rc == NGX_AGAIN */
|
||||
|
||||
if (ctx == NULL) {
|
||||
ctx = ngx_palloc(r->pool, sizeof(ngx_http_auth_basic_ctx_t));
|
||||
if (ctx == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
ngx_http_set_ctx(r, ctx, ngx_http_auth_basic_module);
|
||||
|
||||
ctx->passwd.len = passwd->len;
|
||||
passwd->len++;
|
||||
|
||||
ctx->passwd.data = ngx_pstrdup(r->pool, passwd);
|
||||
if (ctx->passwd.data == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* TODO: add mutex event */
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_auth_basic_set_realm(ngx_http_request_t *r, ngx_str_t *realm)
|
||||
|
@ -9,16 +9,6 @@
|
||||
#include <ngx_core.h>
|
||||
|
||||
|
||||
/*
|
||||
* Solaris has thread-safe crypt()
|
||||
* Linux has crypt_r(); "struct crypt_data" is more than 128K
|
||||
* FreeBSD needs the mutex to protect crypt()
|
||||
*
|
||||
* TODO:
|
||||
* ngx_crypt_init() to init mutex
|
||||
*/
|
||||
|
||||
|
||||
#if (NGX_CRYPT)
|
||||
|
||||
#if (NGX_HAVE_GNU_CRYPT_R)
|
||||
|
Loading…
Reference in New Issue
Block a user