Commit 17ae8578 authored by Lubomir Rintel's avatar Lubomir Rintel

service: add --bus-name argument

Make it possible to specify a different bus name to acquire.
parent c802d6c3
......@@ -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>
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment