OpenVPN
platform.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-2026 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, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include "syshead.h"
28
29#include "openvpn.h"
30#include "options.h"
31
32#include "buffer.h"
33#include "crypto.h"
34#include "error.h"
35#include "misc.h"
36#include "win32.h"
37
38#include "memdbg.h"
39
40#include "platform.h"
41
42#ifdef _WIN32
43#include <direct.h>
44#endif
45
46#ifdef HAVE_LIBCAPNG
47#include <cap-ng.h>
48#include <sys/prctl.h>
49#endif
50
51/* Redefine the top level directory of the filesystem
52 * to restrict access to files for security */
53void
54platform_chroot(const char *path)
55{
56 if (path)
57 {
58#ifdef HAVE_CHROOT
59 const char *top = "/";
60 if (chroot(path))
61 {
62 msg(M_ERR, "chroot to '%s' failed", path);
63 }
64 if (platform_chdir(top))
65 {
66 msg(M_ERR, "cd to '%s' failed", top);
67 }
68 msg(M_INFO, "chroot to '%s' and cd to '%s' succeeded", path, top);
69#else /* ifdef HAVE_CHROOT */
71 "Sorry but I can't chroot to '%s' because this operating system doesn't appear to support the chroot() system call",
72 path);
73#endif
74 }
75}
76
77/* Get/Set UID of process */
78
79#if defined(__GNUC__) || defined(__clang__)
80#pragma GCC diagnostic push
81#pragma GCC diagnostic ignored "-Wsign-conversion"
82#endif
83
84bool
85platform_user_get(const char *username, struct platform_state_user *state)
86{
87 CLEAR(*state);
88 if (username)
89 {
90#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
91 const struct passwd *pw = getpwnam(username);
92 if (!pw)
93 {
94 msg(M_ERR, "failed to find UID for user %s", username);
95 }
96 else
97 {
98 state->uid = pw->pw_uid;
99 state->user_valid = true;
100 }
101 state->username = username;
102#else /* if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID) */
103 msg(M_FATAL,
104 "cannot get UID for user %s -- platform lacks getpwname() or setuid() system calls",
105 username);
106#endif
107 }
108 return state->user_valid;
109}
110
111static void
113{
114#if defined(HAVE_GETPWNAM) && defined(HAVE_SETUID)
115 if (state->username && state->user_valid)
116 {
117 if (setuid(state->uid))
118 {
119 msg(M_ERR, "setuid('%s') failed", state->username);
120 }
121 msg(M_INFO, "UID set to %s", state->username);
122 }
123#endif
124}
125
126/* Get/Set GID of process */
127
128bool
129platform_group_get(const char *groupname, struct platform_state_group *state)
130{
131 CLEAR(*state);
132 if (groupname)
133 {
134#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
135 const struct group *gr = getgrnam(groupname);
136 if (!gr)
137 {
138 msg(M_ERR, "failed to find GID for group %s", groupname);
139 }
140 else
141 {
142 state->gid = gr->gr_gid;
143 state->group_valid = true;
144 }
145 state->groupname = groupname;
146#else /* if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID) */
147 msg(M_FATAL,
148 "cannot get GID for group %s -- platform lacks getgrnam() or setgid() system calls",
149 groupname);
150#endif
151 }
152 return state->group_valid;
153}
154
155static void
157{
158#if defined(HAVE_GETGRNAM) && defined(HAVE_SETGID)
159 if (state->groupname && state->group_valid)
160 {
161 if (setgid(state->gid))
162 {
163 msg(M_ERR, "setgid('%s') failed", state->groupname);
164 }
165 msg(M_INFO, "GID set to %s", state->groupname);
166#ifdef HAVE_SETGROUPS
167 {
168 gid_t gr_list[1];
169 gr_list[0] = state->gid;
170 if (setgroups(1, gr_list))
171 {
172 msg(M_ERR, "setgroups('%s') failed", state->groupname);
173 }
174 }
175#endif
176 }
177#endif
178}
179
180/*
181 * Determine if we need to retain process capabilities. DCO and SITNL need it.
182 * Enforce it for DCO, but only try and soft-fail for SITNL to keep backwards compat.
183 *
184 * Returns the tri-state expected by platform_user_group_set.
185 * -1: try to keep caps, but continue if impossible
186 * 0: don't keep caps
187 * 1: keep caps, fail hard if impossible
188 */
189static int
191{
192 if (!c)
193 {
194 return -1;
195 }
196
197 if (dco_enabled(&c->options))
198 {
199#ifdef TARGET_LINUX
200 /* DCO on Linux does not work at all without CAP_NET_ADMIN */
201 return 1;
202#else
203 /* Windows/BSD/... has no equivalent capability mechanism */
204 return -1;
205#endif
206 }
207
208#ifdef ENABLE_SITNL
209 return -1;
210#else
211 return 0;
212#endif
213}
214
215/* Set user and group, retaining neccesary capabilities required by the platform.
216 *
217 * The keep_caps argument has 3 possible states:
218 * >0: Retain capabilities, and fail hard on failure to do so.
219 * ==0: Don't attempt to retain any capabilities, just sitch user/group.
220 * <0: Try to retain capabilities, but continue on failure.
221 */
222void
224 const struct platform_state_group *group_state, struct context *c)
225{
226 int keep_caps = need_keep_caps(c);
227 unsigned int err_flags = (keep_caps > 0) ? M_FATAL : M_NONFATAL;
228#ifdef HAVE_LIBCAPNG
229 int new_gid = -1, new_uid = -1;
230 int res;
231
232 if (keep_caps == 0)
233 {
234 goto fallback;
235 }
236
237 /*
238 * new_uid/new_gid defaults to -1, which will not make
239 * libcap-ng change the UID/GID unless configured
240 */
241 if (group_state->groupname && group_state->group_valid)
242 {
243 new_gid = (int)group_state->gid;
244 }
245 if (user_state->username && user_state->user_valid)
246 {
247 new_uid = (int)user_state->uid;
248 }
249
250 /* Prepare capabilities before dropping UID/GID */
251 capng_clear(CAPNG_SELECT_BOTH);
252 res = capng_update(CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED, CAP_NET_ADMIN);
253 if (res < 0)
254 {
255 msg(err_flags, "capng_update(CAP_NET_ADMIN) failed: %d", res);
256 goto fallback;
257 }
258
259 /* Change to new UID/GID.
260 * capng_change_id() internally calls capng_apply() to apply prepared capabilities.
261 */
262 res = capng_change_id(new_uid, new_gid, CAPNG_DROP_SUPP_GRP);
263 if (res == -4 || res == -6)
264 {
265 /* -4 and -6 mean failure of setuid/gid respectively.
266 * There is no point for us to continue if those failed. */
267 msg(M_ERR, "capng_change_id('%s','%s') failed: %d", user_state->username,
268 group_state->groupname, res);
269 }
270 else if (res == -3)
271 {
272 msg(M_NONFATAL | M_ERRNO, "capng_change_id() failed applying capabilities");
273 msg(err_flags, "NOTE: previous error likely due to missing capability CAP_SETPCAP.");
274 goto fallback;
275 }
276 else if (res < 0)
277 {
278 msg(err_flags | M_ERRNO, "capng_change_id('%s','%s') failed retaining capabilities: %d",
279 user_state->username, group_state->groupname, res);
280 goto fallback;
281 }
282
283 if (new_uid >= 0)
284 {
285 msg(M_INFO, "UID set to %s", user_state->username);
286 }
287 if (new_gid >= 0)
288 {
289 msg(M_INFO, "GID set to %s", group_state->groupname);
290 }
291
292 msg(M_INFO, "Capabilities retained: CAP_NET_ADMIN");
293 return;
294
295fallback:
296 /* capng_change_id() can leave this flag clobbered on failure
297 * This is working around a bug in libcap-ng, which can leave the flag set
298 * on failure: https://github.com/stevegrubb/libcap-ng/issues/33 */
299 if (prctl(PR_GET_KEEPCAPS) && prctl(PR_SET_KEEPCAPS, 0) < 0)
300 {
301 msg(M_ERR, "Clearing KEEPCAPS flag failed");
302 }
303#endif /* HAVE_LIBCAPNG */
304
305 if (keep_caps)
306 {
307 msg(err_flags, "Unable to retain capabilities");
308 }
309
310 platform_group_set(group_state);
311 platform_user_set(user_state);
312}
313
314/* Change process priority */
315void
316platform_nice(int niceval)
317{
318 if (niceval)
319 {
320#ifdef HAVE_NICE
321 errno = 0;
322 if (nice(niceval) < 0 && errno != 0)
323 {
324 msg(M_WARN | M_ERRNO, "WARNING: nice %d failed", niceval);
325 }
326 else
327 {
328 msg(M_INFO, "nice %d succeeded", niceval);
329 }
330#else /* ifdef HAVE_NICE */
331 msg(M_WARN, "WARNING: nice %d failed (function not implemented)", niceval);
332#endif
333 }
334}
335
336/* Get current PID */
337unsigned int
339{
340#ifdef _WIN32
341 return (unsigned int)GetCurrentProcessId();
342#else
343 return (unsigned int)getpid();
344#endif
345}
346
347/* Disable paging */
348void
349platform_mlockall(bool print_msg)
350{
351#ifdef HAVE_MLOCKALL
352
353#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_MEMLOCK)
354#define MIN_LOCKED_MEM_MB 100
355 struct rlimit rl;
356 if (getrlimit(RLIMIT_MEMLOCK, &rl) < 0)
357 {
358 msg(M_WARN | M_ERRNO, "WARNING: getrlimit(RLIMIT_MEMLOCK) failed");
359 }
360 else
361 {
362 msg(M_INFO, "mlock: MEMLOCK limit: soft=%ld KB, hard=%ld KB",
363 ((long int)rl.rlim_cur) / 1024, ((long int)rl.rlim_max) / 1024);
364 if (rl.rlim_cur < MIN_LOCKED_MEM_MB * 1024 * 1024)
365 {
366 msg(M_INFO, "mlock: RLIMIT_MEMLOCK < %d MB, increase limit", MIN_LOCKED_MEM_MB);
367 rl.rlim_cur = MIN_LOCKED_MEM_MB * 1024 * 1024;
368 if (rl.rlim_max < rl.rlim_cur)
369 {
370 rl.rlim_max = rl.rlim_cur;
371 }
372 if (setrlimit(RLIMIT_MEMLOCK, &rl) < 0)
373 {
374 msg(M_FATAL | M_ERRNO, "ERROR: setrlimit() failed");
375 }
376 }
377 }
378#endif /* if defined(HAVE_GETRLIMIT) && defined(RLIMIT_MEMLOCK) */
379
380 if (mlockall(MCL_CURRENT | MCL_FUTURE))
381 {
382 msg(M_WARN | M_ERRNO, "WARNING: mlockall call failed");
383 }
384 else if (print_msg)
385 {
386 msg(M_INFO, "mlockall call succeeded");
387 }
388#else /* ifdef HAVE_MLOCKALL */
389 msg(M_WARN, "WARNING: mlockall call failed (function not implemented)");
390#endif /* ifdef HAVE_MLOCKALL */
391}
392
393/*
394 * Wrapper for chdir library function
395 */
396int
397platform_chdir(const char *dir)
398{
399#ifdef _WIN32
400 int res;
401 struct gc_arena gc = gc_new();
402 res = _wchdir(wide_string(dir, &gc));
403 gc_free(&gc);
404 return res;
405#else /* ifdef _WIN32 */
406#ifdef HAVE_CHDIR
407 return chdir(dir);
408#else /* ifdef HAVE_CHDIR */
409 return -1;
410#endif
411#endif
412}
413
414/*
415 * convert execve() return into a success/failure value
416 */
417bool
419{
420#ifdef _WIN32
421 return stat == 0;
422#else
423 return stat != -1 && WIFEXITED(stat) && WEXITSTATUS(stat) == 0;
424#endif
425}
426
427#ifdef _WIN32
428int
430{
431 if (stat >= 0 && stat < 255)
432 {
433 return stat;
434 }
435 else
436 {
437 return -1;
438 }
439}
440#else /* ifdef _WIN32 */
441int
442platform_ret_code(int stat)
443{
444 if (!WIFEXITED(stat) || stat == -1)
445 {
446 return -1;
447 }
448
449 int status = WEXITSTATUS(stat);
450 if (status >= 0 && status < 255)
451 {
452 return status;
453 }
454 else
455 {
456 return -1;
457 }
458}
459#endif /* ifdef _WIN32 */
460
461int
462platform_access(const char *path, int mode)
463{
464#ifdef _WIN32
465 struct gc_arena gc = gc_new();
466 int ret = _waccess(wide_string(path, &gc), mode & ~X_OK);
467 gc_free(&gc);
468 return ret;
469#else
470 return access(path, mode);
471#endif
472}
473
474/*
475 * Go to sleep for n milliseconds.
476 */
477void
479{
480#ifdef _WIN32
481 Sleep(n);
482#else
483 struct timeval tv;
484 tv.tv_sec = n / 1000;
485 tv.tv_usec = (n % 1000) * 1000;
486 select(0, NULL, NULL, NULL, &tv);
487#endif
488}
489
490/* delete a file, return true if succeeded */
491bool
492platform_unlink(const char *filename)
493{
494#if defined(_WIN32)
495 struct gc_arena gc = gc_new();
496 BOOL ret = DeleteFileW(wide_string(filename, &gc));
497 gc_free(&gc);
498 return (ret != 0);
499#else
500 return (unlink(filename) == 0);
501#endif
502}
503
504FILE *
505platform_fopen(const char *path, const char *mode)
506{
507#ifdef _WIN32
508 struct gc_arena gc = gc_new();
509 FILE *f = _wfopen(wide_string(path, &gc), wide_string(mode, &gc));
510 gc_free(&gc);
511 return f;
512#else
513 return fopen(path, mode);
514#endif
515}
516
517int
518platform_open(const char *path, int flags, int mode)
519{
520#ifdef _WIN32
521 struct gc_arena gc = gc_new();
522 int fd = _wopen(wide_string(path, &gc), flags, mode);
523 gc_free(&gc);
524 return fd;
525#else
526 return open(path, flags, mode);
527#endif
528}
529
530int
531platform_stat(const char *path, platform_stat_t *buf)
532{
533#ifdef _WIN32
534 struct gc_arena gc = gc_new();
535 int res = _wstat(wide_string(path, &gc), buf);
536 gc_free(&gc);
537 return res;
538#else
539 return stat(path, buf);
540#endif
541}
542
543/* create a temporary filename in directory */
544const char *
545platform_create_temp_file(const char *directory, const char *prefix, struct gc_arena *gc)
546{
547 unsigned int attempts = 0;
548 char fname[256] = { 0 };
549 const char *fname_fmt = PACKAGE "_%.*s_%08" PRIx64 "%08" PRIx64 ".tmp";
550 const int max_prefix_len = sizeof(fname) - (sizeof(PACKAGE) + 7 + (2 * 8));
551
552 while (attempts < 6)
553 {
554 ++attempts;
555
556 if (!checked_snprintf(fname, sizeof(fname), fname_fmt, max_prefix_len, prefix,
557 (uint64_t)get_random(), (uint64_t)get_random()))
558 {
559 msg(M_WARN, "ERROR: temporary filename too long");
560 return NULL;
561 }
562
563 const char *retfname = platform_gen_path(directory, fname, gc);
564 if (!retfname)
565 {
566 msg(M_WARN, "Failed to create temporary filename and path");
567 return NULL;
568 }
569
570 /* Atomically create the file. Errors out if the file already
571 * exists. */
572 const int fd = platform_open(retfname, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
573 if (fd != -1)
574 {
575 close(fd);
576 return retfname;
577 }
578 else if (errno != EEXIST)
579 {
580 /* Something else went wrong, no need to retry. */
581 msg(M_WARN | M_ERRNO, "Could not create temporary file '%s'", retfname);
582 return NULL;
583 }
584 }
585
586 msg(M_WARN, "Failed to create temporary file after %u attempts", attempts);
587 return NULL;
588}
589
590const char *
592{
593 const char *ret;
594#ifdef _WIN32
595 /* On Windows, find temp dir via environment variables */
596 ret = win_get_tempdir();
597
598 if (!ret)
599 {
600 /* Error out if we can't find a valid temporary directory, which should
601 * be very unlikely. */
602 msg(M_USAGE, "Could not find a suitable temporary directory."
603 " (GetTempPath() failed). Consider using --tmp-dir");
604 }
605#else
606 /* Non-windows platforms use $TMPDIR, and if not set, default to '/tmp' */
607 ret = getenv("TMPDIR");
608 if (!ret)
609 {
610 ret = "/tmp";
611 }
612#endif
613
614 return ret;
615}
616
617
618/*
619 * Put a directory and filename together.
620 */
621const char *
622platform_gen_path(const char *directory, const char *filename, struct gc_arena *gc)
623{
624#ifdef _WIN32
625 const int CC_PATH_RESERVED = CC_LESS_THAN | CC_GREATER_THAN | CC_COLON | CC_DOUBLE_QUOTE
627 | CC_ASTERISK;
628#else
629 const int CC_PATH_RESERVED = CC_SLASH;
630#endif
631
632 if (!gc)
633 {
634 return NULL; /* Would leak memory otherwise */
635 }
636
637 const char *safe_filename = string_mod_const(filename, CC_PRINT, CC_PATH_RESERVED, '_', gc);
638
639 if (safe_filename && strcmp(safe_filename, ".") && strcmp(safe_filename, "..")
640#ifdef _WIN32
641 && win_safe_filename(safe_filename)
642#endif
643 )
644 {
645 const size_t outsize = strlen(safe_filename) + (directory ? strlen(directory) : 0) + 16;
646 struct buffer out = alloc_buf_gc(outsize, gc);
647 char dirsep[2];
648
649 dirsep[0] = PATH_SEPARATOR;
650 dirsep[1] = '\0';
651
652 if (directory)
653 {
654 buf_printf(&out, "%s%s", directory, dirsep);
655 }
656 buf_printf(&out, "%s", safe_filename);
657
658 return BSTR(&out);
659 }
660 else
661 {
662 return NULL;
663 }
664}
665
666#if defined(__GNUC__) || defined(__clang__)
667#pragma GCC diagnostic pop
668#endif
669
670bool
671platform_absolute_pathname(const char *pathname)
672{
673 if (pathname)
674 {
675 const int c = pathname[0];
676#ifdef _WIN32
677 return c == '\\' || (isalpha(c) && pathname[1] == ':' && pathname[2] == '\\');
678#else
679 return c == '/';
680#endif
681 }
682 else
683 {
684 return false;
685 }
686}
687
688/* return true if filename can be opened for read */
689bool
690platform_test_file(const char *filename)
691{
692 bool ret = false;
693 if (filename)
694 {
695 FILE *fp = platform_fopen(filename, "r");
696 if (fp)
697 {
698 fclose(fp);
699 ret = true;
700 }
701 else
702 {
703 if (errno == EACCES)
704 {
705 msg(M_WARN | M_ERRNO, "Could not access file '%s'", filename);
706 }
707 }
708 }
709
710 dmsg(D_TEST_FILE, "TEST FILE '%s' [%d]", filename ? filename : "UNDEF", ret);
711
712 return ret;
713}
bool buf_printf(struct buffer *buf, const char *format,...)
printf-style append to a buffer with overflow check.
Definition buffer.c:231
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Allocate a buffer of the given size under garbage collection.
Definition buffer.c:77
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:1072
bool checked_snprintf(char *str, size_t size, const char *format,...)
Like snprintf() but returns an boolean.
Definition buffer.c:1150
Buffer management functions and garbage collection.
#define CC_DOUBLE_QUOTE
double quote
Definition buffer.h:1711
#define CC_PIPE
pipe
Definition buffer.h:1717
#define BSTR(buf)
Return the buffer content pointer cast to char *.
Definition buffer.h:157
#define CC_COLON
colon
Definition buffer.h:1708
#define CC_ASTERISK
asterisk
Definition buffer.h:1719
#define CC_BACKSLASH
backslash
Definition buffer.h:1703
#define CC_LESS_THAN
less than sign
Definition buffer.h:1715
#define CC_SLASH
slash
Definition buffer.h:1709
#define CC_GREATER_THAN
greater than sign
Definition buffer.h:1716
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
Definition buffer.h:1974
#define CC_PRINT
printable (>= 32, != 127)
Definition buffer.h:1694
#define CC_QUESTION_MARK
question mark
Definition buffer.h:1718
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
Definition buffer.h:1958
int64_t get_random(void)
an analogue to the random() function, but use prng_bytes and also int64_t instead of long to avoid LL...
Definition crypto.c:1703
Data Channel Cryptography Module.
#define D_TEST_FILE
Definition errlevel.h:133
#define M_INFO
Definition errlevel.h:54
static SERVICE_STATUS status
Definition interactive.c:52
#define CLEAR(x)
Definition basic.h:32
#define M_USAGE
Definition error.h:107
#define M_FATAL
Definition error.h:90
#define M_NONFATAL
Definition error.h:91
#define dmsg(flags,...)
Definition error.h:164
#define M_ERR
Definition error.h:106
#define msg(flags,...)
Definition error.h:152
#define M_WARN
Definition error.h:92
#define M_ERRNO
Definition error.h:95
static bool dco_enabled(const struct options *o)
Returns whether the current configuration has dco enabled.
Definition options.h:985
bool platform_test_file(const char *filename)
Return true if filename can be opened for read.
Definition platform.c:690
void platform_sleep_milliseconds(unsigned int n)
Definition platform.c:478
unsigned int platform_getpid(void)
Definition platform.c:338
const char * platform_create_temp_file(const char *directory, const char *prefix, struct gc_arena *gc)
Create a temporary file in directory, returns the filename of the created file.
Definition platform.c:545
int platform_ret_code(int stat)
Return an exit code if valid and between 0 and 255, -1 otherwise.
Definition platform.c:429
void platform_user_group_set(const struct platform_state_user *user_state, const struct platform_state_group *group_state, struct context *c)
Definition platform.c:223
void platform_nice(int niceval)
Definition platform.c:316
const char * platform_gen_path(const char *directory, const char *filename, struct gc_arena *gc)
Put a directory and filename together.
Definition platform.c:622
int platform_access(const char *path, int mode)
Definition platform.c:462
bool platform_user_get(const char *username, struct platform_state_user *state)
Definition platform.c:85
static void platform_user_set(const struct platform_state_user *state)
Definition platform.c:112
bool platform_unlink(const char *filename)
Definition platform.c:492
static void platform_group_set(const struct platform_state_group *state)
Definition platform.c:156
FILE * platform_fopen(const char *path, const char *mode)
Definition platform.c:505
bool platform_absolute_pathname(const char *pathname)
Return true if pathname is absolute.
Definition platform.c:671
int platform_chdir(const char *dir)
Definition platform.c:397
void platform_mlockall(bool print_msg)
Definition platform.c:349
void platform_chroot(const char *path)
Definition platform.c:54
const char * platform_get_tmp_dir(void)
Get a directory for temporary files.
Definition platform.c:591
static int need_keep_caps(struct context *c)
Definition platform.c:190
bool platform_group_get(const char *groupname, struct platform_state_group *state)
Definition platform.c:129
int platform_open(const char *path, int flags, int mode)
Definition platform.c:518
bool platform_system_ok(int stat)
interpret the status code returned by execve()
Definition platform.c:418
int platform_stat(const char *path, platform_stat_t *buf)
Definition platform.c:531
struct _stat platform_stat_t
Definition platform.h:118
Wrapper structure for dynamically allocated memory.
Definition buffer.h:71
Contains all state information for one tunnel.
Definition openvpn.h:455
struct options options
Options loaded from command line or configuration file.
Definition openvpn.h:456
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:127
#define PATH_SEPARATOR
Definition syshead.h:428
struct gc_arena gc
Definition test_ssl.c:138
bool win_safe_filename(const char *fn)
Definition win32-util.c:195
const char * win_get_tempdir(void)
Definition win32-util.c:229
WCHAR * wide_string(const char *utf8, struct gc_arena *gc)
Definition win32-util.c:45