[network-manager-libreswan/lr/multiple-vpn: 6/8] helper: add --bus-name argument



commit 9694f812d9343a28cb8512306b8963faa96b23d2
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Thu Oct 29 09:40:05 2015 +0100

    helper: add --bus-name argument

 src/nm-libreswan-service-helper.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/src/nm-libreswan-service-helper.c b/src/nm-libreswan-service-helper.c
index 531bdba..54315e1 100644
--- a/src/nm-libreswan-service-helper.c
+++ b/src/nm-libreswan-service-helper.c
@@ -35,6 +35,27 @@ main (int argc, char *argv[])
        GError *err = NULL;
        gchar **environ;
        gchar **p;
+       const char *bus_name;
+
+       switch (argc) {
+       case 1:
+               bus_name = NM_DBUS_SERVICE_LIBRESWAN;
+               break;
+       case 3:
+               if (strcmp (argv[1], "--bus-name") == 0) {
+                       bus_name = argv[2];
+                       break;
+               }
+               /* fallthrough */
+       default:
+               g_warning ("Usage: %s [--bus-name <name>]", argv[0]);
+               exit (1);
+       }
+
+       if (!g_dbus_is_name (bus_name)) {
+               g_warning ("Not a valid bus name: '%s'\n", bus_name);
+               exit (1);
+       }
 
 #if !GLIB_CHECK_VERSION (2, 35, 0)
        g_type_init ();
@@ -42,7 +63,7 @@ main (int argc, char *argv[])
 
        proxy = nmdbus_libreswan_helper_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                                                G_DBUS_PROXY_FLAGS_NONE,
-                                                               NM_DBUS_SERVICE_LIBRESWAN,
+                                                               bus_name,
                                                                NM_DBUS_PATH_LIBRESWAN_HELPER,
                                                                NULL, &err);
        if (!proxy) {


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