summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2011-09-20 11:06:54 +0400
committerKozlov Dmitry <xeb@mail.ru>2011-09-20 11:06:54 +0400
commit19ac6b6c05c863136855c5577ee3b6e493c499a5 (patch)
treecaeda3536d25a046cabfc772ff7f59ec3a0410bf
parent609af350ace3c284af7bec0b5c27c59a8eff4b8c (diff)
downloadaccel-ppp-19ac6b6c05c863136855c5577ee3b6e493c499a5.tar.gz
accel-ppp-19ac6b6c05c863136855c5577ee3b6e493c499a5.zip
auth: config reload
-rw-r--r--accel-pppd/accel-ppp.conf4
-rw-r--r--accel-pppd/auth/auth_chap_md5.c16
-rw-r--r--accel-pppd/auth/auth_mschap_v1.c16
-rw-r--r--accel-pppd/auth/auth_mschap_v2.c21
-rw-r--r--accel-pppd/auth/auth_pap.c16
5 files changed, 61 insertions, 12 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index 34f4513..8ec8212 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -44,6 +44,10 @@ ipv6-accept-peer-intf-id=1
echo-interval=30
echo-failure=3
+[auth]
+#any-login=0
+#noauth=0
+
[pptp]
#echo-interval=30
verbose=1
diff --git a/accel-pppd/auth/auth_chap_md5.c b/accel-pppd/auth/auth_chap_md5.c
index d72f70a..cc27ba3 100644
--- a/accel-pppd/auth/auth_chap_md5.c
+++ b/accel-pppd/auth/auth_chap_md5.c
@@ -10,6 +10,7 @@
#include "crypto.h"
#include "log.h"
+#include "events.h"
#include "ppp.h"
#include "ppp_auth.h"
#include "ppp_lcp.h"
@@ -414,9 +415,9 @@ static void chap_recv(struct ppp_handler_t *h)
log_ppp_warn("chap-md5: unknown code received %x\n", hdr->code);
}
-static void auth_chap_md5_init()
+static void load_config(void)
{
- char *opt;
+ const char *opt;
opt = conf_get_opt("auth", "timeout");
if (opt && atoi(opt) > 0)
@@ -431,9 +432,12 @@ static void auth_chap_md5_init()
conf_max_failure = atoi(opt);
opt = conf_get_opt("auth", "any-login");
- if (opt && atoi(opt) > 0)
- conf_any_login = 1;
+ if (opt)
+ conf_any_login = atoi(opt);
+}
+static void auth_chap_md5_init()
+{
urandom_fd=open("/dev/urandom", O_RDONLY);
if (urandom_fd < 0) {
@@ -441,8 +445,12 @@ static void auth_chap_md5_init()
return;
}
+ load_config();
+
if (ppp_auth_register_handler(&chap))
log_emerg("chap-md5: failed to register handler\n");
+
+ triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
}
DEFINE_INIT(6, auth_chap_md5_init);
diff --git a/accel-pppd/auth/auth_mschap_v1.c b/accel-pppd/auth/auth_mschap_v1.c
index b212f03..2d33252 100644
--- a/accel-pppd/auth/auth_mschap_v1.c
+++ b/accel-pppd/auth/auth_mschap_v1.c
@@ -481,9 +481,9 @@ static void chap_recv(struct ppp_handler_t *h)
log_ppp_warn("mschap-v1: unknown code received %x\n", hdr->code);
}
-static void auth_mschap_v1_init()
+static void load_config(void)
{
- char *opt;
+ const char *opt;
opt = conf_get_opt("auth", "timeout");
if (opt && atoi(opt) > 0)
@@ -498,16 +498,24 @@ static void auth_mschap_v1_init()
conf_max_failure = atoi(opt);
opt = conf_get_opt("auth", "any-login");
- if (opt && atoi(opt) > 0)
- conf_any_login = 1;
+ if (opt)
+ conf_any_login = atoi(opt);
+}
+static void auth_mschap_v1_init()
+{
urandom_fd = open("/dev/urandom", O_RDONLY);
if (urandom_fd < 0) {
log_emerg("mschap-v1: failed to open /dev/urandom: %s\n", strerror(errno));
return;
}
+
+ load_config();
+
if (ppp_auth_register_handler(&chap))
log_emerg("mschap-v1: failed to register handler\n");
+
+ triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
}
DEFINE_INIT(5, auth_mschap_v1_init);
diff --git a/accel-pppd/auth/auth_mschap_v2.c b/accel-pppd/auth/auth_mschap_v2.c
index 0dd4143..cb97207 100644
--- a/accel-pppd/auth/auth_mschap_v2.c
+++ b/accel-pppd/auth/auth_mschap_v2.c
@@ -618,6 +618,23 @@ static void chap_recv(struct ppp_handler_t *h)
log_ppp_warn("mschap-v2: unknown code received %x\n",hdr->code);
}
+static void load_config(void)
+{
+ const char *opt;
+
+ opt = conf_get_opt("auth", "timeout");
+ if (opt && atoi(opt) > 0)
+ conf_timeout = atoi(opt);
+
+ opt = conf_get_opt("auth", "interval");
+ if (opt && atoi(opt) > 0)
+ conf_interval = atoi(opt);
+
+ opt = conf_get_opt("auth", "max-failure");
+ if (opt && atoi(opt) > 0)
+ conf_max_failure = atoi(opt);
+}
+
static void auth_mschap_v2_init()
{
urandom_fd = open("/dev/urandom", O_RDONLY);
@@ -626,8 +643,12 @@ static void auth_mschap_v2_init()
return;
}
+ load_config();
+
if (ppp_auth_register_handler(&chap))
log_emerg("mschap-v2: failed to register handler\n");
+
+ triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
}
DEFINE_INIT(4, auth_mschap_v2_init);
diff --git a/accel-pppd/auth/auth_pap.c b/accel-pppd/auth/auth_pap.c
index e051dd7..45f9e48 100644
--- a/accel-pppd/auth/auth_pap.c
+++ b/accel-pppd/auth/auth_pap.c
@@ -4,6 +4,7 @@
#include <arpa/inet.h>
#include "log.h"
+#include "events.h"
#include "ppp.h"
#include "ppp_auth.h"
#include "ppp_lcp.h"
@@ -265,19 +266,26 @@ static void pap_recv(struct ppp_handler_t *h)
}
}
-static void auth_pap_init()
+static void load_config(void)
{
- char *opt;
+ const char *opt;
opt = conf_get_opt("auth", "timeout");
if (opt && atoi(opt) > 0)
conf_timeout = atoi(opt);
opt = conf_get_opt("auth", "any-login");
- if (opt && atoi(opt) > 0)
- conf_any_login = 1;
+ if (opt)
+ conf_any_login = atoi(opt);
+}
+
+static void auth_pap_init()
+{
+ load_config();
ppp_auth_register_handler(&pap);
+
+ triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
}
DEFINE_INIT(7, auth_pap_init);