mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-12 01:26:48 +08:00
corrected termination of sessions which had no associated module (i.e., certificate)
This commit is contained in:
+10
-11
@@ -435,7 +435,7 @@ int handle_sec_auth_session_open(int cfd, sec_mod_st *sec, const SecAuthSessionM
|
||||
}
|
||||
|
||||
if (sec->perm_config->acct.amod != NULL && sec->perm_config->acct.amod->open_session != NULL && e->session_is_open == 0) {
|
||||
ret = sec->perm_config->acct.amod->open_session(e->module->type, e->auth_ctx, &e->auth_info, req->sid.data, req->sid.len);
|
||||
ret = sec->perm_config->acct.amod->open_session(e->auth_type, e->auth_ctx, &e->auth_info, req->sid.data, req->sid.len);
|
||||
if (ret < 0) {
|
||||
e->status = PS_AUTH_FAILED;
|
||||
seclog(sec, LOG_INFO, "denied session for user '%s' "SESSION_STR, e->auth_info.username, e->auth_info.psid);
|
||||
@@ -537,7 +537,9 @@ int handle_sec_auth_session_close(int cfd, sec_mod_st *sec, const SecAuthSession
|
||||
memset(&e->stats, 0, sizeof(e->stats));
|
||||
expire_client_entry(sec, e);
|
||||
|
||||
if (e->discon_reason != 0) {
|
||||
if (e->discon_reason == REASON_USER_DISCONNECT || e->discon_reason == REASON_SERVER_DISCONNECT) {
|
||||
seclog(sec, LOG_INFO, "invalidating session of user '%s' "SESSION_STR,
|
||||
e->auth_info.username, e->auth_info.psid);
|
||||
/* immediately disconnect the user */
|
||||
del_client_entry(sec, e);
|
||||
} else {
|
||||
@@ -611,9 +613,7 @@ int handle_sec_auth_stats_cmd(sec_mod_st * sec, const CliStatsMsg * req)
|
||||
if (req->uptime > e->stats.uptime)
|
||||
e->stats.uptime = req->uptime;
|
||||
|
||||
if (req->has_discon_reason && (req->discon_reason == REASON_USER_DISCONNECT || req->discon_reason == REASON_SERVER_DISCONNECT)) {
|
||||
seclog(sec, LOG_INFO, "invalidating session of user '%s' "SESSION_STR,
|
||||
e->auth_info.username, e->auth_info.psid);
|
||||
if (req->has_discon_reason && req->discon_reason != 0) {
|
||||
e->discon_reason = req->discon_reason;
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ int handle_sec_auth_stats_cmd(sec_mod_st * sec, const CliStatsMsg * req)
|
||||
if (req->ipv6)
|
||||
strlcpy(e->auth_info.ipv6, req->ipv6, sizeof(e->auth_info.ipv6));
|
||||
|
||||
sec->perm_config->acct.amod->session_stats(e->module->type, e->auth_ctx, &e->auth_info, &totals);
|
||||
sec->perm_config->acct.amod->session_stats(e->auth_type, e->auth_ctx, &e->auth_info, &totals);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -802,15 +802,14 @@ int handle_sec_auth_init(int cfd, sec_mod_st * sec, const SecAuthInitMsg * req)
|
||||
|
||||
void sec_auth_user_deinit(sec_mod_st *sec, client_entry_st *e)
|
||||
{
|
||||
if (e->module == NULL)
|
||||
return;
|
||||
|
||||
if (e->auth_ctx != NULL) {
|
||||
seclog(sec, LOG_DEBUG, "permamently closing session of user '%s' "SESSION_STR, e->auth_info.username, e->auth_info.psid);
|
||||
if (sec->perm_config->acct.amod != NULL && sec->perm_config->acct.amod->close_session != NULL && e->session_is_open != 0) {
|
||||
sec->perm_config->acct.amod->close_session(e->module->type, e->auth_ctx, &e->auth_info, &e->saved_stats, e->discon_reason);
|
||||
sec->perm_config->acct.amod->close_session(e->auth_type, e->auth_ctx, &e->auth_info, &e->saved_stats, e->discon_reason);
|
||||
}
|
||||
e->module->auth_deinit(e->auth_ctx);
|
||||
|
||||
if (e->module)
|
||||
e->module->auth_deinit(e->auth_ctx);
|
||||
e->auth_ctx = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user