Fix show dbusers

The functionality was broken by the change where the users were moved from
the service to the listener.
This commit is contained in:
Markus Mäkelä
2016-12-22 10:02:16 +02:00
parent d50e25b688
commit 7cbd62db52
3 changed files with 35 additions and 31 deletions

View File

@ -32,6 +32,7 @@
#include <maxscale/hashtable.h>
#include <maxscale/dcb.h>
#include <maxscale/listener.h>
#include <maxscale/service.h>
#include <openssl/sha.h>
MXS_BEGIN_DECLS
@ -71,6 +72,6 @@ extern int users_update(USERS *, const char *, const char *); /**< Change the pa
extern int users_default_loadusers(SERV_LISTENER *port); /**< A generic implementation of the
authenticator loadusers entry point */
extern void usersPrint(const USERS *); /**< Print data about the users loaded */
extern void dcb_usersPrint(DCB *, const USERS *); /**< Print data about the users loaded */
extern void dcb_usersPrint(DCB *, const SERVICE *); /**< Print data about the users loaded */
MXS_END_DECLS

View File

@ -168,48 +168,51 @@ usersPrint(const USERS *users)
* @param users The users table
*/
void
dcb_usersPrint(DCB *dcb, const USERS *users)
dcb_usersPrint(DCB *dcb, const SERVICE *service)
{
if (users == NULL || users->data == NULL)
for (SERV_LISTENER *port = service->ports; port; port = port->next)
{
dcb_printf(dcb, "Users table is empty\n");
}
else
{
HASHITERATOR *iter;
if ((iter = hashtable_iterator(users->data)) != NULL)
if (port->users && port->users->data)
{
dcb_printf(dcb, "User names: ");
char *sep = "";
void *user;
HASHITERATOR *iter = hashtable_iterator(port->users->data);
if (users->usersCustomUserFormat != NULL)
if (iter)
{
while ((user = hashtable_next(iter)) != NULL)
dcb_printf(dcb, "User names: ");
char *sep = "";
void *user;
if (port->users->usersCustomUserFormat != NULL)
{
char *custom_user;
custom_user = users->usersCustomUserFormat(user);
if (custom_user)
while ((user = hashtable_next(iter)) != NULL)
{
dcb_printf(dcb, "%s%s", sep, custom_user);
MXS_FREE(custom_user);
char *custom_user = port->users->usersCustomUserFormat(user);
if (custom_user)
{
dcb_printf(dcb, "%s%s", sep, custom_user);
MXS_FREE(custom_user);
sep = ", ";
}
}
}
else
{
while ((user = hashtable_next(iter)) != NULL)
{
dcb_printf(dcb, "%s%s", sep, (char *)user);
sep = ", ";
}
}
}
else
{
while ((user = hashtable_next(iter)) != NULL)
{
dcb_printf(dcb, "%s%s", sep, (char *)user);
sep = ", ";
}
}
hashtable_iterator_free(iter);
hashtable_iterator_free(iter);
}
}
else
{
dcb_printf(dcb, "Users table is empty\n");
}
}
dcb_printf(dcb, "\n");
}

View File

@ -154,7 +154,7 @@ struct subcommand showoptions[] =
"Show user statistics",
"Show statistics and user names for a service's user table.\n"
"\t\tExample : show dbusers <ptr of 'User's data' from services list>|<service name>",
{ARG_TYPE_DBUSERS, 0, 0}
{ARG_TYPE_SERVICE, 0, 0}
},
{
"epoll", 0, 0, dprintPollStats,