88 c->options.no_advance =
true;
112#ifdef ENABLE_MANAGEMENT
152 for (
i = 1;
m[
i] !=
'\0' &&
m[
i] !=
']'; ++
i)
158 else if (
m[
i] ==
'N')
161 c->options.no_advance =
false;
183#ifdef ENABLE_MANAGEMENT
219#ifdef ENABLE_MANAGEMENT
239#ifdef ENABLE_MANAGEMENT
256 msg(
D_PUSH_ERRORS,
"WARNING: Received INFO command is too long, won't notify management client.");
262 msg(
D_PUSH,
"Info command was pushed by server ('%s')",
m);
275#ifdef ENABLE_MANAGEMENT
287 msg(
D_PUSH,
"CR response was sent by client ('%s')", m);
299 unsigned int *server_timeout)
307#ifdef ENABLE_MANAGEMENT
321#ifdef ENABLE_MANAGEMENT
343 if (!
c->options.pull)
351 c->options.handshake_window);
358 msg(
D_PUSH,
"AUTH_PENDING received, extending handshake timeout from %us "
359 "to %us",
c->options.handshake_window,
381 int msglevel,
const char *fmt, ...)
383#if __USE_MINGW_ANSI_STDIO
406 static const char auth_failed[] =
"AUTH_FAILED";
409 len = (client_reason ? strlen(client_reason)+1 : 0) +
sizeof(auth_failed);
441 const char *
extra,
unsigned int timeout)
445 static const char info_pre[] =
"INFO_PRE,";
454 max_timeout = max_timeout - (
now - ks->
initial);
455 timeout =
min_uint(max_timeout, timeout);
464 static const char auth_pre[] =
"AUTH_PENDING,timeout ";
467 size_t len = 20 + 1 +
sizeof(auth_pre);
510 unsigned int option_types_found = 0;
516 &option_types_found);
711 msg(
M_WARN,
"Warning: reported maximum MTU from client (%d) is lower "
712 "than MTU used on the server (%d). Add tun-max-mtu %d "
714 o->ce.tun_mtu,
o->ce.tun_mtu);
732 const int l = strlen(e->
option);
733 if (
BLEN(buf) + l >= safe_cap)
748 if (
BLEN(buf) + l >= safe_cap)
750 msg(
M_WARN,
"--push option is too long");
786 const int extra = 84;
847 const char *opt,
bool enable,
int msglevel)
851 msg(msglevel,
"PUSH OPTION FAILED (illegal comma (',') in string): '%s'", opt);
906 int msglevel,
const char *format, ...)
911 va_start(arglist, format);
912 len = vsnprintf(tmp,
sizeof(tmp), format, arglist);
914 if (len >
sizeof(tmp)-1)
934 if (
streq(p,
"ifconfig"))
941 if (
streq( p,
"ifconfig-ipv6" ))
955 && strncmp( e->
option, p, strlen(p) ) == 0)
1016 while (
buf_parse(buf,
',', line,
sizeof(line)))
1036 unsigned int permission_mask,
1037 unsigned int *option_types_found,
1045 if (!
c->c2.pulled_options_digest_init_done)
1049 c->c2.pulled_options_digest_init_done =
true;
1059 switch (
c->options.push_continuation)
1064 c->c2.pulled_options_digest.digest);
1067 c->c2.pulled_options_state =
NULL;
1068 c->c2.pulled_options_digest_init_done =
false;
1078 else if (ch ==
'\0')
1091 unsigned int *option_types_found)
1097 c->c2.push_request_received =
true;
1104 option_types_found, &buf);
1119 if (
o &&
o->push_list.head && (
o->iroutes ||
o->iroutes_ipv6))
1136 if (p[0] && !strcmp(p[0],
"route") && !p[3] && o->
iroutes)
1139 bool status1, status2;
1144 if (status1 && status2)
1159 else if (p[0] && !strcmp(p[0],
"route-ipv6") && !p[2]
1163 struct in6_addr network;
1164 unsigned int netbits;
bool buf_string_compare_advance(struct buffer *src, const char *match)
bool buf_printf(struct buffer *buf, const char *format,...)
bool string_class(const char *str, const unsigned int inclusive, const unsigned int exclusive)
char * print_argv(const char **p, struct gc_arena *gc, const unsigned int flags)
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
bool buf_parse(struct buffer *buf, const int delim, char *line, const int size)
char * string_alloc(const char *str, struct gc_arena *gc)
bool buf_string_match_head_str(const struct buffer *src, const char *match)
#define CC_ANY
any character
static bool buf_advance(struct buffer *buf, int size)
static int buf_len(const struct buffer *buf)
#define ALLOC_OBJ_CLEAR_GC(dptr, type, gc)
static int buf_read_u8(struct buffer *buf)
static void buf_reset_len(struct buffer *buf)
static void gc_free(struct gc_arena *a)
static char * buf_str(const struct buffer *buf)
static bool strprefix(const char *str, const char *prefix)
Return true iff str starts with prefix.
static struct gc_arena gc_new(void)
Data Channel Cryptography Module.
#define CO_USE_TLS_KEY_MATERIAL_EXPORT
Bit-flag indicating that data channel key derivation is done using TLS keying material export [RFC570...
#define CO_USE_DYNAMIC_TLS_CRYPT
Bit-flag indicating that renegotiations are using tls-crypt with a TLS-EKM derived key.
#define CO_EPOCH_DATA_KEY_FORMAT
Bit-flag indicating the epoch the data format.
#define CO_USE_CC_EXIT_NOTIFY
Bit-flag indicating that explicit exit notifies should be sent via the control channel instead of usi...
md_ctx_t * md_ctx_new(void)
void md_ctx_update(md_ctx_t *ctx, const uint8_t *src, int src_len)
void md_ctx_cleanup(md_ctx_t *ctx)
void md_ctx_final(md_ctx_t *ctx, uint8_t *dst)
void md_ctx_init(md_ctx_t *ctx, const char *mdname)
Initialises the given message digest context.
void md_ctx_free(md_ctx_t *ctx)
mbedtls_md_context_t md_ctx_t
Generic message digest context.
void reschedule_multi_process(struct context *c)
Reschedule tls_multi_process.
bool send_control_channel_string_dowork(struct tls_session *session, const char *str, int msglevel)
bool schedule_exit(struct context *c)
bool send_control_channel_string(struct context *c, const char *str, int msglevel)
#define TM_INITIAL
As yet un-trusted tls_session being negotiated.
#define KS_PRIMARY
Primary key state index.
#define TM_ACTIVE
Active tls_session.
bool do_up(struct context *c, bool pulled_options, unsigned int option_types_found)
unsigned int pull_permission_mask(const struct context *c)
static unsigned int min_uint(unsigned int x, unsigned int y)
static unsigned int max_uint(unsigned int x, unsigned int y)
static SERVICE_STATUS status
static void event_timeout_clear(struct event_timeout *et)
Clears the timeout and reset all values to 0.
void management_auth_failure(struct management *man, const char *type, const char *reason)
void management_set_state(struct management *man, const int state, const char *detail, const in_addr_t *tun_local_ip, const struct in6_addr *tun_local_ip6, const struct openvpn_sockaddr *local, const struct openvpn_sockaddr *remote)
void management_notify_generic(struct management *man, const char *str)
void management_notify_client_cr_response(unsigned mda_key_id, const struct man_def_auth_context *mdac, const struct env_set *es, const char *response)
void management_notify(struct management *man, const char *severity, const char *type, const char *text)
#define OPENVPN_STATE_AUTH_PENDING
const char ** make_extended_arg_array(char **p, bool is_inline, struct gc_arena *gc)
const char * sanitize_control_message(const char *src, struct gc_arena *gc)
bool options_postprocess_pull(struct options *o, struct env_set *es)
bool apply_push_options(struct options *options, struct buffer *buf, unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es)
int parse_line(const char *line, char *p[], const int n, const char *file, const int line_num, int msglevel, struct gc_arena *gc)
const char * parse_auth_failed_temp(struct options *o, const char *reason)
static time_t openvpn_time(time_t *t)
int process_incoming_push_request(struct context *c)
void receive_auth_pending(struct context *c, const struct buffer *buffer)
Parses an AUTH_PENDING message and if in pull mode extends the timeout.
static bool push_option_fmt(struct gc_arena *gc, struct push_list *push_list, int msglevel, const char *fmt,...)
Add an option to the given push list by providing a format string.
void receive_auth_failed(struct context *c, const struct buffer *buffer)
void send_restart(struct context *c, const char *kill_msg)
void push_option(struct options *o, const char *opt, int msglevel)
void server_pushed_signal(struct context *c, const struct buffer *buffer, const bool restart, const int adv)
void push_reset(struct options *o)
void receive_cr_response(struct context *c, const struct buffer *buffer)
void send_auth_failed(struct context *c, const char *client_reason)
static char push_reply_cmd[]
void clone_push_list(struct options *o)
void receive_exit_message(struct context *c)
void prepare_auth_token_push_reply(struct tls_multi *tls_multi, struct gc_arena *gc, struct push_list *push_list)
Prepare push option for auth-token.
static int process_incoming_push_reply(struct context *c, unsigned int permission_mask, unsigned int *option_types_found, struct buffer *buf)
bool send_push_request(struct context *c)
static void push_option_ex(struct gc_arena *gc, struct push_list *push_list, const char *opt, bool enable, int msglevel)
bool send_auth_pending_messages(struct tls_multi *tls_multi, struct tls_session *session, const char *extra, unsigned int timeout)
Sends the auth pending control messages to a client.
void push_remove_option(struct options *o, const char *p)
void incoming_push_message(struct context *c, const struct buffer *buffer)
void push_options(struct options *o, char **p, int msglevel, struct gc_arena *gc)
bool prepare_push_reply(struct context *c, struct gc_arena *gc, struct push_list *push_list)
Prepare push options, based on local options.
static void push_update_digest(md_ctx_t *ctx, struct buffer *buf, const struct options *opt)
static bool send_push_options(struct context *c, struct buffer *buf, struct push_list *push_list, int safe_cap, bool *push_sent, bool *multi_push)
void remove_iroutes_from_push_route_list(struct options *o)
static void parse_auth_pending_keywords(const struct buffer *buffer, unsigned int *server_timeout)
Parse the keyword for the AUTH_PENDING request.
int process_incoming_push_msg(struct context *c, const struct buffer *buffer, bool honor_received_options, unsigned int permission_mask, unsigned int *option_types_found)
bool send_push_reply(struct context *c, struct push_list *per_client_push_list)
void server_pushed_info(const struct buffer *buffer, const int adv)
void send_push_reply_auth_token(struct tls_multi *multi)
Sends a push reply message only containin the auth-token to update the auth-token on the client.
#define PUSH_MSG_REQUEST_DEFERRED
#define PUSH_MSG_AUTH_FAILURE
#define PUSH_MSG_CONTINUATION
#define PUSH_MSG_ALREADY_REPLIED
static in_addr_t netbits_to_netmask(const int netbits)
void register_signal(struct signal_info *si, int signum, const char *signal_text)
Register a soft signal in the signal_info struct si respecting priority.
bool get_ipv6_addr(const char *hostname, struct in6_addr *network, unsigned int *netbits, int msglevel)
Translate an IPv6 addr or hostname from string form to in6_addr.
const char * print_in6_addr(struct in6_addr a6, unsigned int flags, struct gc_arena *gc)
const char * print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc)
in_addr_t getaddr(unsigned int flags, const char *hostname, int resolve_retry_seconds, bool *succeeded, struct signal_info *sig_info)
Translate an IPv4 addr or hostname from string form to in_addr_t.
#define GETADDR_HOST_ORDER
void ssl_purge_auth(const bool auth_user_pass_only)
void ssl_put_auth_challenge(const char *cr_str)
bool ssl_clean_auth_token(void)
Control Channel SSL/Data channel negotiation module.
#define IV_PROTO_AUTH_PENDING_KW
Supports signaling keywords with AUTH_PENDING, e.g.
@ CAS_FAILED
Option import failed or explicitly denied the client.
static const struct key_state * get_primary_key(const struct tls_multi *multi)
gets an item of key_state objects in the order they should be scanned by data channel modules.
bool tls_peer_supports_ncp(const char *peer_info)
Returns whether the client supports NCP either by announcing IV_NCP>=2 or the IV_CIPHERS list.
Control Channel SSL/Data dynamic negotiation Module This file is split from ssl.h to be able to unit ...
char * extract_var_peer_info(const char *peer_info, const char *var, struct gc_arena *gc)
Extracts a variable from peer info, the returned string will be allocated using the supplied gc_arena...
unsigned int extract_iv_proto(const char *peer_info)
Extracts the IV_PROTO variable and returns its value or 0 if it cannot be extracted.
void verify_crresponse_plugin(struct tls_multi *multi, const char *cr_response)
Call the plugin OPENVPN_PLUGIN_CLIENT_CRRESPONSE.
enum tls_auth_status tls_authentication_status(struct tls_multi *multi)
Return current session authentication state of the tls_multi structure This will return TLS_AUTHENTIC...
void verify_crresponse_script(struct tls_multi *multi, const char *cr_response)
Runs the –client-crresponse script if one is defined.
Control Channel Verification Module.
@ TLS_AUTHENTICATION_SUCCEEDED
@ TLS_AUTHENTICATION_FAILED
static const char * tls_client_reason(struct tls_multi *multi)
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
bool push_ifconfig_ipv6_defined
bool push_ifconfig_defined
time_t push_request_timeout
struct event_timeout wait_for_connect
struct event_timeout push_request_interval
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
time_t sent_push_reply_expiry
struct in6_addr push_ifconfig_ipv6_remote
int push_ifconfig_ipv6_netbits
struct in6_addr push_ifconfig_ipv6_local
in_addr_t push_ifconfig_local_alias
in_addr_t push_ifconfig_remote_netmask
in_addr_t push_ifconfig_local
Contains all state information for one tunnel.
struct signal_info * sig
Internal error signaling object.
struct context_2 c2
Level 2 context.
struct options options
Options loaded from command line or configuration file.
Garbage collection arena used to keep track of dynamically allocated memory.
struct iroute_ipv6 * next
Security parameter state of one TLS and data channel key session.
time_t auth_deferred_expire
unsigned int push_option_types_found
bool push_ifconfig_ipv6_blocked
const char * ifconfig_local
struct connection_entry ce
struct iroute_ipv6 * iroutes_ipv6
struct push_list push_list
bool push_ifconfig_ipv4_blocked
Security parameter state for a single VPN tunnel.
enum multi_status multi_state
struct tls_session session[TM_SIZE]
Array of tls_session objects representing control channel sessions with the remote peer.
char * auth_token
If server sends a generated auth-token, this is the token to use for future user/pass authentications...
interval_t renegotiate_seconds
Security parameter state of a single session within a VPN tunnel.
static int cleanup(void **state)