[network-manager-openvpn/th/bgo556134_up_restart: 4/5] 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/5] helper: gracefully handle missing environment variables in --up-restart invocations
- Date: Thu, 3 Apr 2014 17:28:55 +0000 (UTC)
commit c092f8b7b06ed960b53a6cc977aef92afdfa56b7
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/
https://bugzilla.redhat.com/show_bug.cgi?id=766340
https://bugzilla.redhat.com/show_bug.cgi?id=1083317
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 edf44e7..2c07cff 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 ();
@@ -587,6 +588,8 @@ main (int argc, char *argv[])
argv += shift;
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);
@@ -628,6 +631,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)
@@ -637,13 +642,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]