diff options
Diffstat (limited to 'accel-pptpd/cli')
-rw-r--r-- | accel-pptpd/cli/cli.c | 4 | ||||
-rw-r--r-- | accel-pptpd/cli/std_cmd.c | 29 | ||||
-rw-r--r-- | accel-pptpd/cli/telnet.c | 2 |
3 files changed, 33 insertions, 2 deletions
diff --git a/accel-pptpd/cli/cli.c b/accel-pptpd/cli/cli.c index 534c2c85..b8f82c8e 100644 --- a/accel-pptpd/cli/cli.c +++ b/accel-pptpd/cli/cli.c @@ -9,6 +9,8 @@ #include "cli_p.h" #include "log.h" +#include "memdebug.h" + #define MAX_CMD_ITEMS 100 #define MSG_SYNTAX_ERROR "syntax error\r\n" #define MSG_INVAL_ERROR "invalid argument\r\n" @@ -201,5 +203,5 @@ static void __init init(void) conf_cli_passwd = conf_get_opt("cli", "passwd"); opt = conf_get_opt("cli", "prompt"); if (opt) - conf_cli_prompt = opt; + conf_cli_prompt = _strdup(opt); } diff --git a/accel-pptpd/cli/std_cmd.c b/accel-pptpd/cli/std_cmd.c index a5cfd38f..3563db95 100644 --- a/accel-pptpd/cli/std_cmd.c +++ b/accel-pptpd/cli/std_cmd.c @@ -450,11 +450,40 @@ static int shutdown_exec(const char *cmd, char * const *f, int f_cnt, void *cli) return CLI_CMD_OK; } +//========================== +static int conf_reload_res; +static struct triton_context_t *conf_reload_ctx; +static void conf_reload_notify(int r) +{ + if (!r) + triton_event_fire(EV_CONFIG_RELOAD, NULL); + conf_reload_res = r; + triton_context_wakeup(conf_reload_ctx); +} +static int reload_exec(const char *cmd, char * const *f, int f_cnt, void *cli) +{ + if (f_cnt == 1) { + conf_reload_ctx = triton_context_self(); + triton_conf_reload(conf_reload_notify); + triton_context_schedule(); + if (conf_reload_res) + cli_send(cli, "failed\r\n"); + return CLI_CMD_OK; + } else + return CLI_CMD_SYNTAX; +} + +static void reload_help(char * const *fields, int fields_cnt, void *client) +{ + cli_send(client, "reload - reload config file\r\n"); +} + static void __init init(void) { cli_register_simple_cmd2(show_stat_exec, show_stat_help, 2, "show", "stat"); cli_register_simple_cmd2(show_ses_exec, show_ses_help, 2, "show", "sessions"); cli_register_simple_cmd2(terminate_exec, terminate_help, 1, "terminate"); + cli_register_simple_cmd2(reload_exec, reload_help, 1, "reload"); cli_register_simple_cmd2(shutdown_exec, shutdown_help, 1, "shutdown"); cli_register_simple_cmd2(exit_exec, exit_help, 1, "exit"); } diff --git a/accel-pptpd/cli/telnet.c b/accel-pptpd/cli/telnet.c index 35af3160..b1918646 100644 --- a/accel-pptpd/cli/telnet.c +++ b/accel-pptpd/cli/telnet.c @@ -735,7 +735,7 @@ static void __init init(void) opt = conf_get_opt("cli", "history-file"); if (opt) - conf_history_file = opt; + conf_history_file = _strdup(opt); recv_buf = malloc(RECV_BUF_SIZE); temp_buf = malloc(RECV_BUF_SIZE); |