From e461c5423384f21efdd1cfc8d57e2fd39f0d156e Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Wed, 2 Oct 2013 22:35:17 +0400 Subject: ipoe: intoduced 'password' option to control password generation --- accel-pppd/accel-ppp.conf | 1 + accel-pppd/accel-ppp.conf.5 | 16 +++++++++++++++- accel-pppd/ctrl/ipoe/ipoe.c | 14 +++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index 29ece01..38b0fa8 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -36,6 +36,7 @@ thread-count=4 [ipoe] verbose=1 username=ifname +#password=username lease-time=600 max-lease-time=3600 #unit-cache=1000 diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5 index 6e0d0e0..2d585ba 100644 --- a/accel-pppd/accel-ppp.conf.5 +++ b/accel-pppd/accel-ppp.conf.5 @@ -183,7 +183,7 @@ This should reduce kernel-level interface creation/deletion rate lack. If n is not zero ipoe module will produce verbose logging. .TP .BI "username=" ifname|lua:function -Specifies how to determine username of DHCP user. +Specifies how to determine username of user. .br If username= .B ifname @@ -195,6 +195,20 @@ then lua function with name .B username will be called to construct username from dhcp packet fields. .TP +.BI "password=" username|empty| +Specifies how to generate password. +.br +If password= +.B username +then password will be same as username. +.br +If password= +.B empty +then password will be empty string. +.br +Or you can specify fixed password in +.B . +.TP .BI "lease-time=" n Specifies lease time in seconds to be sent to dhcp client. .TP diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index ac1a68f..7059e2a 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -101,6 +101,7 @@ static uint32_t conf_src; //static int conf_dhcpv6; static int conf_username; +static const char *conf_password; static int conf_unit_cache; static int conf_noauth; #ifdef RADIUS @@ -474,7 +475,7 @@ static void ipoe_session_start(struct ipoe_session *ses) ap_session_starting(&ses->ses); if (!conf_noauth) { - r = pwdb_check(&ses->ses, ses->ses.username, PPP_PAP, ses->ses.username); + r = pwdb_check(&ses->ses, ses->ses.username, PPP_PAP, conf_password ? conf_password : ses->ses.username); if (r == PWDB_NO_IMPL) { passwd = pwdb_get_passwd(&ses->ses, ses->ses.username); if (!passwd) @@ -2690,6 +2691,17 @@ static void load_config(void) log_emerg("ipoe: unknown username value '%s'\n", opt); } else conf_username = USERNAME_UNSET; + + opt = conf_get_opt("ipoe", "password"); + if (opt) { + if (!strcmp(opt, "username")) + conf_password = NULL; + else if (!strcmp(opt, "empty")) + conf_password = ""; + else + conf_password = opt; + } else + conf_password = NULL; opt = conf_get_opt("ipoe", "netmask"); if (opt) { -- cgit v1.2.3