Made exec program return the VP's which were parsed from the
authoraland <aland>
Fri, 24 Jan 2003 20:40:25 +0000 (20:40 +0000)
committeraland <aland>
Fri, 24 Jan 2003 20:40:25 +0000 (20:40 +0000)
executed program.  This allows the caller to decide what to
do with them.

src/include/radiusd.h
src/main/acct.c
src/main/auth.c
src/modules/rlm_exec/rlm_exec.c

index c67e944..fa8d6ae 100644 (file)
@@ -315,7 +315,7 @@ int         rad_check_password(REQUEST *request);
 /* exec.c */
 int            radius_exec_program(const char *,  REQUEST *,
                                    int, char *user_msg,
-                                   int msg_len, int parse_vp);
+                                   int msg_len, VALUE_PAIR **pairs);
 
 /* timestr.c */
 int            timestr_match(char *, time_t);
index a4e773f..e02beb0 100644 (file)
@@ -104,18 +104,25 @@ int rad_accounting(REQUEST *request)
                         */
                        rcode = radius_exec_program(exec_program, request,
                                                    exec_wait,
-                                                   NULL, 0, TRUE);
+                                                   NULL, 0, &vp);
+                       free(exec_program);
+
+                       /*
+                        *      Always add the value-pairs to the reply.
+                        *
+                        *      If we're not waiting, then the pairs
+                        *      will be empty, so this won't matter.
+                        */
+                       pairmove(&request->reply->vps, &vp);
+                       pairfree(&vp);
+                               
                        if (exec_wait) {
                                if (rcode != 0) {
-                                       free(exec_program);
                                        return reply;
                                }
                        }
                }
 
-               if (exec_program) 
-                       free(exec_program);
-
                /*
                 *      Maybe one of the preacct modules has decided
                 *      that a proxy should be used. If so, get out of
index 0f25f1a..136739a 100644 (file)
@@ -804,11 +804,19 @@ autz_redo:
         *      do it first before sending the reply.
         */
        if (exec_program && exec_wait) {
-               if (radius_exec_program(exec_program, request,
+               r = radius_exec_program(exec_program, request,
                                        exec_wait,
-                                       umsg, sizeof(umsg), TRUE) != 0) {
-                       free(exec_program);
+                                       umsg, sizeof(umsg), &tmp);
+               free(exec_program);
+               exec_program = NULL;
+
+               /*
+                *      Always add the value-pairs to the reply.
+                */
+               pairmove(&request->reply->vps, &tmp);
+               pairfree(&tmp);
 
+               if (r < 0) {
                        /*
                         *      Error. radius_exec_program() returns -1 on
                         *      fork/exec errors, or >0 if the exec'ed program
@@ -892,7 +900,7 @@ autz_redo:
                 *      No need to check the exit status here.
                 */
                radius_exec_program(exec_program, request, exec_wait,
-                                   NULL, 0, FALSE);
+                                   NULL, 0, NULL);
        }
 
        if (exec_program) 
index d3769a7..1a3f719 100644 (file)
@@ -79,7 +79,7 @@ static int exec_xlat(void *instance, REQUEST *request,
 
        DEBUG2("rlm_exec: %d %s", inst->wait, buffer);
        result = radius_exec_program(buffer, request, inst->wait,
-                                    out, outlen, FALSE);
+                                    out, outlen, NULL);
        DEBUG2("rlm_exec: result %d", result);
        if (result != 0) {
                out[0] = '\0';