From 2822e350bb1ad4f76909aa31c46474ec837d1888 Mon Sep 17 00:00:00 2001 From: Karl Heyes Date: Wed, 23 Apr 2008 02:48:53 +0000 Subject: [PATCH] htpasswd auth should apply even if no filename is specified, just reject all new listeners with the reason logged. auth_t refcount was getting out of sync which is a potential small memory leak. svn path=/icecast/trunk/icecast/; revision=14788 --- src/auth.c | 10 ++++++++++ src/auth_htpasswd.c | 18 ++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/auth.c b/src/auth.c index b5abc61d..ee7f26aa 100644 --- a/src/auth.c +++ b/src/auth.c @@ -195,15 +195,25 @@ static void auth_new_listener (auth_t *auth, auth_client *auth_user) { DEBUG0 ("listener is no longer connected"); client->respcode = 400; + auth_release (client->auth); + client->auth = NULL; return; } if (auth->authenticate) { if (auth->authenticate (auth_user) != AUTH_OK) + { + auth_release (client->auth); + client->auth = NULL; return; + } } if (auth_postprocess_listener (auth_user) < 0) + { + auth_release (client->auth); + client->auth = NULL; INFO1 ("client %lu failed", client->con->id); + } } diff --git a/src/auth_htpasswd.c b/src/auth_htpasswd.c index e9aa2a57..458a4e2e 100644 --- a/src/auth_htpasswd.c +++ b/src/auth_htpasswd.c @@ -185,6 +185,11 @@ static auth_result htpasswd_auth (auth_client *auth_user) if (client->username == NULL || client->password == NULL) return AUTH_FAILED; + if (htpasswd->filename == NULL) + { + ERROR0("No filename given in options for authenticator."); + return AUTH_FAILED; + } htpasswd_recheckfile (htpasswd); thread_rwlock_rlock (&htpasswd->file_rwlock); @@ -225,19 +230,20 @@ int auth_get_htpasswd_auth (auth_t *authenticator, config_options_t *options) while(options) { if(!strcmp(options->name, "filename")) + { + free (state->filename); state->filename = strdup(options->value); + } options = options->next; } - if(!state->filename) { - free(state); + if (state->filename) + INFO1("Configured htpasswd authentication using password file \"%s\"", + state->filename); + else ERROR0("No filename given in options for authenticator."); - return -1; - } authenticator->state = state; - DEBUG1("Configured htpasswd authentication using password file %s", - state->filename); thread_rwlock_create(&state->file_rwlock); htpasswd_recheckfile (state);