The return_method would be rejected by the dbus-daemon when the NM drops
its match, resulting in an ugly message in the log:
method call time=
1458301860.187048 sender=:1.267 -> destination=:1.276
serial=5302 path=/org/freedesktop/NetworkManager/VPN/Plugin;
interface=org.freedesktop.NetworkManager.VPN.Plugin; member=Disconnect
method call time=
1458301860.187054 sender=:1.267 -> destination=org.freedesktop.DBus
serial=5303 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus;
member=RemoveMatch
string "type='signal',sender='org.freedesktop.DBus',
interface='org.freedesktop.DBus',
member='NameOwnerChanged',
path='/org/freedesktop/DBus',
arg0='org.freedesktop.NetworkManager.libreswan.Connection_10'"
method return time=
1458301860.187061 sender=org.freedesktop.DBus -> destination=:1.267
serial=1835 reply_serial=5303
...
method return time=
1458301860.195351 sender=:1.276 -> destination=:1.267
serial=19 reply_serial=5302
error time=
1458301860.195361 sender=org.freedesktop.DBus -> destination=:1.276
error_name=org.freedesktop.DBus.Error.AccessDenied reply_serial=19
string "Rejected send message, 7 matched rules; type="method_return",
sender=":1.276" (uid=0 pid=26915
comm="/usr/libexec/nm-libreswan-service --bus-name org.f")
interface="(unset)" member="(unset)" error name="(unset)"
requested_reply="0" destination=":1.267" (uid=0 pid=25724
comm="/usr/sbin/NetworkManager --no-daemon ")"
Also, refcount the connection instance. While the proxy is alive, it
invokes singal callbacks that get the object as a parameter.
return con;
}
+static void
+disconnect_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
+{
+ g_dbus_proxy_call_finish (proxy, result, NULL);
+ g_object_unref (user_data);
+}
+
static void
call_plugin_disconnect (NMVpnConnection *self)
{
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self);
- if (priv->proxy) {
- g_dbus_proxy_call (priv->proxy, "Disconnect", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
- g_clear_object (&priv->proxy);
- }
+ g_dbus_proxy_call (priv->proxy,
+ "Disconnect",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ priv->cancellable,
+ (GAsyncReadyCallback) disconnect_cb,
+ g_object_ref (self));
}
static void