]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
save the processes exit status, not the raw one
authorAlan T. DeKok <aland@freeradius.org>
Tue, 4 Aug 2020 12:10:00 +0000 (08:10 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 4 Aug 2020 12:15:16 +0000 (08:15 -0400)
src/lib/unlang/tmpl.c

index 6977eedea015d29932ebd59a60a31c6a51d16ef5..a1f784096fa2a3d348d8de241a3246cabd3cea38 100644 (file)
@@ -334,15 +334,16 @@ static unlang_action_t unlang_tmpl_exec_wait_final(REQUEST *request, rlm_rcode_t
        }
 
        fr_assert(state->pid == 0);
-       if (state->status_p) *state->status_p = state->status;
 
        if (state->status != 0) {
                if (WIFEXITED(state->status)) {
                        RDEBUG("Program failed with status code %d", WEXITSTATUS(state->status));
                        state->status = WEXITSTATUS(state->status);
+
                } else if (WIFSIGNALED(state->status)) {
                        RDEBUG("Program exited due to signal with status code %d", WTERMSIG(state->status));
                        state->status = -WTERMSIG(state->status);
+
                } else {
                        RDEBUG("Program exited due to unknown status %d", state->status);
                        state->status = -state->status;
@@ -352,6 +353,11 @@ static unlang_action_t unlang_tmpl_exec_wait_final(REQUEST *request, rlm_rcode_t
                goto resume;
        }
 
+       /*
+        *      Save the *mangled* exit status, not the raw one.
+        */
+       if (state->status_p) *state->status_p = state->status;
+
        /*
         *      We might want to just get the status of the program,
         *      and not care about the output.