From bc767dc4dd80284e836a9c60eb1eed2e6b94b406 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Sat, 21 Feb 2015 14:55:22 +0300 Subject: ipoe: for option password implemented special value "csid" If password=csid then password will we same as Calling-Station-Id. --- accel-pppd/accel-ppp.conf.5 | 6 +++++- accel-pppd/ctrl/ipoe/ipoe.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5 index 8bb18862..f87c431b 100644 --- a/accel-pppd/accel-ppp.conf.5 +++ b/accel-pppd/accel-ppp.conf.5 @@ -213,7 +213,7 @@ then lua function with name .B username will be called to construct username from dhcp packet fields. .TP -.BI "password=" username|empty| +.BI "password=" username|csid|empty| Specifies how to generate password. .br If password= @@ -224,6 +224,10 @@ If password= .B empty then password will be empty string. .br +If password= +.B csid +then password will be same as Calling-Station-Id. +.br Or you can specify fixed password in .B . .TP diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 0764b200..3739475b 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -591,6 +591,7 @@ static void ipoe_session_start(struct ipoe_session *ses) int r; char *passwd; char *username; + const char *pass; if (ses->dhcpv4_request && conf_verbose) { log_ppp_info2("recv "); @@ -631,15 +632,23 @@ static void ipoe_session_start(struct ipoe_session *ses) } #endif + if (conf_password) { + if (!strcmp(conf_password, "csid")) + pass = ses->ctrl.calling_station_id; + else + pass = conf_password; + } else + pass = username; + ses->username = username; - r = pwdb_check(&ses->ses, (pwdb_callback)auth_result, ses, username, PPP_PAP, conf_password ? conf_password : username); + r = pwdb_check(&ses->ses, (pwdb_callback)auth_result, ses, username, PPP_PAP, pass); if (r == PWDB_WAIT) return; if (r == PWDB_NO_IMPL) { passwd = pwdb_get_passwd(&ses->ses, username); - if (!passwd) + if (!passwd || strcmp(passwd, pass)) r = PWDB_DENIED; else { r = PWDB_SUCCESS; -- cgit v1.2.3