NetworkManager/ifcfg-rh-inotify-update-fix.patch

93 lines
3.9 KiB
Diff

diff --git a/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
index 7e18ed0..bfc36af 100644
--- a/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
+++ b/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
@@ -317,27 +317,27 @@ nm_ifcfg_connection_get_unmanaged (NMIfcfgConnection *self)
return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unmanaged;
}
-static gboolean
-update (NMExportedConnection *exported, GHashTable *new_settings, GError **error)
+gboolean
+nm_ifcfg_connection_update (NMIfcfgConnection *self, GHashTable *new_settings, GError **error)
{
+ NMExportedConnection *exported = NM_EXPORTED_CONNECTION (self);
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (exported);
- gboolean success;
NMConnection *connection;
- success = NM_EXPORTED_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->update (exported, new_settings, error);
- if (success) {
- connection = nm_exported_connection_get_connection (exported);
- success = nm_connection_replace_settings (connection, new_settings, error);
- if (success) {
- success = writer_update_connection (connection,
- IFCFG_DIR,
- priv->filename,
- priv->keyfile,
- error);
- }
- }
+ connection = nm_exported_connection_get_connection (exported);
+ if (!nm_connection_replace_settings (connection, new_settings, error))
+ return FALSE;
+
+ return writer_update_connection (connection, IFCFG_DIR, priv->filename, priv->keyfile, error);
+}
+
+static gboolean
+update (NMExportedConnection *exported, GHashTable *new_settings, GError **error)
+{
+ if (!NM_EXPORTED_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->update (exported, new_settings, error))
+ return FALSE;
- return success;
+ return nm_ifcfg_connection_update (NM_IFCFG_CONNECTION (exported), new_settings, error);
}
static gboolean
diff --git a/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.h b/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.h
index f2a8c6d..dc13aa6 100644
--- a/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.h
+++ b/system-settings/plugins/ifcfg-rh/nm-ifcfg-connection.h
@@ -60,6 +60,10 @@ const char *nm_ifcfg_connection_get_udi (NMIfcfgConnection *self);
gboolean nm_ifcfg_connection_get_unmanaged (NMIfcfgConnection *self);
+gboolean nm_ifcfg_connection_update (NMIfcfgConnection *self,
+ GHashTable *new_settings,
+ GError **error);
+
G_END_DECLS
#endif /* NM_IFCFG_CONNECTION_H */
diff --git a/system-settings/plugins/ifcfg-rh/plugin.c b/system-settings/plugins/ifcfg-rh/plugin.c
index 25d93b9..976090c 100644
--- a/system-settings/plugins/ifcfg-rh/plugin.c
+++ b/system-settings/plugins/ifcfg-rh/plugin.c
@@ -293,9 +293,9 @@ connection_changed_handler (SCPluginIfcfg *plugin,
/* errors reading connection; remove it */
if (!ignore_error) {
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " error: %s",
- error->message ? error->message : "(unknown)");
+ (error && error->message) ? error->message : "(unknown)");
}
- g_error_free (error);
+ g_clear_error (&error);
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "removed %s.", path);
*do_remove = TRUE;
@@ -336,7 +336,11 @@ connection_changed_handler (SCPluginIfcfg *plugin,
/* Only update if different */
if (!nm_connection_compare (new_wrapped, old_wrapped, NM_SETTING_COMPARE_FLAG_EXACT)) {
settings = nm_connection_to_hash (new_wrapped);
- nm_exported_connection_update (NM_EXPORTED_CONNECTION (connection), settings, NULL);
+ if (!nm_ifcfg_connection_update (connection, settings, &error)) {
+ PLUGIN_WARN (IFCFG_PLUGIN_NAME, " error updating: %s",
+ (error && error->message) ? error->message : "(unknown)");
+ g_clear_error (&error);
+ }
g_hash_table_destroy (settings);
}