mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 20:50:19 +01:00
keyfile: don't rename system connection files (bgo #682570)
When updating connections, it is less confusing to reuse the existing file instead of renaming files according to connection's ID. That reduces surprises of moving connection files when a connection is edited.
This commit is contained in:
parent
ceba6bf4c5
commit
eeb19fe216
4 changed files with 31 additions and 6 deletions
|
|
@ -16,7 +16,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2008 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2008 - 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
|
@ -96,6 +96,19 @@ nm_keyfile_connection_get_path (NMKeyfileConnection *self)
|
|||
return NM_KEYFILE_CONNECTION_GET_PRIVATE (self)->path;
|
||||
}
|
||||
|
||||
void
|
||||
nm_keyfile_connection_set_path (NMKeyfileConnection *self, const char *path)
|
||||
{
|
||||
NMKeyfileConnectionPrivate *priv;
|
||||
|
||||
g_return_if_fail (NM_IS_KEYFILE_CONNECTION (self));
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (self);
|
||||
g_free (priv->path);
|
||||
priv->path = g_strdup (path);
|
||||
}
|
||||
|
||||
static void
|
||||
commit_changes (NMSettingsConnection *connection,
|
||||
NMSettingsConnectionCommitFunc callback,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2008 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2008 - 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_KEYFILE_CONNECTION_H
|
||||
|
|
@ -48,6 +48,7 @@ NMKeyfileConnection *nm_keyfile_connection_new (const char *filename,
|
|||
GError **error);
|
||||
|
||||
const char *nm_keyfile_connection_get_path (NMKeyfileConnection *self);
|
||||
void nm_keyfile_connection_set_path (NMKeyfileConnection *self, const char *path);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2008 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2008 - 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
|
@ -268,6 +268,10 @@ dir_changed (GFileMonitor *monitor,
|
|||
* filename property too.
|
||||
*/
|
||||
update_connection_settings (found, connection);
|
||||
/* However, when connections are the same and only the filename changed
|
||||
* we need to update the path manually (commit_changes() is not called.
|
||||
*/
|
||||
nm_keyfile_connection_set_path (found, full_path);
|
||||
|
||||
/* Re-insert the connection back into the hash with the new filename */
|
||||
g_hash_table_insert (priv->hash,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2008 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2008 - 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
|
@ -1026,8 +1026,15 @@ _internal_write_connection (NMConnection *connection,
|
|||
if (!data)
|
||||
goto out;
|
||||
|
||||
filename = _writer_id_to_filename (id);
|
||||
path = g_build_filename (keyfile_dir, filename, NULL);
|
||||
/* If we have existing file path, use it. Else generate one from
|
||||
* connection's ID.
|
||||
*/
|
||||
if (existing_path != NULL) {
|
||||
path = g_strdup (existing_path);
|
||||
} else {
|
||||
filename = _writer_id_to_filename (id);
|
||||
path = g_build_filename (keyfile_dir, filename, NULL);
|
||||
}
|
||||
|
||||
/* If a file with this path already exists (but isn't the existing path
|
||||
* of the connection) then we need another name. Multiple connections
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue