OpenVPN
misc.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-2025 OpenVPN Inc <sales@openvpn.net>
9 * Copyright (C) 2014-2015 David Sommerseth <davids@redhat.com>
10 * Copyright (C) 2016-2025 David Sommerseth <davids@openvpn.net>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, see <https://www.gnu.org/licenses/>.
23 */
24
25#ifdef HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include "syshead.h"
30
31#include "buffer.h"
32#include "misc.h"
33#include "base64.h"
34#include "tun.h"
35#include "error.h"
36#include "otime.h"
37#include "plugin.h"
38#include "options.h"
39#include "manage.h"
40#include "crypto.h"
41#include "route.h"
42#include "console.h"
43#include "win32.h"
44
45#include "memdbg.h"
46
47#ifdef ENABLE_IPROUTE
48const char *iproute_path = IPROUTE_PATH; /* GLOBAL */
49#endif
50
51/*
52 * Set standard file descriptors to /dev/null
53 */
54void
55set_std_files_to_null(bool stdin_only)
56{
57#if defined(HAVE_DUP) && defined(HAVE_DUP2)
58 int fd;
59 if ((fd = open("/dev/null", O_RDWR, 0)) != -1)
60 {
61 dup2(fd, 0);
62 if (!stdin_only)
63 {
64 dup2(fd, 1);
65 dup2(fd, 2);
66 }
67 if (fd > 2)
68 {
69 close(fd);
70 }
71 }
72#endif
73}
74
75#if defined(__GNUC__) || defined(__clang__)
76#pragma GCC diagnostic push
77#pragma GCC diagnostic ignored "-Wconversion"
78#endif
79
80#ifdef ENABLE_MANAGEMENT
81/* Get username/password from the management interface */
82static bool
83auth_user_pass_mgmt(struct user_pass *up, const char *prefix, const unsigned int flags,
84 const char *auth_challenge)
85{
86 const char *sc = NULL;
87
89 {
90 management_auth_failure(management, prefix, "previous auth credentials failed");
91 }
92
94 {
95 sc = auth_challenge;
96 }
97 if (!management_query_user_pass(management, up, prefix, flags, sc))
98 {
99 if ((flags & GET_USER_PASS_NOFATAL) != 0)
100 {
101 return false;
102 }
103 else
104 {
105 msg(M_FATAL,
106 "ERROR: could not read %s username/password/ok/string from management interface",
107 prefix);
108 }
109 }
110 return true;
111}
112
126static struct auth_challenge_info *
128{
130
131 struct auth_challenge_info *ac;
132 const int len = strlen(auth_challenge);
133 char *work = (char *)gc_malloc(len + 1, false, gc);
134 char *cp;
135
136 struct buffer b;
138
140
141 /* parse prefix */
142 if (!buf_parse(&b, ':', work, len))
143 {
144 return NULL;
145 }
146 if (strcmp(work, "CRV1"))
147 {
148 return NULL;
149 }
150
151 /* parse flags */
152 if (!buf_parse(&b, ':', work, len))
153 {
154 return NULL;
155 }
156 for (cp = work; *cp != '\0'; ++cp)
157 {
158 const char c = *cp;
159 if (c == 'E')
160 {
161 ac->flags |= CR_ECHO;
162 }
163 else if (c == 'R')
164 {
165 ac->flags |= CR_RESPONSE;
166 }
167 }
168
169 /* parse state ID */
170 if (!buf_parse(&b, ':', work, len))
171 {
172 return NULL;
173 }
174 ac->state_id = string_alloc(work, gc);
175
176 /* parse user name */
177 if (!buf_parse(&b, ':', work, len))
178 {
179 return NULL;
180 }
181 ac->user = (char *)gc_malloc(strlen(work) + 1, true, gc);
182 openvpn_base64_decode(work, (void *)ac->user, -1);
183
184 /* parse challenge text */
185 ac->challenge_text = string_alloc(BSTR(&b), gc);
186
187 return ac;
188}
189
190#endif /* ifdef ENABLE_MANAGEMENT */
191
192#if defined(__GNUC__) || defined(__clang__)
193#pragma GCC diagnostic pop
194#endif
195
196/*
197 * Get and store a username/password
198 */
199
200bool
201get_user_pass_cr(struct user_pass *up, const char *auth_file, const char *prefix,
202 const unsigned int flags, const char *auth_challenge)
203{
204 struct gc_arena gc = gc_new();
205
206 if (!up->defined)
207 {
208 bool from_authfile = (auth_file && !streq(auth_file, "stdin"));
209 bool username_from_stdin = false;
210 bool password_from_stdin = false;
211 bool response_from_stdin = true;
212
215 {
216 msg(M_WARN, "Note: previous '%s' credentials failed", prefix);
217 }
218
219#ifdef ENABLE_MANAGEMENT
220 /*
221 * Get username/password from management interface?
222 */
223 if (management && (!from_authfile && (flags & GET_USER_PASS_MANAGEMENT))
225 {
226 response_from_stdin = false;
227 if (!auth_user_pass_mgmt(up, prefix, flags, auth_challenge))
228 {
229 return false;
230 }
231 }
232 else
233#endif /* ifdef ENABLE_MANAGEMENT */
234 /*
235 * Get NEED_OK confirmation from the console
236 */
237 if (flags & GET_USER_PASS_NEED_OK)
238 {
239 struct buffer user_prompt = alloc_buf_gc(128, &gc);
240
241 buf_printf(&user_prompt, "NEED-OK|%s|%s:", prefix, up->username);
243 {
244 msg(M_FATAL, "ERROR: could not read %s ok-confirmation from stdin", prefix);
245 }
246
247 if (!strlen(up->password))
248 {
249 strcpy(up->password, "ok");
250 }
251 }
252 else if (flags & GET_USER_PASS_INLINE_CREDS)
253 {
254 struct buffer buf;
255 buf_set_read(&buf, (uint8_t *)auth_file, strlen(auth_file) + 1);
256 if (!(flags & GET_USER_PASS_PASSWORD_ONLY))
257 {
258 buf_parse(&buf, '\n', up->username, USER_PASS_LEN);
259 }
260 buf_parse(&buf, '\n', up->password, USER_PASS_LEN);
261
262 if (strlen(up->password) == 0)
263 {
265 }
266 }
267 /*
268 * Read from auth file unless this is a dynamic challenge request.
269 */
270 else if (from_authfile && !(flags & GET_USER_PASS_DYNAMIC_CHALLENGE))
271 {
272 /*
273 * Try to get username/password from a file.
274 */
275 FILE *fp;
276 char password_buf[USER_PASS_LEN] = { '\0' };
277
278 fp = platform_fopen(auth_file, "r");
279 if (!fp)
280 {
281 msg(M_ERR, "Error opening '%s' auth file: %s", prefix, auth_file);
282 }
283
284 if ((flags & GET_USER_PASS_PASSWORD_ONLY) == 0)
285 {
286 /* Read username first */
287 if (fgets(up->username, USER_PASS_LEN, fp) == NULL)
288 {
289 msg(M_FATAL, "Error reading username from %s authfile: %s", prefix,
290 auth_file);
291 }
292 }
293 chomp(up->username);
294
296 {
298 }
299
300 if (flags & GET_USER_PASS_PASSWORD_ONLY && !password_buf[0])
301 {
302 msg(M_FATAL, "Error reading password from %s authfile: %s", prefix, auth_file);
303 }
304
305 if (password_buf[0])
306 {
308 }
309 /* The auth-file does not have the password: get both username
310 * and password from the management interface if possible.
311 * Otherwise set to read password from console.
312 */
313#if defined(ENABLE_MANAGEMENT)
314 else if (management && (flags & GET_USER_PASS_MANAGEMENT)
316 {
317 msg(D_LOW,
318 "No password found in %s authfile '%s'. Querying the management interface",
319 prefix, auth_file);
320 if (!auth_user_pass_mgmt(up, prefix, flags, auth_challenge))
321 {
322 fclose(fp);
323 return false;
324 }
325 }
326#endif
327 else
328 {
330 }
331
332 fclose(fp);
333
334 if (!(flags & GET_USER_PASS_PASSWORD_ONLY) && strlen(up->username) == 0)
335 {
336 msg(M_FATAL, "ERROR: username from %s authfile '%s' is empty", prefix,
337 auth_file);
338 }
339 }
340 else
341 {
342 username_from_stdin = true;
343 password_from_stdin = true;
344 }
345
346 /*
347 * Get username/password from standard input?
348 */
350 {
351#ifdef ENABLE_MANAGEMENT
353 {
355 if (ac)
356 {
357 char *response = (char *)gc_malloc(USER_PASS_LEN, false, &gc);
359
360 challenge = alloc_buf_gc(14 + strlen(ac->challenge_text), &gc);
361 buf_printf(&challenge, "CHALLENGE: %s", ac->challenge_text);
363
364 if (!query_user_SINGLE(BSTR(&challenge), response,
365 USER_PASS_LEN, BOOL_CAST(ac->flags & CR_ECHO)))
366 {
367 msg(M_FATAL, "ERROR: could not read challenge response from stdin");
368 }
369 strncpynt(up->username, ac->user, USER_PASS_LEN);
370 buf_printf(&packed_resp, "CRV1::%s::%s", ac->state_id, response);
371 }
372 else
373 {
374 msg(M_FATAL, "ERROR: received malformed challenge request from server");
375 }
376 }
377 else
378#endif /* ifdef ENABLE_MANAGEMENT */
379 {
380 struct buffer user_prompt = alloc_buf_gc(128, &gc);
381 struct buffer pass_prompt = alloc_buf_gc(128, &gc);
382
384 buf_printf(&user_prompt, "Enter %s Username:", prefix);
385 buf_printf(&pass_prompt, "Enter %s Password:", prefix);
386
388 {
390 }
391
393 {
395 }
396
397 if (!query_user_exec())
398 {
399 msg(M_FATAL, "ERROR: Failed retrieving username or password");
400 }
401
402 if (!(flags & GET_USER_PASS_PASSWORD_ONLY))
403 {
404 if (strlen(up->username) == 0)
405 {
406 msg(M_FATAL, "ERROR: %s username is empty", prefix);
407 }
408 }
409
410#ifdef ENABLE_MANAGEMENT
413 {
414 char *response = (char *)gc_malloc(USER_PASS_LEN, false, &gc);
416 char *pw64 = NULL, *resp64 = NULL;
417
419 buf_printf(&challenge, "CHALLENGE: %s", auth_challenge);
420
423 {
424 msg(M_FATAL, "ERROR: could not retrieve static challenge response");
425 }
427 {
428 if (openvpn_base64_encode(up->password, (int)strlen(up->password), &pw64) == -1
429 || openvpn_base64_encode(response, (int)strlen(response), &resp64) == -1)
430 {
431 msg(M_FATAL, "ERROR: could not base64-encode password/static_response");
432 }
434 buf_printf(&packed_resp, "SCRV1:%s:%s", pw64, resp64);
436 free(pw64);
438 free(resp64);
439 }
440 else
441 {
442 if (strlen(up->password) + strlen(response) >= USER_PASS_LEN)
443 {
444 msg(M_FATAL,
445 "ERROR: could not concatenate password/static_response: string too long");
446 }
447 strncat(up->password, response, USER_PASS_LEN - strlen(up->password) - 1);
448 }
449 }
450#endif /* ifdef ENABLE_MANAGEMENT */
451 }
452 }
453
456
457 up->defined = true;
458 }
459
460#if 0
461 msg(M_INFO, "GET_USER_PASS %s u='%s' p='%s'", prefix, up->username, up->password);
462#endif
463
464 gc_free(&gc);
465
466 return true;
467}
468
469void
470purge_user_pass(struct user_pass *up, const bool force)
471{
472 const bool nocache = up->nocache;
473 static bool warn_shown = false;
474 if (nocache || force)
475 {
476 secure_memzero(up, sizeof(*up));
477 up->nocache = nocache;
478 }
479 else
480 {
482 /*
483 * don't show warning if the pass has been replaced by a token: this is an
484 * artificial "auth-nocache"
485 */
486 if (!warn_shown)
487 {
488 msg(M_WARN,
489 "WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this");
490 warn_shown = true;
491 }
492 }
493}
494
495void
496set_auth_token(struct user_pass *tk, const char *token)
497{
498 if (strlen(token))
499 {
501 strncpynt(tk->password, token, USER_PASS_LEN);
502 tk->token_defined = true;
503
504 /*
505 * If username already set, tk is fully defined.
506 */
507 if (strlen(tk->username))
508 {
509 tk->defined = true;
510 }
512 }
513}
514
515void
516set_auth_token_user(struct user_pass *tk, const char *username)
517{
518 if (strlen(username))
519 {
521 /* Clear the username before decoding to ensure no old material is left
522 * and also allow decoding to not use all space to ensure the last byte is
523 * always 0 */
524 CLEAR(tk->username);
525 int len = openvpn_base64_decode(username, tk->username, USER_PASS_LEN - 1);
526 tk->defined = len > 0;
527 if (!tk->defined)
528 {
529 msg(D_PUSH, "Error decoding auth-token-username");
530 }
532 }
533}
534
535
536/*
537 * Process string received by untrusted peer before
538 * printing to console or log file.
539 *
540 * Assumes that string has been null terminated.
541 */
542const char *
543safe_print(const char *str, struct gc_arena *gc)
544{
545 return string_mod_const(str, CC_PRINT, CC_CRLF, '.', gc);
546}
547
548const char **
549make_arg_array(const char *first, const char *parms, struct gc_arena *gc)
550{
551 char **ret = NULL;
552 int base = 0;
553 const int max_parms = MAX_PARMS + 2;
554 int n = 0;
555
556 /* alloc return array */
557 ALLOC_ARRAY_CLEAR_GC(ret, char *, max_parms, gc);
558
559 /* process first parameter, if provided */
560 if (first)
561 {
562 ret[base++] = string_alloc(first, gc);
563 }
564
565 if (parms)
566 {
567 n = parse_line(parms, &ret[base], max_parms - base - 1, "make_arg_array", 0, M_WARN, gc);
568 ASSERT(n >= 0 && n + base + 1 <= max_parms);
569 }
570 ret[base + n] = NULL;
571
572 return (const char **)ret;
573}
574
575static const char **
576make_inline_array(const char *str, struct gc_arena *gc)
577{
579 struct buffer buf;
580 int len = 0;
581 char **ret = NULL;
582 int i = 0;
583
584 buf_set_read(&buf, (const uint8_t *)str, strlen(str));
585 while (buf_parse(&buf, '\n', line, sizeof(line)))
586 {
587 ++len;
588 }
589
590 /* alloc return array */
591 ALLOC_ARRAY_CLEAR_GC(ret, char *, len + 1, gc);
592
593 buf_set_read(&buf, (const uint8_t *)str, strlen(str));
594 while (buf_parse(&buf, '\n', line, sizeof(line)))
595 {
596 chomp(line);
597 ASSERT(i < len);
599 ++i;
600 }
601 ASSERT(i <= len);
602 ret[i] = NULL;
603 return (const char **)ret;
604}
605
606static const char **
607make_arg_copy(char **p, struct gc_arena *gc)
608{
609 char **ret = NULL;
610 const int len = string_array_len((const char **)p);
611 const int max_parms = len + 1;
612 int i;
613
614 /* alloc return array */
615 ALLOC_ARRAY_CLEAR_GC(ret, char *, max_parms, gc);
616
617 for (i = 0; i < len; ++i)
618 {
619 ret[i] = p[i];
620 }
621
622 return (const char **)ret;
623}
624
625const char **
627{
628 const int argc = string_array_len((const char **)p);
629 if (is_inline)
630 {
631 return make_inline_array(p[0], gc);
632 }
633 else if (argc == 0)
634 {
635 return make_arg_array(NULL, NULL, gc);
636 }
637 else if (argc == 1)
638 {
639 return make_arg_array(p[0], NULL, gc);
640 }
641 else if (argc == 2)
642 {
643 return make_arg_array(p[0], p[1], gc);
644 }
645 else
646 {
647 return make_arg_copy(p, gc);
648 }
649}
650
651/*
652 * Remove security-sensitive strings from control message
653 * so that they will not be output to log file.
654 */
655const char *
657{
658 char *ret = gc_malloc(strlen(src) + 1, false, gc);
659 char *dest = ret;
660 bool redact = false;
661 int skip = 0;
662
663 for (;;)
664 {
665 const char c = *src;
666 if (c == '\0')
667 {
668 break;
669 }
670 if (c == 'S' && !strncmp(src, "SESS_ID_", 8))
671 {
672 skip = 7;
673 redact = true;
674 }
675 else if (c == 'e' && !strncmp(src, "echo ", 5))
676 {
677 skip = 4;
678 redact = true;
679 }
680 else if (!check_debug_level(D_SHOW_KEYS) && (c == 'a' && !strncmp(src, "auth-token ", 11)))
681 {
682 /* Unless --verb is 7 or higher (D_SHOW_KEYS), hide
683 * the auth-token value coming in the src string
684 */
685 skip = 10;
686 redact = true;
687 }
688
689 if (c == ',') /* end of redacted item? */
690 {
691 skip = 0;
692 redact = false;
693 }
694
695 if (redact)
696 {
697 if (skip > 0)
698 {
699 --skip;
700 *dest++ = c;
701 }
702 }
703 else
704 {
705 *dest++ = c;
706 }
707
708 ++src;
709 }
710 *dest = '\0';
711 return ret;
712}
713
714/* helper to parse peer_info received from multi client, validate
715 * (this is untrusted data) and put into environment
716 */
717bool
719{
720 uint8_t c;
721 int state = 0;
722 while (*line)
723 {
724 c = *line;
725 switch (state)
726 {
727 case 0:
728 case 1:
729 if (c == '=' && state == 1)
730 {
731 state = 2;
732 }
733 else if (isalnum(c) || c == '_')
734 {
735 state = 1;
736 }
737 else
738 {
739 return false;
740 }
741 /* Intentional [[fallthrough]]; */
742 case 2:
743 /* after the '=', replace non-printable or shell meta with '_' */
744 if (!isprint(c) || isspace(c) || c == '$' || c == '(' || c == '`')
745 {
746 *line = '_';
747 }
748 }
749 line++;
750 }
751 return (state == 2);
752}
753
754void
755output_peer_info_env(struct env_set *es, const char *peer_info)
756{
757 char line[256];
758 struct buffer buf;
759 buf_set_read(&buf, (const uint8_t *)peer_info, strlen(peer_info));
760 while (buf_parse(&buf, '\n', line, sizeof(line)))
761 {
762 chomp(line);
764 && (strncmp(line, "IV_", 3) == 0 || strncmp(line, "UV_", 3) == 0))
765 {
766 msg(M_INFO, "peer info: %s", line);
768 }
769 else
770 {
771 msg(M_WARN, "validation failed on peer_info line received from client");
772 }
773 }
774}
775
776struct buffer
777prepend_dir(const char *dir, const char *path, struct gc_arena *gc)
778{
779 size_t len = strlen(dir) + strlen(PATH_SEPARATOR_STR) + strlen(path) + 1;
782 ASSERT(combined_path.len > 0);
783
784 return combined_path;
785}
786
787void
789{
790 if (up->protected)
791 {
792 return;
793 }
794#ifdef _WIN32
795 if (protect_buffer_win32(up->username, sizeof(up->username))
796 && protect_buffer_win32(up->password, sizeof(up->password)))
797 {
798 up->protected = true;
799 }
800 else
801 {
802 purge_user_pass(up, true);
803 }
804#endif
805}
806
807void
809{
810 if (!up->protected)
811 {
812 return;
813 }
814#ifdef _WIN32
815 if (unprotect_buffer_win32(up->username, sizeof(up->username))
816 && unprotect_buffer_win32(up->password, sizeof(up->password)))
817 {
818 up->protected = false;
819 }
820 else
821 {
822 purge_user_pass(up, true);
823 }
824#endif
825}
const char * skip_leading_whitespace(const char *str)
Definition buffer.c:579
bool buf_printf(struct buffer *buf, const char *format,...)
Definition buffer.c:241
void string_clear(char *str)
Definition buffer.c:691
void chomp(char *str)
Definition buffer.c:614
void * gc_malloc(size_t size, bool clear, struct gc_arena *a)
Definition buffer.c:336
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Definition buffer.c:89
bool string_mod(char *str, const unsigned int inclusive, const unsigned int exclusive, const char replace)
Modifies a string in place by replacing certain classes of characters of it with a specified characte...
Definition buffer.c:1046
const char * string_mod_const(const char *str, const unsigned int inclusive, const unsigned int exclusive, const char replace, struct gc_arena *gc)
Returns a copy of a string with certain classes of characters of it replaced with a specified charact...
Definition buffer.c:1096
int string_array_len(const char **array)
Definition buffer.c:703
bool buf_parse(struct buffer *buf, const int delim, char *line, const int size)
Definition buffer.c:825
char * string_alloc(const char *str, struct gc_arena *gc)
Definition buffer.c:649
#define BSTR(buf)
Definition buffer.h:128
#define ALLOC_ARRAY_CLEAR_GC(dptr, type, n, gc)
Definition buffer.h:1074
#define CC_CRLF
carriage return or newline
Definition buffer.h:914
static void buf_set_write(struct buffer *buf, uint8_t *data, int size)
Definition buffer.h:331
static void buf_set_read(struct buffer *buf, const uint8_t *data, size_t size)
Definition buffer.h:348
static void secure_memzero(void *data, size_t len)
Securely zeroise memory.
Definition buffer.h:414
#define ALLOC_OBJ_CLEAR_GC(dptr, type, gc)
Definition buffer.h:1089
static void strncpynt(char *dest, const char *src, size_t maxlen)
Definition buffer.h:361
static void gc_free(struct gc_arena *a)
Definition buffer.h:1025
#define CC_PRINT
printable (>= 32, != 127)
Definition buffer.h:885
static struct gc_arena gc_new(void)
Definition buffer.h:1017
void query_user_clear(void)
Wipes all data put into all of the query_user structs.
Definition console.c:44
void query_user_add(char *prompt, char *resp, int resp_len, bool echo)
Adds an item to ask the user for.
Definition console.c:56
static bool query_user_SINGLE(char *prompt, char *resp, int resp_len, bool echo)
A plain "make Gert happy" wrapper.
Definition console.h:118
static bool query_user_exec(void)
Wrapper function enabling query_user_exec() if no alternative methods have been enabled.
Definition console.h:103
Data Channel Cryptography Module.
void env_set_add(struct env_set *es, const char *str)
Definition env_set.c:193
#define D_PUSH
Definition errlevel.h:82
#define D_SHOW_KEYS
Definition errlevel.h:120
#define D_LOW
Definition errlevel.h:96
#define M_INFO
Definition errlevel.h:54
void management_auth_failure(struct management *man, const char *type, const char *reason)
Definition manage.c:3117
bool management_query_user_pass(struct management *man, struct user_pass *up, const char *type, const unsigned int flags, const char *static_challenge)
Definition manage.c:3516
static bool management_query_user_pass_enabled(const struct management *man)
Definition manage.h:419
static const char ** make_inline_array(const char *str, struct gc_arena *gc)
Definition misc.c:576
void unprotect_user_pass(struct user_pass *up)
Decrypt username and password buffers in user_pass.
Definition misc.c:808
bool get_user_pass_cr(struct user_pass *up, const char *auth_file, const char *prefix, const unsigned int flags, const char *auth_challenge)
Retrieves the user credentials from various sources depending on the flags.
Definition misc.c:201
const char ** make_arg_array(const char *first, const char *parms, struct gc_arena *gc)
Definition misc.c:549
void purge_user_pass(struct user_pass *up, const bool force)
Definition misc.c:470
bool validate_peer_info_line(char *line)
Definition misc.c:718
void set_auth_token_user(struct user_pass *tk, const char *username)
Sets the auth-token username by base64 decoding the passed username.
Definition misc.c:516
void set_std_files_to_null(bool stdin_only)
Definition misc.c:55
void output_peer_info_env(struct env_set *es, const char *peer_info)
Definition misc.c:755
struct buffer prepend_dir(const char *dir, const char *path, struct gc_arena *gc)
Prepend a directory to a path.
Definition misc.c:777
static struct auth_challenge_info * parse_auth_challenge(const char *auth_challenge, struct gc_arena *gc)
Parses an authentication challenge string and returns an auth_challenge_info structure.
Definition misc.c:127
void protect_user_pass(struct user_pass *up)
Encrypt username and password buffers in user_pass.
Definition misc.c:788
const char ** make_extended_arg_array(char **p, bool is_inline, struct gc_arena *gc)
Definition misc.c:626
static const char ** make_arg_copy(char **p, struct gc_arena *gc)
Definition misc.c:607
const char * safe_print(const char *str, struct gc_arena *gc)
Definition misc.c:543
const char * sanitize_control_message(const char *src, struct gc_arena *gc)
Definition misc.c:656
static bool auth_user_pass_mgmt(struct user_pass *up, const char *prefix, const unsigned int flags, const char *auth_challenge)
Definition misc.c:83
void set_auth_token(struct user_pass *tk, const char *token)
Sets the auth-token to token.
Definition misc.c:496
#define USER_PASS_LEN
Definition misc.h:64
#define GET_USER_PASS_STATIC_CHALLENGE_CONCAT
indicates password and response should be concatenated
Definition misc.h:125
#define GET_USER_PASS_MANAGEMENT
Definition misc.h:110
#define GET_USER_PASS_PASSWORD_ONLY
Definition misc.h:112
#define GET_USER_PASS_STATIC_CHALLENGE_ECHO
SCRV1 protocol – echo response.
Definition misc.h:120
#define CR_ECHO
Definition misc.h:77
#define CR_RESPONSE
Definition misc.h:78
#define GET_USER_PASS_INLINE_CREDS
indicates that auth_file is actually inline creds
Definition misc.h:123
#define GET_USER_PASS_STATIC_CHALLENGE
SCRV1 protocol – static challenge.
Definition misc.h:119
#define GET_USER_PASS_NEED_OK
Definition misc.h:113
#define GET_USER_PASS_NOFATAL
Definition misc.h:114
#define GET_USER_PASS_PREVIOUS_CREDS_FAILED
Definition misc.h:116
#define GET_USER_PASS_DYNAMIC_CHALLENGE
CRV1 protocol – dynamic challenge.
Definition misc.h:118
#define BOOL_CAST(x)
Definition basic.h:26
#define CLEAR(x)
Definition basic.h:32
static bool check_debug_level(msglvl_t level)
Definition error.h:259
#define M_FATAL
Definition error.h:90
#define M_ERR
Definition error.h:106
#define msg(flags,...)
Definition error.h:152
#define ASSERT(x)
Definition error.h:219
#define M_WARN
Definition error.h:92
#define streq(x, y)
Definition options.h:730
int parse_line(const char *line, char *p[], const int n, const char *file, const int line_num, msglvl_t msglevel, struct gc_arena *gc)
#define MAX_PARMS
Definition options.h:51
#define OPTION_LINE_SIZE
Definition options.h:57
FILE * platform_fopen(const char *path, const char *mode)
Definition platform.c:500
int openvpn_base64_decode(const char *str, void *data, int size)
Definition base64.c:160
int openvpn_base64_encode(const void *data, int size, char **str)
Definition base64.c:51
static char * auth_challenge
Definition ssl.c:293
Wrapper structure for dynamically allocated memory.
Definition buffer.h:60
int len
Length in bytes of the actual content within the allocated memory.
Definition buffer.h:65
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:116
bool protected
Definition misc.h:58
bool defined
Definition misc.h:53
char password[USER_PASS_LEN]
Definition misc.h:68
bool nocache
Definition misc.h:57
char username[USER_PASS_LEN]
Definition misc.h:67
#define PATH_SEPARATOR_STR
Definition syshead.h:428
struct env_set * es
struct gc_arena gc
Definition test_ssl.c:131
bool protect_buffer_win32(char *buf, DWORD len)
Encrypt a region of memory using CryptProtectMemory() with access restricted to the current process.
Definition win32.c:1601
bool unprotect_buffer_win32(char *buf, DWORD len)
Decrypt a previously encrypted region of memory using CryptUnProtectMemory() with access restricted t...
Definition win32.c:1619