OpenVPN
push.c
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single TCP/UDP port, with support for SSL/TLS-based
4  * session authentication and key exchange,
5  * packet encryption, packet authentication, and
6  * packet compression.
7  *
8  * Copyright (C) 2002-2024 OpenVPN Inc <sales@openvpn.net>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2
12  * as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27 
28 #include "syshead.h"
29 
30 #include "push.h"
31 #include "options.h"
32 #include "ssl.h"
33 #include "ssl_verify.h"
34 #include "ssl_ncp.h"
35 #include "manage.h"
36 
37 #include "memdbg.h"
38 #include "ssl_util.h"
39 #include "options_util.h"
40 
41 static char push_reply_cmd[] = "PUSH_REPLY";
42 
43 /*
44  * Auth username/password
45  *
46  * Client received an authentication failed message from server.
47  * Runs on client.
48  */
49 void
50 receive_auth_failed(struct context *c, const struct buffer *buffer)
51 {
52  msg(M_VERB0, "AUTH: Received control message: %s", BSTR(buffer));
53  c->options.no_advance = true;
54 
55  if (!c->options.pull)
56  {
57  return;
58  }
59 
60  struct buffer buf = *buffer;
61 
62  /* If the AUTH_FAIL message ends with a , it is an extended message that
63  * contains further flags */
64  bool authfail_extended = buf_string_compare_advance(&buf, "AUTH_FAILED,");
65 
66  const char *reason = NULL;
67  if (authfail_extended && BLEN(&buf))
68  {
69  reason = BSTR(&buf);
70  }
71 
72  if (authfail_extended && buf_string_match_head_str(&buf, "TEMP"))
73  {
74  parse_auth_failed_temp(&c->options, reason + strlen("TEMP"));
75  register_signal(c->sig, SIGUSR1, "auth-temp-failure (server temporary reject)");
76  }
77 
78  /* Before checking how to react on AUTH_FAILED, first check if the
79  * failed auth might be the result of an expired auth-token.
80  * Note that a server restart will trigger a generic AUTH_FAILED
81  * instead an AUTH_FAILED,SESSION so handle all AUTH_FAILED message
82  * identical for this scenario */
83  else if (ssl_clean_auth_token())
84  {
85  /* SOFT-SIGUSR1 -- Auth failure error */
86  register_signal(c->sig, SIGUSR1, "auth-failure (auth-token)");
87  c->options.no_advance = true;
88  }
89  else
90  {
91  switch (auth_retry_get())
92  {
93  case AR_NONE:
94  /* SOFT-SIGTERM -- Auth failure error */
95  register_signal(c->sig, SIGTERM, "auth-failure");
96  break;
97 
98  case AR_INTERACT:
99  ssl_purge_auth(false);
100 
101  case AR_NOINTERACT:
102  /* SOFT-SIGTUSR1 -- Auth failure error */
103  register_signal(c->sig, SIGUSR1, "auth-failure");
104  break;
105 
106  default:
107  ASSERT(0);
108  }
109  }
110 #ifdef ENABLE_MANAGEMENT
111  if (management)
112  {
114  }
115  /*
116  * Save the dynamic-challenge text even when management is defined
117  */
118  if (authfail_extended
119  && buf_string_match_head_str(&buf, "CRV1:") && BLEN(&buf))
120  {
122  }
123 #endif /* ifdef ENABLE_MANAGEMENT */
124 
125 }
126 
127 /*
128  * Act on received restart message from server
129  */
130 void
131 server_pushed_signal(struct context *c, const struct buffer *buffer, const bool restart, const int adv)
132 {
133  if (c->options.pull)
134  {
135  struct buffer buf = *buffer;
136  const char *m = "";
137  if (buf_advance(&buf, adv) && buf_read_u8(&buf) == ',' && BLEN(&buf))
138  {
139  m = BSTR(&buf);
140  }
141 
142  /* preserve cached passwords? */
143  /* advance to next server? */
144  {
145  bool purge = true;
146 
147  if (m[0] == '[')
148  {
149  int i;
150  for (i = 1; m[i] != '\0' && m[i] != ']'; ++i)
151  {
152  if (m[i] == 'P')
153  {
154  purge = false;
155  }
156  else if (m[i] == 'N')
157  {
158  /* next server? */
159  c->options.no_advance = false;
160  }
161  }
162  }
163  if (purge)
164  {
165  ssl_purge_auth(true);
166  }
167  }
168 
169  if (restart)
170  {
171  msg(D_STREAM_ERRORS, "Connection reset command was pushed by server ('%s')", m);
172  /* SOFT-SIGUSR1 -- server-pushed connection reset */
173  register_signal(c->sig, SIGUSR1, "server-pushed-connection-reset");
174  }
175  else
176  {
177  msg(D_STREAM_ERRORS, "Halt command was pushed by server ('%s')", m);
178  /* SOFT-SIGTERM -- server-pushed halt */
179  register_signal(c->sig, SIGTERM, "server-pushed-halt");
180  }
181 #ifdef ENABLE_MANAGEMENT
182  if (management)
183  {
184  management_notify(management, "info", c->sig->signal_text, m);
185  }
186 #endif
187  }
188 }
189 
190 void
192 {
193  dmsg(D_STREAM_ERRORS, "CC-EEN exit message received by peer");
194  /* With control channel exit notification, we want to give the session
195  * enough time to handle retransmits and acknowledgment, so that eventual
196  * retries from the client to resend the exit or ACKs will not trigger
197  * a new session (we already forgot the session but the packet's HMAC
198  * is still valid). This could happen for the entire period that the
199  * HMAC timeslot is still valid, but waiting five seconds here does not
200  * hurt much, takes care of the retransmits, and is easier code-wise.
201  *
202  * This does not affect OCC exit since the HMAC session code will
203  * ignore DATA packets
204  * */
205  if (c->options.mode == MODE_SERVER)
206  {
207  if (!schedule_exit(c))
208  {
209  /* Return early when we don't need to notify management */
210  return;
211  }
212  }
213  else
214  {
215  register_signal(c->sig, SIGUSR1, "remote-exit");
216  }
217 #ifdef ENABLE_MANAGEMENT
218  if (management)
219  {
220  management_notify(management, "info", "remote-exit", "EXIT");
221  }
222 #endif
223 }
224 
225 
226 void
227 server_pushed_info(struct context *c, const struct buffer *buffer,
228  const int adv)
229 {
230  const char *m = "";
231  struct buffer buf = *buffer;
232 
233  if (buf_advance(&buf, adv) && buf_read_u8(&buf) == ',' && BLEN(&buf))
234  {
235  m = BSTR(&buf);
236  }
237 
238 #ifdef ENABLE_MANAGEMENT
239  struct gc_arena gc;
240  if (management)
241  {
242  gc = gc_new();
243 
244  /*
245  * We use >INFOMSG here instead of plain >INFO since INFO is used to
246  * for management greeting and we don't want to confuse the client
247  */
248  struct buffer out = alloc_buf_gc(256, &gc);
249  if (buf_printf(&out, ">%s:%s", "INFOMSG", m))
250  {
252  }
253  else
254  {
255  msg(D_PUSH_ERRORS, "WARNING: Received INFO command is too long, won't notify management client.");
256  }
257 
258  gc_free(&gc);
259  }
260  #endif
261  msg(D_PUSH, "Info command was pushed by server ('%s')", m);
262 }
263 
264 void
265 receive_cr_response(struct context *c, const struct buffer *buffer)
266 {
267  struct buffer buf = *buffer;
268  const char *m = "";
269 
270  if (buf_advance(&buf, 11) && buf_read_u8(&buf) == ',' && BLEN(&buf))
271  {
272  m = BSTR(&buf);
273  }
274 #ifdef ENABLE_MANAGEMENT
276  struct man_def_auth_context *mda = session->opt->mda_context;
277  struct env_set *es = session->opt->es;
278  unsigned int mda_key_id = get_primary_key(c->c2.tls_multi)->mda_key_id;
279 
280  management_notify_client_cr_response(mda_key_id, mda, es, m);
281 #endif
282 #if ENABLE_PLUGIN
284 #endif
286  msg(D_PUSH, "CR response was sent by client ('%s')", m);
287 }
288 
296 static void
298  unsigned int *server_timeout)
299 {
300  struct buffer buf = *buffer;
301 
302  /* does the buffer start with "AUTH_PENDING," ? */
303  if (!buf_advance(&buf, strlen("AUTH_PENDING"))
304  || !(buf_read_u8(&buf) == ',') || !BLEN(&buf))
305  {
306 #ifdef ENABLE_MANAGEMENT
307  if (management)
308  {
310  "", NULL, NULL, NULL, NULL);
311  }
312 #endif
313 
314  return;
315  }
316 
317  /* parse the keywords in the same way that push options are parsed */
318  char line[OPTION_LINE_SIZE];
319 
320 #ifdef ENABLE_MANAGEMENT
321  /* Need to do the management notification with the keywords before
322  * buf_parse is called, as it will insert \0 bytes into the buffer */
323  if (management)
324  {
326  BSTR(&buf), NULL, NULL, NULL, NULL);
327  }
328 #endif
329 
330  while (buf_parse(&buf, ',', line, sizeof(line)))
331  {
332  if (sscanf(line, "timeout %u", server_timeout) != 1)
333  {
334  msg(D_PUSH, "ignoring AUTH_PENDING parameter: %s", line);
335  }
336  }
337 }
338 
339 void
340 receive_auth_pending(struct context *c, const struct buffer *buffer)
341 {
342  if (!c->options.pull)
343  {
344  return;
345  }
346 
347  /* Cap the increase at the maximum time we are willing stay in the
348  * pending authentication state */
349  unsigned int max_timeout = max_uint(c->options.renegotiate_seconds/2,
351 
352  /* try to parse parameter keywords, default to hand-winow timeout if the
353  * server does not supply a timeout */
354  unsigned int server_timeout = c->options.handshake_window;
355  parse_auth_pending_keywords(buffer, &server_timeout);
356 
357  msg(D_PUSH, "AUTH_PENDING received, extending handshake timeout from %us "
358  "to %us", c->options.handshake_window,
359  min_uint(max_timeout, server_timeout));
360 
361  const struct key_state *ks = get_primary_key(c->c2.tls_multi);
362  c->c2.push_request_timeout = ks->established + min_uint(max_timeout, server_timeout);
363 }
364 
379 static bool push_option_fmt(struct gc_arena *gc, struct push_list *push_list,
380  int msglevel, const char *fmt, ...)
381 #ifdef __GNUC__
382 #if __USE_MINGW_ANSI_STDIO
383 __attribute__ ((format(gnu_printf, 4, 5)))
384 #else
385 __attribute__ ((format(__printf__, 4, 5)))
386 #endif
387 #endif
388 ;
389 
390 /*
391  * Send auth failed message from server to client.
392  *
393  * Does nothing if an exit is already scheduled
394  */
395 void
396 send_auth_failed(struct context *c, const char *client_reason)
397 {
398  if (!schedule_exit(c))
399  {
400  msg(D_TLS_DEBUG, "exit already scheduled for context");
401  return;
402  }
403 
404  struct gc_arena gc = gc_new();
405  static const char auth_failed[] = "AUTH_FAILED";
406  size_t len;
407 
408  len = (client_reason ? strlen(client_reason)+1 : 0) + sizeof(auth_failed);
409  if (len > PUSH_BUNDLE_SIZE)
410  {
411  len = PUSH_BUNDLE_SIZE;
412  }
413 
414  {
415  struct buffer buf = alloc_buf_gc(len, &gc);
416  buf_printf(&buf, auth_failed);
417  if (client_reason)
418  {
419  buf_printf(&buf, ",%s", client_reason);
420  }
421 
422  /* We kill the whole session, send the AUTH_FAILED to any TLS session
423  * that might be active */
425  BSTR(&buf), D_PUSH);
427  BSTR(&buf), D_PUSH);
428 
430 
431  }
432 
433  gc_free(&gc);
434 }
435 
436 
437 bool
439  struct tls_session *session,
440  const char *extra, unsigned int timeout)
441 {
442  struct key_state *ks = &session->key[KS_PRIMARY];
443 
444  static const char info_pre[] = "INFO_PRE,";
445 
446  const char *const peer_info = tls_multi->peer_info;
447  unsigned int proto = extract_iv_proto(peer_info);
448 
449 
450  /* Calculate the maximum timeout and subtract the time we already waited */
451  unsigned int max_timeout = max_uint(tls_multi->opt.renegotiate_seconds/2,
453  max_timeout = max_timeout - (now - ks->initial);
454  timeout = min_uint(max_timeout, timeout);
455 
456  struct gc_arena gc = gc_new();
457  if ((proto & IV_PROTO_AUTH_PENDING_KW) == 0)
458  {
460  }
461  else
462  {
463  static const char auth_pre[] = "AUTH_PENDING,timeout ";
464  /* Assume a worst case of 8 byte uint64 in decimal which */
465  /* needs 20 bytes */
466  size_t len = 20 + 1 + sizeof(auth_pre);
467  struct buffer buf = alloc_buf_gc(len, &gc);
468  buf_printf(&buf, auth_pre);
469  buf_printf(&buf, "%u", timeout);
471  }
472 
473  size_t len = strlen(extra) + 1 + sizeof(info_pre);
474  if (len > PUSH_BUNDLE_SIZE)
475  {
476  gc_free(&gc);
477  return false;
478  }
479 
480  struct buffer buf = alloc_buf_gc(len, &gc);
481  buf_printf(&buf, info_pre);
482  buf_printf(&buf, "%s", extra);
484 
485  ks->auth_deferred_expire = now + timeout;
486 
487  gc_free(&gc);
488  return true;
489 }
490 
491 /*
492  * Send restart message from server to client.
493  */
494 void
495 send_restart(struct context *c, const char *kill_msg)
496 {
497  schedule_exit(c);
498  send_control_channel_string(c, kill_msg ? kill_msg : "RESTART", D_PUSH);
499 }
500 
501 /*
502  * Push/Pull
503  */
504 
505 void
506 incoming_push_message(struct context *c, const struct buffer *buffer)
507 {
508  struct gc_arena gc = gc_new();
509  unsigned int option_types_found = 0;
510 
511  msg(D_PUSH, "PUSH: Received control message: '%s'", sanitize_control_message(BSTR(buffer), &gc));
512 
515  &option_types_found);
516 
517  if (status == PUSH_MSG_ERROR)
518  {
519  msg(D_PUSH_ERRORS, "WARNING: Received bad push/pull message: %s", sanitize_control_message(BSTR(buffer), &gc));
520  }
522  {
523  c->options.push_option_types_found |= option_types_found;
524 
525  /* delay bringing tun/tap up until --push parms received from remote */
526  if (status == PUSH_MSG_REPLY)
527  {
528  if (!options_postprocess_pull(&c->options, c->c2.es))
529  {
530  goto error;
531  }
532  if (!do_up(c, true, c->options.push_option_types_found))
533  {
534  msg(D_PUSH_ERRORS, "Failed to open tun/tap interface");
535  goto error;
536  }
537  }
540  }
541 
542  goto cleanup;
543 
544 error:
545  register_signal(c->sig, SIGUSR1, "process-push-msg-failed");
546 cleanup:
547  gc_free(&gc);
548 }
549 
550 bool
552 {
553  const struct key_state *ks = get_primary_key(c->c2.tls_multi);
554 
555  /* We timeout here under two conditions:
556  * a) we reached the hard limit of push_request_timeout
557  * b) we have not seen anything from the server in hand_window time
558  *
559  * for non auth-pending scenario, push_request_timeout is the same as
560  * hand_window timeout. For b) every PUSH_REQUEST is a acknowledged by
561  * the server by a P_ACK_V1 packet that reset the keepalive timer
562  */
563 
564  if (c->c2.push_request_timeout > now
566  {
567  return send_control_channel_string(c, "PUSH_REQUEST", D_PUSH);
568  }
569  else
570  {
571  msg(D_STREAM_ERRORS, "No reply from server to push requests in %ds",
572  (int)(now - ks->established));
573  /* SOFT-SIGUSR1 -- server-pushed connection reset */
574  register_signal(c->sig, SIGUSR1, "no-push-reply");
575  return false;
576  }
577 }
578 
587 void
589  struct push_list *push_list)
590 {
591  /*
592  * If server uses --auth-gen-token and we have an auth token
593  * to send to the client
594  */
595  if (tls_multi->auth_token)
596  {
598  "auth-token %s",
600  }
601 }
602 
612 bool
613 prepare_push_reply(struct context *c, struct gc_arena *gc,
614  struct push_list *push_list)
615 {
616  struct tls_multi *tls_multi = c->c2.tls_multi;
617  struct options *o = &c->options;
618 
619  /* ipv6 */
621  {
622  push_option_fmt(gc, push_list, M_USAGE, "ifconfig-ipv6 %s/%d %s",
626  0, gc));
627  }
628 
629  /* ipv4 */
633  {
634  in_addr_t ifconfig_local = c->c2.push_ifconfig_local;
636  {
638  }
639  push_option_fmt(gc, push_list, M_USAGE, "ifconfig %s %s",
642  0, gc));
643  }
644 
645  if (tls_multi->use_peer_id)
646  {
647  push_option_fmt(gc, push_list, M_USAGE, "peer-id %d",
648  tls_multi->peer_id);
649  }
650  /*
651  * If server uses --auth-gen-token and we have an auth token
652  * to send to the client
653  */
655 
656  /*
657  * Push the selected cipher, at this point the cipher has been
658  * already negotiated and been fixed.
659  *
660  * We avoid pushing the cipher to clients not supporting NCP
661  * to avoid error messages in their logs
662  */
664  {
665  push_option_fmt(gc, push_list, M_USAGE, "cipher %s", o->ciphername);
666  }
667 
668  struct buffer proto_flags = alloc_buf_gc(128, gc);
669 
671  {
672  buf_printf(&proto_flags, " cc-exit");
673 
674  /* if the cc exit flag is supported, pushing tls-ekm via protocol-flags
675  * is also supported */
677  {
678  buf_printf(&proto_flags, " tls-ekm");
679  }
680  }
682  {
683  push_option_fmt(gc, push_list, M_USAGE, "key-derivation tls-ekm");
684  }
685 
687  {
688  buf_printf(&proto_flags, " dyn-tls-crypt");
689  }
690 
691  if (buf_len(&proto_flags) > 0)
692  {
693  push_option_fmt(gc, push_list, M_USAGE, "protocol-flags%s", buf_str(&proto_flags));
694  }
695 
696  /* Push our mtu to the peer if it supports pushable MTUs */
697  int client_max_mtu = 0;
698  const char *iv_mtu = extract_var_peer_info(tls_multi->peer_info, "IV_MTU=", gc);
699 
700  if (iv_mtu && sscanf(iv_mtu, "%d", &client_max_mtu) == 1)
701  {
702  push_option_fmt(gc, push_list, M_USAGE, "tun-mtu %d", o->ce.tun_mtu);
703  if (client_max_mtu < o->ce.tun_mtu)
704  {
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,
708  o->ce.tun_mtu, o->ce.tun_mtu);
709  }
710  }
711 
712  return true;
713 }
714 
715 static bool
716 send_push_options(struct context *c, struct buffer *buf,
717  struct push_list *push_list, int safe_cap,
718  bool *push_sent, bool *multi_push)
719 {
720  struct push_entry *e = push_list->head;
721 
722  while (e)
723  {
724  if (e->enable)
725  {
726  const int l = strlen(e->option);
727  if (BLEN(buf) + l >= safe_cap)
728  {
729  buf_printf(buf, ",push-continuation 2");
730  {
731  const bool status = send_control_channel_string(c, BSTR(buf), D_PUSH);
732  if (!status)
733  {
734  return false;
735  }
736  *push_sent = true;
737  *multi_push = true;
738  buf_reset_len(buf);
739  buf_printf(buf, "%s", push_reply_cmd);
740  }
741  }
742  if (BLEN(buf) + l >= safe_cap)
743  {
744  msg(M_WARN, "--push option is too long");
745  return false;
746  }
747  buf_printf(buf, ",%s", e->option);
748  }
749  e = e->next;
750  }
751  return true;
752 }
753 
754 void
756 {
757  struct gc_arena gc = gc_new();
758  struct push_list push_list = { 0 };
759  struct tls_session *session = &multi->session[TM_ACTIVE];
760 
762 
763  /* prepare auth token should always add the auth-token option */
764  struct push_entry *e = push_list.head;
765  ASSERT(e && e->enable);
766 
767  /* Construct a mimimal control channel push reply message */
768  struct buffer buf = alloc_buf_gc(PUSH_BUNDLE_SIZE, &gc);
769  buf_printf(&buf, "%s,%s", push_reply_cmd, e->option);
771  gc_free(&gc);
772 }
773 
774 bool
775 send_push_reply(struct context *c, struct push_list *per_client_push_list)
776 {
777  struct gc_arena gc = gc_new();
778  struct buffer buf = alloc_buf_gc(PUSH_BUNDLE_SIZE, &gc);
779  bool multi_push = false;
780  const int extra = 84; /* extra space for possible trailing ifconfig and push-continuation */
781  const int safe_cap = BCAP(&buf) - extra;
782  bool push_sent = false;
783 
784  buf_printf(&buf, "%s", push_reply_cmd);
785 
786  /* send options which are common to all clients */
787  if (!send_push_options(c, &buf, &c->options.push_list, safe_cap,
788  &push_sent, &multi_push))
789  {
790  goto fail;
791  }
792 
793  /* send client-specific options */
794  if (!send_push_options(c, &buf, per_client_push_list, safe_cap,
795  &push_sent, &multi_push))
796  {
797  goto fail;
798  }
799 
800  if (multi_push)
801  {
802  buf_printf(&buf, ",push-continuation 1");
803  }
804 
805  if (BLEN(&buf) > sizeof(push_reply_cmd)-1)
806  {
807  const bool status = send_control_channel_string(c, BSTR(&buf), D_PUSH);
808  if (!status)
809  {
810  goto fail;
811  }
812  push_sent = true;
813  }
814 
815  /* If nothing have been pushed, send an empty push,
816  * as the client is expecting a response
817  */
818  if (!push_sent)
819  {
820  bool status = false;
821 
822  buf_reset_len(&buf);
823  buf_printf(&buf, "%s", push_reply_cmd);
825  if (!status)
826  {
827  goto fail;
828  }
829  }
830 
831  gc_free(&gc);
832  return true;
833 
834 fail:
835  gc_free(&gc);
836  return false;
837 }
838 
839 static void
841  const char *opt, bool enable, int msglevel)
842 {
843  if (!string_class(opt, CC_ANY, CC_COMMA))
844  {
845  msg(msglevel, "PUSH OPTION FAILED (illegal comma (',') in string): '%s'", opt);
846  }
847  else
848  {
849  struct push_entry *e;
850  ALLOC_OBJ_CLEAR_GC(e, struct push_entry, gc);
851  e->enable = true;
852  e->option = opt;
853  if (push_list->head)
854  {
856  push_list->tail->next = e;
857  push_list->tail = e;
858  }
859  else
860  {
861  ASSERT(!push_list->tail);
862  push_list->head = e;
863  push_list->tail = e;
864  }
865  }
866 }
867 
868 void
869 push_option(struct options *o, const char *opt, int msglevel)
870 {
871  push_option_ex(&o->gc, &o->push_list, opt, true, msglevel);
872 }
873 
874 void
876 {
877  if (o->push_list.head)
878  {
879  const struct push_entry *e = o->push_list.head;
880  push_reset(o);
881  while (e)
882  {
883  push_option_ex(&o->gc, &o->push_list,
884  string_alloc(e->option, &o->gc), true, M_FATAL);
885  e = e->next;
886  }
887  }
888 }
889 
890 void
891 push_options(struct options *o, char **p, int msglevel, struct gc_arena *gc)
892 {
893  const char **argv = make_extended_arg_array(p, false, gc);
894  char *opt = print_argv(argv, gc, 0);
895  push_option(o, opt, msglevel);
896 }
897 
898 static bool
900  int msglevel, const char *format, ...)
901 {
902  va_list arglist;
903  char tmp[256] = {0};
904  int len;
905  va_start(arglist, format);
906  len = vsnprintf(tmp, sizeof(tmp), format, arglist);
907  va_end(arglist);
908  if (len > sizeof(tmp)-1)
909  {
910  return false;
911  }
912  push_option_ex(gc, push_list, string_alloc(tmp, gc), true, msglevel);
913  return true;
914 }
915 
916 void
917 push_reset(struct options *o)
918 {
919  CLEAR(o->push_list);
920 }
921 
922 void
923 push_remove_option(struct options *o, const char *p)
924 {
925  msg(D_PUSH_DEBUG, "PUSH_REMOVE searching for: '%s'", p);
926 
927  /* ifconfig is special, as not part of the push list */
928  if (streq(p, "ifconfig"))
929  {
930  o->push_ifconfig_ipv4_blocked = true;
931  return;
932  }
933 
934  /* ifconfig-ipv6 is special, as not part of the push list */
935  if (streq( p, "ifconfig-ipv6" ))
936  {
937  o->push_ifconfig_ipv6_blocked = true;
938  return;
939  }
940 
941  if (o && o->push_list.head)
942  {
943  struct push_entry *e = o->push_list.head;
944 
945  /* cycle through the push list */
946  while (e)
947  {
948  if (e->enable
949  && strncmp( e->option, p, strlen(p) ) == 0)
950  {
951  msg(D_PUSH_DEBUG, "PUSH_REMOVE removing: '%s'", e->option);
952  e->enable = false;
953  }
954 
955  e = e->next;
956  }
957  }
958 }
959 
960 int
962 {
963  int ret = PUSH_MSG_ERROR;
964 
965 
968  {
969  const char *client_reason = tls_client_reason(c->c2.tls_multi);
970  send_auth_failed(c, client_reason);
971  ret = PUSH_MSG_AUTH_FAILURE;
972  }
975  {
976  time_t now;
977 
978  openvpn_time(&now);
979  if (c->c2.sent_push_reply_expiry > now)
980  {
982  }
983  else
984  {
985  /* per-client push options - peer-id, cipher, ifconfig, ipv6-ifconfig */
986  struct push_list push_list = { 0 };
987  struct gc_arena gc = gc_new();
988 
989  if (prepare_push_reply(c, &gc, &push_list)
990  && send_push_reply(c, &push_list))
991  {
992  ret = PUSH_MSG_REQUEST;
993  c->c2.sent_push_reply_expiry = now + 30;
994  }
995  gc_free(&gc);
996  }
997  }
998  else
999  {
1001  }
1002 
1003  return ret;
1004 }
1005 
1006 static void
1007 push_update_digest(md_ctx_t *ctx, struct buffer *buf, const struct options *opt)
1008 {
1009  char line[OPTION_PARM_SIZE];
1010  while (buf_parse(buf, ',', line, sizeof(line)))
1011  {
1012  /* peer-id and auth-token might change on restart and this should not trigger reopening tun */
1013  if (strprefix(line, "peer-id ")
1014  || strprefix(line, "auth-token ")
1015  || strprefix(line, "auth-token-user "))
1016  {
1017  continue;
1018  }
1019  /* tun reopen only needed if cipher change can change tun MTU */
1020  if (strprefix(line, "cipher ") && !opt->ce.tun_mtu_defined)
1021  {
1022  continue;
1023  }
1024  md_ctx_update(ctx, (const uint8_t *) line, strlen(line)+1);
1025  }
1026 }
1027 
1028 static int
1030  unsigned int permission_mask,
1031  unsigned int *option_types_found,
1032  struct buffer *buf)
1033 {
1034  int ret = PUSH_MSG_ERROR;
1035  const uint8_t ch = buf_read_u8(buf);
1036  if (ch == ',')
1037  {
1038  struct buffer buf_orig = (*buf);
1040  {
1042  md_ctx_init(c->c2.pulled_options_state, "SHA256");
1044  }
1045  if (apply_push_options(&c->options,
1046  buf,
1047  permission_mask,
1048  option_types_found,
1049  c->c2.es))
1050  {
1052  &c->options);
1053  switch (c->options.push_continuation)
1054  {
1055  case 0:
1056  case 1:
1061  c->c2.pulled_options_state = NULL;
1063  ret = PUSH_MSG_REPLY;
1064  break;
1065 
1066  case 2:
1067  ret = PUSH_MSG_CONTINUATION;
1068  break;
1069  }
1070  }
1071  }
1072  else if (ch == '\0')
1073  {
1074  ret = PUSH_MSG_REPLY;
1075  }
1076  /* show_settings (&c->options); */
1077  return ret;
1078 }
1079 
1080 int
1082  const struct buffer *buffer,
1083  bool honor_received_options,
1084  unsigned int permission_mask,
1085  unsigned int *option_types_found)
1086 {
1087  struct buffer buf = *buffer;
1088 
1089  if (buf_string_compare_advance(&buf, "PUSH_REQUEST"))
1090  {
1091  c->c2.push_request_received = true;
1093  }
1094  else if (honor_received_options
1096  {
1097  return process_incoming_push_reply(c, permission_mask,
1098  option_types_found, &buf);
1099  }
1100  else
1101  {
1102  return PUSH_MSG_ERROR;
1103  }
1104 }
1105 
1106 
1107 /*
1108  * Remove iroutes from the push_list.
1109  */
1110 void
1112 {
1113  if (o && o->push_list.head && (o->iroutes || o->iroutes_ipv6))
1114  {
1115  struct gc_arena gc = gc_new();
1116  struct push_entry *e = o->push_list.head;
1117 
1118  /* cycle through the push list */
1119  while (e)
1120  {
1121  char *p[MAX_PARMS+1];
1122  bool enable = true;
1123 
1124  /* parse the push item */
1125  CLEAR(p);
1126  if (e->enable
1127  && parse_line(e->option, p, SIZE(p)-1, "[PUSH_ROUTE_REMOVE]", 1, D_ROUTE_DEBUG, &gc))
1128  {
1129  /* is the push item a route directive? */
1130  if (p[0] && !strcmp(p[0], "route") && !p[3] && o->iroutes)
1131  {
1132  /* get route parameters */
1133  bool status1, status2;
1134  const in_addr_t network = getaddr(GETADDR_HOST_ORDER, p[1], 0, &status1, NULL);
1135  const in_addr_t netmask = getaddr(GETADDR_HOST_ORDER, p[2] ? p[2] : "255.255.255.255", 0, &status2, NULL);
1136 
1137  /* did route parameters parse correctly? */
1138  if (status1 && status2)
1139  {
1140  const struct iroute *ir;
1141 
1142  /* does route match an iroute? */
1143  for (ir = o->iroutes; ir != NULL; ir = ir->next)
1144  {
1145  if (network == ir->network && netmask == netbits_to_netmask(ir->netbits >= 0 ? ir->netbits : 32))
1146  {
1147  enable = false;
1148  break;
1149  }
1150  }
1151  }
1152  }
1153  else if (p[0] && !strcmp(p[0], "route-ipv6") && !p[2]
1154  && o->iroutes_ipv6)
1155  {
1156  /* get route parameters */
1157  struct in6_addr network;
1158  unsigned int netbits;
1159 
1160  /* parse route-ipv6 arguments */
1161  if (get_ipv6_addr(p[1], &network, &netbits, D_ROUTE_DEBUG))
1162  {
1163  struct iroute_ipv6 *ir;
1164 
1165  /* does this route-ipv6 match an iroute-ipv6? */
1166  for (ir = o->iroutes_ipv6; ir != NULL; ir = ir->next)
1167  {
1168  if (!memcmp(&network, &ir->network, sizeof(network))
1169  && netbits == ir->netbits)
1170  {
1171  enable = false;
1172  break;
1173  }
1174  }
1175  }
1176  }
1177 
1178  /* should we copy the push item? */
1179  e->enable = enable;
1180  if (!enable)
1181  {
1182  msg(D_PUSH, "REMOVE PUSH ROUTE: '%s'", e->option);
1183  }
1184  }
1185 
1186  e = e->next;
1187  }
1188 
1189  gc_free(&gc);
1190  }
1191 }
context_2::pulled_options_digest_init_done
bool pulled_options_digest_init_done
Definition: openvpn.h:446
parse_auth_pending_keywords
static void parse_auth_pending_keywords(const struct buffer *buffer, unsigned int *server_timeout)
Parse the keyword for the AUTH_PENDING request.
Definition: push.c:297
pull_permission_mask
unsigned int pull_permission_mask(const struct context *c)
Definition: init.c:2516
D_TLS_DEBUG
#define D_TLS_DEBUG
Definition: errlevel.h:165
tls_multi::auth_token
char * auth_token
If server sends a generated auth-token, this is the token to use for future user/pass authentications...
Definition: ssl_common.h:644
management_set_state
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)
Definition: manage.c:2737
iroute
Definition: route.h:234
min_uint
static unsigned int min_uint(unsigned int x, unsigned int y)
Definition: integer.h:63
tls_authentication_status
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...
Definition: ssl_verify.c:1154
PUSH_MSG_REQUEST_DEFERRED
#define PUSH_MSG_REQUEST_DEFERRED
Definition: push.h:32
push_list::head
struct push_entry * head
Definition: pushlist.h:36
verify_crresponse_script
void verify_crresponse_script(struct tls_multi *multi, const char *cr_response)
Runs the –client-crresponse script if one is defined.
Definition: ssl_verify.c:1420
process_incoming_push_reply
static int process_incoming_push_reply(struct context *c, unsigned int permission_mask, unsigned int *option_types_found, struct buffer *buf)
Definition: push.c:1029
send_push_reply_auth_token
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.
Definition: push.c:755
gc_new
static struct gc_arena gc_new(void)
Definition: buffer.h:1030
push_remove_option
void push_remove_option(struct options *o, const char *p)
Definition: push.c:923
context_2::tls_multi
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
Definition: openvpn.h:326
signal_info::signal_text
const char * signal_text
Definition: sig.h:45
buffer::len
int len
Length in bytes of the actual content within the allocated memory.
Definition: buffer.h:66
options::push_list
struct push_list push_list
Definition: options.h:471
M_FATAL
#define M_FATAL
Definition: error.h:89
md_ctx_t
mbedtls_md_context_t md_ctx_t
Generic message digest context.
Definition: crypto_mbedtls.h:43
push_entry
Definition: pushlist.h:29
argv
Definition: argv.h:35
PUSH_MSG_REQUEST
#define PUSH_MSG_REQUEST
Definition: push.h:30
streq
#define streq(x, y)
Definition: options.h:707
management_auth_failure
void management_auth_failure(struct management *man, const char *type, const char *reason)
Definition: manage.c:3080
manage.h
KS_PRIMARY
#define KS_PRIMARY
Primary key state index.
Definition: ssl_common.h:448
context
Contains all state information for one tunnel.
Definition: openvpn.h:476
es
struct env_set * es
Definition: test_pkcs11.c:133
receive_auth_pending
void receive_auth_pending(struct context *c, const struct buffer *buffer)
Parses an AUTH_PENDING message and if in pull mode extends the timeout.
Definition: push.c:340
tls_multi::session
struct tls_session session[TM_SIZE]
Array of tls_session objects representing control channel sessions with the remote peer.
Definition: ssl_common.h:675
connection_entry::tun_mtu_defined
bool tun_mtu_defined
Definition: options.h:122
BSTR
#define BSTR(buf)
Definition: buffer.h:129
context_2::push_ifconfig_ipv6_local
struct in6_addr push_ifconfig_ipv6_local
Definition: openvpn.h:438
AR_NONE
#define AR_NONE
Definition: options.h:884
options::iroutes
struct iroute * iroutes
Definition: options.h:494
push_option_fmt
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.
Definition: push.c:899
push_options
void push_options(struct options *o, char **p, int msglevel, struct gc_arena *gc)
Definition: push.c:891
make_extended_arg_array
const char ** make_extended_arg_array(char **p, bool is_inline, struct gc_arena *gc)
Definition: misc.c:620
TLS_AUTHENTICATION_SUCCEEDED
@ TLS_AUTHENTICATION_SUCCEEDED
Definition: ssl_verify.h:70
alloc_buf_gc
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Definition: buffer.c:88
context_2::es
struct env_set * es
Definition: openvpn.h:423
context_2::push_ifconfig_defined
bool push_ifconfig_defined
Definition: openvpn.h:431
remove_iroutes_from_push_route_list
void remove_iroutes_from_push_route_list(struct options *o)
Definition: push.c:1111
session::key
char key[48]
Definition: keyingmaterialexporter.c:58
context_2::push_ifconfig_local
in_addr_t push_ifconfig_local
Definition: openvpn.h:433
options::mode
int mode
Definition: options.h:247
parse_line
int parse_line(const char *line, char *p[], const int n, const char *file, const int line_num, int msglevel, struct gc_arena *gc)
Definition: options.c:4966
MAX_PARMS
#define MAX_PARMS
Definition: options.h:52
get_primary_key
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.
Definition: ssl_common.h:722
dmsg
#define dmsg(flags,...)
Definition: error.h:148
options::ce
struct connection_entry ce
Definition: options.h:275
iroute::netbits
int netbits
Definition: route.h:236
tls_client_reason
static const char * tls_client_reason(struct tls_multi *multi)
Definition: ssl_verify.h:254
context_2::pulled_options_state
md_ctx_t * pulled_options_state
Definition: openvpn.h:447
PUSH_MSG_ERROR
#define PUSH_MSG_ERROR
Definition: push.h:29
options.h
management_notify_client_cr_response
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)
Definition: manage.c:2951
tls_options::renegotiate_seconds
interval_t renegotiate_seconds
Definition: ssl_common.h:336
do_up
bool do_up(struct context *c, bool pulled_options, unsigned int option_types_found)
Definition: init.c:2372
MODE_SERVER
#define MODE_SERVER
Definition: options.h:246
options::push_continuation
int push_continuation
Definition: options.h:540
tls_multi
Security parameter state for a single VPN tunnel.
Definition: ssl_common.h:590
push_entry::option
const char * option
Definition: pushlist.h:32
md_ctx_new
md_ctx_t * md_ctx_new(void)
Definition: crypto_openssl.c:1125
parse_auth_failed_temp
const char * parse_auth_failed_temp(struct options *o, const char *reason)
Definition: options_util.c:34
CAS_FAILED
@ CAS_FAILED
Option import failed or explicitly denied the client.
Definition: ssl_common.h:567
iroute_ipv6::network
struct in6_addr network
Definition: route.h:241
push_reset
void push_reset(struct options *o)
Definition: push.c:917
key_state
Security parameter state of one TLS and data channel key session.
Definition: ssl_common.h:198
context_2::push_request_received
bool push_request_received
Definition: openvpn.h:430
buf_reset_len
static void buf_reset_len(struct buffer *buf)
Definition: buffer.h:312
management_notify_generic
void management_notify_generic(struct management *man, const char *str)
Definition: manage.c:2894
iroute::next
struct iroute * next
Definition: route.h:237
options::renegotiate_seconds
int renegotiate_seconds
Definition: options.h:628
context_2::wait_for_connect
struct event_timeout wait_for_connect
Definition: openvpn.h:285
CLEAR
#define CLEAR(x)
Definition: basic.h:33
options_util.h
tls_multi::multi_state
enum multi_status multi_state
Definition: ssl_common.h:612
man_def_auth_context
Definition: manage.h:64
iroute::network
in_addr_t network
Definition: route.h:235
ssl_util.h
context::c2
struct context_2 c2
Level 2 context.
Definition: openvpn.h:517
options_postprocess_pull
bool options_postprocess_pull(struct options *o, struct env_set *es)
Definition: options.c:4193
getaddr
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.
Definition: socket.c:180
context_2::push_ifconfig_ipv6_remote
struct in6_addr push_ifconfig_ipv6_remote
Definition: openvpn.h:440
md_ctx_final
void md_ctx_final(md_ctx_t *ctx, uint8_t *dst)
push_option
void push_option(struct options *o, const char *opt, int msglevel)
Definition: push.c:869
TM_ACTIVE
#define TM_ACTIVE
Active tls_session.
Definition: ssl_common.h:529
string_alloc
char * string_alloc(const char *str, struct gc_arena *gc)
Definition: buffer.c:667
prepare_auth_token_push_reply
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.
Definition: push.c:588
ssl_verify.h
ASSERT
#define ASSERT(x)
Definition: error.h:195
D_STREAM_ERRORS
#define D_STREAM_ERRORS
Definition: errlevel.h:63
print_in6_addr
const char * print_in6_addr(struct in6_addr a6, unsigned int flags, struct gc_arena *gc)
Definition: socket.c:2924
send_auth_failed
void send_auth_failed(struct context *c, const char *client_reason)
Definition: push.c:396
iroute_ipv6::netbits
unsigned int netbits
Definition: route.h:242
buf_advance
static bool buf_advance(struct buffer *buf, int size)
Definition: buffer.h:623
push_option_ex
static void push_option_ex(struct gc_arena *gc, struct push_list *push_list, const char *opt, bool enable, int msglevel)
Definition: push.c:840
OPTION_PARM_SIZE
#define OPTION_PARM_SIZE
Definition: options.h:57
management_notify
void management_notify(struct management *man, const char *severity, const char *type, const char *text)
Definition: manage.c:2888
PUSH_MSG_ALREADY_REPLIED
#define PUSH_MSG_ALREADY_REPLIED
Definition: push.h:35
ssl_clean_auth_token
bool ssl_clean_auth_token(void)
Definition: ssl.c:365
M_VERB0
#define M_VERB0
Definition: errlevel.h:53
BLEN
#define BLEN(buf)
Definition: buffer.h:127
ssl_put_auth_challenge
void ssl_put_auth_challenge(const char *cr_str)
Definition: ssl.c:401
schedule_exit
bool schedule_exit(struct context *c)
Definition: forward.c:555
OPTION_LINE_SIZE
#define OPTION_LINE_SIZE
Definition: options.h:58
send_push_request
bool send_push_request(struct context *c)
Definition: push.c:551
clone_push_list
void clone_push_list(struct options *o)
Definition: push.c:875
options::imported_protocol_flags
unsigned int imported_protocol_flags
Definition: options.h:704
send_auth_pending_messages
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.
Definition: push.c:438
send_push_options
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)
Definition: push.c:716
server_pushed_signal
void server_pushed_signal(struct context *c, const struct buffer *buffer, const bool restart, const int adv)
Definition: push.c:131
tls_multi::opt
struct tls_options opt
Definition: ssl_common.h:596
options::push_ifconfig_ipv6_blocked
bool push_ifconfig_ipv6_blocked
Definition: options.h:508
push.h
reschedule_multi_process
void reschedule_multi_process(struct context *c)
Reschedule tls_multi_process.
Definition: forward.c:424
md_ctx_cleanup
void md_ctx_cleanup(md_ctx_t *ctx)
M_WARN
#define M_WARN
Definition: error.h:91
ALLOC_OBJ_CLEAR_GC
#define ALLOC_OBJ_CLEAR_GC(dptr, type, gc)
Definition: buffer.h:1102
context::options
struct options options
Options loaded from command line or configuration file.
Definition: openvpn.h:478
verify_crresponse_plugin
void verify_crresponse_plugin(struct tls_multi *multi, const char *cr_response)
Call the plugin OPENVPN_PLUGIN_CLIENT_CRRESPONSE.
Definition: ssl_verify.c:1407
PUSH_MSG_AUTH_FAILURE
#define PUSH_MSG_AUTH_FAILURE
Definition: push.h:33
tls_peer_supports_ncp
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.
Definition: ssl_ncp.c:77
options
Definition: options.h:236
context_2::push_ifconfig_local_alias
in_addr_t push_ifconfig_local_alias
Definition: openvpn.h:435
push_update_digest
static void push_update_digest(md_ctx_t *ctx, struct buffer *buf, const struct options *opt)
Definition: push.c:1007
TLS_AUTHENTICATION_FAILED
@ TLS_AUTHENTICATION_FAILED
Definition: ssl_verify.h:71
key_state::established
time_t established
Definition: ssl_common.h:219
tls_options::handshake_window
int handshake_window
Definition: ssl_common.h:332
options::gc
struct gc_arena gc
Definition: options.h:238
options::no_advance
bool no_advance
Definition: options.h:280
auth_retry_get
int auth_retry_get(void)
Definition: options.c:4766
context_2::push_ifconfig_ipv6_netbits
int push_ifconfig_ipv6_netbits
Definition: openvpn.h:439
D_ROUTE_DEBUG
#define D_ROUTE_DEBUG
Definition: errlevel.h:133
PUSH_MSG_REPLY
#define PUSH_MSG_REPLY
Definition: push.h:31
process_incoming_push_msg
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)
Definition: push.c:1081
tls_multi::peer_info
char * peer_info
Definition: ssl_common.h:643
SIZE
#define SIZE(x)
Definition: basic.h:30
buffer
Wrapper structure for dynamically allocated memory.
Definition: buffer.h:60
context_2::sent_push_reply_expiry
time_t sent_push_reply_expiry
Definition: openvpn.h:432
md_ctx_update
void md_ctx_update(md_ctx_t *ctx, const uint8_t *src, int src_len)
context_2::push_request_timeout
time_t push_request_timeout
Definition: openvpn.h:443
D_PUSH_ERRORS
#define D_PUSH_ERRORS
Definition: errlevel.h:67
md_ctx_init
void md_ctx_init(md_ctx_t *ctx, const char *mdname)
Initialises the given message digest context.
CO_USE_DYNAMIC_TLS_CRYPT
#define CO_USE_DYNAMIC_TLS_CRYPT
Bit-flag indicating that renegotiations are using tls-crypt with a TLS-EKM derived key.
Definition: crypto.h:278
CC_COMMA
#define CC_COMMA
comma
Definition: buffer.h:909
print_in_addr_t
const char * print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc)
Definition: socket.c:2904
options::handshake_window
int handshake_window
Definition: options.h:633
BCAP
#define BCAP(buf)
Definition: buffer.h:130
ssl.h
CC_ANY
#define CC_ANY
any character
Definition: buffer.h:888
tls_session
Security parameter state of a single session within a VPN tunnel.
Definition: ssl_common.h:471
key_state::mda_key_id
unsigned int mda_key_id
Definition: ssl_common.h:254
CAS_CONNECT_DONE
@ CAS_CONNECT_DONE
Definition: ssl_common.h:573
syshead.h
options::push_ifconfig_ipv4_blocked
bool push_ifconfig_ipv4_blocked
Definition: options.h:503
D_PUSH
#define D_PUSH
Definition: errlevel.h:83
IV_PROTO_AUTH_PENDING_KW
#define IV_PROTO_AUTH_PENDING_KW
Supports signaling keywords with AUTH_PENDING, e.g.
Definition: ssl.h:89
UP_TYPE_AUTH
#define UP_TYPE_AUTH
Definition: ssl_common.h:41
gc_arena
Garbage collection arena used to keep track of dynamically allocated memory.
Definition: buffer.h:116
context::sig
struct signal_info * sig
Internal error signaling object.
Definition: openvpn.h:503
iroute_ipv6::next
struct iroute_ipv6 * next
Definition: route.h:243
string_class
bool string_class(const char *str, const unsigned int inclusive, const unsigned int exclusive)
Definition: buffer.c:1040
send_control_channel_string_dowork
bool send_control_channel_string_dowork(struct tls_session *session, const char *str, int msglevel)
Definition: forward.c:402
sha256_digest::digest
uint8_t digest[SHA256_DIGEST_LENGTH]
Definition: crypto.h:133
env_set
Definition: env_set.h:42
key_state::initial
time_t initial
Definition: ssl_common.h:218
push_list::tail
struct push_entry * tail
Definition: pushlist.h:37
strprefix
static bool strprefix(const char *str, const char *prefix)
Return true iff str starts with prefix.
Definition: buffer.h:982
tls_multi::use_peer_id
bool use_peer_id
Definition: ssl_common.h:667
get_ipv6_addr
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.
Definition: socket.c:211
buf_string_match_head_str
bool buf_string_match_head_str(const struct buffer *src, const char *match)
Definition: buffer.c:796
md_ctx_free
void md_ctx_free(md_ctx_t *ctx)
OPENVPN_STATE_AUTH_PENDING
#define OPENVPN_STATE_AUTH_PENDING
Definition: manage.h:485
buf_len
static int buf_len(const struct buffer *buf)
Definition: buffer.h:253
GETADDR_HOST_ORDER
#define GETADDR_HOST_ORDER
Definition: socket.h:506
send_restart
void send_restart(struct context *c, const char *kill_msg)
Definition: push.c:495
openvpn_time
static time_t openvpn_time(time_t *t)
Definition: otime.h:90
buf_string_compare_advance
bool buf_string_compare_advance(struct buffer *src, const char *match)
Definition: buffer.c:807
netbits_to_netmask
static in_addr_t netbits_to_netmask(const int netbits)
Definition: route.h:379
ssl_purge_auth
void ssl_purge_auth(const bool auth_user_pass_only)
Definition: ssl.c:376
receive_exit_message
void receive_exit_message(struct context *c)
Definition: push.c:191
iroute_ipv6
Definition: route.h:240
status
static SERVICE_STATUS status
Definition: interactive.c:53
context_2::push_ifconfig_remote_netmask
in_addr_t push_ifconfig_remote_netmask
Definition: openvpn.h:434
management
Definition: manage.h:335
gc_free
static void gc_free(struct gc_arena *a)
Definition: buffer.h:1038
server_pushed_info
void server_pushed_info(struct context *c, const struct buffer *buffer, const int adv)
Definition: push.c:227
prepare_push_reply
bool prepare_push_reply(struct context *c, struct gc_arena *gc, struct push_list *push_list)
Prepare push options, based on local options.
Definition: push.c:613
__attribute__
__attribute__((unused))
Definition: test.c:42
extract_iv_proto
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.
Definition: ssl_util.c:62
context_2::pulled_options_digest
struct sha256_digest pulled_options_digest
Definition: openvpn.h:448
now
time_t now
Definition: otime.c:34
AR_INTERACT
#define AR_INTERACT
Definition: options.h:885
key_state::auth_deferred_expire
time_t auth_deferred_expire
Definition: ssl_common.h:251
config.h
D_PUSH_DEBUG
#define D_PUSH_DEBUG
Definition: errlevel.h:150
ssl_ncp.h
key_state::peer_last_packet
time_t peer_last_packet
Definition: ssl_common.h:222
tls_multi::peer_id
uint32_t peer_id
Definition: ssl_common.h:666
sanitize_control_message
const char * sanitize_control_message(const char *src, struct gc_arena *gc)
Definition: misc.c:650
context_2::push_request_interval
struct event_timeout push_request_interval
Definition: openvpn.h:442
push_reply_cmd
static char push_reply_cmd[]
Definition: push.c:41
TM_INITIAL
#define TM_INITIAL
As yet un-trusted tls_session being negotiated.
Definition: ssl_common.h:530
push_entry::next
struct push_entry * next
Definition: pushlist.h:30
AR_NOINTERACT
#define AR_NOINTERACT
Definition: options.h:886
PUSH_BUNDLE_SIZE
#define PUSH_BUNDLE_SIZE
Definition: common.h:88
buf_str
static char * buf_str(const struct buffer *buf)
Definition: buffer.h:297
options::push_option_types_found
unsigned int push_option_types_found
Definition: options.h:541
session
Definition: keyingmaterialexporter.c:56
receive_auth_failed
void receive_auth_failed(struct context *c, const struct buffer *buffer)
Definition: push.c:50
receive_cr_response
void receive_cr_response(struct context *c, const struct buffer *buffer)
Definition: push.c:265
buf_read_u8
static int buf_read_u8(struct buffer *buf)
Definition: buffer.h:795
context_2::push_ifconfig_ipv6_defined
bool push_ifconfig_ipv6_defined
Definition: openvpn.h:437
apply_push_options
bool apply_push_options(struct options *options, struct buffer *buf, unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es)
Definition: options.c:5503
options::iroutes_ipv6
struct iroute_ipv6 * iroutes_ipv6
Definition: options.h:495
send_push_reply
bool send_push_reply(struct context *c, struct push_list *per_client_push_list)
Definition: push.c:775
event_timeout_clear
static void event_timeout_clear(struct event_timeout *et)
Clears the timeout and reset all values to 0.
Definition: interval.h:155
max_uint
static unsigned int max_uint(unsigned int x, unsigned int y)
Definition: integer.h:50
print_argv
char * print_argv(const char **p, struct gc_arena *gc, const unsigned int flags)
Definition: buffer.c:735
extract_var_peer_info
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...
Definition: ssl_util.c:32
register_signal
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.
Definition: sig.c:231
PUSH_MSG_CONTINUATION
#define PUSH_MSG_CONTINUATION
Definition: push.h:34
CO_USE_TLS_KEY_MATERIAL_EXPORT
#define CO_USE_TLS_KEY_MATERIAL_EXPORT
Bit-flag indicating that data channel key derivation is done using TLS keying material export [RFC570...
Definition: crypto.h:262
options::ifconfig_local
const char * ifconfig_local
Definition: options.h:308
connection_entry::tun_mtu
int tun_mtu
Definition: options.h:118
memdbg.h
incoming_push_message
void incoming_push_message(struct context *c, const struct buffer *buffer)
Definition: push.c:506
options::ciphername
const char * ciphername
Definition: options.h:556
M_USAGE
#define M_USAGE
Definition: error.h:106
CO_USE_CC_EXIT_NOTIFY
#define CO_USE_CC_EXIT_NOTIFY
Bit-flag indicating that explicit exit notifies should be sent via the control channel instead of usi...
Definition: crypto.h:274
msg
#define msg(flags,...)
Definition: error.h:144
push_entry::enable
bool enable
Definition: pushlist.h:31
buf_printf
bool buf_printf(struct buffer *buf, const char *format,...)
Definition: buffer.c:240
options::pull
bool pull
Definition: options.h:539
push_list
Definition: pushlist.h:35
process_incoming_push_request
int process_incoming_push_request(struct context *c)
Definition: push.c:961
send_control_channel_string
bool send_control_channel_string(struct context *c, const char *str, int msglevel)
Definition: forward.c:431
buf_parse
bool buf_parse(struct buffer *buf, const int delim, char *line, const int size)
Definition: buffer.c:843
cleanup
static int cleanup(void **state)
Definition: test_pkcs11.c:280