diff --git a/admin/manageauth.xsl b/admin/manageauth.xsl index aff56f54..0732101b 100644 --- a/admin/manageauth.xsl +++ b/admin/manageauth.xsl @@ -34,13 +34,6 @@ - diff --git a/admin/stats.xsl b/admin/stats.xsl index fbd8c343..85556a88 100644 --- a/admin/stats.xsl +++ b/admin/stats.xsl @@ -38,6 +38,24 @@
+ + + +
+
@@ -89,6 +107,24 @@ + + + +
+
diff --git a/src/admin.c b/src/admin.c index 9ef7f0bb..9060d3c3 100644 --- a/src/admin.c +++ b/src/admin.c @@ -775,6 +775,26 @@ static void command_buildm3u(client_t *client, const char *mount) fserve_add_client (client, NULL); } +xmlNodePtr admin_add_role_to_authentication(auth_t *auth, xmlNodePtr parent) { + xmlNodePtr rolenode = xmlNewChild(parent, NULL, XMLSTR("role"), NULL); + char idbuf[32]; + + snprintf(idbuf, sizeof(idbuf), "%lu", auth->id); + xmlSetProp(rolenode, XMLSTR("id"), XMLSTR(idbuf)); + + if (auth->type) + xmlSetProp(rolenode, XMLSTR("type"), XMLSTR(auth->type)); + if (auth->role) + xmlSetProp(rolenode, XMLSTR("name"), XMLSTR(auth->role)); + if (auth->management_url) + xmlSetProp(rolenode, XMLSTR("management-url"), XMLSTR(auth->management_url)); + + xmlSetProp(rolenode, XMLSTR("can-adduser"), XMLSTR(auth->adduser ? "true" : "false")); + xmlSetProp(rolenode, XMLSTR("can-deleteuser"), XMLSTR(auth->deleteuser ? "true" : "false")); + xmlSetProp(rolenode, XMLSTR("can-listuser"), XMLSTR(auth->listuser ? "true" : "false")); + + return rolenode; +} static void command_manageauth(client_t *client, int response) { xmlDocPtr doc; @@ -789,7 +809,6 @@ static void command_manageauth(client_t *client, int response) { long unsigned int id; ice_config_t *config = config_get_config(); auth_t *auth; - char idbuf[32]; do { @@ -871,19 +890,8 @@ static void command_manageauth(client_t *client, int response) { doc = xmlNewDoc(XMLSTR("1.0")); node = xmlNewDocNode(doc, NULL, XMLSTR("icestats"), NULL); - rolenode = xmlNewChild(node, NULL, XMLSTR("role"), NULL); - snprintf(idbuf, sizeof(idbuf), "%lu", auth->id); - xmlSetProp(rolenode, XMLSTR("id"), XMLSTR(idbuf)); - - if (auth->type) - xmlSetProp(rolenode, XMLSTR("type"), XMLSTR(auth->type)); - if (auth->role) - xmlSetProp(rolenode, XMLSTR("name"), XMLSTR(auth->role)); - - xmlSetProp(rolenode, XMLSTR("can-adduser"), XMLSTR(auth->adduser ? "true" : "false")); - xmlSetProp(rolenode, XMLSTR("can-deleteuser"), XMLSTR(auth->deleteuser ? "true" : "false")); - xmlSetProp(rolenode, XMLSTR("can-listuser"), XMLSTR(auth->listuser ? "true" : "false")); + rolenode = admin_add_role_to_authentication(auth, node); if (message) { msgnode = xmlNewChild(node, NULL, XMLSTR("iceresponse"), NULL); diff --git a/src/admin.h b/src/admin.h index ef9d1d24..17392f18 100644 --- a/src/admin.h +++ b/src/admin.h @@ -19,6 +19,7 @@ #include "refbuf.h" #include "client.h" #include "source.h" +#include "auth.h" /* types */ #define ADMINTYPE_ERROR (-1) @@ -40,6 +41,7 @@ void admin_send_response(xmlDocPtr doc, client_t *client, int response, const char *xslt_template); void admin_add_listeners_to_mount(source_t *source, xmlNodePtr parent, operation_mode mode); +xmlNodePtr admin_add_role_to_authentication(auth_t *auth, xmlNodePtr parent); int admin_get_command(const char *command); int admin_get_command_type(int command); diff --git a/src/stats.c b/src/stats.c index 77aa99c3..a64c9609 100644 --- a/src/stats.c +++ b/src/stats.c @@ -815,16 +815,29 @@ static int _send_event_to_client(stats_event_t *event, client_t *client) return 0; } +static inline void __add_authstack (auth_stack_t *stack, xmlNodePtr parent) { + xmlNodePtr authentication; + authentication = xmlNewTextChild(parent, NULL, XMLSTR("authentication"), NULL); -static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, int hidden) -{ + auth_stack_addref(stack); + + while (stack) { + auth_t *auth = auth_stack_get(stack); + admin_add_role_to_authentication(auth, authentication); + auth_release(auth); + auth_stack_next(&stack); + } +} +static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, int hidden) { avl_node *avlnode; xmlNodePtr ret = NULL; + ice_config_t *config; thread_mutex_lock(&_stats_mutex); /* general stats first */ avlnode = avl_get_first(_stats.global_tree); - while (avlnode) + +while (avlnode) { stats_node_t *stat = avlnode->key; if (stat->hidden <= hidden) @@ -833,6 +846,10 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i } /* now per mount stats */ avlnode = avl_get_first(_stats.source_tree); + config = config_get_config(); + __add_authstack(config->authstack, root); + config_release_config(); + while (avlnode) { stats_source_t *source = (stats_source_t *)avlnode->key; @@ -840,11 +857,9 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i if (source->hidden <= hidden && (show_mount == NULL || strcmp (show_mount, source->source) == 0)) { - xmlNodePtr metadata, authentication, role; + xmlNodePtr metadata; source_t *source_real; - ice_config_t *config; mount_proxy *mountproxy; - auth_stack_t *stack; int i; avl_node *avlnode2 = avl_get_first (source->stats_tree); @@ -870,25 +885,9 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i } avl_tree_unlock(global.source_tree); - authentication = xmlNewTextChild(xmlnode, NULL, XMLSTR("authentication"), NULL); config = config_get_config(); mountproxy = config_find_mount(config, source->source, MOUNT_TYPE_NORMAL); - auth_stack_addref(stack = mountproxy->authstack); - while (stack) { - auth_t *auth = auth_stack_get(stack); - char idbuf[32]; - snprintf(idbuf, sizeof(idbuf), "%lu", auth->id); - role = xmlNewTextChild(authentication, NULL, XMLSTR("role"), NULL); - xmlSetProp(role, XMLSTR("id"), XMLSTR(idbuf)); - if (auth->type) - xmlSetProp(role, XMLSTR("type"), XMLSTR(auth->type)); - if (auth->role) - xmlSetProp(role, XMLSTR("name"), XMLSTR(auth->role)); - if (auth->management_url) - xmlSetProp(role, XMLSTR("management-url"), XMLSTR(auth->management_url)); - auth_release(auth); - auth_stack_next(&stack); - } + __add_authstack(mountproxy->authstack, xmlnode); config_release_config(); } avlnode = avl_get_next (avlnode);