diff options
author | Vladislav Grishenko <themiron@mail.ru> | 2022-05-13 15:10:10 +0500 |
---|---|---|
committer | Vladislav Grishenko <themiron@mail.ru> | 2022-05-13 15:10:10 +0500 |
commit | 37a4f391f1a4140dfd656aa2e01366686e7380ab (patch) | |
tree | d9b12935e17ca0371cd3c85d9f1107663b69c3dc /accel-pppd | |
parent | b75f468e3a366837fdb139dd772eb856b293fbec (diff) | |
download | accel-ppp-37a4f391f1a4140dfd656aa2e01366686e7380ab.tar.gz accel-ppp-37a4f391f1a4140dfd656aa2e01366686e7380ab.zip |
auth: add support challenge-name option for CHAP
Fine tune commit 39a9eb807ade35cf60edc6f2e209ed74ba1d262f
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/accel-ppp.conf | 1 | ||||
-rw-r--r-- | accel-pppd/accel-ppp.conf.5 | 6 | ||||
-rw-r--r-- | accel-pppd/auth/auth_chap_md5.c | 44 |
3 files changed, 34 insertions, 17 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index abc82469..34f32bf0 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -69,6 +69,7 @@ unit-cache=1 [auth] #any-login=0 #noauth=0 +#challenge-name=accel-ppp [pptp] verbose=1 diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5 index 6eca3582..717af1e6 100644 --- a/accel-pppd/accel-ppp.conf.5 +++ b/accel-pppd/accel-ppp.conf.5 @@ -239,6 +239,12 @@ This should reduce kernel-level interface creation/deletion rate lack. .TP .BI "unit-preallocate=" 0|1 If set to 1 then allocate ppp unit (interface) before authorization, so Nas-Port and Nas-Port-Id would be defined in Access-Request phase. +.SH [auth] +.br +Contains authentication params +.TP +.BI "challenge-name=" name +Specifies challenge name for CHAP authentication. .SH [ipoe] .TP .BI "verbose=" n diff --git a/accel-pppd/auth/auth_chap_md5.c b/accel-pppd/auth/auth_chap_md5.c index d3982334..3ff685e6 100644 --- a/accel-pppd/auth/auth_chap_md5.c +++ b/accel-pppd/auth/auth_chap_md5.c @@ -36,6 +36,7 @@ static int conf_timeout = 5; static int conf_interval = 0; static int conf_max_failure = 3; static int conf_any_login = 0; +static const char *conf_challenge_name = "accel-ppp"; struct chap_hdr { uint16_t proto; @@ -220,31 +221,36 @@ static void chap_send_success(struct chap_auth_data *ad, int id) static void chap_send_challenge(struct chap_auth_data *ad, int new) { -#define CHAP_CHALLENGE_NAME "accel-ppp" - struct { - struct chap_challenge m; - char name[sizeof(CHAP_CHALLENGE_NAME)]; - } __attribute__((packed)) msg = { - .m.hdr.proto = htons(PPP_CHAP), - .m.hdr.code = CHAP_CHALLENGE, - .m.hdr.id = ad->id, - .m.hdr.len = htons(sizeof(struct chap_challenge) - 2 + strlen(CHAP_CHALLENGE_NAME)), - .m.val_size = VALUE_SIZE, - .name = CHAP_CHALLENGE_NAME, - }; + struct chap_challenge *msg; + int name_len; + + name_len = conf_challenge_name ? strlen(conf_challenge_name) : 0; + msg = alloca(sizeof(*msg) + name_len); + memset(msg, 0, sizeof(*msg) + name_len); + + msg->hdr.proto = htons(PPP_CHAP); + msg->hdr.code = CHAP_CHALLENGE; + msg->hdr.id = ad->id; + msg->hdr.len = htons(sizeof(*msg) + name_len - 2); if (new) read(urandom_fd, ad->val, VALUE_SIZE); - memcpy(msg.m.val, ad->val, VALUE_SIZE); + memcpy(msg->val, ad->val, VALUE_SIZE); + msg->val_size = VALUE_SIZE; + + if (name_len) + memcpy(msg->name, conf_challenge_name, name_len); if (conf_ppp_verbose) { - log_ppp_info2("send [CHAP Challenge id=%x <", msg.m.hdr.id); - print_buf(msg.m.val, VALUE_SIZE); - log_ppp_info2(">]\n"); + log_ppp_info2("send [CHAP Challenge id=%x <", msg->hdr.id); + print_buf(msg->val, VALUE_SIZE); + log_ppp_info2("> name=\""); + print_str(msg->name, ntohs(msg->hdr.len) - sizeof(*msg) + 2); + log_ppp_info2("\"]\n"); } - ppp_chan_send(ad->ppp, &msg, ntohs(msg.m.hdr.len) + 2); + ppp_chan_send(ad->ppp, msg, ntohs(msg->hdr.len) + 2); if (conf_timeout && !ad->timeout.tpd) triton_timer_add(ad->ppp->ses.ctrl->ctx, &ad->timeout, 0); @@ -481,6 +487,10 @@ static void load_config(void) opt = conf_get_opt("auth", "any-login"); if (opt) conf_any_login = atoi(opt); + + opt = conf_get_opt("auth", "challenge-name"); + if (opt) + conf_challenge_name = opt; } static void auth_chap_md5_init() |