NetworkManager/nm-controlled.patch
Ray Strode ad57d03301 handle changes to ifcfg files properly
This commit adds upstream commits:

312c7c952cbb3f20bcb1092db9bfbb51485fcebd
adc7ec170d429b6b8cdeb302c8afa96fbd3ba907

in order to squash an alpha blocker.

See https://bugzilla.redhat.com/show_bug.cgi?id=727501
2011-08-05 16:03:43 -04:00

124 lines
5.3 KiB
Diff

From 312c7c952cbb3f20bcb1092db9bfbb51485fcebd Mon Sep 17 00:00:00 2001
From: Jiří Klimeš <jklimes@redhat.com>
Date: Tue, 02 Aug 2011 07:15:37 +0000
Subject: ifcfg-rh: emit "updated" signal when connection file is changed (rh #727501)
Chain up to parent's commit_changes() even if in-memory and on-disk data are the
same; they are the same when another process changes the on-disk file. Just make
sure not to write out the data needlessly when same.
This fixes a regression caused by 9cba854fa0a32022a44e922dd4e70aaaf3c00dd2.
It exhibits e.g. by not auto-activating connection when ONBOOT is changed from
"no" to "yes". Connection "updated" signal was not emitted and listeners like
NMPolicy was not prodded.
---
diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
index 534f44d..04d3d3e 100644
--- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
+++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2008 - 2010 Red Hat, Inc.
+ * Copyright (C) 2008 - 2011 Red Hat, Inc.
*/
#include <string.h>
@@ -181,7 +181,7 @@ nm_ifcfg_connection_get_unmanaged_spec (NMIfcfgConnection *self)
static void
commit_changes (NMSettingsConnection *connection,
NMSettingsConnectionCommitFunc callback,
- gpointer user_data)
+ gpointer user_data)
{
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection);
GError *error = NULL;
@@ -208,9 +208,12 @@ commit_changes (NMSettingsConnection *connection,
NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS);
g_object_unref (reread);
- /* Don't bother writing anything out if nothing really changed */
- if (same == TRUE)
+ /* Don't bother writing anything out if in-memory and on-disk data are the same */
+ if (same) {
+ /* But chain up to parent to handle success - emits updated signal */
+ NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, callback, user_data);
return;
+ }
}
if (writer_update_connection (NM_CONNECTION (connection),
@@ -227,7 +230,7 @@ commit_changes (NMSettingsConnection *connection,
}
}
-static void
+static void
do_delete (NMSettingsConnection *connection,
NMSettingsConnectionDeleteFunc callback,
gpointer user_data)
--
cgit v0.8.3-6-g21f6
From adc7ec170d429b6b8cdeb302c8afa96fbd3ba907 Mon Sep 17 00:00:00 2001
From: Jiří Klimeš <jklimes@redhat.com>
Date: Tue, 02 Aug 2011 08:45:43 +0000
Subject: ifcfg-rh: make NM_CONTROLLED changes function properly (rh #727501)
Changing NM_CONTROLED from "no" to "yes" worked just the first time.
Fix that by storing unmanaged spec when interface becomes unmanaged
and adjust condition identifying "no-change" updates to the ifcfg
file.
---
diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c
index 7d27656..ed0dcec 100644
--- a/src/settings/plugins/ifcfg-rh/plugin.c
+++ b/src/settings/plugins/ifcfg-rh/plugin.c
@@ -269,20 +269,24 @@ connection_new_or_changed (SCPluginIfcfg *self,
/* Successfully read connection changes */
- /* When the connections are the same, nothing is done */
- if (nm_connection_compare (NM_CONNECTION (existing),
- NM_CONNECTION (new),
- NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS |
- NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) {
+ old_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (NM_IFCFG_CONNECTION (existing));
+ new_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (NM_IFCFG_CONNECTION (new));
+
+ /* When interface is unmanaged or the connections and unmanaged specs are the same
+ * there's nothing to do */
+ if ( (g_strcmp0 (old_unmanaged, new_unmanaged) == 0 && new_unmanaged != NULL)
+ || ( nm_connection_compare (NM_CONNECTION (existing),
+ NM_CONNECTION (new),
+ NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS |
+ NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)
+ && g_strcmp0 (old_unmanaged, new_unmanaged) == 0)) {
+
g_object_unref (new);
return;
}
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "updating %s", path);
- old_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (NM_IFCFG_CONNECTION (existing));
- new_unmanaged = nm_ifcfg_connection_get_unmanaged_spec (NM_IFCFG_CONNECTION (new));
-
if (new_unmanaged) {
if (!old_unmanaged) {
/* Unexport the connection by telling the settings service it's
@@ -290,6 +294,11 @@ connection_new_or_changed (SCPluginIfcfg *self,
* unmanaged specs have changed.
*/
nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (existing));
+ /* Remove the path so that claim_connection() doesn't complain later when
+ * interface gets managed and connection is re-added. */
+ nm_connection_set_path (NM_CONNECTION (existing), NULL);
+
+ g_object_set (existing, NM_IFCFG_CONNECTION_UNMANAGED, new_unmanaged, NULL);
g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
}
} else {
--
cgit v0.8.3-6-g21f6