summary refs log tree commit diff
path: root/src/settings/plugins/ifcfg-rh/plugin.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2015-07-14 19:38:58 +0200
committerMichael Biebl <biebl@debian.org>2015-07-14 19:38:58 +0200
commit50a58f0fabd8a34c1b6108a107e08abe3c1ccd24 (patch)
tree6790165f39daee79e2b6c6617483320613493367 /src/settings/plugins/ifcfg-rh/plugin.c
parentf408e27bccfacf347605a8d98649975a68f38a17 (diff)
Imported Upstream version 1.0.4 upstream/1.0.4
Diffstat (limited to 'src/settings/plugins/ifcfg-rh/plugin.c')
-rw-r--r--src/settings/plugins/ifcfg-rh/plugin.c59
1 files changed, 26 insertions, 33 deletions
diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c
index b7efa864..1a3f791a 100644
--- a/src/settings/plugins/ifcfg-rh/plugin.c
+++ b/src/settings/plugins/ifcfg-rh/plugin.c
@@ -169,7 +169,8 @@ remove_connection (SCPluginIfcfg *self, NMIfcfgConnection *connection)
 
 	g_object_ref (connection);
 	g_hash_table_remove (priv->connections, nm_connection_get_uuid (NM_CONNECTION (connection)));
-	nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection));
+	if (!unmanaged && !unrecognized)
+		nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection));
 	g_object_unref (connection);
 
 	/* Emit changes _after_ removing the connection */
@@ -213,6 +214,7 @@ update_connection (SCPluginIfcfg *self,
 	const char *new_unrecognized = NULL, *old_unrecognized = NULL;
 	gboolean unmanaged_changed = FALSE, unrecognized_changed = FALSE;
 	const char *uuid;
+	gboolean ignore_error = FALSE;
 
 	g_return_val_if_fail (!source || NM_IS_CONNECTION (source), NULL);
 	g_return_val_if_fail (full_path || source, NULL);
@@ -222,13 +224,16 @@ update_connection (SCPluginIfcfg *self,
 
 	/* Create a NMIfcfgConnection instance, either by reading from @full_path or
 	 * based on @source. */
-	connection_new = nm_ifcfg_connection_new (source, full_path, error);
+	connection_new = nm_ifcfg_connection_new (source, full_path, &local, &ignore_error);
 	if (!connection_new) {
 		/* Unexpected failure. Probably the file is invalid? */
 		if (   connection
 		    && !protect_existing_connection
 		    && (!protected_connections || !g_hash_table_contains (protected_connections, connection)))
 			remove_connection (self, connection);
+		if (!source && !ignore_error)
+			_LOGW ("loading \"%s\" fails: %s", full_path, local ? local->message : "(unknown reason)");
+		g_propagate_error (error, local);
 		return NULL;
 	}
 
@@ -421,25 +426,13 @@ ifcfg_dir_changed (GFileMonitor *monitor,
                    gpointer user_data)
 {
 	SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data);
-	char *path, *base, *ifcfg_path;
+	char *path, *ifcfg_path;
 	NMIfcfgConnection *connection;
 
 	path = g_file_get_path (file);
-	if (utils_should_ignore_file (path, FALSE)) {
-		g_free (path);
-		return;
-	}
-
-	_LOGD ("ifcfg_dir_changed(%s) = %d", path, event_type);
 
-	base = g_file_get_basename (file);
-	if (utils_is_ifcfg_alias_file (base, NULL)) {
-		/* Alias file changed. Get the base ifcfg file from it */
-		ifcfg_path = utils_get_ifcfg_from_alias (path);
-	} else {
-		/* Given any ifcfg, keys, or routes file, get the ifcfg file path */
-		ifcfg_path = utils_get_ifcfg_path (path);
-	}
+	ifcfg_path = utils_detect_ifcfg_path (path, FALSE);
+	_LOGD ("ifcfg_dir_changed(%s) = %d // %s", path, event_type, ifcfg_path ? ifcfg_path : "(none)");
 	if (ifcfg_path) {
 		connection = find_by_path (plugin, ifcfg_path);
 		switch (event_type) {
@@ -458,7 +451,6 @@ ifcfg_dir_changed (GFileMonitor *monitor,
 		g_free (ifcfg_path);
 	}
 	g_free (path);
-	g_free (base);
 }
 
 static void
@@ -542,18 +534,14 @@ read_connections (SCPluginIfcfg *plugin)
 
 	filenames = g_ptr_array_new_with_free_func (g_free);
 	while ((item = g_dir_read_name (dir))) {
-		char *full_path;
-
-		if (utils_should_ignore_file (item, TRUE))
-			continue;
-		if (utils_is_ifcfg_alias_file (item, NULL))
-			continue;
+		char *full_path, *real_path;
 
 		full_path = g_build_filename (IFCFG_DIR, item, NULL);
-		if (!utils_get_ifcfg_name (full_path, TRUE))
-			g_free (full_path);
-		else
-			g_ptr_array_add (filenames, full_path);
+		real_path = utils_detect_ifcfg_path (full_path, TRUE);
+
+		if (real_path)
+			g_ptr_array_add (filenames, real_path);
+		g_free (full_path);
 	}
 	g_dir_close (dir);
 
@@ -625,20 +613,25 @@ load_connection (NMSystemConfigInterface *config,
 	SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (config);
 	NMIfcfgConnection *connection;
 	int dir_len = strlen (IFCFG_DIR);
+	char *ifcfg_path;
 
 	if (   strncmp (filename, IFCFG_DIR, dir_len) != 0
 	    || filename[dir_len] != '/'
 	    || strchr (filename + dir_len + 1, '/') != NULL)
 		return FALSE;
 
-	if (utils_should_ignore_file (filename + dir_len + 1, TRUE))
+	/* get the real ifcfg-path. This allows us to properly
+	 * handle load command using a route-* file etc. */
+	ifcfg_path = utils_detect_ifcfg_path (filename, FALSE);
+	if (!ifcfg_path)
 		return FALSE;
 
-	connection = find_by_path (plugin, filename);
-	update_connection (plugin, NULL, filename, connection, TRUE, NULL, NULL);
+	connection = find_by_path (plugin, ifcfg_path);
+	update_connection (plugin, NULL, ifcfg_path, connection, TRUE, NULL, NULL);
 	if (!connection)
-		connection = find_by_path (plugin, filename);
+		connection = find_by_path (plugin, ifcfg_path);
 
+	g_free (ifcfg_path);
 	return (connection != NULL);
 }
 
@@ -1139,7 +1132,7 @@ nm_system_config_factory (void)
 			dbus_g_connection_register_g_object (priv->bus,
 			                                     DBUS_OBJECT_PATH,
 			                                     G_OBJECT (singleton));
-		_LOGI ("Acquired D-Bus service %s", DBUS_SERVICE_NAME);
+		_LOGD ("Acquired D-Bus service %s", DBUS_SERVICE_NAME);
 	} else
 		g_object_ref (singleton);