OpenVPN
Functions
platform.c File Reference
#include "syshead.h"
#include "openvpn.h"
#include "options.h"
#include "buffer.h"
#include "crypto.h"
#include "error.h"
#include "misc.h"
#include "win32.h"
#include "memdbg.h"
#include "platform.h"
#include <direct.h>
Include dependency graph for platform.c:

Go to the source code of this file.

Functions

void platform_chroot (const char *path)
 
bool platform_user_get (const char *username, struct platform_state_user *state)
 
static void platform_user_set (const struct platform_state_user *state)
 
bool platform_group_get (const char *groupname, struct platform_state_group *state)
 
static void platform_group_set (const struct platform_state_group *state)
 
static int need_keep_caps (struct context *c)
 
void platform_user_group_set (const struct platform_state_user *user_state, const struct platform_state_group *group_state, struct context *c)
 
void platform_nice (int niceval)
 
unsigned int platform_getpid (void)
 
void platform_mlockall (bool print_msg)
 
int platform_chdir (const char *dir)
 
bool platform_system_ok (int stat)
 interpret the status code returned by execve() More...
 
int platform_ret_code (int stat)
 Return an exit code if valid and between 0 and 255, -1 otherwise. More...
 
int platform_access (const char *path, int mode)
 
void platform_sleep_milliseconds (unsigned int n)
 
void platform_sleep_until_signal (void)
 
bool platform_unlink (const char *filename)
 
FILE * platform_fopen (const char *path, const char *mode)
 
int platform_open (const char *path, int flags, int mode)
 
int platform_stat (const char *path, platform_stat_t *buf)
 
const char * platform_create_temp_file (const char *directory, const char *prefix, struct gc_arena *gc)
 Create a temporary file in directory, returns the filename of the created file. More...
 
const char * platform_gen_path (const char *directory, const char *filename, struct gc_arena *gc)
 Put a directory and filename together. More...
 
bool platform_absolute_pathname (const char *pathname)
 Return true if pathname is absolute. More...
 
bool platform_test_file (const char *filename)
 Return true if filename can be opened for read. More...
 

Function Documentation

◆ need_keep_caps()

static int need_keep_caps ( struct context c)
static

Definition at line 184 of file platform.c.

References dco_enabled(), and context::options.

Referenced by platform_user_group_set().

◆ platform_absolute_pathname()

bool platform_absolute_pathname ( const char *  pathname)

Return true if pathname is absolute.

Definition at line 654 of file platform.c.

Referenced by plugin_init_item().

◆ platform_access()

int platform_access ( const char *  path,
int  mode 
)

Definition at line 458 of file platform.c.

References gc_free(), gc_new(), and wide_string().

Referenced by check_file_access().

◆ platform_chdir()

int platform_chdir ( const char *  dir)

Definition at line 393 of file platform.c.

References gc_free(), gc_new(), and wide_string().

Referenced by add_option(), do_init_first_time(), and platform_chroot().

◆ platform_chroot()

void platform_chroot ( const char *  path)

Definition at line 55 of file platform.c.

References M_ERR, M_FATAL, M_INFO, msg, and platform_chdir().

Referenced by do_uid_gid_chroot().

◆ platform_create_temp_file()

const char* platform_create_temp_file ( const char *  directory,
const char *  prefix,
struct gc_arena gc 
)

◆ platform_fopen()

FILE* platform_fopen ( const char *  path,
const char *  mode 
)

◆ platform_gen_path()

const char* platform_gen_path ( const char *  directory,
const char *  filename,
struct gc_arena gc 
)

◆ platform_getpid()

unsigned int platform_getpid ( void  )

Definition at line 333 of file platform.c.

Referenced by man_dispatch_command(), setenv_settings(), and write_pid_file().

◆ platform_group_get()

bool platform_group_get ( const char *  groupname,
struct platform_state_group state 
)

Definition at line 123 of file platform.c.

References CLEAR, M_ERR, M_FATAL, and msg.

Referenced by do_init_first_time(), and man_settings_init().

◆ platform_group_set()

static void platform_group_set ( const struct platform_state_group state)
static

Definition at line 150 of file platform.c.

References M_ERR, M_INFO, and msg.

Referenced by platform_user_group_set().

◆ platform_mlockall()

void platform_mlockall ( bool  print_msg)

Definition at line 344 of file platform.c.

References M_ERRNO, M_FATAL, M_INFO, M_WARN, and msg.

Referenced by do_genkey(), and init_instance().

◆ platform_nice()

void platform_nice ( int  niceval)

Definition at line 311 of file platform.c.

References M_ERRNO, M_INFO, M_WARN, and msg.

Referenced by do_init_first_time().

◆ platform_open()

int platform_open ( const char *  path,
int  flags,
int  mode 
)

◆ platform_ret_code()

int platform_ret_code ( int  stat)

Return an exit code if valid and between 0 and 255, -1 otherwise.

Definition at line 425 of file platform.c.

Referenced by openvpn_execve_check().

◆ platform_sleep_milliseconds()

void platform_sleep_milliseconds ( unsigned int  n)

Definition at line 474 of file platform.c.

Referenced by x_check_status().

◆ platform_sleep_until_signal()

void platform_sleep_until_signal ( void  )

Definition at line 490 of file platform.c.

References ASSERT.

◆ platform_stat()

int platform_stat ( const char *  path,
platform_stat_t buf 
)

Definition at line 540 of file platform.c.

References gc_free(), gc_new(), and wide_string().

Referenced by buffer_read_from_file(), check_file_access(), and tls_ctx_reload_crl().

◆ platform_system_ok()

bool platform_system_ok ( int  stat)

interpret the status code returned by execve()

Definition at line 414 of file platform.c.

Referenced by openvpn_execve_check().

◆ platform_test_file()

bool platform_test_file ( const char *  filename)

Return true if filename can be opened for read.

Definition at line 673 of file platform.c.

References D_TEST_FILE, dmsg, M_ERRNO, M_WARN, msg, and platform_fopen().

Referenced by multi_client_connect_post(), multi_client_connect_source_ccd(), and verify_final_auth_checks().

◆ platform_unlink()

bool platform_unlink ( const char *  filename)

◆ platform_user_get()

bool platform_user_get ( const char *  username,
struct platform_state_user state 
)

Definition at line 79 of file platform.c.

References CLEAR, M_ERR, M_FATAL, and msg.

Referenced by do_init_first_time(), and man_settings_init().

◆ platform_user_group_set()

void platform_user_group_set ( const struct platform_state_user user_state,
const struct platform_state_group group_state,
struct context c 
)

◆ platform_user_set()

static void platform_user_set ( const struct platform_state_user state)
static

Definition at line 106 of file platform.c.

References M_ERR, M_INFO, and msg.

Referenced by platform_user_group_set().