18 msg(
M_WARN,
"Offending option received from server");
45 unsigned int permission_mask,
unsigned int *option_types_found,
50 while (
buf_parse(buf,
',', line,
sizeof(line)))
52 unsigned int push_update_option_flags = 0;
58 while (isspace(line[
i]))
83 bool honor_received_options,
unsigned int permission_mask,
84 unsigned int *option_types_found)
112#ifndef ENABLE_MANAGEMENT
157 "PUSH_UPDATE,dhcp-option DNS 8.8.8.8, route 0.0.0.0 0.0.0.0 10.10.10.1";
159 unsigned int option_types_found = 0;
162 &option_types_found),
173 const char *
update_msg =
"PUSH_UPDATEerr,dhcp-option DNS 8.8.8.8";
175 unsigned int option_types_found = 0;
178 &option_types_found),
189 const char *
update_msg =
"PUSH_UPDATE ,dhcp-option DNS 8.8.8.8";
191 unsigned int option_types_found = 0;
194 &option_types_found),
205 const char *
update_msg =
"PUSH_UPDATE, -?dns, route something, ?dhcp-option DNS 8.8.8.8";
207 unsigned int option_types_found = 0;
210 &option_types_found),
221 const char *
update_msg =
"PUSH_UPDATE, -dhcp-option, ?-dns";
223 unsigned int option_types_found = 0;
226 &option_types_found),
237 const char *
update_msg =
"PUSH_UPDATE, dev tun";
239 unsigned int option_types_found = 0;
242 &option_types_found),
254 "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";
256 unsigned int option_types_found = 0;
259 &option_types_found),
271 "PUSH_UPDATE,-dhcp-option,dhcp-option DNS 8.8.8.8,redirect-gateway local,route 192.168.1.0 255.255.255.0";
273 unsigned int option_types_found = 0;
276 &option_types_found),
282#ifdef ENABLE_MANAGEMENT
284 "PUSH_UPDATE,redirect-gateway local,route 192.168.1.0 255.255.255.0"
287 "PUSH_UPDATE,-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,push-continuation 2",
288 "PUSH_UPDATE, akakakakakakakakakakakaf, dhcp-option DNS 8.8.8.8,redirect-gateway local,push-continuation 2",
289 "PUSH_UPDATE,route 192.168.1.0 255.255.255.0,push-continuation 1"
295 "PUSH_UPDATE,-dhcp-option, blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,push-continuation 2",
296 "PUSH_UPDATE, akakakakakakakakakakakaf,dhcp-option DNS 8.8.8.8, redirect-gateway local,push-continuation 2",
297 "PUSH_UPDATE, route 192.168.1.0 255.255.255.0,,push-continuation 1"
300 "PUSH_UPDATE,,-dhcp-option, blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,push-continuation 2",
301 "PUSH_UPDATE, akakakakakakakakakakakaf,dhcp-option DNS 8.8.8.8, redirect-gateway local,push-continuation 2",
302 "PUSH_UPDATE, route 192.168.1.0 255.255.255.0,push-continuation 1"
305 "PUSH_UPDATE,-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,push-continuation 2",
306 "PUSH_UPDATE, akakakakakakakakakakakaf, dhcp-option DNS 8.8.8.8, redirect-gateway 10.10.10.10,,push-continuation 2",
307 "PUSH_UPDATE, route 192.168.1.0 255.255.255.0,,push-continuation 1"
310 "PUSH_UPDATE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,push-continuation 2",
311 "PUSH_UPDATE,,,,,,,,,,,,,,,,,,,push-continuation 1"
314 "PUSH_UPDATE,-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,push-continuation 2",
315 "PUSH_UPDATE, akakakakakakakakakakakaf, dhcp-option DNS 8.8.8.8,redirect-gateway\n local,push-continuation 2",
316 "PUSH_UPDATE,route 192.168.1.0 255.255.255.0\n\n\n,push-continuation 1"
323const char *
msg0 =
"redirect-gateway local,route 192.168.1.0 255.255.255.0";
324const char *
msg1 =
"-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,"
325 " akakakakakakakakakakakaf, dhcp-option DNS 8.8.8.8,redirect-gateway local,route 192.168.1.0 255.255.255.0";
328const char *
msg4 =
"-dhcp-option, blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,"
329 " akakakakakakakakakakakaf,dhcp-option DNS 8.8.8.8, redirect-gateway local, route 192.168.1.0 255.255.255.0,";
330const char *
msg5 =
",-dhcp-option, blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf,"
331 " akakakakakakakakakakakaf,dhcp-option DNS 8.8.8.8, redirect-gateway local, route 192.168.1.0 255.255.255.0";
332const char *
msg6 =
"-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf, akakakakakakakakakakakaf,"
333 " dhcp-option DNS 8.8.8.8, redirect-gateway 10.10.10.10,, route 192.168.1.0 255.255.255.0,";
334const char *
msg7 =
",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,";
335const char *
msg8 =
"-dhcp-option,blablalalalalalalalalalalalalf, lalalalalalalalalalalalalalaf, akakakakakakakakakakakaf,"
336 " dhcp-option DNS 8.8.8.8,redirect-gateway\n local,route 192.168.1.0 255.255.255.0\n\n\n";
339const char *
msg10 =
"abandon ability able about above absent absorb abstract absurd abuse access accident account accuse achieve"
340 "acid acoustic acquire across act action actor actress actual adapt add addict address adjust"
341 "baby bachelor bacon badge bag balance balcony ball bamboo banana banner bar barely bargain barrel base basic"
342 "basket battle beach bean beauty because become beef before begin behave behind"
343 "cabbage cabin cable cactus cage cake call calm camera camp can canal cancel candy cannon canoe canvas canyon"
344 "capable capital captain car carbon card cargo carpet carry cart case"
345 "daisy damage damp dance danger daring dash daughter dawn day deal debate debris decade december decide decline"
346 "decorate decrease deer defense define defy degree delay deliver demand demise denial";
348#define PUSH_BUNDLE_SIZE_TEST 184
356 const unsigned long cid = 0;
365 const unsigned long cid = 0;
375 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;
459#undef PUSH_BUNDLE_SIZE_TEST
504 const struct CMUnitTest tests[] = {
514#ifdef ENABLE_MANAGEMENT
529 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 send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const int push_bundle_size)
A function to send a PUSH_UPDATE control message from server to client(s).
#define PUSH_OPT_OPTIONAL
int process_incoming_push_update(struct context *c, 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.
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
Contains all state information for one tunnel.
struct options options
Options loaded from command line or configuration file.
Main OpenVPN server state structure.
struct multi_instance ** instances
Array of multi_instances.
Server-mode state structure for one single 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)
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)
void update_vhash(struct multi_context *m, struct multi_instance *mi, const char *old_ip, const char *old_ipv6)
Update the vhash with new IP/IPv6 addresses in the multi_context when a push-update message containin...
static void test_send_push_msg6(void **state)
static void test_send_push_msg7(void **state)
bool send_control_channel_string(struct context *c, const char *str, int msglevel)
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)
static void test_incoming_push_message_not_updatable_option(void **state)
#define PUSH_BUNDLE_SIZE_TEST
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.