[network-manager-pptp/NM_0_8] core: add --debug command-line option
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-pptp/NM_0_8] core: add --debug command-line option
- Date: Tue, 10 Aug 2010 19:23:57 +0000 (UTC)
commit 4452ed90809e9e7c37e734130b6c0a2f65d80219
Author: Dan Williams <dcbw redhat com>
Date: Tue Aug 10 14:25:16 2010 -0500
core: add --debug command-line option
configure.ac | 8 ++++++++
src/nm-pptp-service.c | 46 ++++++++++++++++++++++++++++++++++++++++------
2 files changed, 48 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a78afd3..e06462c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,6 +97,14 @@ fi
NM_COMPILER_WARNINGS
+dnl
+dnl Distribution version string
+dnl
+AC_ARG_WITH(dist-version, AS_HELP_STRING([--with-dist-version=<dist-version>], [Define the custom version (like distribution package name and revision)]), ac_distver=$withval, ac_distver="")
+if ! test x"$ac_distver" = x""; then
+ AC_DEFINE_UNQUOTED(DIST_VERSION, "$ac_distver", [Define the distribution version string])
+fi
+
AC_CONFIG_FILES([
Makefile
src/Makefile
diff --git a/src/nm-pptp-service.c b/src/nm-pptp-service.c
index 5bbda7b..a692cb8 100644
--- a/src/nm-pptp-service.c
+++ b/src/nm-pptp-service.c
@@ -17,9 +17,11 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2008 - 2009 Red Hat, Inc.
+ * (C) Copyright 2008 - 2010 Red Hat, Inc.
*/
+#include <config.h>
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -47,6 +49,12 @@
#include "nm-pptp-service.h"
#include "nm-ppp-status.h"
+#if !defined(DIST_VERSION)
+# define DIST_VERSION VERSION
+#endif
+
+static gboolean debug = FALSE;
+
/********************************************************/
/* ppp plugin <-> pptp-service object */
/********************************************************/
@@ -710,11 +718,11 @@ construct_pppd_args (NMPptpPlugin *plugin,
g_ptr_array_add (args, (gpointer) g_strdup ("pty"));
tmp = g_strdup_printf ("%s %s --nolaunchpppd %s --logstring %s",
pptp_binary, value,
- getenv ("NM_PPTP_DEBUG") ? loglevel2 : loglevel0,
+ debug ? loglevel2 : loglevel0,
ipparam);
g_ptr_array_add (args, (gpointer) tmp);
- if (getenv ("NM_PPP_DEBUG"))
+ if (debug)
g_ptr_array_add (args, (gpointer) g_strdup ("debug"));
/* PPP options */
@@ -1245,18 +1253,44 @@ main (int argc, char *argv[])
{
NMPptpPlugin *plugin;
GMainLoop *main_loop;
+ gboolean persist = FALSE;
+ GOptionContext *opt_ctx = NULL;
+
+ GOptionEntry options[] = {
+ { "persist", 0, 0, G_OPTION_ARG_NONE, &persist, "Don't quit when VPN connection terminates", NULL },
+ { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, "Enable verbose debug logging (may expose passwords)", NULL },
+ {NULL}
+ };
g_type_init ();
+ /* Parse options */
+ opt_ctx = g_option_context_new ("");
+ g_option_context_set_translation_domain (opt_ctx, "UTF-8");
+ g_option_context_set_ignore_unknown_options (opt_ctx, FALSE);
+ g_option_context_set_help_enabled (opt_ctx, TRUE);
+ g_option_context_add_main_entries (opt_ctx, options, NULL);
+
+ g_option_context_set_summary (opt_ctx,
+ "nm-vpnc-service provides integrated Cisco Legacy IPSec VPN capability to NetworkManager.");
+
+ g_option_context_parse (opt_ctx, &argc, &argv, NULL);
+ g_option_context_free (opt_ctx);
+
+ if (getenv ("NM_PPP_DEBUG"))
+ debug = TRUE;
+
+ if (debug)
+ g_message ("nm-pptp-service (version " DIST_VERSION ") starting...");
+
plugin = nm_pptp_plugin_new ();
if (!plugin)
exit (EXIT_FAILURE);
main_loop = g_main_loop_new (NULL, FALSE);
- g_signal_connect (plugin, "quit",
- G_CALLBACK (quit_mainloop),
- main_loop);
+ if (!persist)
+ g_signal_connect (plugin, "quit", G_CALLBACK (quit_mainloop), main_loop);
g_main_loop_run (main_loop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]