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/httpauthd.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'daemon/httpauthd.c') diff --git a/daemon/httpauthd.c b/daemon/httpauthd.c index bae758a..4450b7a 100644 --- a/daemon/httpauthd.c +++ b/daemon/httpauthd.c @@ -33,6 +33,7 @@ extern ha_handler_t simple_handler; extern ha_handler_t ldap_handler; extern ha_handler_t ntlm_handler; extern ha_handler_t pgsql_handler; +extern ha_handler_t mysql_handler; /* This is the list of all available handlers */ ha_handler_t* g_handlerlist[] = @@ -45,6 +46,9 @@ ha_handler_t* g_handlerlist[] = #endif #if WITH_PGSQL &pgsql_handler, +#endif +#if WITH_MYSQL + &mysql_handler, #endif &simple_handler, }; @@ -115,6 +119,7 @@ int g_console = 0; /* debug mode read write from console int g_debuglevel = LOG_ERR; /* what gets logged to console */ const char* g_socket = DEFAULT_SOCKET; /* The socket to communicate on */ int g_maxthreads = DEFAULT_MAXTHREADS; /* The maximum number of threads */ +unsigned int g_unique = 0x10000; /* A unique identifier (incremented) */ /* For main loop and signal handlers */ int g_quit = 0; @@ -251,6 +256,9 @@ int main(int argc, char* argv[]) if(sock < 0) err(1, "couldn't open socket"); + i = 1; + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&i, sizeof(i)); + /* Unlink the socket file if it exists */ /* TODO: Is this safe? */ unlink(g_socket); @@ -970,7 +978,7 @@ static int httpauth_auth(ha_request_t* rq, int ofd) return HA_OK; } -static int httpauth_set(ha_request_t* rq, int ofd) +static int httpauth_set(ha_request_t* rq, ha_buffer_t* cbuf, int ofd) { httpauth_loaded_t* h; const char* name = rq->req_args[0]; @@ -985,7 +993,8 @@ static int httpauth_set(ha_request_t* rq, int ofd) if(strcasecmp(name, "Domain") == 0) { - rq->digest_domain = value ? value : ""; + /* We need to copy this string so it doesn't get destroyed on next req */ + rq->digest_domain = ha_bufcpy(rq->conn_buf, value ? value : ""); } else if(strcasecmp(name, "Handler") == 0) @@ -1026,6 +1035,7 @@ static int httpauth_set(ha_request_t* rq, int ofd) static int httpauth_processor(int ifd, int ofd) { + ha_buffer_t cbuf; ha_buffer_t buf; ha_request_t rq; int result = -1; @@ -1036,13 +1046,18 @@ static int httpauth_processor(int ifd, int ofd) /* Initialize the memory buffers */ ha_bufinit(&buf); + ha_bufinit(&cbuf); memset(&rq, 0, sizeof(rq)); /* Set up some context stuff */ rq.digest_domain = ""; rq.buf = &buf; + rq.conn_buf = &cbuf; + ha_lock(NULL); + rq.id = g_unique++; + ha_unlock(NULL); if(httpauth_ready(&rq, ofd) == -1) { @@ -1079,7 +1094,7 @@ static int httpauth_processor(int ifd, int ofd) break; case REQTYPE_SET: - r = httpauth_set(&rq, ofd); + r = httpauth_set(&rq, &cbuf, ofd); break; case REQTYPE_QUIT: @@ -1121,6 +1136,7 @@ static int httpauth_processor(int ifd, int ofd) } finally: + ha_buffree(&cbuf); ha_buffree(&buf); return result; } -- cgit v1.2.3