static const CONF_PARSER module_config[] = {
{"driver", PW_TYPE_STRING_PTR,
static const CONF_PARSER module_config[] = {
{"driver", PW_TYPE_STRING_PTR,
- offsetof(SQL_CONFIG,sql_driver), NULL, "mysql"},
+ offsetof(rlm_sql_config_t,sql_driver), NULL, "mysql"},
- offsetof(SQL_CONFIG,sql_server), NULL, "localhost"},
+ offsetof(rlm_sql_config_t,sql_server), NULL, "localhost"},
- offsetof(SQL_CONFIG,sql_port), NULL, ""},
+ offsetof(rlm_sql_config_t,sql_port), NULL, ""},
- offsetof(SQL_CONFIG,sql_login), NULL, ""},
+ offsetof(rlm_sql_config_t,sql_login), NULL, ""},
- offsetof(SQL_CONFIG,sql_password), NULL, ""},
+ offsetof(rlm_sql_config_t,sql_password), NULL, ""},
- offsetof(SQL_CONFIG,sql_db), NULL, "radius"},
+ offsetof(rlm_sql_config_t,sql_db), NULL, "radius"},
- offsetof(SQL_CONFIG,sql_file), NULL, NULL},
+ offsetof(rlm_sql_config_t,sql_file), NULL, NULL},
- offsetof(SQL_CONFIG,read_groups), NULL, "yes"},
+ offsetof(rlm_sql_config_t,read_groups), NULL, "yes"},
- offsetof(SQL_CONFIG,do_clients), NULL, "no"},
+ offsetof(rlm_sql_config_t,do_clients), NULL, "no"},
- offsetof(SQL_CONFIG,deletestalesessions), NULL, "yes"},
+ offsetof(rlm_sql_config_t,deletestalesessions), NULL, "yes"},
- offsetof(SQL_CONFIG,query_user), NULL, ""},
+ offsetof(rlm_sql_config_t,query_user), NULL, ""},
- offsetof(SQL_CONFIG,logfile), NULL, NULL},
+ offsetof(rlm_sql_config_t,logfile), NULL, NULL},
- offsetof(SQL_CONFIG,default_profile), NULL, ""},
+ offsetof(rlm_sql_config_t,default_profile), NULL, ""},
- offsetof(SQL_CONFIG,nas_query), NULL,
+ offsetof(rlm_sql_config_t,nas_query), NULL,
"SELECT id,nasname,shortname,type,secret FROM nas"},
{"authorize_check_query", PW_TYPE_STRING_PTR,
"SELECT id,nasname,shortname,type,secret FROM nas"},
{"authorize_check_query", PW_TYPE_STRING_PTR,
- offsetof(SQL_CONFIG,authorize_check_query), NULL, ""},
+ offsetof(rlm_sql_config_t,authorize_check_query), NULL, ""},
- offsetof(SQL_CONFIG,authorize_reply_query), NULL, NULL},
+ offsetof(rlm_sql_config_t,authorize_reply_query), NULL, NULL},
- offsetof(SQL_CONFIG,authorize_group_check_query), NULL, ""},
+ offsetof(rlm_sql_config_t,authorize_group_check_query), NULL, ""},
- offsetof(SQL_CONFIG,authorize_group_reply_query), NULL, ""},
+ offsetof(rlm_sql_config_t,authorize_group_reply_query), NULL, ""},
- offsetof(SQL_CONFIG,groupmemb_query), NULL, NULL},
+ offsetof(rlm_sql_config_t,groupmemb_query), NULL, NULL},
- offsetof(SQL_CONFIG,simul_count_query), NULL, ""},
+ offsetof(rlm_sql_config_t,simul_count_query), NULL, ""},
- offsetof(SQL_CONFIG,simul_verify_query), NULL, ""},
+ offsetof(rlm_sql_config_t,simul_verify_query), NULL, ""},
- offsetof(SQL_CONFIG,allowed_chars), NULL,
+ offsetof(rlm_sql_config_t,allowed_chars), NULL,
"@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /"},
/*
* This only works for a few drivers.
*/
{"query_timeout", PW_TYPE_INTEGER,
"@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /"},
/*
* This only works for a few drivers.
*/
{"query_timeout", PW_TYPE_INTEGER,
- offsetof(SQL_CONFIG,query_timeout), NULL, NULL},
+ offsetof(rlm_sql_config_t,query_timeout), NULL, NULL},
{NULL, -1, 0, NULL, NULL}
};
{NULL, -1, 0, NULL, NULL}
};
static size_t sql_escape_func(REQUEST *, char *out, size_t outlen, const char *in, void *arg);
/*
static size_t sql_escape_func(REQUEST *, char *out, size_t outlen, const char *in, void *arg);
/*
static size_t sql_xlat(void *instance, REQUEST *request,
const char *fmt, char *out, size_t freespace)
{
static size_t sql_xlat(void *instance, REQUEST *request,
const char *fmt, char *out, size_t freespace)
{
return 0;
rlm_sql_query_log(inst, request, NULL, querystr);
return 0;
rlm_sql_query_log(inst, request, NULL, querystr);
- if (rlm_sql_query(&sqlsocket,inst,querystr)) {
- sql_release_socket(inst,sqlsocket);
+ if (rlm_sql_query(&handle,inst,querystr)) {
+ sql_release_socket(inst,handle);
if (ret >= freespace){
RDEBUG("rlm_sql (%s): Can't write result, insufficient string space",
inst->config->xlat_name);
if (ret >= freespace){
RDEBUG("rlm_sql (%s): Can't write result, insufficient string space",
inst->config->xlat_name);
- (inst->module->sql_finish_query)(sqlsocket, inst->config);
- sql_release_socket(inst,sqlsocket);
+ (inst->module->sql_finish_query)(handle, inst->config);
+ sql_release_socket(inst,handle);
- if (rlm_sql_select_query(&sqlsocket,inst,querystr)){
- sql_release_socket(inst,sqlsocket);
+ if (rlm_sql_select_query(&handle,inst,querystr)){
+ sql_release_socket(inst,handle);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst,sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst,handle);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst,sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst,handle);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst,sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst,handle);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst,sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst,handle);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst,sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst,handle);
DEBUG("rlm_sql (%s) in generate_sql_clients: query is %s",
inst->config->xlat_name, querystr);
DEBUG("rlm_sql (%s) in generate_sql_clients: query is %s",
inst->config->xlat_name, querystr);
if ((numf > 5) && (row[5] != NULL) && *row[5]) c->server = strdup(row[5]);
DEBUG("rlm_sql (%s): Adding client %s (%s, server=%s) to clients list",
inst->config->xlat_name,
c->longname,c->shortname, c->server ? c->server : "<none>");
if (!client_add(NULL, c)) {
if ((numf > 5) && (row[5] != NULL) && *row[5]) c->server = strdup(row[5]);
DEBUG("rlm_sql (%s): Adding client %s (%s, server=%s) to clients list",
inst->config->xlat_name,
c->longname,c->shortname, c->server ? c->server : "<none>");
if (!client_add(NULL, c)) {
DEBUG("rlm_sql (%s): Failed to add client %s (%s) to clients list. Maybe there's a duplicate?",
inst->config->xlat_name,
c->longname,c->shortname);
DEBUG("rlm_sql (%s): Failed to add client %s (%s) to clients list. Maybe there's a duplicate?",
inst->config->xlat_name,
c->longname,c->shortname);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst, sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst, handle);
static size_t sql_escape_func(UNUSED REQUEST *request, char *out, size_t outlen,
const char *in, void *arg)
{
static size_t sql_escape_func(UNUSED REQUEST *request, char *out, size_t outlen,
const char *in, void *arg)
{
* escape it twice. (it will make things wrong if we have an
* escape candidate character in the username)
*/
* escape it twice. (it will make things wrong if we have an
* escape candidate character in the username)
*/
-static int sql_get_grouplist (SQL_INST *inst, SQLSOCK *sqlsocket, REQUEST *request, SQL_GROUPLIST **group_list)
+static int sql_get_grouplist (rlm_sql_t *inst, rlm_sql_handle_t *handle, REQUEST *request, rlm_sql_grouplist_t **group_list)
group_list_tmp = group_list_tmp->next;
}
group_list_tmp->next = NULL;
strlcpy(group_list_tmp->groupname, row[0], MAX_STRING_LEN);
}
group_list_tmp = group_list_tmp->next;
}
group_list_tmp->next = NULL;
strlcpy(group_list_tmp->groupname, row[0], MAX_STRING_LEN);
}
static int sql_groupcmp(void *instance, REQUEST *request, VALUE_PAIR *request_vp, VALUE_PAIR *check,
VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
{
static int sql_groupcmp(void *instance, REQUEST *request, VALUE_PAIR *request_vp, VALUE_PAIR *check,
VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
{
- SQLSOCK *sqlsocket;
- SQL_INST *inst = instance;
- SQL_GROUPLIST *group_list, *group_list_tmp;
+ rlm_sql_handle_t *handle;
+ rlm_sql_t *inst = instance;
+ rlm_sql_grouplist_t *group_list, *group_list_tmp;
- if (sql_get_grouplist(inst, sqlsocket, request, &group_list) < 0) {
+ if (sql_get_grouplist(inst, handle, request, &group_list) < 0) {
radlog_request(L_ERR, 0, request,
"Error getting group membership");
radlog_request(L_ERR, 0, request,
"Error getting group membership");
-static int rlm_sql_process_groups(SQL_INST *inst, REQUEST *request, SQLSOCK *sqlsocket, int *dofallthrough)
+static int rlm_sql_process_groups(rlm_sql_t *inst, REQUEST *request, rlm_sql_handle_t *handle, int *dofallthrough)
- if (sql_get_grouplist(inst, sqlsocket, request, &group_list) < 0) {
+ if (sql_get_grouplist(inst, handle, request, &group_list) < 0) {
radlog_request(L_ERR, 0, request, "Error retrieving group list");
return -1;
}
radlog_request(L_ERR, 0, request, "Error retrieving group list");
return -1;
}
- rows = sql_getvpdata(inst, &sqlsocket, &check_tmp, querystr);
+ rows = sql_getvpdata(inst, &handle, &check_tmp, querystr);
if (rows < 0) {
radlog_request(L_ERR, 0, request, "Error retrieving check pairs for group %s",
group_list_tmp->groupname);
if (rows < 0) {
radlog_request(L_ERR, 0, request, "Error retrieving check pairs for group %s",
group_list_tmp->groupname);
- if (sql_getvpdata(inst, &sqlsocket, &reply_tmp, querystr) < 0) {
+ if (sql_getvpdata(inst, &handle, &reply_tmp, querystr) < 0) {
radlog_request(L_ERR, 0, request, "Error retrieving reply pairs for group %s",
group_list_tmp->groupname);
/* Remove the grouup we added above */
radlog_request(L_ERR, 0, request, "Error retrieving reply pairs for group %s",
group_list_tmp->groupname);
/* Remove the grouup we added above */
- if (sql_getvpdata(inst, &sqlsocket, &reply_tmp, querystr) < 0) {
+ if (sql_getvpdata(inst, &handle, &reply_tmp, querystr) < 0) {
radlog_request(L_ERR, 0, request, "Error retrieving reply pairs for group %s",
group_list_tmp->groupname);
/* Remove the grouup we added above */
radlog_request(L_ERR, 0, request, "Error retrieving reply pairs for group %s",
group_list_tmp->groupname);
/* Remove the grouup we added above */
* After this point use goto error or goto release to cleanup sockets
* temporary pairlists and temporary attributes.
*/
* After this point use goto error or goto release to cleanup sockets
* temporary pairlists and temporary attributes.
*/
- rows = sql_getvpdata(inst, &sqlsocket, &check_tmp, querystr);
+ rows = sql_getvpdata(inst, &handle, &check_tmp, querystr);
if (rows < 0) {
radlog_request(L_ERR, 0, request, "SQL query error; rejecting user");
if (rows < 0) {
radlog_request(L_ERR, 0, request, "SQL query error; rejecting user");
- rows = sql_getvpdata(inst, &sqlsocket, &reply_tmp, querystr);
+ rows = sql_getvpdata(inst, &handle, &reply_tmp, querystr);
if (rows < 0) {
radlog_request(L_ERR, 0, request, "SQL query error; rejecting user");
if (rows < 0) {
radlog_request(L_ERR, 0, request, "SQL query error; rejecting user");
- rows = rlm_sql_process_groups(inst, request, sqlsocket, &dofallthrough);
+ rows = rlm_sql_process_groups(inst, request, handle, &dofallthrough);
if (rows < 0) {
radlog_request(L_ERR, 0, request, "Error processing groups; rejecting user");
if (rows < 0) {
radlog_request(L_ERR, 0, request, "Error processing groups; rejecting user");
- rows = rlm_sql_process_groups(inst, request, sqlsocket, &dofallthrough);
+ rows = rlm_sql_process_groups(inst, request, handle, &dofallthrough);
if (rows < 0) {
radlog_request(L_ERR, 0, request, "Error processing profile groups; rejecting user");
if (rows < 0) {
radlog_request(L_ERR, 0, request, "Error processing profile groups; rejecting user");
* were exhausted, and we couldn't create a new connection,
* so we do not need to call sql_release_socket.
*/
* were exhausted, and we couldn't create a new connection,
* so we do not need to call sql_release_socket.
*/
* Accounting: Insert or update session data in our sql table
*/
static rlm_rcode_t rlm_sql_accounting(void *instance, REQUEST * request) {
* Accounting: Insert or update session data in our sql table
*/
static rlm_rcode_t rlm_sql_accounting(void *instance, REQUEST * request) {
if (inst->config->accounting) {
return acct_redundant(inst, request, inst->config->accounting);
if (inst->config->accounting) {
return acct_redundant(inst, request, inst->config->accounting);
radius_xlat(querystr, sizeof(querystr), inst->config->simul_count_query, request, sql_escape_func, inst);
/* initialize the sql socket */
radius_xlat(querystr, sizeof(querystr), inst->config->simul_count_query, request, sql_escape_func, inst);
/* initialize the sql socket */
- if(rlm_sql_select_query(&sqlsocket, inst, querystr)) {
- sql_release_socket(inst, sqlsocket);
+ if(rlm_sql_select_query(&handle, inst, querystr)) {
+ sql_release_socket(inst, handle);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst, sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst, handle);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst, sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst, handle);
return RLM_MODULE_OK;
}
radius_xlat(querystr, sizeof(querystr), inst->config->simul_verify_query, request, sql_escape_func, inst);
return RLM_MODULE_OK;
}
radius_xlat(querystr, sizeof(querystr), inst->config->simul_verify_query, request, sql_escape_func, inst);
- if(rlm_sql_select_query(&sqlsocket, inst, querystr)) {
- sql_release_socket(inst, sqlsocket);
+ if(rlm_sql_select_query(&handle, inst, querystr)) {
+ sql_release_socket(inst, handle);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst, sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst, handle);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst, sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst, handle);
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst, sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst, handle);
radlog_request(L_ERR, 0, request, "Failed to check the terminal server for user '%s'.", row[2]);
return RLM_MODULE_FAIL;
}
}
radlog_request(L_ERR, 0, request, "Failed to check the terminal server for user '%s'.", row[2]);
return RLM_MODULE_FAIL;
}
}
- (inst->module->sql_finish_select_query)(sqlsocket, inst->config);
- sql_release_socket(inst, sqlsocket);
+ (inst->module->sql_finish_select_query)(handle, inst->config);
+ sql_release_socket(inst, handle);
* Postauth: Write a record of the authentication attempt
*/
static rlm_rcode_t rlm_sql_postauth(void *instance, REQUEST * request) {
* Postauth: Write a record of the authentication attempt
*/
static rlm_rcode_t rlm_sql_postauth(void *instance, REQUEST * request) {
if (inst->config->postauth) {
return acct_redundant(inst, request, inst->config->postauth);
if (inst->config->postauth) {
return acct_redundant(inst, request, inst->config->postauth);