radius: differentiate between user termination and session timeout

This commit is contained in:
Nikos Mavrogiannopoulos
2015-04-27 09:49:45 +02:00
parent 1cdc70763c
commit a034626add
4 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ int pret;
return 0;
}
static void pam_acct_close_session(unsigned auth_method, void *ctx, const struct common_auth_info_st *ai, stats_st *stats)
static void pam_acct_close_session(unsigned auth_method, void *ctx, const struct common_auth_info_st *ai, stats_st *stats, unsigned status)
{
struct pam_ctx_st * pctx = ctx;
int pret;
+5 -2
View File
@@ -246,7 +246,7 @@ VALUE_PAIR *send = NULL, *recvd = NULL;
return ret;
}
static void radius_acct_close_session(unsigned auth_method, void *ctx, const common_auth_info_st *ai, stats_st *stats)
static void radius_acct_close_session(unsigned auth_method, void *ctx, const common_auth_info_st *ai, stats_st *stats, unsigned status)
{
int ret;
uint32_t status_type;
@@ -258,7 +258,10 @@ VALUE_PAIR *send = NULL, *recvd = NULL;
if (rc_avpair_add(rh, &send, PW_ACCT_STATUS_TYPE, &status_type, -1, 0) == NULL)
return;
ret = PW_USER_REQUEST;
if (status == PS_AUTH_USER_TERM)
ret = PW_USER_REQUEST;
else
ret = PW_LOST_CARRIER;
if (rc_avpair_add(rh, &send, PW_ACCT_TERMINATE_CAUSE, &ret, -1, 0) == NULL) {
goto cleanup;
}
+1 -1
View File
@@ -33,7 +33,7 @@ typedef struct acct_mod_st {
/* The context provided below is of the authentication method */
int (*open_session)(unsigned auth_method, void *ctx, const common_auth_info_st *ai, const void *sid, unsigned sid_size); /* optional, may be null */
void (*session_stats)(unsigned auth_method, void *ctx, const common_auth_info_st *ai, struct stats_st *stats); /* optional, may be null */
void (*close_session)(unsigned auth_method, void *ctx, const common_auth_info_st *ai, struct stats_st *stats); /* optional may be null */
void (*close_session)(unsigned auth_method, void *ctx, const common_auth_info_st *ai, struct stats_st *stats, unsigned status/*PS_AUTH_*/); /* optional may be null */
} acct_mod_st;
/* The accounting messages exchanged with the worker thread are shown in ipc.proto.
+2 -2
View File
@@ -794,7 +794,7 @@ int handle_sec_auth_init(int cfd, sec_mod_st * sec, const SecAuthInitMsg * req)
return handle_sec_auth_res(cfd, sec, e, ret);
}
void sec_auth_user_deinit(sec_mod_st * sec, client_entry_st * e)
void sec_auth_user_deinit(sec_mod_st *sec, client_entry_st *e)
{
if (e->module == NULL)
return;
@@ -802,7 +802,7 @@ void sec_auth_user_deinit(sec_mod_st * sec, client_entry_st * e)
seclog(sec, LOG_DEBUG, "permamently closing session of user '%s' "SESSION_STR, e->auth_info.username, e->auth_info.psid);
if (e->auth_ctx != NULL) {
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);
sec->perm_config->acct.amod->close_session(e->module->type, e->auth_ctx, &e->auth_info, &e->saved_stats, e->status);
}
e->module->auth_deinit(e->auth_ctx);
e->auth_ctx = NULL;