[network-manager-openvpn] core: print out helper environment when debugging



commit d21d4263f8f4c2f48760ea186387629cbb32c507
Author: Dan Williams <dcbw redhat com>
Date:   Tue Jul 27 12:43:39 2010 -0700

    core: print out helper environment when debugging

 src/nm-openvpn-service-openvpn-helper.c |   11 +++++++++++
 src/nm-openvpn-service.c                |    5 ++++-
 2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/nm-openvpn-service-openvpn-helper.c b/src/nm-openvpn-service-openvpn-helper.c
index 47c093b..f84112f 100644
--- a/src/nm-openvpn-service-openvpn-helper.c
+++ b/src/nm-openvpn-service-openvpn-helper.c
@@ -47,6 +47,8 @@
 #include "nm-openvpn-service.h"
 #include "nm-utils.h"
 
+extern char **environ;
+
 /* These are here because nm-dbus-glib-types.h isn't exported */
 #define DBUS_TYPE_G_ARRAY_OF_UINT          (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
 #define DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_ARRAY_OF_UINT))
@@ -371,6 +373,7 @@ main (int argc, char *argv[])
 	GValue *dns_domain = NULL;
 	struct in_addr temp_addr;
 	gboolean tapdev = FALSE;
+	char **iter;
 
 	g_type_init ();
 
@@ -380,6 +383,14 @@ main (int argc, char *argv[])
 		exit (1);
 	}
 
+	if (argc >= 2 && !g_strcmp0 (argv[1], "--helper-debug")) {
+		g_message ("openvpn script environment ---------------------------");
+		iter = environ;
+		while (iter && *iter)
+			g_print ("%s\n", *iter++);
+		g_message ("------------------------------------------------------");
+	}
+
 	config = g_hash_table_new (g_str_hash, g_str_equal);
 
 	/* External world-visible VPN gateway */
diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
index d770e8c..aada7db 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -869,7 +869,10 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
 
 	/* Up script, called when connection has been established or has been restarted */
 	add_openvpn_arg (args, "--up");
-	add_openvpn_arg (args, NM_OPENVPN_HELPER_PATH);
+	if (getenv ("OPENVPN_DEBUG"))
+		add_openvpn_arg (args, NM_OPENVPN_HELPER_PATH " --helper-debug");
+	else
+		add_openvpn_arg (args, NM_OPENVPN_HELPER_PATH);
 	add_openvpn_arg (args, "--up-restart");
 
 	/* Keep key and tun if restart is needed */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]