summaryrefslogtreecommitdiff
path: root/accel-pptpd/cli
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-12-27 15:25:38 +0300
committerKozlov Dmitry <dima@server>2010-12-27 15:25:38 +0300
commit2b34d862111f1fd84cdb9d744ac34c1c933f34da (patch)
tree1e758ddc96689793e1c4c1b55cf3671bb05f2884 /accel-pptpd/cli
parentccaeb500e38d82c37568292d7850b66691793626 (diff)
downloadaccel-ppp-xebd-2b34d862111f1fd84cdb9d744ac34c1c933f34da.tar.gz
accel-ppp-xebd-2b34d862111f1fd84cdb9d744ac34c1c933f34da.zip
implemented partial config reload via SIGUSR1 signal or cli
Diffstat (limited to 'accel-pptpd/cli')
-rw-r--r--accel-pptpd/cli/cli.c4
-rw-r--r--accel-pptpd/cli/std_cmd.c29
-rw-r--r--accel-pptpd/cli/telnet.c2
3 files changed, 33 insertions, 2 deletions
diff --git a/accel-pptpd/cli/cli.c b/accel-pptpd/cli/cli.c
index 534c2c8..b8f82c8 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 a5cfd38..3563db9 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 35af316..b191864 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);