keyfile: don't crash when in-memory-only connections don't have paths

If the connection has never been saved to disk, it won't have a path yet,
but that doesn't mean we should crash.  Next, when reloading connections,
only try to do connection matching on connections that have paths, otherwise
all in-memory-only connections would be removed at the end of
read_connections().
This commit is contained in:
Jiří Klimeš 2013-11-12 15:04:15 +01:00
parent 696f655d7c
commit 07bf4eb802

View file

@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2008 - 2012 Red Hat, Inc.
* Copyright (C) 2008 - 2013 Red Hat, Inc.
*/
#include <config.h>
@ -345,8 +345,11 @@ read_connections (NMSystemConfigInterface *config)
oldconns = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
g_hash_table_iter_init (&iter, priv->connections);
while (g_hash_table_iter_next (&iter, NULL, &data))
g_hash_table_insert (oldconns, g_strdup (nm_keyfile_connection_get_path (data)), data);
while (g_hash_table_iter_next (&iter, NULL, &data)) {
const char *con_path = nm_keyfile_connection_get_path (data);
if (con_path)
g_hash_table_insert (oldconns, g_strdup (con_path), data);
}
while ((item = g_dir_read_name (dir))) {
NMKeyfileConnection *connection;