diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2013-01-24 23:53:53 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2013-01-24 23:53:53 +0400 |
commit | 1845b7ce4ea0c717401936ba8157c90f431d7932 (patch) | |
tree | 0920a94a42d87a141d100a75ed10600736e727e4 /accel-pppd/ppp | |
parent | 4c7ad9a5f8839d2e13c6f012c7cd3653e04b98b7 (diff) | |
download | accel-ppp-1845b7ce4ea0c717401936ba8157c90f431d7932.tar.gz accel-ppp-1845b7ce4ea0c717401936ba8157c90f431d7932.zip |
generalize single-session checking
Diffstat (limited to 'accel-pppd/ppp')
-rw-r--r-- | accel-pppd/ppp/ppp.c | 10 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp.h | 1 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_auth.c | 28 |
3 files changed, 2 insertions, 37 deletions
diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c index 116e134..fee9334 100644 --- a/accel-pppd/ppp/ppp.c +++ b/accel-pppd/ppp/ppp.c @@ -28,7 +28,6 @@ #include "memdebug.h" int __export conf_ppp_verbose; -int conf_single_session = -1; int conf_unit_cache = 0; static mempool_t buf_pool; @@ -599,15 +598,6 @@ static void load_config(void) if (opt && atoi(opt) > 0) conf_ppp_verbose = 1; - opt = conf_get_opt("ppp", "single-session"); - if (opt) { - if (!strcmp(opt, "deny")) - conf_single_session = 0; - else if (!strcmp(opt, "replace")) - conf_single_session = 1; - } else - conf_single_session = -1; - opt = conf_get_opt("ppp", "unit-cache"); if (opt && atoi(opt) > 0) conf_unit_cache = atoi(opt); diff --git a/accel-pppd/ppp/ppp.h b/accel-pppd/ppp/ppp.h index f07e028..e403087 100644 --- a/accel-pppd/ppp/ppp.h +++ b/accel-pppd/ppp/ppp.h @@ -127,6 +127,5 @@ struct ppp_layer_data_t *ppp_find_layer_data(struct ppp_t *, struct ppp_layer_t int ppp_ipv6_nd_start(struct ppp_t *ppp, uint64_t intf_id); extern int conf_ppp_verbose; -extern int conf_single_session; #endif diff --git a/accel-pppd/ppp/ppp_auth.c b/accel-pppd/ppp/ppp_auth.c index 2b4aff9..42bbbc6 100644 --- a/accel-pppd/ppp/ppp_auth.c +++ b/accel-pppd/ppp/ppp_auth.c @@ -317,11 +317,6 @@ static void auth_layer_free(struct ppp_layer_data_t *ld) _free(ad); } -static void __terminate_sec(struct ap_session *ses) -{ - ap_session_terminate(ses, TERM_NAS_REQUEST, 0); -} - static void __ppp_auth_started(struct ppp_t *ppp) { struct auth_layer_data_t *ad = container_of(ppp_find_layer_data(ppp, &auth_layer), typeof(*ad), ld); @@ -339,31 +334,12 @@ static void __ppp_auth_started(struct ppp_t *ppp) int __export ppp_auth_succeeded(struct ppp_t *ppp, char *username) { - struct ap_session *ses; struct auth_layer_data_t *ad = container_of(ppp_find_layer_data(ppp, &auth_layer), typeof(*ad), ld); - if (conf_single_session >= 0) { - pthread_rwlock_rdlock(&ses_lock); - list_for_each_entry(ses, &ses_list, entry) { - if (ses->username && !strcmp(ses->username, username)) { - if (conf_single_session == 0) { - pthread_rwlock_unlock(&ses_lock); - log_ppp_info1("%s: second session denied\n", username); - return -1; - } else { - if (conf_single_session == 1) { - ap_session_ifdown(ses); - triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate_sec, ses); - } - } - } - } - pthread_rwlock_unlock(&ses_lock); - } + if (ap_session_check_single(username)) + return -1; - pthread_rwlock_wrlock(&ses_lock); ppp->ses.username = username; - pthread_rwlock_unlock(&ses_lock); triton_context_call(ppp->ses.ctrl->ctx, (triton_event_func)__ppp_auth_started, ppp); |