20 msg(
M_WARN,
"Offending option received from server");
59 unsigned int permission_mask,
unsigned int *option_types_found,
64 while (
buf_parse(buf,
',', line,
sizeof(line)))
66 unsigned int push_update_option_flags = 0;
72 while (isspace(line[
i]))
97 bool honor_received_options,
unsigned int permission_mask,
98 unsigned int *option_types_found)
126#ifndef ENABLE_MANAGEMENT
177 "PUSH_UPDATE,dhcp-option DNS 8.8.8.8, route 0.0.0.0 0.0.0.0 10.10.10.1";
179 unsigned int option_types_found = 0;
182 &option_types_found),
193 const char *
update_msg =
"PUSH_UPDATEerr,dhcp-option DNS 8.8.8.8";
195 unsigned int option_types_found = 0;
198 &option_types_found),
209 const char *
update_msg =
"PUSH_UPDATE ,dhcp-option DNS 8.8.8.8";
211 unsigned int option_types_found = 0;
214 &option_types_found),
225 const char *
update_msg =
"PUSH_UPDATE, -?dns, route something, ?dhcp-option DNS 8.8.8.8";
227 unsigned int option_types_found = 0;
230 &option_types_found),
241 const char *
update_msg =
"PUSH_UPDATE, -dhcp-option, ?-dns";
243 unsigned int option_types_found = 0;
246 &option_types_found),
257 const char *
update_msg =
"PUSH_UPDATE, dev tun";
259 unsigned int option_types_found = 0;
262 &option_types_found),
274 "PUSH_UPDATE,-dhcp-option, route 10.10.10.0, dhcp-option DNS 1.1.1.1, route 10.11.12.0, dhcp-option DOMAIN corp.local, keepalive 10 60";
276 unsigned int option_types_found = 0;
279 &option_types_found),
291 "PUSH_UPDATE,-dhcp-option,dhcp-option DNS 8.8.8.8,redirect-gateway local,route 192.168.1.0 255.255.255.0";
293 unsigned int option_types_found = 0;
296 &option_types_found),
302#ifdef ENABLE_MANAGEMENT
304 "PUSH_UPDATE,redirect-gateway local,route 192.168.1.0 255.255.255.0"
307 "PUSH_UPDATE,-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,push-continuation 2",
308 "PUSH_UPDATE, akakakakakakakakakakakaf, dhcp-option DNS 8.8.8.8,redirect-gateway local,push-continuation 2",
309 "PUSH_UPDATE,route 192.168.1.0 255.255.255.0,push-continuation 1"
315 "PUSH_UPDATE,-dhcp-option, blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,push-continuation 2",
316 "PUSH_UPDATE, akakakakakakakakakakakaf,dhcp-option DNS 8.8.8.8, redirect-gateway local,push-continuation 2",
317 "PUSH_UPDATE, route 192.168.1.0 255.255.255.0,,push-continuation 1"
320 "PUSH_UPDATE,,-dhcp-option, blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,push-continuation 2",
321 "PUSH_UPDATE, akakakakakakakakakakakaf,dhcp-option DNS 8.8.8.8, redirect-gateway local,push-continuation 2",
322 "PUSH_UPDATE, route 192.168.1.0 255.255.255.0,push-continuation 1"
325 "PUSH_UPDATE,-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,push-continuation 2",
326 "PUSH_UPDATE, akakakakakakakakakakakaf, dhcp-option DNS 8.8.8.8, redirect-gateway 10.10.10.10,,push-continuation 2",
327 "PUSH_UPDATE, route 192.168.1.0 255.255.255.0,,push-continuation 1"
330 "PUSH_UPDATE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,push-continuation 2",
331 "PUSH_UPDATE,,,,,,,,,,,,,,,,,,,push-continuation 1"
334 "PUSH_UPDATE,-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,push-continuation 2",
335 "PUSH_UPDATE, akakakakakakakakakakakaf, dhcp-option DNS 8.8.8.8,redirect-gateway\n local,push-continuation 2",
336 "PUSH_UPDATE,route 192.168.1.0 255.255.255.0\n\n\n,push-continuation 1"
343const char *
msg0 =
"redirect-gateway local,route 192.168.1.0 255.255.255.0";
344const char *
msg1 =
"-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,"
345 " akakakakakakakakakakakaf, dhcp-option DNS 8.8.8.8,redirect-gateway local,route 192.168.1.0 255.255.255.0";
348const char *
msg4 =
"-dhcp-option, blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,"
349 " akakakakakakakakakakakaf,dhcp-option DNS 8.8.8.8, redirect-gateway local, route 192.168.1.0 255.255.255.0,";
350const char *
msg5 =
",-dhcp-option, blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,"
351 " akakakakakakakakakakakaf,dhcp-option DNS 8.8.8.8, redirect-gateway local, route 192.168.1.0 255.255.255.0";
352const char *
msg6 =
"-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf, akakakakakakakakakakakaf,"
353 " dhcp-option DNS 8.8.8.8, redirect-gateway 10.10.10.10,, route 192.168.1.0 255.255.255.0,";
354const char *
msg7 =
",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,";
355const char *
msg8 =
"-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf, akakakakakakakakakakakaf,"
356 " dhcp-option DNS 8.8.8.8,redirect-gateway\n local,route 192.168.1.0 255.255.255.0\n\n\n";
359const char *
msg10 =
"abandon ability able about above absent absorb abstract absurd abuse access accident account accuse achieve"
360 "acid acoustic acquire across act action actor actress actual adapt add addict address adjust"
361 "baby bachelor bacon badge bag balance balcony ball bamboo banana banner bar barely bargain barrel base basic"
362 "basket battle beach bean beauty because become beef before begin behave behind"
363 "cabbage cabin cable cactus cage cake call calm camera camp can canal cancel candy cannon canoe canvas canyon"
364 "capable capital captain car carbon card cargo carpet carry cart case"
365 "daisy damage damp dance danger daring dash daughter dawn day deal debate debris decade december decide decline"
366 "decorate decrease deer defense define defy degree delay deliver demand demise denial";
368#define PUSH_BUNDLE_SIZE_TEST 184
376 const unsigned long cid = 0;
385 const unsigned long cid = 0;
395 const unsigned long cid = 0;
405 const unsigned long cid = 0;
415 const unsigned long cid = 0;
425 const unsigned long cid = 0;
435 const unsigned long cid = 0;
445 const unsigned long cid = 0;
455 const unsigned long cid = 0;
465 const unsigned long cid = 0;
475 const unsigned long cid = 0;
479#undef PUSH_BUNDLE_SIZE_TEST
498 free((*(m->
instances))->context.c2.tls_multi);
527 const struct CMUnitTest tests[] = {
537#ifdef ENABLE_MANAGEMENT
552 return cmocka_run_group_tests(tests, NULL, NULL);
bool buf_string_compare_advance(struct buffer *src, const char *match)
void free_buf(struct buffer *buf)
struct buffer alloc_buf(size_t size)
bool buf_parse(struct buffer *buf, const int delim, char *line, const int size)
static bool buf_write(struct buffer *dest, const void *src, size_t size)
Header file for server-mode related structures and functions.
#define OPT_P_NCP
Negotiable crypto parameters.
#define OPT_P_EXPLICIT_NOTIFY
#define OPT_P_ROUTE_EXTRAS
bool check_push_update_option_flags(char *line, int *i, unsigned int *flags)
Checks the formatting and validity of options inside push-update messages.
bool apply_pull_filter(const struct options *o, char *line)
Filter an option line by all pull filters.
int process_push_update(struct context *c, struct options *o, unsigned int permission_mask, unsigned int *option_types_found, struct buffer *buf, bool msg_sender)
Handles the receiving of a push-update message and applies updates to the specified options.
#define PUSH_OPT_OPTIONAL
static int send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const size_t push_bundle_size)
A function to send a PUSH_UPDATE control message from server to client(s).
#define IV_PROTO_PUSH_UPDATE
Supports push-update.
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
Contains all state information for one tunnel.
struct context_2 c2
Level 2 context.
struct options options
Options loaded from command line or configuration file.
Main OpenVPN server state structure.
struct context top
Storage structure for process-wide configuration.
struct multi_instance ** instances
Array of multi_instances.
Server-mode state structure for one single VPN tunnel.
struct context context
The context structure storing state for this VPN tunnel.
struct pull_filter_list * pull_filter_list
Security parameter state for a single VPN tunnel.
bool options_postprocess_pull(struct options *options, struct env_set *es)
static void test_send_push_msg2(void **state)
bool send_control_channel_string(struct context *c, const char *str, msglvl_t msglevel)
static int teardown(void **state)
static void test_send_push_msg9(void **state)
void throw_signal_soft(const int signum, const char *signal_text)
Throw a soft global signal.
static void test_send_push_msg4(void **state)
static void test_send_push_msg1(void **state)
bool mroute_extract_openvpn_sockaddr(struct mroute_addr *addr, const struct openvpn_sockaddr *osaddr, bool use_port)
static void test_send_push_msg3(void **state)
static void test_send_push_msg0(void **state)
static void test_send_push_msg8(void **state)
struct multi_instance * lookup_by_cid(struct multi_context *m, const unsigned long cid)
static int teardown2(void **state)
static void test_incoming_push_message_bad_format(void **state)
static void test_send_push_msg6(void **state)
static void test_send_push_msg7(void **state)
static void test_incoming_push_message_error2(void **state)
static void test_send_push_msg5(void **state)
static int setup2(void **state)
bool apply_push_options(struct context *c, struct options *options, struct buffer *buf, unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es, bool is_update)
static void test_send_push_msg10(void **state)
static void test_incoming_push_message_mix(void **state)
static int setup(void **state)
static void test_incoming_push_message_basic(void **state)
static void test_incoming_push_message_1(void **state)
static void test_incoming_push_message_error1(void **state)
static void test_incoming_push_message_mix2(void **state)
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 unlearn_ifconfig_ipv6(struct multi_context *m, struct multi_instance *mi)
void unlearn_ifconfig(struct multi_context *m, struct multi_instance *mi)
static void test_incoming_push_message_not_updatable_option(void **state)
#define PUSH_BUNDLE_SIZE_TEST
void update_vhash(struct multi_context *m, struct multi_instance *mi, const char *new_ip, const char *new_ipv6)
Update the vhash with new IP/IPv6 addresses in the multi_context when a push-update message containin...
unsigned int pull_permission_mask(const struct context *c)
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)
const char * tls_common_name(const struct tls_multi *multi, const bool null)
Returns the common name field for the given tunnel.