[network-manager-pptp] service: add --bus-name argument
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-pptp] service: add --bus-name argument
- Date: Sun, 20 Mar 2016 15:51:57 +0000 (UTC)
commit 17ae85788987ef1f7c92a251c535312163144c33
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Sun Mar 20 11:32:53 2016 +0100
service: add --bus-name argument
Make it possible to specify a different bus name to acquire.
nm-pptp-service.conf | 10 ++++++----
nm-pptp-service.name.in | 1 +
src/nm-pptp-pppd-plugin.c | 8 +++++++-
src/nm-pptp-service.c | 13 +++++++++----
src/nm-pptp-service.h | 2 +-
5 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/nm-pptp-service.conf b/nm-pptp-service.conf
index 53909d1..343cc0e 100644
--- a/nm-pptp-service.conf
+++ b/nm-pptp-service.conf
@@ -3,17 +3,19 @@
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="root">
- <allow own="org.freedesktop.NetworkManager.pptp"/>
+ <allow own_prefix="org.freedesktop.NetworkManager.pptp"/>
<allow send_destination="org.freedesktop.NetworkManager.pptp"/>
+ <allow send_interface="org.freedesktop.NetworkManager.pptp"/>
- <allow own="org.freedesktop.NetworkManager.pptp-ppp"/>
+ <allow own_prefix="org.freedesktop.NetworkManager.pptp-ppp"/>
<allow send_destination="org.freedesktop.NetworkManager.pptp-ppp"/>
+ <allow send_interface="org.freedesktop.NetworkManager.pptp-ppp"/>
</policy>
<policy context="default">
- <deny own="org.freedesktop.NetworkManager.pptp"/>
+ <deny own_prefix="org.freedesktop.NetworkManager.pptp"/>
<deny send_destination="org.freedesktop.NetworkManager.pptp"/>
- <deny own="org.freedesktop.NetworkManager.pptp-ppp"/>
+ <deny own_prefix="org.freedesktop.NetworkManager.pptp-ppp"/>
<deny send_destination="org.freedesktop.NetworkManager.pptp-ppp"/>
</policy>
</busconfig>
diff --git a/nm-pptp-service.name.in b/nm-pptp-service.name.in
index 90b4e34..fe6f5d7 100644
--- a/nm-pptp-service.name.in
+++ b/nm-pptp-service.name.in
@@ -2,6 +2,7 @@
name=pptp
service=org.freedesktop.NetworkManager.pptp
program= LIBEXECDIR@/nm-pptp-service
+supports-multiple-connections=true
[libnm]
plugin= PLUGINDIR@/libnm-vpn-plugin-pptp.so
diff --git a/src/nm-pptp-pppd-plugin.c b/src/nm-pptp-pppd-plugin.c
index e7a9afd..d10029c 100644
--- a/src/nm-pptp-pppd-plugin.c
+++ b/src/nm-pptp-pppd-plugin.c
@@ -21,6 +21,7 @@
*/
#include <string.h>
+#include <stdlib.h>
#include <pppd/pppd.h>
#include <pppd/fsm.h>
#include <pppd/ipcp.h>
@@ -292,11 +293,16 @@ plugin_init (void)
{
GDBusConnection *bus;
GError *err = NULL;
+ const char *bus_name;
#if !GLIB_CHECK_VERSION (2, 35, 0)
g_type_init ();
#endif
+ bus_name = getenv ("NM_DBUS_SERVICE_PPTP");
+ if (!bus_name)
+ bus_name = NM_DBUS_SERVICE_PPTP;
+
g_message ("nm-pptp-ppp-plugin: (%s): initializing", __func__);
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &err);
@@ -311,7 +317,7 @@ plugin_init (void)
proxy = g_dbus_proxy_new_sync (bus, G_DBUS_CALL_FLAGS_NONE, NULL,
NM_DBUS_SERVICE_PPTP_PPP,
- NM_DBUS_PATH_PPTP_PPP,
+ bus_name,
NM_DBUS_INTERFACE_PPTP_PPP,
NULL, &err);
g_object_unref (bus);
diff --git a/src/nm-pptp-service.c b/src/nm-pptp-service.c
index d56c56f..f8e4c7b 100644
--- a/src/nm-pptp-service.c
+++ b/src/nm-pptp-service.c
@@ -1298,14 +1298,14 @@ nm_pptp_plugin_class_init (NMPptpPluginClass *pptp_class)
}
NMPptpPlugin *
-nm_pptp_plugin_new (void)
+nm_pptp_plugin_new (const char *bus_name)
{
NMPptpPlugin *plugin;
GError *error = NULL;
plugin = g_initable_new (NM_TYPE_PPTP_PLUGIN, NULL, &error,
- NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME,
- NM_DBUS_SERVICE_PPTP,
+ NM_VPN_SERVICE_PLUGIN_DBUS_SERVICE_NAME, bus_name,
+ NM_VPN_SERVICE_PLUGIN_DBUS_WATCH_PEER, !debug,
NULL);
if (plugin)
g_signal_connect (G_OBJECT (plugin), "state-changed", G_CALLBACK (state_changed_cb), NULL);
@@ -1332,10 +1332,12 @@ main (int argc, char *argv[])
GOptionContext *opt_ctx = NULL;
char *conntrack_module[] = { "/sbin/modprobe", "nf_conntrack_pptp", NULL };
GError *error = NULL;
+ gchar *bus_name = NM_DBUS_SERVICE_PPTP;
GOptionEntry options[] = {
{ "persist", 0, 0, G_OPTION_ARG_NONE, &persist, N_("Don't quit when VPN connection
terminates"), NULL },
{ "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable verbose debug logging (may expose
passwords)"), NULL },
+ { "bus-name", 0, 0, G_OPTION_ARG_STRING, &bus_name, N_("D-Bus name to use for this
instance"), NULL },
{NULL}
};
@@ -1369,7 +1371,10 @@ main (int argc, char *argv[])
if (debug)
g_message ("nm-pptp-service (version " DIST_VERSION ") starting...");
- plugin = nm_pptp_plugin_new ();
+ if (bus_name)
+ setenv ("NM_DBUS_SERVICE_PPTP", bus_name, 0);
+
+ plugin = nm_pptp_plugin_new (bus_name);
if (!plugin)
exit (EXIT_FAILURE);
diff --git a/src/nm-pptp-service.h b/src/nm-pptp-service.h
index 989a06b..8342d07 100644
--- a/src/nm-pptp-service.h
+++ b/src/nm-pptp-service.h
@@ -47,6 +47,6 @@ typedef struct {
GType nm_pptp_plugin_get_type (void);
-NMPptpPlugin *nm_pptp_plugin_new (void);
+NMPptpPlugin *nm_pptp_plugin_new (const gchar *);
#endif /* NM_PPTP_PLUGIN_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]