1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

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
This commit is contained in:
Karl Heyes 2008-04-23 02:48:53 +00:00
parent a3d1ff8098
commit 2822e350bb
2 changed files with 22 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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);