Go to the documentation of this file.
66 const char *reason = NULL;
67 if (authfail_extended &&
BLEN(&buf))
110 #ifdef ENABLE_MANAGEMENT
118 if (authfail_extended
150 for (i = 1; m[i] !=
'\0' && m[i] !=
']'; ++i)
156 else if (m[i] ==
'N')
181 #ifdef ENABLE_MANAGEMENT
217 #ifdef ENABLE_MANAGEMENT
238 #ifdef ENABLE_MANAGEMENT
255 msg(
D_PUSH_ERRORS,
"WARNING: Received INFO command is too long, won't notify management client.");
261 msg(
D_PUSH,
"Info command was pushed by server ('%s')", m);
274 #ifdef ENABLE_MANAGEMENT
286 msg(
D_PUSH,
"CR response was sent by client ('%s')", m);
298 unsigned int *server_timeout)
306 #ifdef ENABLE_MANAGEMENT
310 "", NULL, NULL, NULL, NULL);
320 #ifdef ENABLE_MANAGEMENT
326 BSTR(&buf), NULL, NULL, NULL, NULL);
330 while (
buf_parse(&buf,
',', line,
sizeof(line)))
332 if (sscanf(line,
"timeout %u", server_timeout) != 1)
334 msg(
D_PUSH,
"ignoring AUTH_PENDING parameter: %s", line);
357 msg(
D_PUSH,
"AUTH_PENDING received, extending handshake timeout from %us "
359 min_uint(max_timeout, server_timeout));
380 int msglevel,
const char *fmt, ...)
382 #if __USE_MINGW_ANSI_STDIO
405 static const char auth_failed[] =
"AUTH_FAILED";
408 len = (client_reason ? strlen(client_reason)+1 : 0) +
sizeof(auth_failed);
440 const char *extra,
unsigned int timeout)
444 static const char info_pre[] =
"INFO_PRE,";
453 max_timeout = max_timeout - (
now - ks->
initial);
454 timeout =
min_uint(max_timeout, timeout);
463 static const char auth_pre[] =
"AUTH_PENDING,timeout ";
466 size_t len = 20 + 1 +
sizeof(auth_pre);
473 size_t len = strlen(extra) + 1 +
sizeof(info_pre);
509 unsigned int option_types_found = 0;
515 &option_types_found);
697 int client_max_mtu = 0;
700 if (iv_mtu && sscanf(iv_mtu,
"%d", &client_max_mtu) == 1)
703 if (client_max_mtu < o->ce.tun_mtu)
705 msg(
M_WARN,
"Warning: reported maximum MTU from client (%d) is lower "
706 "than MTU used on the server (%d). Add tun-max-mtu %d "
707 "to client configuration.", client_max_mtu,
718 bool *push_sent,
bool *multi_push)
726 const int l = strlen(e->
option);
727 if (
BLEN(buf) + l >= safe_cap)
742 if (
BLEN(buf) + l >= safe_cap)
744 msg(
M_WARN,
"--push option is too long");
779 bool multi_push =
false;
780 const int extra = 84;
781 const int safe_cap =
BCAP(&buf) - extra;
782 bool push_sent =
false;
788 &push_sent, &multi_push))
795 &push_sent, &multi_push))
841 const char *opt,
bool enable,
int msglevel)
845 msg(msglevel,
"PUSH OPTION FAILED (illegal comma (',') in string): '%s'", opt);
900 int msglevel,
const char *format, ...)
905 va_start(arglist, format);
906 len = vsnprintf(tmp,
sizeof(tmp), format, arglist);
908 if (len >
sizeof(tmp)-1)
928 if (
streq(p,
"ifconfig"))
935 if (
streq( p,
"ifconfig-ipv6" ))
949 && strncmp( e->
option, p, strlen(p) ) == 0)
1010 while (
buf_parse(buf,
',', line,
sizeof(line)))
1030 unsigned int permission_mask,
1031 unsigned int *option_types_found,
1038 struct buffer buf_orig = (*buf);
1072 else if (ch ==
'\0')
1083 bool honor_received_options,
1084 unsigned int permission_mask,
1085 unsigned int *option_types_found)
1094 else if (honor_received_options
1098 option_types_found, &buf);
1130 if (p[0] && !strcmp(p[0],
"route") && !p[3] && o->
iroutes)
1133 bool status1, status2;
1138 if (status1 && status2)
1153 else if (p[0] && !strcmp(p[0],
"route-ipv6") && !p[2]
1157 struct in6_addr network;
1158 unsigned int netbits;
bool pulled_options_digest_init_done
static void parse_auth_pending_keywords(const struct buffer *buffer, unsigned int *server_timeout)
Parse the keyword for the AUTH_PENDING request.
unsigned int pull_permission_mask(const struct context *c)
char * auth_token
If server sends a generated auth-token, this is the token to use for future user/pass authentications...
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)
static unsigned int min_uint(unsigned int x, unsigned int y)
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...
#define PUSH_MSG_REQUEST_DEFERRED
void verify_crresponse_script(struct tls_multi *multi, const char *cr_response)
Runs the –client-crresponse script if one is defined.
static int process_incoming_push_reply(struct context *c, unsigned int permission_mask, unsigned int *option_types_found, struct buffer *buf)
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.
static struct gc_arena gc_new(void)
void push_remove_option(struct options *o, const char *p)
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
int len
Length in bytes of the actual content within the allocated memory.
struct push_list push_list
mbedtls_md_context_t md_ctx_t
Generic message digest context.
void management_auth_failure(struct management *man, const char *type, const char *reason)
#define KS_PRIMARY
Primary key state index.
Contains all state information for one tunnel.
void receive_auth_pending(struct context *c, const struct buffer *buffer)
Parses an AUTH_PENDING message and if in pull mode extends the timeout.
struct tls_session session[TM_SIZE]
Array of tls_session objects representing control channel sessions with the remote peer.
struct in6_addr push_ifconfig_ipv6_local
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 push_options(struct options *o, char **p, int msglevel, struct gc_arena *gc)
const char ** make_extended_arg_array(char **p, bool is_inline, struct gc_arena *gc)
@ TLS_AUTHENTICATION_SUCCEEDED
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
bool push_ifconfig_defined
void remove_iroutes_from_push_route_list(struct options *o)
in_addr_t push_ifconfig_local
int parse_line(const char *line, char *p[], const int n, const char *file, const int line_num, int msglevel, struct gc_arena *gc)
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.
struct connection_entry ce
static const char * tls_client_reason(struct tls_multi *multi)
md_ctx_t * pulled_options_state
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)
interval_t renegotiate_seconds
bool do_up(struct context *c, bool pulled_options, unsigned int option_types_found)
Security parameter state for a single VPN tunnel.
md_ctx_t * md_ctx_new(void)
const char * parse_auth_failed_temp(struct options *o, const char *reason)
@ CAS_FAILED
Option import failed or explicitly denied the client.
void push_reset(struct options *o)
Security parameter state of one TLS and data channel key session.
bool push_request_received
static void buf_reset_len(struct buffer *buf)
void management_notify_generic(struct management *man, const char *str)
struct event_timeout wait_for_connect
enum multi_status multi_state
struct context_2 c2
Level 2 context.
bool options_postprocess_pull(struct options *o, struct env_set *es)
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.
struct in6_addr push_ifconfig_ipv6_remote
void md_ctx_final(md_ctx_t *ctx, uint8_t *dst)
void push_option(struct options *o, const char *opt, int msglevel)
#define TM_ACTIVE
Active tls_session.
char * string_alloc(const char *str, struct gc_arena *gc)
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.
const char * print_in6_addr(struct in6_addr a6, unsigned int flags, struct gc_arena *gc)
void send_auth_failed(struct context *c, const char *client_reason)
static bool buf_advance(struct buffer *buf, int size)
static void push_option_ex(struct gc_arena *gc, struct push_list *push_list, const char *opt, bool enable, int msglevel)
void management_notify(struct management *man, const char *severity, const char *type, const char *text)
#define PUSH_MSG_ALREADY_REPLIED
bool ssl_clean_auth_token(void)
void ssl_put_auth_challenge(const char *cr_str)
bool schedule_exit(struct context *c)
bool send_push_request(struct context *c)
void clone_push_list(struct options *o)
unsigned int imported_protocol_flags
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.
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 server_pushed_signal(struct context *c, const struct buffer *buffer, const bool restart, const int adv)
bool push_ifconfig_ipv6_blocked
void reschedule_multi_process(struct context *c)
Reschedule tls_multi_process.
void md_ctx_cleanup(md_ctx_t *ctx)
#define ALLOC_OBJ_CLEAR_GC(dptr, type, gc)
struct options options
Options loaded from command line or configuration file.
void verify_crresponse_plugin(struct tls_multi *multi, const char *cr_response)
Call the plugin OPENVPN_PLUGIN_CLIENT_CRRESPONSE.
#define PUSH_MSG_AUTH_FAILURE
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.
in_addr_t push_ifconfig_local_alias
static void push_update_digest(md_ctx_t *ctx, struct buffer *buf, const struct options *opt)
@ TLS_AUTHENTICATION_FAILED
int push_ifconfig_ipv6_netbits
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)
Wrapper structure for dynamically allocated memory.
time_t sent_push_reply_expiry
void md_ctx_update(md_ctx_t *ctx, const uint8_t *src, int src_len)
time_t push_request_timeout
void md_ctx_init(md_ctx_t *ctx, const char *mdname)
Initialises the given message digest context.
#define CO_USE_DYNAMIC_TLS_CRYPT
Bit-flag indicating that renegotiations are using tls-crypt with a TLS-EKM derived key.
const char * print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc)
#define CC_ANY
any character
Security parameter state of a single session within a VPN tunnel.
bool push_ifconfig_ipv4_blocked
#define IV_PROTO_AUTH_PENDING_KW
Supports signaling keywords with AUTH_PENDING, e.g.
Garbage collection arena used to keep track of dynamically allocated memory.
struct signal_info * sig
Internal error signaling object.
struct iroute_ipv6 * next
bool string_class(const char *str, const unsigned int inclusive, const unsigned int exclusive)
bool send_control_channel_string_dowork(struct tls_session *session, const char *str, int msglevel)
uint8_t digest[SHA256_DIGEST_LENGTH]
static bool strprefix(const char *str, const char *prefix)
Return true iff str starts with prefix.
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.
bool buf_string_match_head_str(const struct buffer *src, const char *match)
void md_ctx_free(md_ctx_t *ctx)
#define OPENVPN_STATE_AUTH_PENDING
static int buf_len(const struct buffer *buf)
#define GETADDR_HOST_ORDER
void send_restart(struct context *c, const char *kill_msg)
static time_t openvpn_time(time_t *t)
bool buf_string_compare_advance(struct buffer *src, const char *match)
static in_addr_t netbits_to_netmask(const int netbits)
void ssl_purge_auth(const bool auth_user_pass_only)
void receive_exit_message(struct context *c)
static SERVICE_STATUS status
in_addr_t push_ifconfig_remote_netmask
static void gc_free(struct gc_arena *a)
void server_pushed_info(struct context *c, const struct buffer *buffer, const int adv)
bool prepare_push_reply(struct context *c, struct gc_arena *gc, struct push_list *push_list)
Prepare push options, based on local options.
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.
struct sha256_digest pulled_options_digest
time_t auth_deferred_expire
const char * sanitize_control_message(const char *src, struct gc_arena *gc)
struct event_timeout push_request_interval
static char push_reply_cmd[]
#define TM_INITIAL
As yet un-trusted tls_session being negotiated.
static char * buf_str(const struct buffer *buf)
unsigned int push_option_types_found
void receive_auth_failed(struct context *c, const struct buffer *buffer)
void receive_cr_response(struct context *c, const struct buffer *buffer)
static int buf_read_u8(struct buffer *buf)
bool push_ifconfig_ipv6_defined
bool apply_push_options(struct options *options, struct buffer *buf, unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es)
struct iroute_ipv6 * iroutes_ipv6
bool send_push_reply(struct context *c, struct push_list *per_client_push_list)
static void event_timeout_clear(struct event_timeout *et)
Clears the timeout and reset all values to 0.
static unsigned int max_uint(unsigned int x, unsigned int y)
char * print_argv(const char **p, struct gc_arena *gc, const unsigned int flags)
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...
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.
#define PUSH_MSG_CONTINUATION
#define CO_USE_TLS_KEY_MATERIAL_EXPORT
Bit-flag indicating that data channel key derivation is done using TLS keying material export [RFC570...
const char * ifconfig_local
void incoming_push_message(struct context *c, const struct buffer *buffer)
#define CO_USE_CC_EXIT_NOTIFY
Bit-flag indicating that explicit exit notifies should be sent via the control channel instead of usi...
bool buf_printf(struct buffer *buf, const char *format,...)
int process_incoming_push_request(struct context *c)
bool send_control_channel_string(struct context *c, const char *str, int msglevel)
bool buf_parse(struct buffer *buf, const int delim, char *line, const int size)
static int cleanup(void **state)