mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
make sure config lock is released in all failure cases of manageauth
svn path=/icecast/trunk/icecast/; revision=13792
This commit is contained in:
parent
a2cb69a789
commit
337f4a3272
46
src/admin.c
46
src/admin.c
@ -711,23 +711,34 @@ static void command_manageauth(client_t *client, source_t *source,
|
|||||||
xmlNodePtr node, srcnode, msgnode;
|
xmlNodePtr node, srcnode, msgnode;
|
||||||
const char *action = NULL;
|
const char *action = NULL;
|
||||||
const char *username = NULL;
|
const char *username = NULL;
|
||||||
const char *password = NULL;
|
|
||||||
char *message = NULL;
|
char *message = NULL;
|
||||||
int ret = AUTH_OK;
|
int ret = AUTH_OK;
|
||||||
ice_config_t *config = config_get_config ();
|
ice_config_t *config = config_get_config ();
|
||||||
mount_proxy *mountinfo = config_find_mount (config, source->mount);
|
mount_proxy *mountinfo = config_find_mount (config, source->mount);
|
||||||
|
|
||||||
if((COMMAND_OPTIONAL(client, "action", action))) {
|
do
|
||||||
|
{
|
||||||
if (mountinfo == NULL || mountinfo->auth == NULL)
|
if (mountinfo == NULL || mountinfo->auth == NULL)
|
||||||
{
|
{
|
||||||
WARN1 ("manage auth request for %s but no facility available", source->mount);
|
WARN1 ("manage auth request for %s but no facility available", source->mount);
|
||||||
config_release_config ();
|
break;
|
||||||
client_send_404 (client, "no such auth facility");
|
}
|
||||||
return;
|
COMMAND_OPTIONAL(client, "action", action);
|
||||||
|
COMMAND_OPTIONAL (client, "username", username);
|
||||||
|
|
||||||
|
if (action == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!strcmp(action, "add"))
|
||||||
|
{
|
||||||
|
const char *password = NULL;
|
||||||
|
COMMAND_OPTIONAL (client, "password", password);
|
||||||
|
|
||||||
|
if (username == NULL || password == NULL)
|
||||||
|
{
|
||||||
|
WARN1 ("manage auth request add for %s but no user/pass", source->mount);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!strcmp(action, "add")) {
|
|
||||||
COMMAND_REQUIRE(client, "username", username);
|
|
||||||
COMMAND_REQUIRE(client, "password", password);
|
|
||||||
ret = mountinfo->auth->adduser(mountinfo->auth, username, password);
|
ret = mountinfo->auth->adduser(mountinfo->auth, username, password);
|
||||||
if (ret == AUTH_FAILED) {
|
if (ret == AUTH_FAILED) {
|
||||||
message = strdup("User add failed - check the icecast error log");
|
message = strdup("User add failed - check the icecast error log");
|
||||||
@ -739,8 +750,13 @@ static void command_manageauth(client_t *client, source_t *source,
|
|||||||
message = strdup("User already exists - not added");
|
message = strdup("User already exists - not added");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!strcmp(action, "delete")) {
|
if (!strcmp(action, "delete"))
|
||||||
COMMAND_REQUIRE(client, "username", username);
|
{
|
||||||
|
if (username == NULL)
|
||||||
|
{
|
||||||
|
WARN1 ("manage auth request delete for %s but no username", source->mount);
|
||||||
|
break;
|
||||||
|
}
|
||||||
ret = mountinfo->auth->deleteuser(mountinfo->auth, username);
|
ret = mountinfo->auth->deleteuser(mountinfo->auth, username);
|
||||||
if (ret == AUTH_FAILED) {
|
if (ret == AUTH_FAILED) {
|
||||||
message = strdup("User delete failed - check the icecast error log");
|
message = strdup("User delete failed - check the icecast error log");
|
||||||
@ -749,7 +765,6 @@ static void command_manageauth(client_t *client, source_t *source,
|
|||||||
message = strdup("User deleted");
|
message = strdup("User deleted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
doc = xmlNewDoc("1.0");
|
doc = xmlNewDoc("1.0");
|
||||||
node = xmlNewDocNode(doc, NULL, "icestats", NULL);
|
node = xmlNewDocNode(doc, NULL, "icestats", NULL);
|
||||||
@ -770,10 +785,13 @@ static void command_manageauth(client_t *client, source_t *source,
|
|||||||
|
|
||||||
admin_send_response(doc, client, response,
|
admin_send_response(doc, client, response,
|
||||||
MANAGEAUTH_TRANSFORMED_REQUEST);
|
MANAGEAUTH_TRANSFORMED_REQUEST);
|
||||||
if (message) {
|
free (message);
|
||||||
free(message);
|
|
||||||
}
|
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
return;
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
config_release_config ();
|
||||||
|
client_send_400 (client, "missing parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void command_kill_source(client_t *client, source_t *source,
|
static void command_kill_source(client_t *client, source_t *source,
|
||||||
|
Loading…
Reference in New Issue
Block a user