1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2025-02-02 15:07:36 -05:00

Regression Fix: Correction of old-style <authentication>.

Old-style <authentication> within <mount> didn't work for type="url"
as well as some other parameters due to confusion between "node"
and "child" variable.

Thanks for trilliot for pointing out! Should work now.
closes #2039
This commit is contained in:
Philipp Schafft 2014-12-14 09:27:49 +00:00
parent 8a4c529347
commit c73e214f8f
3 changed files with 25 additions and 13 deletions

View File

@ -263,7 +263,7 @@ static void *auth_run_thread (void *arg)
thread_mutex_unlock (&auth->lock);
continue;
}
ICECAST_LOG_DEBUG("%d client(s) pending on %s", auth->pending_count, auth->mount);
ICECAST_LOG_DEBUG("%d client(s) pending on %s (role %s)", auth->pending_count, auth->mount, auth->role);
auth->head = auth_user->next;
if (auth->head == NULL)
auth->tailp = &auth->head;
@ -308,9 +308,11 @@ static void *auth_run_thread (void *arg)
static void auth_add_client(auth_t *auth, client_t *client, void (*on_no_match)(client_t *client, void (*on_result)(client_t *client, void *userdata, auth_result result), void *userdata), void (*on_result)(client_t *client, void *userdata, auth_result result), void *userdata) {
auth_client *auth_user;
ICECAST_LOG_DEBUG("Trying to add client %p to auth %p's (role %s) queue.", client, auth, auth->role);
/* TODO: replace that magic number */
if (auth->pending_count > 100) {
ICECAST_LOG_WARN("too many clients awaiting authentication");
ICECAST_LOG_WARN("too many clients awaiting authentication on auth %p", auth);
client_send_error(client, 403, 1, "busy, please try again later");
return;
}

View File

@ -215,7 +215,7 @@ static void __append_old_style_urlauth(auth_stack_t **stack, const char *client_
xmlNodePtr role;
auth_t *auth;
if (!stack || !client_add || !!client_remove)
if (!stack || (!client_add && !client_remove))
return;
role = xmlNewNode(NULL, XMLSTR("role"));
@ -248,8 +248,13 @@ static void __append_old_style_urlauth(auth_stack_t **stack, const char *client_
__append_option_tag(role, "header_prefix", header_prefix);
auth = auth_get_authenticator(role);
if (auth) {
auth_stack_push(stack, auth);
auth_release(auth);
ICECAST_LOG_DEBUG("Pushed authenticator %p on stack %p.", auth, stack);
} else {
ICECAST_LOG_DEBUG("Failed to set up authenticator.");
}
xmlFreeNode(role);
}
@ -890,9 +895,9 @@ static void _parse_mount_oldstyle_authentication(mount_proxy *mount, xmlNodePtr
child = node->xmlChildrenNode;
while (child) {
if (xmlStrcmp(node->name, XMLSTR("option")) == 0) {
name = (char *)xmlGetProp(node, XMLSTR("name"));
value = (char *)xmlGetProp(node, XMLSTR("value"));
if (xmlStrcmp(child->name, XMLSTR("option")) == 0) {
name = (char *)xmlGetProp(child, XMLSTR("name"));
value = (char *)xmlGetProp(child, XMLSTR("value"));
if (name && value) {
if (strcmp(name, "allow_duplicate_users") == 0) {
allow_duplicate_users = util_str_to_bool(value);
@ -942,9 +947,9 @@ static void _parse_mount_oldstyle_authentication(mount_proxy *mount, xmlNodePtr
child = node->xmlChildrenNode;
while (child) {
if (xmlStrcmp(node->name, XMLSTR("option")) == 0) {
name = (char *)xmlGetProp(node, XMLSTR("name"));
value = (char *)xmlGetProp(node, XMLSTR("value"));
if (xmlStrcmp(child->name, XMLSTR("option")) == 0) {
name = (char *)xmlGetProp(child, XMLSTR("name"));
value = (char *)xmlGetProp(child, XMLSTR("value"));
if (name && value) {
if (strcmp(name, "mount_add") == 0) {
@ -1248,6 +1253,8 @@ static void _parse_mount(xmlDocPtr doc, xmlNodePtr node,
auth_stack_release(mount->authstack);
auth_stack_addref(mount->authstack = authstack);
ICECAST_LOG_DEBUG("Mount %p (mountpoint %s) has %sactive roles on authstack.", mount, mount->mountname, authstack ? "" : "no ");
/* make sure we have at least the mountpoint name */
if (mount->mountname == NULL && mount->mounttype != MOUNT_TYPE_DEFAULT)
{

View File

@ -946,8 +946,8 @@ static inline void source_startup (client_t *client, const char *uri)
/* only called for native icecast source clients */
static void _handle_source_request (client_t *client, const char *uri)
{
ICECAST_LOG_INFO("Source logging in at mountpoint \"%s\" from %s",
uri, client->con->ip);
ICECAST_LOG_INFO("Source logging in at mountpoint \"%s\" from %s as role %s",
uri, client->con->ip, client->role);
if (uri[0] != '/')
{
@ -1342,6 +1342,7 @@ static void _handle_authentication_global(client_t *client, void *uri, auth_resu
return;
}
ICECAST_LOG_DEBUG("Trying global authenticators for client %p.", client);
config = config_get_config();
auth_stack_add_client(config->authstack, client, _handle_authed_client, uri);
config_release_config();
@ -1391,10 +1392,12 @@ static void _handle_authentication_mount_default(client_t *client, void *uri, au
return;
}
ICECAST_LOG_DEBUG("Trying <mount type=\"default\"> specific authenticators for client %p.", client);
_handle_authentication_mount_generic(client, uri, MOUNT_TYPE_DEFAULT, _handle_authentication_global);
}
static void _handle_authentication_mount_normal(client_t *client, char *uri) {
ICECAST_LOG_DEBUG("Trying <mount type=\"normal\"> specific authenticators for client %p.", client);
_handle_authentication_mount_generic(client, uri, MOUNT_TYPE_NORMAL, _handle_authentication_mount_default);
}