fr_exec_state_t *exec = uctx; /* may not be talloced */
if (exec->stdout_fd < 0) {
- fr_strerror_const("Timeout waiting for program to exit - killing it and failing the request");
+ fr_strerror_const("Timeout waiting for program to exit");
} else {
- fr_strerror_const("Timeout running program - killing it and failing the request");
+ fr_strerror_const("Timeout running program");
}
- exec->failed = true;
+
+ exec->failed = FR_EXEC_FAIL_TIMEOUT;
fr_exec_oneshot_cleanup(exec, SIGKILL);
unlang_interpret_mark_runnable(exec->request);
REDEBUG("Too much output from program - killing it and failing the request");
error:
- exec->failed = true;
+ exec->failed = FR_EXEC_FAIL_TOO_MUCH_DATA;
fr_exec_oneshot_cleanup(exec, SIGKILL);
break;
}
extern "C" {
#endif
+typedef enum {
+ FR_EXEC_FAIL_NONE = 0,
+ FR_EXEC_FAIL_TOO_MUCH_DATA,
+ FR_EXEC_FAIL_TIMEOUT,
+} fr_exec_fail_t;
+
typedef struct {
fr_sbuff_t stdout_buff; //!< Expandable buffer to store process output.
fr_sbuff_uctx_talloc_t stdout_tctx; //!< sbuff talloc ctx data.
fr_event_timer_t const *ev; //!< for timing out the child
fr_event_pid_t const *ev_pid; //!< for cleaning up the process
- bool failed; //!< due to exec timeout or buffer overflow
+ fr_exec_fail_t failed; //!< what kind of failure
int status; //!< return code of the program
fr_exec_state_t *exec = talloc_get_type_abort(xctx->rctx, fr_exec_state_t);
fr_value_box_t *vb;
+ if (exec->failed == FR_EXEC_FAIL_TIMEOUT) {
+ RPEDEBUG("Execution of external program failed");
+ return XLAT_ACTION_FAIL;
+ }
+
/*
* Allow a return code of 3 as success to match the behaviour of
* inline module calls.
&request -= &Tmp-String-0
&Tmp-String-0 := "%(exec_sync:/bin/sleep 10)"
-if (&Module-Failure-Message[*] != "Timeout running program - killing it and failing the request") {
+if (&Module-Failure-Message[*] != "Execution of external program failed: Timeout running program") {
test_fail
}