--- rlm_sql.c-orig 2014-11-28 14:09:47.738796013 +0100 +++ rlm_sql.c 2014-11-28 18:05:11.630574073 +0100 @@ -685,11 +685,26 @@ goto finish; } + /* + * Does not examine groups if any group query is missing from config + */ + if (! (inst->config->authorize_group_check_query && *inst->config->authorize_group_check_query && + inst->config->authorize_group_reply_query && *inst->config->authorize_group_reply_query) ) { + + /* + * If there's no reply query configured, then we assume + * FALL_THROUGH_NO, which is the same as the users file if you + * had no reply attributes. + */ + *do_fall_through = FALL_THROUGH_DEFAULT; + + goto finish; + } + entry = head; do { pairstrcpy(sql_group, entry->name); - if (inst->config->authorize_group_check_query && *inst->config->authorize_group_check_query) { vp_cursor_t cursor; VALUE_PAIR *vp; @@ -718,11 +733,14 @@ if ((rows > 0) && (paircompare(request, request->packet->vps, check_tmp, &request->reply->vps) != 0)) { pairfree(&check_tmp); - entry = entry->next; + // If it does not match... continue to next group continue; } + /* + * At this point, this group matches + */ RDEBUG2("Group \"%s\": Conditional check items matched", entry->name); rcode = RLM_MODULE_OK; @@ -738,9 +756,7 @@ REXDENT(); radius_pairmove(request, &request->config_items, check_tmp, true); check_tmp = NULL; - } - if (inst->config->authorize_group_reply_query && *inst->config->authorize_group_reply_query) { /* * Now get the reply pairs since the paircompare matched */ @@ -767,17 +783,15 @@ radius_pairmove(request, &request->reply->vps, reply_tmp, true); reply_tmp = NULL; + /* - * If there's no reply query configured, then we assume - * FALL_THROUGH_NO, which is the same as the users file if you - * had no reply attributes. + * Now examine fall-through... not enabled => bail out */ - } else { - *do_fall_through = FALL_THROUGH_DEFAULT; + if (*do_fall_through != FALL_THROUGH_YES) { + break; } - entry = entry->next; - } while (entry != NULL && (*do_fall_through == FALL_THROUGH_YES)); + } while ((entry = entry->next) != NULL); finish: talloc_free(head);