[network-manager-openvpn/lr/multiple-vpn: 2/5] helper: add --bus-name argument



commit 570557c854fedca5d62c5aaf8ad4467f6e1f7472
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Wed Aug 19 11:54:59 2015 +0200

    helper: add --bus-name argument
    
    Makes it possible to make helper speak to a different bus.

 src/nm-openvpn-service-openvpn-helper.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/nm-openvpn-service-openvpn-helper.c b/src/nm-openvpn-service-openvpn-helper.c
index 28456da..eddbc06 100644
--- a/src/nm-openvpn-service-openvpn-helper.c
+++ b/src/nm-openvpn-service-openvpn-helper.c
@@ -439,6 +439,7 @@ main (int argc, char *argv[])
        int shift = 0;
        gboolean is_restart;
        gboolean has_ip4_prefix = FALSE;
+       gchar *bus_name = NM_DBUS_SERVICE_OPENVPN;
 
 #if !GLIB_CHECK_VERSION (2, 35, 0)
        g_type_init ();
@@ -455,7 +456,17 @@ main (int argc, char *argv[])
                        tapdev = 0;
                else if (!strcmp (argv[i], "--tap"))
                        tapdev = 1;
-               else
+               else if (!strcmp (argv[i], "--bus-name")) {
+                       if (++i == argc) {
+                               g_warning ("Missing bus name argument");
+                               exit (1);
+                       }
+                       if (!g_dbus_is_name (argv[i])) {
+                               g_warning ("Invalid bus name");
+                               exit (1);
+                       }
+                       bus_name = argv[i];
+               } else
                        break;
        }
        shift = i - 1;
@@ -493,7 +504,7 @@ main (int argc, char *argv[])
        proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                               G_DBUS_PROXY_FLAGS_NONE,
                                               NULL,
-                                              NM_DBUS_SERVICE_OPENVPN,
+                                              bus_name,
                                               NM_VPN_DBUS_PLUGIN_PATH,
                                               NM_VPN_DBUS_PLUGIN_INTERFACE,
                                               NULL, &err);


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