From: Alan T. DeKok Date: Tue, 4 Aug 2020 12:10:00 +0000 (-0400) Subject: save the processes exit status, not the raw one X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8fcdd9869321e8aec1f406231b587fe6b43e4ade;p=thirdparty%2Ffreeradius-server.git save the processes exit status, not the raw one --- diff --git a/src/lib/unlang/tmpl.c b/src/lib/unlang/tmpl.c index 6977eedea01..a1f784096fa 100644 --- a/src/lib/unlang/tmpl.c +++ b/src/lib/unlang/tmpl.c @@ -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.