Commit b638d3c9 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Fix: Added support to admin/ interface to list <role>s

This adds support to list global and per mount roles on stats.xsl.
This isn't nicest formated but works.
This also adds <source>-like <authentication> with <role>s to
root node.
Closes: #2133
parent dfc30122
......@@ -34,13 +34,6 @@
<small><xsl:value-of select="server_name" /></small>
</xsl:if>
</h3>
<ul class="nav">
<li><a href="listclients.xsl?mount={@mount}">List Clients</a></li>
<li><a href="moveclients.xsl?mount={@mount}">Move Listeners</a></li>
<li><a href="updatemetadata.xsl?mount={@mount}">Update Metadata</a></li>
<li><a href="manageauth.xsl?mount={@mount}">Manage Authentication</a></li>
<li><a href="killsource.xsl?mount={@mount}">Kill Source</a></li>
</ul>
<xsl:if test="users">
<table class="colortable">
<thead>
......
......@@ -38,6 +38,24 @@
</xsl:for-each>
</tbody>
</table>
<xsl:if test="authentication">
<table>
<ul>
<xsl:for-each select="authentication/role">
<li>
Role
<xsl:if test="@name">
<xsl:value-of select="@name" />
</xsl:if>
of type <xsl:value-of select="@type" />:
<xsl:if test="@management-url">
<a href="{@management-url}">Manage Authentication</a>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</table>
</xsl:if>
</div>
<!--end global server stats-->
......@@ -89,6 +107,24 @@
</xsl:for-each>
</tbody>
</table>
<xsl:if test="authentication">
<table>
<ul>
<xsl:for-each select="authentication/role">
<li>
Role
<xsl:if test="@name">
<xsl:value-of select="@name" />
</xsl:if>
of type <xsl:value-of select="@type" />:
<xsl:if test="@management-url">
<a href="{@management-url}">Manage Authentication</a>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</table>
</xsl:if>
</div>
</div>
</xsl:if>
......
......@@ -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);
......
......@@ -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);
......
......@@ -815,16 +815,29 @@ static int _send_event_to_client(stats_event_t *event, client_t *client)
return 0;
}
static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, int hidden)
{
static inline void __add_authstack (auth_stack_t *stack, xmlNodePtr parent) {
xmlNodePtr authentication;
authentication = xmlNewTextChild(parent, NULL, XMLSTR("authentication"), NULL);
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);
......
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