From d92564c87818157b09ddfbf3314406b765ca390a Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 17 Aug 2004 20:59:04 +0000 Subject: - Changed 'goto finally' to RETURN(xx) - Added MYSQL support and tested it. --- daemon/bd.c | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) (limited to 'daemon/bd.c') diff --git a/daemon/bd.c b/daemon/bd.c index 5519cfa..9c3b429 100644 --- a/daemon/bd.c +++ b/daemon/bd.c @@ -174,8 +174,7 @@ static int do_basic_response(ha_request_t* rq, bd_context_t* ctx, const char* he { ha_messagex(rq, LOG_NOTICE, "validated basic user against cache: %s", basic.user); - ret = HA_OK; - goto finally; + RETURN(HA_OK); } /* If we have a user name and password */ @@ -183,8 +182,7 @@ static int do_basic_response(ha_request_t* rq, bd_context_t* ctx, const char* he !basic.password || !basic.password[0]) { ha_messagex(rq, LOG_NOTICE, "no valid basic auth info"); - ret = HA_FALSE; - goto finally; + RETURN(HA_FALSE); } ASSERT(ctx->f_validate_basic); @@ -266,7 +264,7 @@ static int do_digest_response(ha_request_t* rq, bd_context_t* ctx, const char* h if(!dg.client.username) { ha_messagex(rq, LOG_WARNING, "digest response contains no user name"); - goto finally; + RETURN(HA_FALSE); } #ifdef _DEBUG @@ -275,7 +273,7 @@ static int do_digest_response(ha_request_t* rq, bd_context_t* ctx, const char* h if(dg.client.nonce && strcmp(dg.client.nonce, rq->context->digest_debugnonce) != 0) { ha_messagex(rq, LOG_WARNING, "digest response contains invalid nonce"); - goto finally; + RETURN(HA_FALSE); } /* Do a rough hash into the real nonce, for use as a key */ @@ -305,7 +303,7 @@ static int do_digest_response(ha_request_t* rq, bd_context_t* ctx, const char* h if(r == HA_FALSE) ha_messagex(rq, LOG_WARNING, "digest response contains invalid nonce"); - goto finally; + RETURN(r); } /* Check to see if we're stale */ @@ -315,7 +313,7 @@ static int do_digest_response(ha_request_t* rq, bd_context_t* ctx, const char* h dg.client.username); stale = 1; - goto finally; + RETURN(HA_FALSE); } } @@ -340,7 +338,7 @@ static int do_digest_response(ha_request_t* rq, bd_context_t* ctx, const char* h rq->resp_code = HA_SERVER_BADREQ; } - goto finally; + RETURN(ret); } /* @@ -359,19 +357,13 @@ static int do_digest_response(ha_request_t* rq, bd_context_t* ctx, const char* h rec = make_digest_rec(nonce, dg.client.username); if(!rec) - { - ret = HA_CRITERROR; - goto finally; - } + RETURN(HA_CRITERROR); ASSERT(ctx->f_validate_digest); r = ctx->f_validate_digest(rq, dg.client.username, &dg); if(r != HA_OK) - { - ret = r; - goto finally; - } + RETURN(r); /* Save away pertinent information when successful*/ memcpy(rec->ha1, dg.ha1, MD5_LEN); @@ -387,8 +379,7 @@ static int do_digest_response(ha_request_t* rq, bd_context_t* ctx, const char* h if(md5_strcmp(rec->userhash, dg.client.username) != 0) { ha_messagex(NULL, LOG_ERR, "digest response contains invalid username"); - ret = HA_FALSE; - goto finally; + RETURN(HA_FALSE); } /* And do the validation ourselves */ @@ -408,7 +399,7 @@ static int do_digest_response(ha_request_t* rq, bd_context_t* ctx, const char* h ha_messagex(NULL, LOG_WARNING, "digest re-authentication failed for user: %s", dg.client.username); - goto finally; + RETURN(ret); } } @@ -429,10 +420,7 @@ static int do_digest_response(ha_request_t* rq, bd_context_t* ctx, const char* h t = digest_respond(&dg, rq->buf, stale ? nonce : NULL); if(!t) - { - ret = HA_CRITERROR; - goto finally; - } + RETURN(HA_CRITERROR); if(t[0]) ha_addheader(rq, "Authentication-Info", t); @@ -450,7 +438,7 @@ finally: free(rec); /* If nobody above responded then challenge the client again */ - if(rq->resp_code == -1) + if(ret == HA_FALSE && rq->resp_code == -1) return do_digest_challenge(rq, ctx, stale); return ret; @@ -552,8 +540,6 @@ int bd_init(ha_context_t* context) htc.f_freeval = free_hash_object; htc.arg = NULL; hsh_set_table_calls(ctx->cache, &htc); - - ha_messagex(NULL, LOG_INFO, "initialized handler"); } return HA_OK; -- cgit v1.2.3