mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 18:20:22 +01:00
ifcfg-rh: 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:
parent
6b6265ebeb
commit
c23e1bbb44
1 changed files with 6 additions and 3 deletions
|
|
@ -212,7 +212,7 @@ find_by_path (SCPluginIfcfg *self, const char *path)
|
|||
|
||||
g_hash_table_iter_init (&iter, priv->connections);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) {
|
||||
if (g_str_equal (path, nm_ifcfg_connection_get_path (candidate)))
|
||||
if (g_strcmp0 (path, nm_ifcfg_connection_get_path (candidate)) == 0)
|
||||
return candidate;
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -445,8 +445,11 @@ read_connections (SCPluginIfcfg *plugin)
|
|||
|
||||
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, &value))
|
||||
g_hash_table_insert (oldconns, g_strdup (nm_ifcfg_connection_get_path (value)), value);
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value)) {
|
||||
const char *ifcfg_path = nm_ifcfg_connection_get_path (value);
|
||||
if (ifcfg_path)
|
||||
g_hash_table_insert (oldconns, g_strdup (ifcfg_path), value);
|
||||
}
|
||||
|
||||
while ((item = g_dir_read_name (dir))) {
|
||||
char *full_path, *old_path;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue