Remove CLI service modes
The modes weren't used and provided access to raw memory which is not safe.
This commit is contained in:
@ -44,7 +44,6 @@ typedef struct cli_instance
|
|||||||
{
|
{
|
||||||
SPINLOCK lock; /*< The instance spinlock */
|
SPINLOCK lock; /*< The instance spinlock */
|
||||||
SERVICE *service; /*< The debug cli service */
|
SERVICE *service; /*< The debug cli service */
|
||||||
int mode; /*< CLI interface mode */
|
|
||||||
struct cli_session
|
struct cli_session
|
||||||
*sessions; /*< Linked list of sessions within this instance */
|
*sessions; /*< Linked list of sessions within this instance */
|
||||||
struct cli_instance
|
struct cli_instance
|
||||||
@ -60,16 +59,11 @@ typedef struct cli_instance
|
|||||||
typedef struct cli_session
|
typedef struct cli_session
|
||||||
{
|
{
|
||||||
char cmdbuf[CMDBUFLEN]; /*< The command buffer used to build up user commands */
|
char cmdbuf[CMDBUFLEN]; /*< The command buffer used to build up user commands */
|
||||||
int mode; /*< The CLI Mode for this session */
|
|
||||||
SESSION *session; /*< The gateway session */
|
SESSION *session; /*< The gateway session */
|
||||||
struct cli_session
|
struct cli_session
|
||||||
*next; /*< The next pointer for the list of sessions */
|
*next; /*< The next pointer for the list of sessions */
|
||||||
} CLI_SESSION;
|
} CLI_SESSION;
|
||||||
|
|
||||||
/* Command line interface modes */
|
|
||||||
#define CLIM_USER 1
|
|
||||||
#define CLIM_DEVELOPER 2
|
|
||||||
|
|
||||||
MXS_END_DECLS
|
MXS_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -140,7 +140,6 @@ createInstance(SERVICE *service, char **options)
|
|||||||
inst->service = service;
|
inst->service = service;
|
||||||
spinlock_init(&inst->lock);
|
spinlock_init(&inst->lock);
|
||||||
inst->sessions = NULL;
|
inst->sessions = NULL;
|
||||||
inst->mode = CLIM_USER;
|
|
||||||
|
|
||||||
if (options)
|
if (options)
|
||||||
{
|
{
|
||||||
@ -190,7 +189,6 @@ newSession(ROUTER *instance, SESSION *session)
|
|||||||
spinlock_release(&inst->lock);
|
spinlock_release(&inst->lock);
|
||||||
|
|
||||||
session->state = SESSION_STATE_READY;
|
session->state = SESSION_STATE_READY;
|
||||||
client->mode = inst->mode;
|
|
||||||
|
|
||||||
return (void *)client;
|
return (void *)client;
|
||||||
}
|
}
|
||||||
|
@ -139,26 +139,6 @@ createInstance(SERVICE *service, char **options)
|
|||||||
inst->service = service;
|
inst->service = service;
|
||||||
spinlock_init(&inst->lock);
|
spinlock_init(&inst->lock);
|
||||||
inst->sessions = NULL;
|
inst->sessions = NULL;
|
||||||
inst->mode = CLIM_USER;
|
|
||||||
|
|
||||||
if (options)
|
|
||||||
{
|
|
||||||
for (i = 0; options[i]; i++)
|
|
||||||
{
|
|
||||||
if (!strcasecmp(options[i], "developer"))
|
|
||||||
{
|
|
||||||
inst->mode = CLIM_DEVELOPER;
|
|
||||||
}
|
|
||||||
else if (!strcasecmp(options[i], "user"))
|
|
||||||
{
|
|
||||||
inst->mode = CLIM_USER;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MXS_ERROR("Unknown option for CLI '%s'", options[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have completed the creation of the instance data, so now
|
* We have completed the creation of the instance data, so now
|
||||||
@ -200,16 +180,9 @@ newSession(ROUTER *instance, SESSION *session)
|
|||||||
spinlock_release(&inst->lock);
|
spinlock_release(&inst->lock);
|
||||||
|
|
||||||
session->state = SESSION_STATE_READY;
|
session->state = SESSION_STATE_READY;
|
||||||
client->mode = inst->mode;
|
|
||||||
|
|
||||||
dcb_printf(session->client_dcb, "Welcome to the MariaDB Corporation MaxScale Debug Interface (%s).\n",
|
dcb_printf(session->client_dcb, "Welcome to the MariaDB Corporation MaxScale Debug Interface (%s).\n",
|
||||||
version_str);
|
version_str);
|
||||||
if (client->mode == CLIM_DEVELOPER)
|
|
||||||
{
|
|
||||||
dcb_printf(session->client_dcb, "WARNING: This interface is meant for developer usage,\n");
|
|
||||||
dcb_printf(session->client_dcb,
|
|
||||||
"passing incorrect addresses to commands can endanger your MaxScale server.\n\n");
|
|
||||||
}
|
|
||||||
dcb_printf(session->client_dcb, "Type help for a list of available commands.\n\n");
|
dcb_printf(session->client_dcb, "Type help for a list of available commands.\n\n");
|
||||||
|
|
||||||
return (void *)client;
|
return (void *)client;
|
||||||
|
@ -1784,7 +1784,7 @@ execute_cmd(CLI_SESSION *cli)
|
|||||||
|
|
||||||
for (int k = 0; k < cmds[i].options[j].argc_max && k < argc; k++)
|
for (int k = 0; k < cmds[i].options[j].argc_max && k < argc; k++)
|
||||||
{
|
{
|
||||||
arg_list[k] = convert_arg(cli->mode, args[k + 2], cmds[i].options[j].arg_types[k]);
|
arg_list[k] = convert_arg(args[k + 2], cmds[i].options[j].arg_types[k]);
|
||||||
if (arg_list[k] == 0)
|
if (arg_list[k] == 0)
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "Invalid argument: %s\n", args[k + 2]);
|
dcb_printf(dcb, "Invalid argument: %s\n", args[k + 2]);
|
||||||
|
Reference in New Issue
Block a user