Skip to content

Commit

Permalink
simplify the code now that the old code is gone
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Oct 16, 2018
1 parent 362a28f commit 2f6a431
Showing 1 changed file with 23 additions and 32 deletions.
55 changes: 23 additions & 32 deletions src/lib/server/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,41 +41,14 @@ RCSID("$Id$")

#include <ctype.h>

static rlm_rcode_t virtual_server_async(REQUEST *request, bool parent)
{
fr_io_final_t final;

if (parent) {
request->async = talloc_memdup(request, request->parent->async, sizeof(fr_async_t));
talloc_set_name_const(request->async, talloc_get_name(request->parent->async));
}

RDEBUG("server %s {", cf_section_name2(request->server_cs));
final = request->async->process(request->async->process_inst, request, FR_IO_ACTION_RUN);
RDEBUG("} # server %s", cf_section_name2(request->server_cs));

fr_cond_assert(final == FR_IO_REPLY);

if (!request->reply->code ||
(request->reply->code == FR_CODE_ACCESS_REJECT)) {
return RLM_MODULE_REJECT;
}

if (request->reply->code == FR_CODE_ACCESS_CHALLENGE) {
return RLM_MODULE_HANDLED;
}

return RLM_MODULE_OK;
}


/*
* Run a virtual server auth and postauth
*
*/
rlm_rcode_t rad_virtual_server(REQUEST *request)
{
VALUE_PAIR *vp;
fr_io_final_t final;

RDEBUG("Virtual server %s received request", cf_section_name2(request->server_cs));
log_request_pair_list(L_DBG_LVL_1, request, request->packet->vps, NULL);
Expand All @@ -93,7 +66,7 @@ rlm_rcode_t rad_virtual_server(REQUEST *request)
*/
if (request->parent->username->da->attr == FR_STRIPPED_USER_NAME) {
vp = fr_pair_find_by_num(request->parent->packet->vps, 0, FR_USER_NAME, TAG_ANY);
if (!vp) goto skip;
if (!vp) goto runit;
} else {
vp = request->parent->username;
}
Expand Down Expand Up @@ -174,10 +147,28 @@ rlm_rcode_t rad_virtual_server(REQUEST *request)
}
}

skip:
if (request->async) return virtual_server_async(request, false);
runit:
if (!request->async) {
request->async = talloc_memdup(request, request->parent->async, sizeof(fr_async_t));
talloc_set_name_const(request->async, talloc_get_name(request->parent->async));
}

RDEBUG("server %s {", cf_section_name2(request->server_cs));
final = request->async->process(request->async->process_inst, request, FR_IO_ACTION_RUN);
RDEBUG("} # server %s", cf_section_name2(request->server_cs));

return virtual_server_async(request, true);
fr_cond_assert(final == FR_IO_REPLY);

if (!request->reply->code ||
(request->reply->code == FR_CODE_ACCESS_REJECT)) {
return RLM_MODULE_REJECT;
}

if (request->reply->code == FR_CODE_ACCESS_CHALLENGE) {
return RLM_MODULE_HANDLED;
}

return RLM_MODULE_OK;
}

/*
Expand Down

0 comments on commit 2f6a431

Please sign in to comment.