The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions
exec_legacy.c File Reference

Execute external programs. More...

#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/server/request.h>
#include <freeradius-devel/server/util.h>
#include <freeradius-devel/server/exec_legacy.h>
#include <freeradius-devel/server/exec_priv.h>
+ Include dependency graph for exec_legacy.c:

Go to the source code of this file.

Macros

#define MAX_ARGV   (256)
 
#define MAX_ENVP   1024
 

Functions

static NEVER_RETURNS void exec_child_legacy (request_t *request, char **argv, char **envp, bool exec_wait, int stdin_pipe[static 2], int stdout_pipe[static 2], int stderr_pipe[static 2])
 
static void exec_pair_to_env_legacy (request_t *request, fr_pair_list_t *input_pairs, char **envp, size_t envlen, bool shell_escape)
 
int radius_exec_program_legacy (char *out, size_t outlen, request_t *request, char const *cmd, fr_pair_list_t *input_pairs, bool exec_wait, bool shell_escape, fr_time_delta_t timeout)
 Execute a program. More...
 
int radius_readfrom_program_legacy (int fd, pid_t pid, fr_time_delta_t timeout, char *answer, int left)
 Read from the child process. More...
 
pid_t radius_start_program_legacy (int *stdin_fd, int *stdout_fd, int *stderr_fd, char const *cmd, request_t *request, bool exec_wait, fr_pair_list_t *input_pairs, bool shell_escape)
 Start a process. More...
 

Detailed Description

Execute external programs.

Id
1435f94150996de950a092d0d3fb0c28f7ba2dd0

Definition in file exec_legacy.c.

Macro Definition Documentation

◆ MAX_ARGV

#define MAX_ARGV   (256)

Definition at line 33 of file exec_legacy.c.

◆ MAX_ENVP

#define MAX_ENVP   1024

Function Documentation

◆ exec_child_legacy()

static NEVER_RETURNS void exec_child_legacy ( request_t request,
char **  argv,
char **  envp,
bool  exec_wait,
int  stdin_pipe[static 2],
int  stdout_pipe[static 2],
int  stderr_pipe[static 2] 
)
static

Definition at line 105 of file exec_legacy.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exec_pair_to_env_legacy()

static void exec_pair_to_env_legacy ( request_t request,
fr_pair_list_t input_pairs,
char **  envp,
size_t  envlen,
bool  shell_escape 
)
static

Definition at line 35 of file exec_legacy.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ radius_exec_program_legacy()

int radius_exec_program_legacy ( char *  out,
size_t  outlen,
request_t request,
char const *  cmd,
fr_pair_list_t input_pairs,
bool  exec_wait,
bool  shell_escape,
fr_time_delta_t  timeout 
)

Execute a program.

Parameters
[out]outbuffer to append plaintext (non valuepair) output.
[in]outlenlength of out buffer.
[in]requestCurrent request (may be NULL).
[in]cmdCommand to execute. This is parsed into argv[] parts, then each individual argv part is xlat'ed.
[in]input_pairslist of value pairs - these will be available in the environment of the child.
[in]exec_waitset to 1 if you want to read from or write to child.
[in]shell_escapevalues before passing them as arguments.
[in]timeoutamount of time to wait, in seconds.
Returns
  • 0 if exec_wait==0.
  • exit code if exec_wait!=0.
  • -1 on failure.

Definition at line 474 of file exec_legacy.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ radius_readfrom_program_legacy()

int radius_readfrom_program_legacy ( int  fd,
pid_t  pid,
fr_time_delta_t  timeout,
char *  answer,
int  left 
)

Read from the child process.

Parameters
fdfile descriptor to read from.
pidpid of child, will be reaped if it dies.
timeoutamount of time to wait, in seconds.
answerbuffer to write into.
leftlength of buffer.
Returns
  • -1 on failure.
  • Length of output.

Definition at line 357 of file exec_legacy.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ radius_start_program_legacy()

pid_t radius_start_program_legacy ( int *  stdin_fd,
int *  stdout_fd,
int *  stderr_fd,
char const *  cmd,
request_t request,
bool  exec_wait,
fr_pair_list_t input_pairs,
bool  shell_escape 
)

Start a process.

Parameters
[out]stdin_fdpointer to int, receives the stdin file descriptor. Set to NULL and the child will have /dev/null on stdin.
[out]stdout_fdpointer to int, receives the stdout file descriptor. Set to NULL and the child will have /dev/null on stdout.
[out]stderr_fdpointer to int, receives the stderr file descriptor. Set to NULL and the child will have /dev/null on stderr.
[in]cmdCommand to execute. This is parsed into argv[] parts, then each individual argv part is xlat'ed.
[in]requestCurrent request
[in]exec_waitset to true to read from or write to child.
[in]input_pairslist of value pairs - these will be put into the environment variables of the child.
[in]shell_escapevalues before passing them as arguments.
Returns
  • PID of the child process.
  • -1 on failure.

Definition at line 227 of file exec_legacy.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: