OpenVPN
Data Structures | Macros | Functions | Variables
misc.h File Reference
#include "argv.h"
#include "basic.h"
#include "common.h"
#include "env_set.h"
#include "integer.h"
#include "buffer.h"
#include "platform.h"
Include dependency graph for misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  user_pass
 
struct  auth_challenge_info
 
struct  static_challenge_info
 

Macros

#define INETD_SOCKET_DESCRIPTOR   0
 
#define USER_PASS_LEN   128
 
#define CR_ECHO   (1<<0) /* echo response when typed by user */
 
#define CR_RESPONSE   (1<<1) /* response needed */
 
#define SC_ECHO   (1<<0) /* echo response when typed by user */
 
#define GET_USER_PASS_MANAGEMENT   (1<<0)
 
#define GET_USER_PASS_PASSWORD_ONLY   (1<<2)
 
#define GET_USER_PASS_NEED_OK   (1<<3)
 
#define GET_USER_PASS_NOFATAL   (1<<4)
 
#define GET_USER_PASS_NEED_STR   (1<<5)
 
#define GET_USER_PASS_PREVIOUS_CREDS_FAILED   (1<<6)
 
#define GET_USER_PASS_DYNAMIC_CHALLENGE   (1<<7) /* CRV1 protocol -- dynamic challenge */
 
#define GET_USER_PASS_STATIC_CHALLENGE   (1<<8) /* SCRV1 protocol -- static challenge */
 
#define GET_USER_PASS_STATIC_CHALLENGE_ECHO   (1<<9) /* SCRV1 protocol -- echo response */
 
#define GET_USER_PASS_INLINE_CREDS   (1<<10) /* indicates that auth_file is actually inline creds */
 

Functions

void set_std_files_to_null (bool stdin_only)
 
void save_inetd_socket_descriptor (void)
 
const char ** make_arg_array (const char *first, const char *parms, struct gc_arena *gc)
 
const char ** make_extended_arg_array (char **p, struct gc_arena *gc)
 
const char * hostname_randomize (const char *hostname, struct gc_arena *gc)
 
struct auth_challenge_infoget_auth_challenge (const char *auth_challenge, struct gc_arena *gc)
 
bool get_user_pass_cr (struct user_pass *up, const char *auth_file, const char *prefix, const unsigned int flags, const char *auth_challenge)
 
static bool get_user_pass (struct user_pass *up, const char *auth_file, const char *prefix, const unsigned int flags)
 
void fail_user_pass (const char *prefix, const unsigned int flags, const char *reason)
 
void purge_user_pass (struct user_pass *up, const bool force)
 
void set_auth_token (struct user_pass *up, struct user_pass *tk, const char *token)
 
const char * safe_print (const char *str, struct gc_arena *gc)
 
void configure_path (void)
 
const char * sanitize_control_message (const char *str, struct gc_arena *gc)
 
bool validate_peer_info_line (char *line)
 
void output_peer_info_env (struct env_set *es, const char *peer_info)
 

Variables

int inetd_socket_descriptor
 

Macro Definition Documentation

◆ CR_ECHO

#define CR_ECHO   (1<<0) /* echo response when typed by user */

Definition at line 83 of file misc.h.

Referenced by get_auth_challenge(), and get_user_pass_cr().

◆ CR_RESPONSE

#define CR_RESPONSE   (1<<1) /* response needed */

Definition at line 84 of file misc.h.

Referenced by get_auth_challenge().

◆ GET_USER_PASS_DYNAMIC_CHALLENGE

#define GET_USER_PASS_DYNAMIC_CHALLENGE   (1<<7) /* CRV1 protocol -- dynamic challenge */

Definition at line 120 of file misc.h.

Referenced by auth_user_pass_setup(), and get_user_pass_cr().

◆ GET_USER_PASS_INLINE_CREDS

#define GET_USER_PASS_INLINE_CREDS   (1<<10) /* indicates that auth_file is actually inline creds */

Definition at line 124 of file misc.h.

Referenced by get_user_pass_cr(), and get_user_pass_http().

◆ GET_USER_PASS_MANAGEMENT

#define GET_USER_PASS_MANAGEMENT   (1<<0)

◆ GET_USER_PASS_NEED_OK

#define GET_USER_PASS_NEED_OK   (1<<3)

Definition at line 115 of file misc.h.

Referenced by context_init_1(), get_user_pass_cr(), man_io_error(), and management_query_user_pass().

◆ GET_USER_PASS_NEED_STR

#define GET_USER_PASS_NEED_STR   (1<<5)

Definition at line 117 of file misc.h.

Referenced by management_query_user_pass().

◆ GET_USER_PASS_NOFATAL

#define GET_USER_PASS_NOFATAL   (1<<4)

Definition at line 116 of file misc.h.

Referenced by get_user_pass_cr().

◆ GET_USER_PASS_PASSWORD_ONLY

#define GET_USER_PASS_PASSWORD_ONLY   (1<<2)

◆ GET_USER_PASS_PREVIOUS_CREDS_FAILED

#define GET_USER_PASS_PREVIOUS_CREDS_FAILED   (1<<6)

Definition at line 118 of file misc.h.

Referenced by get_user_pass_cr(), and get_user_pass_http().

◆ GET_USER_PASS_STATIC_CHALLENGE

#define GET_USER_PASS_STATIC_CHALLENGE   (1<<8) /* SCRV1 protocol -- static challenge */

Definition at line 121 of file misc.h.

Referenced by auth_user_pass_setup(), and get_user_pass_cr().

◆ GET_USER_PASS_STATIC_CHALLENGE_ECHO

#define GET_USER_PASS_STATIC_CHALLENGE_ECHO   (1<<9) /* SCRV1 protocol -- echo response */

Definition at line 122 of file misc.h.

Referenced by auth_user_pass_setup(), get_user_pass_cr(), and management_query_user_pass().

◆ INETD_SOCKET_DESCRIPTOR

#define INETD_SOCKET_DESCRIPTOR   0

Definition at line 36 of file misc.h.

Referenced by save_inetd_socket_descriptor().

◆ SC_ECHO

#define SC_ECHO   (1<<0) /* echo response when typed by user */

Definition at line 98 of file misc.h.

Referenced by add_option(), and auth_user_pass_setup().

◆ USER_PASS_LEN

#define USER_PASS_LEN   128

Function Documentation

◆ configure_path()

void configure_path ( void  )

Referenced by get_user_pass().

◆ fail_user_pass()

void fail_user_pass ( const char *  prefix,
const unsigned int  flags,
const char *  reason 
)

Referenced by get_user_pass().

◆ get_auth_challenge()

struct auth_challenge_info* get_auth_challenge ( const char *  auth_challenge,
struct gc_arena gc 
)

◆ get_user_pass()

static bool get_user_pass ( struct user_pass up,
const char *  auth_file,
const char *  prefix,
const unsigned int  flags 
)
inlinestatic

◆ get_user_pass_cr()

bool get_user_pass_cr ( struct user_pass up,
const char *  auth_file,
const char *  prefix,
const unsigned int  flags,
const char *  auth_challenge 
)

◆ hostname_randomize()

const char* hostname_randomize ( const char *  hostname,
struct gc_arena gc 
)

Definition at line 104 of file misc.c.

References alloc_buf_gc(), BSTR, buf_printf(), format_hex_ex(), n_rnd_bytes, and prng_bytes().

Referenced by openvpn_getaddrinfo().

◆ make_arg_array()

const char** make_arg_array ( const char *  first,
const char *  parms,
struct gc_arena gc 
)

Definition at line 507 of file misc.c.

References ALLOC_ARRAY_CLEAR_GC, ASSERT, M_WARN, MAX_PARMS, parse_line(), and string_alloc().

Referenced by make_extended_arg_array().

◆ make_extended_arg_array()

const char** make_extended_arg_array ( char **  p,
struct gc_arena gc 
)

◆ output_peer_info_env()

void output_peer_info_env ( struct env_set es,
const char *  peer_info 
)

◆ purge_user_pass()

void purge_user_pass ( struct user_pass up,
const bool  force 
)

◆ safe_print()

const char* safe_print ( const char *  str,
struct gc_arena gc 
)

Definition at line 501 of file misc.c.

References CC_CRLF, CC_PRINT, and string_mod_const().

Referenced by get_user_pass(), and options_warning_safe_scan2().

◆ sanitize_control_message()

const char* sanitize_control_message ( const char *  str,
struct gc_arena gc 
)

◆ save_inetd_socket_descriptor()

void save_inetd_socket_descriptor ( void  )

Definition at line 85 of file misc.c.

References INETD_SOCKET_DESCRIPTOR, inetd_socket_descriptor, M_ERR, msg, and set_std_files_to_null().

Referenced by add_option().

◆ set_auth_token()

void set_auth_token ( struct user_pass up,
struct user_pass tk,
const char *  token 
)

◆ set_std_files_to_null()

void set_std_files_to_null ( bool  stdin_only)

Definition at line 58 of file misc.c.

Referenced by open_syslog(), possibly_become_daemon(), and save_inetd_socket_descriptor().

◆ validate_peer_info_line()

bool validate_peer_info_line ( char *  line)

Definition at line 679 of file misc.c.

Referenced by get_user_pass(), management_notify_generic(), and output_peer_info_env().

Variable Documentation

◆ inetd_socket_descriptor

int inetd_socket_descriptor

Definition at line 82 of file misc.c.

Referenced by link_socket_init_phase1(), and save_inetd_socket_descriptor().