diff options
Diffstat (limited to 'openvpn/src')
-rw-r--r-- | openvpn/src/openvpn/error.c | 1 | ||||
-rw-r--r-- | openvpn/src/openvpn/event.c | 3 | ||||
-rw-r--r-- | openvpn/src/openvpn/init.c | 8 | ||||
-rw-r--r-- | openvpn/src/openvpn/misc.c | 30 | ||||
-rw-r--r-- | openvpn/src/openvpn/platform.c | 28 | ||||
-rw-r--r-- | openvpn/src/openvpn/socket.c | 13 | ||||
-rw-r--r-- | openvpn/src/openvpn/status.c | 2 |
7 files changed, 25 insertions, 60 deletions
diff --git a/openvpn/src/openvpn/error.c b/openvpn/src/openvpn/error.c index 98611a1b..d9450a6c 100644 --- a/openvpn/src/openvpn/error.c +++ b/openvpn/src/openvpn/error.c @@ -404,6 +404,7 @@ void assert_failed (const char *filename, int line) { #ifdef GOOGLE_BREAKPAD + msg (M_NONFATAL, "Assertion failed at %s:%d", filename, line); breakpad_dodump(); #endif msg (M_FATAL, "Assertion failed at %s:%d", filename, line); diff --git a/openvpn/src/openvpn/event.c b/openvpn/src/openvpn/event.c index 2a13e1cf..34a3c451 100644 --- a/openvpn/src/openvpn/event.c +++ b/openvpn/src/openvpn/event.c @@ -34,6 +34,7 @@ #include "error.h" #include "integer.h" #include "event.h" +#include "fdmisc.h" #include "memdbg.h" @@ -582,6 +583,8 @@ ep_init (int *maxevents, unsigned int flags) if (fd < 0) return NULL; + set_cloexec (fd); + ALLOC_OBJ_CLEAR (eps, struct ep_set); /* set dispatch functions */ diff --git a/openvpn/src/openvpn/init.c b/openvpn/src/openvpn/init.c index b3125282..28121235 100644 --- a/openvpn/src/openvpn/init.c +++ b/openvpn/src/openvpn/init.c @@ -3288,6 +3288,10 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int /* init garbage collection level */ gc_init (&c->c2.gc); + /* inherit environmental variables */ + if (env) + do_inherit_env (c, env); + /* signals caught here will abort */ c->sig->signal_received = 0; c->sig->signal_text = NULL; @@ -3339,10 +3343,6 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int if (c->mode == CM_P2P || c->mode == CM_TOP) do_option_warnings (c); - /* inherit environmental variables */ - if (env) - do_inherit_env (c, env); - #ifdef ENABLE_PLUGIN /* initialize plugins */ if (c->mode == CM_P2P || c->mode == CM_TOP) diff --git a/openvpn/src/openvpn/misc.c b/openvpn/src/openvpn/misc.c index fcc85526..fa327f8c 100644 --- a/openvpn/src/openvpn/misc.c +++ b/openvpn/src/openvpn/misc.c @@ -707,13 +707,6 @@ env_set_remove_from_environment (const struct env_set *es) static struct env_item *global_env = NULL; /* GLOBAL */ -void -manage_env (char *str) -{ - remove_env_item (str, true, &global_env); - add_env_item (str, false, &global_env, NULL); -} - #endif /* add/modify/delete environmental strings */ @@ -789,27 +782,18 @@ setenv_str_ex (struct env_set *es, if (value) val_tmp = string_mod_const (value, value_include, value_exclude, value_replace, &gc); - if (es) + ASSERT (es); + + if (val_tmp) { - if (val_tmp) - { - const char *str = construct_name_value (name_tmp, val_tmp, &gc); - env_set_add (es, str); + const char *str = construct_name_value (name_tmp, val_tmp, &gc); + env_set_add (es, str); #if DEBUG_VERBOSE_SETENV - msg (M_INFO, "SETENV_ES '%s'", str); + msg (M_INFO, "SETENV_ES '%s'", str); #endif - } - else - env_set_del (es, name_tmp); } else - { - char *str = construct_name_value (name_tmp, val_tmp, NULL); - if (platform_putenv(str)) - { - msg (M_WARN | M_ERRNO, "putenv('%s') failed", str); - } - } + env_set_del (es, name_tmp); gc_free (&gc); } diff --git a/openvpn/src/openvpn/platform.c b/openvpn/src/openvpn/platform.c index e79de7a7..16d4daca 100644 --- a/openvpn/src/openvpn/platform.c +++ b/openvpn/src/openvpn/platform.c @@ -275,34 +275,6 @@ platform_unlink (const char *filename) #endif } -int platform_putenv(char *string) -{ - int status; -#if defined(WIN32) - struct gc_arena gc = gc_new (); - char *s = string_alloc(string, &gc); - char *value = strchr(s, '='); - if (value!=NULL) - { - *value = '\0'; - value++; - if (*value == '\0') - value = NULL; - } - - status = SetEnvironmentVariableW (wide_string (s, &gc), - wide_string (value, &gc)) ? 1: 0; - gc_free (&gc); -#elif defined(HAVE_PUTENV) - void manage_env (char *str); /* TODO: Resolve properly */ - status = putenv (string); - if (!status) - manage_env (string); -#endif - - return status; -} - FILE * platform_fopen (const char *path, const char *mode) { diff --git a/openvpn/src/openvpn/socket.c b/openvpn/src/openvpn/socket.c index e3e93525..83af046f 100644 --- a/openvpn/src/openvpn/socket.c +++ b/openvpn/src/openvpn/socket.c @@ -686,7 +686,6 @@ create_socket (struct link_socket *sock) { ASSERT (0); } - /* set socket buffers based on --sndbuf and --rcvbuf options */ socket_set_buffers (sock->sd, &sock->socket_buffer_sizes); @@ -939,7 +938,6 @@ openvpn_connect (socket_descriptor_t sd, protect_fd_nonlocal(sd, remote); status = connect (sd, remote, af_addr_size(remote->sa_family)); - if (status) status = openvpn_errno (); if ( @@ -1780,12 +1778,17 @@ link_socket_init_phase2 (struct link_socket *sock, phase2_tcp_client (sock, sig_info); } -#ifdef ENABLE_SOCKS - else if (sock->info.proto == PROTO_UDP && sock->socks_proxy && sock->info.af == AF_INET) + else if (sock->info.proto == PROTO_UDP) { - phase2_socks_client (sock, sig_info); +#ifdef ENABLE_SOCKS + if (sock->info.proto == PROTO_UDP && sock->socks_proxy) + { + phase2_socks_client (sock, sig_info); #endif + } + protect_fd_nonlocal (sock->sd, &sock->info.lsa->actual.dest.addr.sa); } + if (sig_info && sig_info->signal_received) goto done; } diff --git a/openvpn/src/openvpn/status.c b/openvpn/src/openvpn/status.c index 5f9ab9ee..b7ff4843 100644 --- a/openvpn/src/openvpn/status.c +++ b/openvpn/src/openvpn/status.c @@ -33,6 +33,7 @@ #include "status.h" #include "perf.h" #include "misc.h" +#include "fdmisc.h" #include "memdbg.h" @@ -98,6 +99,7 @@ status_open (const char *filename, if (so->fd >= 0) { so->filename = string_alloc (filename, NULL); + set_cloexec (so->fd); /* allocate read buffer */ if (so->flags & STATUS_OUTPUT_READ) |