Commit 2822e350 authored by Karl Heyes's avatar Karl Heyes

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
parent a3d1ff80
...@@ -195,15 +195,25 @@ static void auth_new_listener (auth_t *auth, auth_client *auth_user) ...@@ -195,15 +195,25 @@ static void auth_new_listener (auth_t *auth, auth_client *auth_user)
{ {
DEBUG0 ("listener is no longer connected"); DEBUG0 ("listener is no longer connected");
client->respcode = 400; client->respcode = 400;
auth_release (client->auth);
client->auth = NULL;
return; return;
} }
if (auth->authenticate) if (auth->authenticate)
{ {
if (auth->authenticate (auth_user) != AUTH_OK) if (auth->authenticate (auth_user) != AUTH_OK)
{
auth_release (client->auth);
client->auth = NULL;
return; return;
}
} }
if (auth_postprocess_listener (auth_user) < 0) if (auth_postprocess_listener (auth_user) < 0)
{
auth_release (client->auth);
client->auth = NULL;
INFO1 ("client %lu failed", client->con->id); INFO1 ("client %lu failed", client->con->id);
}
} }
......
...@@ -185,6 +185,11 @@ static auth_result htpasswd_auth (auth_client *auth_user) ...@@ -185,6 +185,11 @@ static auth_result htpasswd_auth (auth_client *auth_user)
if (client->username == NULL || client->password == NULL) if (client->username == NULL || client->password == NULL)
return AUTH_FAILED; return AUTH_FAILED;
if (htpasswd->filename == NULL)
{
ERROR0("No filename given in options for authenticator.");
return AUTH_FAILED;
}
htpasswd_recheckfile (htpasswd); htpasswd_recheckfile (htpasswd);
thread_rwlock_rlock (&htpasswd->file_rwlock); thread_rwlock_rlock (&htpasswd->file_rwlock);
...@@ -225,19 +230,20 @@ int auth_get_htpasswd_auth (auth_t *authenticator, config_options_t *options) ...@@ -225,19 +230,20 @@ int auth_get_htpasswd_auth (auth_t *authenticator, config_options_t *options)
while(options) { while(options) {
if(!strcmp(options->name, "filename")) if(!strcmp(options->name, "filename"))
{
free (state->filename);
state->filename = strdup(options->value); state->filename = strdup(options->value);
}
options = options->next; options = options->next;
} }
if(!state->filename) { if (state->filename)
free(state); INFO1("Configured htpasswd authentication using password file \"%s\"",
state->filename);
else
ERROR0("No filename given in options for authenticator."); ERROR0("No filename given in options for authenticator.");
return -1;
}
authenticator->state = state; authenticator->state = state;
DEBUG1("Configured htpasswd authentication using password file %s",
state->filename);
thread_rwlock_create(&state->file_rwlock); thread_rwlock_create(&state->file_rwlock);
htpasswd_recheckfile (state); htpasswd_recheckfile (state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment