From: Matthew Newton Date: Tue, 25 Sep 2012 22:04:04 +0000 (+0100) Subject: Add rad_virtual_server to call rad_authenticate and rad_postauth X-Git-Tag: release_3_0_0_beta1~1682^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00cadac7c473ee25fe95b4d470306a85e76142c5;p=thirdparty%2Ffreeradius-server.git Add rad_virtual_server to call rad_authenticate and rad_postauth --- diff --git a/src/include/radiusd.h b/src/include/radiusd.h index 686bef6596b..553815a8dbd 100644 --- a/src/include/radiusd.h +++ b/src/include/radiusd.h @@ -672,6 +672,7 @@ void radlog_request(int lvl, int priority, REQUEST *request, const char *msg, .. char *auth_name(char *buf, size_t buflen, REQUEST *request, int do_cli); int rad_authenticate (REQUEST *); int rad_postauth(REQUEST *); +int rad_virtual_server(REQUEST *); /* exec.c */ pid_t radius_start_program(const char *cmd, REQUEST *request, diff --git a/src/main/auth.c b/src/main/auth.c index 7b4cb2a7952..c08c7dc2661 100644 --- a/src/main/auth.c +++ b/src/main/auth.c @@ -798,3 +798,36 @@ autz_redo: return result; } + +/* + * Run a virtual server auth and postauth + * + */ +int rad_virtual_server(REQUEST *request) +{ + VALUE_PAIR *vp; + int result; + + /* + * We currently only handle AUTH packets here. + * This could be expanded to handle other packets as well if required. + */ + rad_assert(request->packet->code == PW_AUTHENTICATION_REQUEST); + + result = rad_authenticate(request); + + if (request->reply->code == PW_AUTHENTICATION_REJECT) { + pairdelete(&request->config_items, PW_POST_AUTH_TYPE, 0); + vp = radius_pairmake(request, &request->config_items, + "Post-Auth-Type", "Reject", + T_OP_SET); + if (vp) rad_postauth(request); + } + + if (request->reply->code == PW_AUTHENTICATION_ACK) { + rad_postauth(request); + } + + return result; +} +