OpenVPN
Macros | Functions
run_command.h File Reference
#include "basic.h"
#include "env_set.h"
Include dependency graph for run_command.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SSEC_NONE   0 /* strictly no calling of external programs */
 
#define SSEC_BUILT_IN   1 /* only call built-in programs such as ifconfig, route, netsh, etc.*/
 
#define SSEC_SCRIPTS   2 /* allow calling of built-in programs and user-defined scripts */
 
#define SSEC_PW_ENV   3 /* allow calling of built-in programs and user-defined scripts that may receive a password as an environmental variable */
 
#define OPENVPN_EXECVE_ERROR   -1 /* generic error while forking to run an external program */
 
#define OPENVPN_EXECVE_NOT_ALLOWED   -2 /* external program not run due to script security */
 
#define OPENVPN_EXECVE_FAILURE   127 /* exit code passed back from child when execve fails */
 
#define S_SCRIPT   (1<<0)
 
#define S_FATAL   (1<<1)
 
#define S_EXITCODE   (1<<2)
 Instead of returning 1/0 for success/fail, return exit code when between 0 and 255 and -1 otherwise. More...
 

Functions

int script_security (void)
 
void script_security_set (int level)
 
int openvpn_popen (const struct argv *a, const struct env_set *es)
 
bool openvpn_execve_allowed (const unsigned int flags)
 
int openvpn_execve_check (const struct argv *a, const struct env_set *es, const unsigned int flags, const char *error_message)
 
static int openvpn_run_script (const struct argv *a, const struct env_set *es, const unsigned int flags, const char *hook)
 Will run a script and return the exit code of the script if between 0 and 255, -1 otherwise. More...
 

Macro Definition Documentation

◆ OPENVPN_EXECVE_ERROR

#define OPENVPN_EXECVE_ERROR   -1 /* generic error while forking to run an external program */

Definition at line 36 of file run_command.h.

◆ OPENVPN_EXECVE_FAILURE

#define OPENVPN_EXECVE_FAILURE   127 /* exit code passed back from child when execve fails */

Definition at line 38 of file run_command.h.

◆ OPENVPN_EXECVE_NOT_ALLOWED

#define OPENVPN_EXECVE_NOT_ALLOWED   -2 /* external program not run due to script security */

Definition at line 37 of file run_command.h.

◆ S_EXITCODE

#define S_EXITCODE   (1<<2)

Instead of returning 1/0 for success/fail, return exit code when between 0 and 255 and -1 otherwise.

Definition at line 49 of file run_command.h.

◆ S_FATAL

#define S_FATAL   (1<<1)

Definition at line 46 of file run_command.h.

◆ S_SCRIPT

#define S_SCRIPT   (1<<0)

Definition at line 45 of file run_command.h.

◆ SSEC_BUILT_IN

#define SSEC_BUILT_IN   1 /* only call built-in programs such as ifconfig, route, netsh, etc.*/

Definition at line 32 of file run_command.h.

◆ SSEC_NONE

#define SSEC_NONE   0 /* strictly no calling of external programs */

Definition at line 31 of file run_command.h.

◆ SSEC_PW_ENV

#define SSEC_PW_ENV   3 /* allow calling of built-in programs and user-defined scripts that may receive a password as an environmental variable */

Definition at line 34 of file run_command.h.

◆ SSEC_SCRIPTS

#define SSEC_SCRIPTS   2 /* allow calling of built-in programs and user-defined scripts */

Definition at line 33 of file run_command.h.

Function Documentation

◆ openvpn_execve_allowed()

bool openvpn_execve_allowed ( const unsigned int  flags)

Definition at line 110 of file run_command.c.

References S_SCRIPT, script_security(), SSEC_BUILT_IN, and SSEC_SCRIPTS.

Referenced by openvpn_execve().

◆ openvpn_execve_check()

int openvpn_execve_check ( const struct argv a,
const struct env_set es,
const unsigned int  flags,
const char *  error_message 
)

◆ openvpn_popen()

int openvpn_popen ( const struct argv a,
const struct env_set es 
)

◆ openvpn_run_script()

static int openvpn_run_script ( const struct argv a,
const struct env_set es,
const unsigned int  flags,
const char *  hook 
)
inlinestatic

◆ script_security()

int script_security ( void  )

◆ script_security_set()

void script_security_set ( int  level)

Definition at line 49 of file run_command.c.

References script_security_level.

Referenced by add_option().