From e7d09a09b377e0b778958d156a3047337aefc6f8 Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Mon, 7 Jan 2013 20:01:26 +0100 Subject: Fix boolean options parsing in configuration file Explicitely interpret zero values when parsing boolean options. This allows to unset boolean parameters such as "verbose" when reloading the configuration. Signed-off-by: Guillaume Nault --- accel-pppd/ctrl/l2tp/l2tp.c | 8 ++++---- accel-pppd/ctrl/pptp/pptp.c | 6 +++--- accel-pppd/ppp/ipcp_opt_ipaddr.c | 4 ++-- accel-pppd/ppp/ipv6cp_opt_intfid.c | 6 +++--- accel-pppd/ppp/ppp.c | 4 ++-- accel-pppd/radius/radius.c | 12 ++++++------ accel-pppd/shaper/shaper.c | 6 +++--- 7 files changed, 23 insertions(+), 23 deletions(-) (limited to 'accel-pppd') diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index dd8b81b..1588797 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -1612,12 +1612,12 @@ static void load_config(void) const char *opt; opt = conf_get_opt("l2tp", "verbose"); - if (opt && atoi(opt) > 0) - conf_verbose = 1; + if (opt && atoi(opt) >= 0) + conf_verbose = atoi(opt) > 0; opt = conf_get_opt("l2tp", "avp_permissive"); - if (opt && atoi(opt) > 0) - conf_avp_permissive = 1; + if (opt && atoi(opt) >= 0) + conf_avp_permissive = atoi(opt) > 0; opt = conf_get_opt("l2tp", "hello-interval"); if (opt && atoi(opt) > 0) diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c index c00f29f..e735c72 100644 --- a/accel-pppd/ctrl/pptp/pptp.c +++ b/accel-pppd/ctrl/pptp/pptp.c @@ -744,9 +744,9 @@ static void load_config(void) conf_echo_failure = atoi(opt); opt = conf_get_opt("pptp", "verbose"); - if (opt && atoi(opt) > 0) - conf_verbose = 1; - + if (opt && atoi(opt) >= 0) + conf_verbose = atoi(opt) > 0; + conf_mppe = MPPE_UNSET; opt = conf_get_opt("pptp", "mppe"); if (opt) { diff --git a/accel-pppd/ppp/ipcp_opt_ipaddr.c b/accel-pppd/ppp/ipcp_opt_ipaddr.c index 44dd3dd..e5246d5 100644 --- a/accel-pppd/ppp/ipcp_opt_ipaddr.c +++ b/accel-pppd/ppp/ipcp_opt_ipaddr.c @@ -177,8 +177,8 @@ static void load_config(void) const char *opt; opt = conf_get_opt("ppp", "check-ip"); - if (opt && atoi(opt) > 0) - conf_check_exists = 1; + if (opt && atoi(opt) >= 0) + conf_check_exists = atoi(opt) > 0; } static void ipaddr_opt_init() diff --git a/accel-pppd/ppp/ipv6cp_opt_intfid.c b/accel-pppd/ppp/ipv6cp_opt_intfid.c index 21f0b93..a46ae17 100644 --- a/accel-pppd/ppp/ipv6cp_opt_intfid.c +++ b/accel-pppd/ppp/ipv6cp_opt_intfid.c @@ -284,9 +284,9 @@ static void load_config(void) const char *opt; opt = conf_get_opt("ppp", "check-ip"); - if (opt && atoi(opt) > 0) - conf_check_exists = 1; - + if (opt && atoi(opt) >= 0) + conf_check_exists = atoi(opt) > 0; + opt = conf_get_opt("ppp", "ipv6-intf-id"); if (opt) { if (!strcmp(opt, "random")) diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c index f5877ed..5363094 100644 --- a/accel-pppd/ppp/ppp.c +++ b/accel-pppd/ppp/ppp.c @@ -595,8 +595,8 @@ static void load_config(void) const char *opt; opt = conf_get_opt("ppp", "verbose"); - if (opt && atoi(opt) > 0) - conf_ppp_verbose = 1; + if (opt && atoi(opt) >= 0) + conf_ppp_verbose = atoi(opt) > 0; opt = conf_get_opt("ppp", "unit-cache"); if (opt && atoi(opt) > 0) diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c index 5313fe1..bae5876 100644 --- a/accel-pppd/radius/radius.c +++ b/accel-pppd/radius/radius.c @@ -542,13 +542,13 @@ static int load_config(void) conf_acct_timeout = atoi(opt); opt = conf_get_opt("radius", "verbose"); - if (opt && atoi(opt) > 0) - conf_verbose = 1; - + if (opt && atoi(opt) >= 0) + conf_verbose = atoi(opt) > 0; + opt = conf_get_opt("radius", "interim-verbose"); - if (opt && atoi(opt) > 0) - conf_interim_verbose = 1; - + if (opt && atoi(opt) >= 0) + conf_interim_verbose = atoi(opt) > 0; + opt = conf_get_opt("radius", "nas-ip-address"); if (opt) conf_nas_ip_address = inet_addr(opt); diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c index 2b749c9..d5a376b 100644 --- a/accel-pppd/shaper/shaper.c +++ b/accel-pppd/shaper/shaper.c @@ -908,9 +908,9 @@ static void load_config(void) opt = conf_get_opt("shaper", "verbose"); - if (opt && atoi(opt) > 0) - conf_verbose = 1; - + if (opt && atoi(opt) >= 0) + conf_verbose = atoi(opt) > 0; + triton_context_call(&shaper_ctx, (triton_event_func)load_time_ranges, NULL); } -- cgit v1.2.3