mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-10 02:20:22 +01:00
settings: return re-read connection from ifcfg-rh writer
As writing a connection to disk might modify it, we re-read it back and use what we actually found on disk. For example, if you have a connection with ipv6.method=ignore, ifcfg-rh writer will not persist the ipv6.route-metric. That is likely a bug in the writer. Before this patch, changing the route metric would seemingly succeed, but on the next reload from this, the changes are lost. We should fix such bugs. Regardless, it's better to pick up what we wrote to disk, instead of later.
This commit is contained in:
parent
713ad38fe5
commit
3c3fc089ad
1 changed files with 19 additions and 15 deletions
|
|
@ -332,6 +332,9 @@ commit_changes (NMSettingsConnection *connection,
|
|||
GError **error)
|
||||
{
|
||||
const char *filename;
|
||||
gs_unref_object NMConnection *reread = NULL;
|
||||
gboolean reread_same = TRUE;
|
||||
const char *operation_message;
|
||||
|
||||
nm_assert (out_reread_connection && !*out_reread_connection);
|
||||
nm_assert (!out_logmsg_change || !*out_logmsg_change);
|
||||
|
|
@ -343,28 +346,29 @@ commit_changes (NMSettingsConnection *connection,
|
|||
if (!writer_new_connection (new_connection ?: NM_CONNECTION (connection),
|
||||
IFCFG_DIR,
|
||||
&ifcfg_path,
|
||||
NULL,
|
||||
NULL,
|
||||
&reread,
|
||||
&reread_same,
|
||||
error))
|
||||
return FALSE;
|
||||
nm_settings_connection_set_filename (connection, ifcfg_path);
|
||||
NM_SET_OUT (out_logmsg_change,
|
||||
g_strdup_printf ("ifcfg-rh: persist %s",
|
||||
ifcfg_path));
|
||||
return TRUE;
|
||||
operation_message = "persist";
|
||||
} else {
|
||||
if (!writer_update_connection (new_connection ?: NM_CONNECTION (connection),
|
||||
IFCFG_DIR,
|
||||
filename,
|
||||
&reread,
|
||||
&reread_same,
|
||||
error))
|
||||
return FALSE;
|
||||
operation_message = "update";
|
||||
}
|
||||
|
||||
if (!writer_update_connection (new_connection ?: NM_CONNECTION (connection),
|
||||
IFCFG_DIR,
|
||||
filename,
|
||||
NULL,
|
||||
NULL,
|
||||
error))
|
||||
return FALSE;
|
||||
if (reread && !reread_same)
|
||||
*out_reread_connection = g_steal_pointer (&reread);
|
||||
|
||||
NM_SET_OUT (out_logmsg_change,
|
||||
g_strdup_printf ("ifcfg-rh: update %s",
|
||||
filename));
|
||||
g_strdup_printf ("ifcfg-rh: %s %s",
|
||||
operation_message, filename));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue