diff options
author | Arne Schwabe <arne@rfc2549.org> | 2013-02-03 14:13:10 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2013-02-03 14:13:10 +0100 |
commit | 8944196988e70d747f19153796b5bea2a0166b92 (patch) | |
tree | c33ecbad3bd8ea6e610c04416949b63c90a2f2bf /openvpn/src | |
parent | f00cd03f5aa1f8042b55ebee5050d297cef6bb8a (diff) |
OpenVPN Fixes and merge with upstream
Diffstat (limited to 'openvpn/src')
-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/status.c | 2 |
5 files changed, 16 insertions, 55 deletions
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 1e9a7fc0..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, &gc); - 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/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) |