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

Feature: Allow to define ACLs in <acl> (child of <role>)

This commit is contained in:
Philipp Schafft 2018-11-04 09:57:44 +00:00
parent ca83e6b44b
commit aeeee071d4

View File

@ -716,7 +716,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
{ {
auth_t *auth = calloc(1, sizeof(auth_t)); auth_t *auth = calloc(1, sizeof(auth_t));
config_options_t *options = NULL, **next_option = &options; config_options_t *options = NULL, **next_option = &options;
xmlNodePtr option; xmlNodePtr child;
char *method; char *method;
char *tmp; char *tmp;
size_t i; size_t i;
@ -817,36 +817,45 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
auth_get_authenticator__permission_alter(auth, node, "may-alter", AUTH_MATCHTYPE_MATCH); auth_get_authenticator__permission_alter(auth, node, "may-alter", AUTH_MATCHTYPE_MATCH);
auth_get_authenticator__permission_alter(auth, node, "may-not-alter", AUTH_MATCHTYPE_NOMATCH); auth_get_authenticator__permission_alter(auth, node, "may-not-alter", AUTH_MATCHTYPE_NOMATCH);
/* BEFORE RELEASE 2.5.0 TODO: Migrate this to config_parse_options(). */ /* sub node parsing */
option = node->xmlChildrenNode; child = node->xmlChildrenNode;
while (option) do {
{ if (child == NULL)
xmlNodePtr current = option; break;
option = option->next;
if (xmlStrcmp (current->name, XMLSTR("option")) == 0) if (xmlIsBlankNode(child))
{ continue;
if (xmlStrcmp (child->name, XMLSTR("option")) == 0) {
config_options_t *opt = calloc(1, sizeof (config_options_t)); config_options_t *opt = calloc(1, sizeof (config_options_t));
opt->name = (char *)xmlGetProp(current, XMLSTR("name")); opt->name = (char *)xmlGetProp(child, XMLSTR("name"));
if (opt->name == NULL) if (opt->name == NULL) {
{
free(opt); free(opt);
continue; continue;
} }
opt->value = (char *)xmlGetProp(current, XMLSTR("value")); opt->value = (char *)xmlGetProp(child, XMLSTR("value"));
if (opt->value == NULL) if (opt->value == NULL) {
{
xmlFree(opt->name); xmlFree(opt->name);
free(opt); free(opt);
continue; continue;
} }
*next_option = opt; *next_option = opt;
next_option = &opt->next; next_option = &opt->next;
} else if (xmlStrcmp (child->name, XMLSTR("acl")) == 0) {
if (!auth->acl) {
auth->acl = acl_new_from_xml_node(child);
} else {
ICECAST_LOG_ERROR("More than one ACL defined in role! Not supported (yet).");
} }
else } else {
if (xmlStrcmp (current->name, XMLSTR("text")) != 0) ICECAST_LOG_WARN("unknown auth setting (%H)", child->name);
ICECAST_LOG_WARN("unknown auth setting (%s)", current->name);
} }
} while ((child = child->next));
if (!auth->acl) {
/* If we did not get a <acl> try ACL as part of <role> (old style). */
auth->acl = acl_new_from_xml_node(node); auth->acl = acl_new_from_xml_node(node);
}
if (!auth->acl) { if (!auth->acl) {
auth_release(auth); auth_release(auth);
auth = NULL; auth = NULL;