mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 19:00:11 +01:00
ifcfg-rh: don't check PolicyKit when on-disk ifcfg file changes (rh #495884)
The plugin called nm_exported_connection_update() which ended up checking PolicyKit for authorization to update the connection, which of course fails completely when it's just an inotify-triggered update. inotify-triggered updates don't need authorization because they require root access anyway.
This commit is contained in:
parent
47527601af
commit
42b4d04fe1
3 changed files with 28 additions and 20 deletions
|
|
@ -317,27 +317,27 @@ nm_ifcfg_connection_get_unmanaged (NMIfcfgConnection *self)
|
|||
return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->unmanaged;
|
||||
}
|
||||
|
||||
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);
|
||||
NMConnection *connection;
|
||||
|
||||
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)
|
||||
{
|
||||
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (exported);
|
||||
gboolean success;
|
||||
NMConnection *connection;
|
||||
if (!NM_EXPORTED_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->update (exported, new_settings, error))
|
||||
return FALSE;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
return nm_ifcfg_connection_update (NM_IFCFG_CONNECTION (exported), new_settings, error);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue