[network-manager-vpnc/th/multiple-vpn-support: 4/4] service: add missing error handling when parsing command line



commit ed802c1b703075a741c84c24c80c5e74772b8741
Author: Thomas Haller <thaller redhat com>
Date:   Mon May 16 12:28:16 2016 +0200

    service: add missing error handling when parsing command line

 src/nm-vpnc-service.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/nm-vpnc-service.c b/src/nm-vpnc-service.c
index 331762d..8b994a9 100644
--- a/src/nm-vpnc-service.c
+++ b/src/nm-vpnc-service.c
@@ -1172,6 +1172,7 @@ main (int argc, char *argv[])
        GOptionContext *opt_ctx = NULL;
        gs_free char *bus_name_free = NULL;
        const char *bus_name;
+       GError *error = NULL;
 
        GOptionEntry options[] = {
                { "persist", 0, 0, G_OPTION_ARG_NONE, &persist, N_("Don't quit when VPN connection 
terminates"), NULL },
@@ -1202,7 +1203,13 @@ main (int argc, char *argv[])
                                      _("nm-vpnc-service provides integrated "
                                        "Cisco Legacy IPsec VPN capability to NetworkManager."));
 
-       g_option_context_parse (opt_ctx, &argc, &argv, NULL);
+       if (!g_option_context_parse (opt_ctx, &argc, &argv, &error)) {
+               g_warning ("Error parsing the command line options: %s", error->message);
+               g_option_context_free (opt_ctx);
+               g_clear_error (&error);
+               exit (EXIT_FAILURE);
+       }
+
        g_option_context_free (opt_ctx);
 
        bus_name = bus_name_free ?: NM_DBUS_SERVICE_VPNC;


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