From 90a33321998de233aaa256ca73228647db0f1235 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 12 Nov 2014 14:31:56 +0100 Subject: [PATCH] firewall: invoke FwAddToZoneFunc callback also when cancelling Not invoking a callback when cancelling the operation is counter intuitive. Note that NMPolicy refs the device, cancelling the call would leave the reference hanging. That was not an issue because the call was never cancelled. But still the behavior of NMFirewallManager is unexpected. Signed-off-by: Thomas Haller --- src/devices/nm-device.c | 13 ++++++++++--- src/nm-firewall-manager.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 4a6ac2f151..2c60b69dd4 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4545,8 +4545,14 @@ out: static void fw_change_zone_cb (GError *error, gpointer user_data) { - NMDevice *self = NM_DEVICE (user_data); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMDevice *self; + NMDevicePrivate *priv; + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_DEVICE (user_data); + priv = NM_DEVICE_GET_PRIVATE (self); priv->fw_call = NULL; @@ -4555,7 +4561,6 @@ fw_change_zone_cb (GError *error, gpointer user_data) } activation_source_schedule (self, nm_device_activate_stage3_ip_config_start, 0); - _LOGI (LOGD_DEVICE, "Activation: Stage 3 of 5 (IP Configure Start) scheduled."); } @@ -4577,6 +4582,8 @@ nm_device_activate_schedule_stage3_ip_config_start (NMDevice *self) priv = NM_DEVICE_GET_PRIVATE (self); g_return_if_fail (priv->act_request); + g_return_if_fail (!priv->fw_call); + /* Add the interface to the specified firewall zone */ connection = nm_device_get_connection (self); g_assert (connection); diff --git a/src/nm-firewall-manager.c b/src/nm-firewall-manager.c index deb1c973ca..34f2c37555 100644 --- a/src/nm-firewall-manager.c +++ b/src/nm-firewall-manager.c @@ -22,6 +22,7 @@ #include #include +#include #include #include "nm-firewall-manager.h" @@ -71,9 +72,17 @@ cb_info_free (CBInfo *info) { g_return_if_fail (info != NULL); - if (!info->completed) + if (!info->completed) { nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone call cancelled [%u]", info->iface, info->id); + if (info->callback) { + GError *error; + error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CANCELLED, + "Operation was cancelled"); + info->callback (error, info->user_data); + g_error_free (error); + } + } g_free (info->iface); g_free (info); }