Skip to content

Commit 7622552

Browse files
committed
Merge pull request mdirolf#45 from xrchen/master
Fix authentication bug
2 parents e5d8cc7 + df91a6d commit 7622552

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

ngx_http_gridfs_module.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,11 @@ static ngx_int_t ngx_http_mongo_authenticate(ngx_log_t *log, ngx_http_gridfs_loc
431431

432432
// Authenticate
433433
if (gridfs_loc_conf->user.data != NULL && gridfs_loc_conf->pass.data != NULL) {
434-
if (!mongo_cmd_authenticate( &mongo_conn->conn,
435-
(const char*)gridfs_loc_conf->db.data,
436-
(const char*)gridfs_loc_conf->user.data,
437-
(const char*)gridfs_loc_conf->pass.data )) {
434+
if (mongo_cmd_authenticate( &mongo_conn->conn,
435+
(const char*)gridfs_loc_conf->db.data,
436+
(const char*)gridfs_loc_conf->user.data,
437+
(const char*)gridfs_loc_conf->pass.data )
438+
!= MONGO_OK) {
438439
ngx_log_error(NGX_LOG_ERR, log, 0,
439440
"Invalid mongo user/pass: %s/%s",
440441
gridfs_loc_conf->user.data,
@@ -609,15 +610,16 @@ static ngx_int_t ngx_http_mongo_reconnect(ngx_log_t *log, ngx_http_mongo_connect
609610

610611
static ngx_int_t ngx_http_mongo_reauth(ngx_log_t *log, ngx_http_mongo_connection_t *mongo_conn) {
611612
ngx_http_mongo_auth_t *auths;
612-
volatile ngx_uint_t i, success = 0;
613+
volatile ngx_uint_t i;
614+
volatile ngx_int_t status = 0;
613615
auths = mongo_conn->auths->elts;
614616

615617
for (i = 0; i < mongo_conn->auths->nelts; i++) {
616-
success = mongo_cmd_authenticate( &mongo_conn->conn,
617-
(const char*)auths[i].db.data,
618-
(const char*)auths[i].user.data,
619-
(const char*)auths[i].pass.data );
620-
if (!success) {
618+
status = mongo_cmd_authenticate( &mongo_conn->conn,
619+
(const char*)auths[i].db.data,
620+
(const char*)auths[i].user.data,
621+
(const char*)auths[i].pass.data );
622+
if (status != MONGO_OK) {
621623
ngx_log_error(NGX_LOG_ERR, log, 0,
622624
"Invalid mongo user/pass: %s/%s, during reauth",
623625
auths[i].user.data,

0 commit comments

Comments
 (0)