26 RCSIDH(exec_h,
"$Id: 7f5335e8e504121f52f0f1d4909d63700993ebb8 $")
32 #define EXEC_TIMEOUT 10
38 #include <freeradius-devel/server/request.h>
39 #include <freeradius-devel/util/pair.h>
40 #include <freeradius-devel/util/talloc.h>
41 #include <sys/types.h>
59 char stdout_prefix[
sizeof(
"pid -9223372036854775808 (stdout)")];
60 char stderr_prefix[
sizeof(
"pid -9223372036854775808 (stderr)")];
97 char ***argv_p, fr_value_box_list_t
const *
in);
102 char **argv_in,
char **env_in,
103 bool env_inherit,
bool debug);
107 char **argv_in,
char **env_usr,
108 bool env_inherit,
bool debug);
119 bool env_escape,
bool env_inherit);
124 fr_value_box_list_t *
args,
static fr_time_delta_t timeout
fr_event_pid_t const * ev_pid
for cleaning up the process
request_t * request
request this exec is related to
char ** fr_exec_pair_to_env(request_t *request, fr_pair_list_t *env_pairs, bool env_escape)
Convert env_pairs into an array of environmental variables using thread local buffers.
log_fd_event_ctx_t stdout_uctx
Config for the stdout logger.
int stderr_fd
for producing error messages.
log_fd_event_ctx_t stderr_uctx
Config for the stderr logger.
TALLOC_CTX * stdout_ctx
ctx to allocate output buffers
int stdout_fd
for reading from the child.
int stdin_fd
for writing to the child.
fr_pair_list_t * env_pairs
input VPs.
@ FR_EXEC_FAIL_TOO_MUCH_DATA
fr_sbuff_t stdout_buff
Expandable buffer to store process output.
int fr_exec_oneshot(TALLOC_CTX *ctx, fr_exec_state_t *exec, request_t *request, fr_value_box_list_t *args, fr_pair_list_t *env_pairs, bool env_escape, bool env_inherit, bool need_stdin, bool store_stdout, TALLOC_CTX *stdout_ctx, fr_time_delta_t timeout)
Call an child program, optionally reading it's output.
int fr_exec_oneshot_nowait(request_t *request, fr_value_box_list_t *args, fr_pair_list_t *env_pairs, bool env_escape, bool env_inherit)
Similar to fr_exec_oneshot, but does not attempt to parse output.
bool stdout_used
use stdout fd?
fr_sbuff_uctx_talloc_t stdout_tctx
sbuff talloc ctx data.
int status
return code of the program
bool stdin_used
use stdin fd?
fr_exec_fail_t failed
what kind of failure
fr_event_timer_t const * ev
for timing out the child
int fr_exec_fork_wait(pid_t *pid_p, int *stdin_fd, int *stdout_fd, int *stderr_fd, char **argv_in, char **env_usr, bool env_inherit, bool debug)
Execute a program assuming that the caller waits for it to finish.
int fr_exec_fork_nowait(fr_event_list_t *el, char **argv_in, char **env_in, bool env_inherit, bool debug)
Execute a program without waiting for the program to finish.
int fr_exec_value_box_list_to_argv(TALLOC_CTX *ctx, char ***argv_p, fr_value_box_list_t const *in)
Flatten a list into individual "char *" argv-style array.
void fr_exec_oneshot_cleanup(fr_exec_state_t *exec, int signal)
Cleans up an exec'd process on error.
Context structure for the log fd event function.
Stores all information relating to an event list.
static int stdout_fd
The original unmolested stdout file descriptor.
static fr_log_fd_event_ctx_t stdout_ctx
Logging ctx for stdout.
static int stderr_fd
The original unmolested stderr file descriptor.
Talloc sbuff extension structure.
A time delta, a difference in time measured in nanoseconds.
static fr_event_list_t * el