diff options
author | Kozlov Dmitry <dima@server> | 2010-12-27 15:25:38 +0300 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2010-12-27 15:25:38 +0300 |
commit | 2b34d862111f1fd84cdb9d744ac34c1c933f34da (patch) | |
tree | 1e758ddc96689793e1c4c1b55cf3671bb05f2884 /accel-pptpd/extra | |
parent | ccaeb500e38d82c37568292d7850b66691793626 (diff) | |
download | accel-ppp-xebd-2b34d862111f1fd84cdb9d744ac34c1c933f34da.tar.gz accel-ppp-xebd-2b34d862111f1fd84cdb9d744ac34c1c933f34da.zip |
implemented partial config reload via SIGUSR1 signal or cli
Diffstat (limited to 'accel-pptpd/extra')
-rw-r--r-- | accel-pptpd/extra/chap-secrets.c | 18 | ||||
-rw-r--r-- | accel-pptpd/extra/pppd_compat.c | 17 | ||||
-rw-r--r-- | accel-pptpd/extra/shaper_tbf.c | 14 |
3 files changed, 33 insertions, 16 deletions
diff --git a/accel-pptpd/extra/chap-secrets.c b/accel-pptpd/extra/chap-secrets.c index 410b4e8..8983f90 100644 --- a/accel-pptpd/extra/chap-secrets.c +++ b/accel-pptpd/extra/chap-secrets.c @@ -13,7 +13,8 @@ #include "memdebug.h" -static const char *conf_chap_secrets = "/etc/ppp/chap-secrets"; +static char *def_chap_secrets = "/etc/ppp/chap-secrets"; +static char *conf_chap_secrets; static in_addr_t conf_gw_ip_address = 0; static void *pd_key; @@ -220,21 +221,32 @@ static struct pwdb_t pwdb = { .get_passwd = get_passwd, }; -static void __init init(void) +static void load_config(void) { const char *opt; + if (conf_chap_secrets && conf_chap_secrets != def_chap_secrets) + _free(conf_chap_secrets); opt = conf_get_opt("chap-secrets", "chap-secrets"); if (opt) - conf_chap_secrets = opt; + conf_chap_secrets = _strdup(opt); + else + conf_chap_secrets = def_chap_secrets; opt = conf_get_opt("chap-secrets", "gw-ip-address"); if (opt) conf_gw_ip_address = inet_addr(opt); +} + +static void __init init(void) +{ + load_config(); pwdb_register(&pwdb); ipdb_register(&ipdb); triton_event_register_handler(EV_PPP_FINISHED, (triton_event_func)ev_ppp_finished); triton_event_register_handler(EV_PPP_PRE_UP, (triton_event_func)ev_ppp_pre_up); + triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config); } + diff --git a/accel-pptpd/extra/pppd_compat.c b/accel-pptpd/extra/pppd_compat.c index 3a28c93..f6e85b0 100644 --- a/accel-pptpd/extra/pppd_compat.c +++ b/accel-pptpd/extra/pppd_compat.c @@ -151,7 +151,7 @@ static void ev_ppp_pre_up(struct ppp_t *ppp) if (conf_verbose) log_ppp_info2("pppd_compat: ip-pre-up started (pid %i)\n", pid); sigchld_unlock(); - triton_context_schedule(pd->ppp->ctrl->ctx); + triton_context_schedule(); pthread_mutex_lock(&pd->ip_pre_up_hnd.lock); pthread_mutex_unlock(&pd->ip_pre_up_hnd.lock); if (pd->res != 0) { @@ -274,7 +274,7 @@ static void ev_ppp_finished(struct ppp_t *ppp) if (conf_verbose) log_ppp_info2("pppd_compat: ip-down started (pid %i)\n", pid); sigchld_unlock(); - triton_context_schedule(pd->ppp->ctrl->ctx); + triton_context_schedule(); pthread_mutex_lock(&pd->ip_down_hnd.lock); pthread_mutex_unlock(&pd->ip_down_hnd.lock); } else if (pid == 0) { @@ -344,7 +344,7 @@ static void ev_radius_coa(struct ev_radius_t *ev) sigchld_unlock(); if (conf_verbose) log_ppp_info2("pppd_compat: ip-change started (pid %i)\n", pid); - triton_context_schedule(pd->ppp->ctrl->ctx); + triton_context_schedule(); if (!ev->res) ev->res = pd->res; } else if (pid == 0) { @@ -490,23 +490,23 @@ static void __init init(void) opt = conf_get_opt("pppd-compat", "ip-pre-up"); if (opt) - conf_ip_pre_up = opt; + conf_ip_pre_up = _strdup(opt); opt = conf_get_opt("pppd-compat", "ip-up"); if (opt) - conf_ip_up = opt; + conf_ip_up = _strdup(opt); opt = conf_get_opt("pppd-compat", "ip-down"); if (opt) - conf_ip_down = opt; + conf_ip_down = _strdup(opt); opt = conf_get_opt("pppd-compat", "ip-change"); if (opt) - conf_ip_change = opt; + conf_ip_change = _strdup(opt); opt = conf_get_opt("pppd-compat", "radattr-prefix"); if (opt) - conf_radattr_prefix = opt; + conf_radattr_prefix = _strdup(opt); opt = conf_get_opt("pppd-compat", "verbose"); if (opt && atoi(opt) > 0) @@ -522,4 +522,3 @@ static void __init init(void) triton_event_register_handler(EV_RADIUS_COA, (triton_event_func)ev_radius_coa); #endif } - diff --git a/accel-pptpd/extra/shaper_tbf.c b/accel-pptpd/extra/shaper_tbf.c index 965fd16..d974bda 100644 --- a/accel-pptpd/extra/shaper_tbf.c +++ b/accel-pptpd/extra/shaper_tbf.c @@ -897,13 +897,10 @@ static int parse_vendor_opt(const char *opt) } #endif -static void __init init(void) +void load_config(void) { const char *opt; - if (clock_init()) - return; - #ifdef RADIUS opt = conf_get_opt("tbf", "vendor"); if (opt) @@ -954,6 +951,14 @@ static void __init init(void) opt = conf_get_opt("tbf", "verbose"); if (opt && atoi(opt) > 0) conf_verbose = 1; +} + +static void __init init(void) +{ + if (clock_init()) + return; + + load_config(); #ifdef RADIUS triton_event_register_handler(EV_RADIUS_ACCESS_ACCEPT, (triton_event_func)ev_radius_access_accept); @@ -961,6 +966,7 @@ static void __init init(void) #endif triton_event_register_handler(EV_CTRL_FINISHED, (triton_event_func)ev_ctrl_finished); triton_event_register_handler(EV_SHAPER, (triton_event_func)ev_shaper); + triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config); cli_register_simple_cmd2(shaper_change_exec, shaper_change_help, 2, "shaper", "change"); cli_register_simple_cmd2(shaper_restore_exec, shaper_restore_help, 2, "shaper", "restore"); |