rcode = rlm_sql_query(inst, request, &handle, fmt);
if (rcode != RLM_SQL_OK) {
query_error:
- RERROR("SQL query failed: %s", fr_int2str(sql_rcode_table, rcode, "<INVALID>"));
+ RERROR("SQL query failed: %s", fr_int2str(sql_rcode_description_table, rcode, "<INVALID>"));
ret = -1;
goto finish;
ret = rlm_sql_select_query(inst, request, &handle, query_str);
if (ret != RLM_SQL_OK) {
- RERROR("SQL query failed: %s", fr_int2str(sql_rcode_table, ret, "<INVALID>"));
+ RERROR("SQL query failed: %s", fr_int2str(sql_rcode_description_table, ret, "<INVALID>"));
rcode = RLM_MODULE_FAIL;
goto finish;
}
*/
ret = (inst->driver->sql_fields)(&fields, handle, inst->config);
if (ret != RLM_SQL_OK) {
- RERROR("Failed retrieving field names: %s", fr_int2str(sql_rcode_table, ret, "<INVALID>"));
+ RERROR("Failed retrieving field names: %s", fr_int2str(sql_rcode_description_table, ret, "<INVALID>"));
goto error;
}
rad_assert(fields);
static int sql_get_grouplist(rlm_sql_t const *inst, rlm_sql_handle_t **handle, REQUEST *request,
rlm_sql_grouplist_t **phead)
{
- char *expanded = NULL;
- int num_groups = 0;
- rlm_sql_row_t row;
- rlm_sql_grouplist_t *entry;
- int ret;
+ char *expanded = NULL;
+ int num_groups = 0;
+ rlm_sql_row_t row;
+ rlm_sql_grouplist_t *entry;
+ int ret;
/* NOTE: sql_set_user should have been run before calling this function */
static rlm_rcode_t mod_authorize(void *instance, UNUSED void *thread, REQUEST *request) CC_HINT(nonnull);
static rlm_rcode_t mod_authorize(void *instance, UNUSED void *thread, REQUEST *request)
{
- rlm_rcode_t rcode = RLM_MODULE_NOOP;
+ rlm_rcode_t rcode = RLM_MODULE_NOOP;
- rlm_sql_t const *inst = instance;
- rlm_sql_handle_t *handle;
+ rlm_sql_t const *inst = instance;
+ rlm_sql_handle_t *handle;
- VALUE_PAIR *check_tmp = NULL;
- VALUE_PAIR *reply_tmp = NULL;
- VALUE_PAIR *user_profile = NULL;
+ VALUE_PAIR *check_tmp = NULL;
+ VALUE_PAIR *reply_tmp = NULL;
+ VALUE_PAIR *user_profile = NULL;
- bool user_found = false;
+ bool user_found = false;
- sql_fall_through_t do_fall_through = FALL_THROUGH_DEFAULT;
+ sql_fall_through_t do_fall_through = FALL_THROUGH_DEFAULT;
- int rows;
+ int rows;
- char *expanded = NULL;
+ char *expanded = NULL;
rad_assert(request->packet != NULL);
rad_assert(request->reply != NULL);
/*
* Set, escape, and check the user attr here
*/
- if (sql_set_user(inst, request, NULL) < 0) {
- return RLM_MODULE_FAIL;
- }
+ if (sql_set_user(inst, request, NULL) < 0) return RLM_MODULE_FAIL;
/*
* Reserve a socket
*/
handle = fr_pool_connection_get(inst->pool, request);
if (!handle) {
- rcode = RLM_MODULE_FAIL;
- goto error;
+ sql_unset_user(inst, request);
+ return RLM_MODULE_FAIL;
}
/*
inst->sql_escape_func, handle) < 0) {
REDEBUG("Failed generating query");
rcode = RLM_MODULE_FAIL;
- goto error;
+
+ error:
+ fr_pair_list_free(&check_tmp);
+ fr_pair_list_free(&reply_tmp);
+ sql_unset_user(inst, request);
+
+ fr_pool_connection_release(inst->pool, request, handle);
+
+ return rcode;
}
rows = sql_getvpdata(request, inst, request, &handle, &check_tmp, expanded);
goto error;
}
- if (rows == 0) goto skipreply; /* Don't need to free VPs we don't have */
+ if (rows == 0) goto skip_reply; /* Don't need to free VPs we don't have */
/*
* Only do this if *some* check pairs were returned
if (paircmp(request, request->packet->vps, check_tmp, &request->reply->vps) != 0) {
fr_pair_list_free(&check_tmp);
check_tmp = NULL;
- goto skipreply;
+ goto skip_reply;
}
RDEBUG2("Conditional check items matched, merging assignment check items");
goto error;
}
- if (rows == 0) goto skipreply;
+ if (rows == 0) goto skip_reply;
do_fall_through = fall_through(reply_tmp);
*/
if (!inst->config->groupmemb_query) goto release;
-skipreply:
+skip_reply:
if ((do_fall_through == FALL_THROUGH_YES) ||
(inst->config->read_groups && (do_fall_through == FALL_THROUGH_DEFAULT))) {
rlm_rcode_t ret;
*/
if ((do_fall_through == FALL_THROUGH_YES) ||
(inst->config->read_profiles && (do_fall_through == FALL_THROUGH_DEFAULT))) {
- rlm_rcode_t ret;
+ rlm_rcode_t ret;
+ char const *profile;
/*
* Check for a default_profile or for a User-Profile.
RDEBUG3("... falling-through to profile processing");
user_profile = fr_pair_find_by_da(request->control, attr_user_profile, TAG_ANY);
- char const *profile = user_profile ?
+ profile = user_profile ?
user_profile->vp_strvalue :
inst->config->default_profile;
- if (!profile || !*profile) {
- goto release;
- }
+ if (!profile || !*profile) goto release;
RDEBUG2("Checking profile %s", profile);
* or the group mapping table, and there was no matching profile.
*/
release:
- if (!user_found) {
- rcode = RLM_MODULE_NOTFOUND;
- }
+ if (!user_found) rcode = RLM_MODULE_NOTFOUND;
fr_pool_connection_release(inst->pool, request, handle);
sql_unset_user(inst, request);
- return rcode;
-
-error:
- fr_pair_list_free(&check_tmp);
- fr_pair_list_free(&reply_tmp);
- sql_unset_user(inst, request);
-
- fr_pool_connection_release(inst->pool, request, handle);
-
return rcode;
}
rad_assert(section);
- if (section->reference[0] != '.') {
- *p++ = '.';
- }
+ if (section->reference[0] != '.') *p++ = '.';
if (xlat_eval(p, sizeof(path) - (p - path), request, section->reference, NULL, NULL) < 0) {
rcode = RLM_MODULE_FAIL;
sql_ret = rlm_sql_query(inst, request, &handle, expanded);
TALLOC_FREE(expanded);
- RDEBUG2("SQL query returned: %s", fr_int2str(sql_rcode_table, sql_ret, "<INVALID>"));
+ RDEBUG2("SQL query returned: %s", fr_int2str(sql_rcode_description_table, sql_ret, "<INVALID>"));
switch (sql_ret) {
/*
RDEBUG2("Trying next query...");
}
-
finish:
talloc_free(expanded);
fr_pool_connection_release(inst->pool, request, handle);