Add rad_virtual_server to call rad_authenticate and rad_postauth
authorMatthew Newton <mcn4@leicester.ac.uk>
Tue, 25 Sep 2012 22:04:04 +0000 (23:04 +0100)
committerMatthew Newton <mcn4@leicester.ac.uk>
Tue, 25 Sep 2012 22:04:04 +0000 (23:04 +0100)
src/include/radiusd.h
src/main/auth.c

index 686bef6..553815a 100644 (file)
@@ -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,
index 7b4cb2a..c08c7dc 100644 (file)
@@ -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;
+}
+