[network-manager-openvpn/th/bgo556134_up_restart: 4/4] helper: gracefully handle missing environment variables in --up-restart invocations
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn/th/bgo556134_up_restart: 4/4] helper: gracefully handle missing environment variables in --up-restart invocations
- Date: Tue, 18 Mar 2014 14:47:37 +0000 (UTC)
commit ace7c89cd0f53198822b7d07f11c14fd53502a90
Author: Thomas Haller <thaller redhat com>
Date: Tue Mar 18 15:42:13 2014 +0100
helper: gracefully handle missing environment variables in --up-restart invocations
When calling the script during restart, some environment variables are
not set properly. Work around this by taking the values from the
command line arguments instead.
https://bugzilla.gnome.org/show_bug.cgi?id=556134
https://bugs.launchpad.net/ubuntu/+source/network-manager-openvpn/+bug/280160/
Signed-off-by: Thomas Haller <thaller redhat com>
src/nm-openvpn-service-openvpn-helper.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/nm-openvpn-service-openvpn-helper.c b/src/nm-openvpn-service-openvpn-helper.c
index da0d715..2343e6f 100644
--- a/src/nm-openvpn-service-openvpn-helper.c
+++ b/src/nm-openvpn-service-openvpn-helper.c
@@ -538,6 +538,7 @@ main (int argc, char *argv[])
int tapdev = -1;
char **iter;
int shift = 0;
+ gboolean is_restart;
#if !GLIB_CHECK_VERSION (2, 35, 0)
g_type_init ();
@@ -593,6 +594,8 @@ main (int argc, char *argv[])
argc -= shift;
}
+ is_restart = argc >= 7 && !g_strcmp0 (argv[6], "restart");
+
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
if (!connection) {
g_warning ("Could not get the system bus: %s", err->message);
@@ -634,6 +637,8 @@ main (int argc, char *argv[])
/* IPv4 address */
tmp = getenv ("ifconfig_local");
+ if (!tmp && is_restart)
+ tmp = argv[4];
if (tmp && strlen (tmp)) {
val = addr4_to_gvalue (tmp);
if (val)
@@ -643,13 +648,15 @@ main (int argc, char *argv[])
}
/* PTP address; for vpnc PTP address == internal IP4 address */
- val = addr4_to_gvalue (getenv ("ifconfig_remote"));
+ tmp = getenv ("ifconfig_remote");
+ if (!tmp && is_restart)
+ tmp = argv[5];
+ val = addr4_to_gvalue (tmp);
if (val) {
/* Sigh. Openvpn added 'topology' stuff in 2.1 that changes the meaning
* of the ifconfig bits without actually telling you what they are
* supposed to mean; basically relying on specific 'ifconfig' behavior.
*/
- tmp = getenv ("ifconfig_remote");
if (tmp && !strncmp (tmp, "255.", 4)) {
guint32 addr;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]