Skip to content

Commit

Permalink
Remove simul_zap_query and replace it with a call to session_zap.
Browse files Browse the repository at this point in the history
Fix a typo in the dialup_admin Changelog
  • Loading branch information
kkalev committed Aug 26, 2002
1 parent 016e558 commit 84e62de
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dialup_admin/Changelog
Expand Up @@ -10,7 +10,7 @@ Ver 1.55:
operators was set to the opeator
* Add a user find page. User can be searched based on the full name, department or RADIUS attribute.
The radius attribute should be included in the _user_ profile, not in a group/regular/default profile.
* Add support for the user ldap regular profile attribute
* Add support for the user ldap regular profile attribute in user_edit.attrs
Ver 1.54:
* Add attributes for the sql group tables in admin.conf. Now SQL group support should really work!
Ver 1.53:
Expand Down
7 changes: 1 addition & 6 deletions raddb/sql.conf
Expand Up @@ -134,16 +134,11 @@ sql {
# simul_verify_query - query to return details of current connections for verification
# - Leave blank or commented out to disable verification step
# - Note that the returned field order should not be changed.
# simul_zap_query - query to close "stale" sessions where NAS shows call
# - was disconnected, but no stop account packet was received.
# - ( %s will be replaced with the appropriate RadAcctId )
# - Leave blank or commented out to skip zapping stale sessions
#######################################################################

# Uncomment simul_count_query to enable simultaneous use checking
# simul_count_query = "SELECT COUNT(*) FROM ${acct_table1} WHERE UserName='%{SQL-User-Name}' AND AcctStopTime = 0"
simul_verify_query = "SELECT RadAcctId, AcctSessionId, UserName, NASIPAddress, NASPortId, FramedIPAddress, CalledStationId FROM ${acct_table1} WHERE UserName='%{SQL-User-Name}' AND AcctStopTime = 0"
simul_zap_query = "DELETE FROM ${acct_table1} WHERE RadAcctId = '%s'"
simul_verify_query = "SELECT RadAcctId, AcctSessionId, UserName, NASIPAddress, NASPortId, FramedIPAddress, CalledStationId, FramedProtocol FROM ${acct_table1} WHERE UserName='%{SQL-User-Name}' AND AcctStopTime = 0"

#######################################################################
# Group Membership Queries
Expand Down
1 change: 0 additions & 1 deletion src/modules/rlm_sql/conf.h
Expand Up @@ -37,7 +37,6 @@ typedef struct sql_config {
char *accounting_stop_query_alt;
char *simul_count_query;
char *simul_verify_query;
char *simul_zap_query;
char *groupmemb_query;
int sqltrace;
char *tracefile;
Expand Down
43 changes: 30 additions & 13 deletions src/modules/rlm_sql/rlm_sql.c
Expand Up @@ -83,7 +83,6 @@ static CONF_PARSER module_config[] = {
{"connect_failure_retry_delay", PW_TYPE_INTEGER, offsetof(SQL_CONFIG,connect_failure_retry_delay), NULL, "60"},
{"simul_count_query", PW_TYPE_STRING_PTR, offsetof(SQL_CONFIG,simul_count_query), NULL, ""},
{"simul_verify_query", PW_TYPE_STRING_PTR, offsetof(SQL_CONFIG,simul_verify_query), NULL, ""},
{"simul_zap_query", PW_TYPE_STRING_PTR, offsetof(SQL_CONFIG,simul_zap_query), NULL, ""},

{NULL, -1, 0, NULL, NULL}
};
Expand Down Expand Up @@ -862,19 +861,37 @@ static int rlm_sql_checksimul(void *instance, REQUEST * request) {
/*
* Stale record - zap it.
*/
if(inst->config->simul_zap_query[0] != 0) {
SQLSOCK *sqlsocket1;
radlog(L_ERR, "rlm_sql: Deleting stale session [%s] (from %s/%s)",
row[1],row[3],row[4]);
sqlsocket1 = sql_get_socket(inst);
sprintf(querystr, inst->config->simul_zap_query, row[0]);
if (rlm_sql_query(sqlsocket1, inst, querystr)) {
radlog(L_ERR, "rlm_sql: Deletion of stale session [%s] failed",
row[1]);
}
(inst->module->sql_finish_select_query)(sqlsocket1, inst->config);
sql_release_socket(inst, sqlsocket1);
uint32_t nas_addr = 0;
uint32_t framed_addr = 0;
int nas_port = 0;
char proto = 'P';

if (row[3])
nas_addr = inet_addr(row[3]);
if (row[4])
nas_port = atoi(row[4]);
if (row[5])
framed_addr = inet_addr(row[5]);
if (row[7])
if (strcmp(row[7],"SLIP") == 0)
proto = 'S';
if (!row[2]){
(inst->module->sql_finish_select_query)(sqlsocket, inst->config);
sql_release_socket(inst, sqlsocket);
DEBUG("rlm_sql: Cannot zap stale entry. No username present in entry.");
return RLM_MODULE_FAIL;
}
if (!row[1]){
(inst->module->sql_finish_select_query)(sqlsocket, inst->config);
sql_release_socket(inst, sqlsocket);
DEBUG("rlm_sql: Cannot zap stale entry. No session id in entry.");
return RLM_MODULE_FAIL;
}

session_zap(request->packet->sockfd,
nas_addr,nas_port,row[2],row[1],
framed_addr, proto,0);

}
}

Expand Down

0 comments on commit 84e62de

Please sign in to comment.