ifcfg-rh: merge branch 'ifcfg-rh-cleanup-bgo741659'

https://bugzilla.gnome.org/show_bug.cgi?id=741659
This commit is contained in:
Dan Winship 2014-12-18 11:35:22 -05:00
commit e531fb2f88
6 changed files with 664 additions and 1852 deletions

View file

@ -102,8 +102,7 @@ files_changed_cb (NMInotifyHelper *ih,
NMIfcfgConnection *
nm_ifcfg_connection_new (NMConnection *source,
const char *full_path,
GError **error,
gboolean *ignore_error)
GError **error)
{
GObject *object;
NMConnection *tmp;
@ -117,18 +116,9 @@ nm_ifcfg_connection_new (NMConnection *source,
if (source)
tmp = g_object_ref (source);
else {
char *keyfile = NULL, *routefile = NULL, *route6file = NULL;
tmp = connection_from_file (full_path, NULL, NULL,
tmp = connection_from_file (full_path,
&unhandled_spec,
&keyfile,
&routefile,
&route6file,
error,
ignore_error);
g_free (keyfile);
g_free (routefile);
g_free (route6file);
error);
if (!tmp)
return NULL;
@ -267,10 +257,7 @@ commit_changes (NMSettingsConnection *connection,
* it if it's really changed.
*/
if (priv->path) {
reread = connection_from_file (priv->path, NULL, NULL,
NULL, NULL, NULL, NULL,
&error, NULL);
g_clear_error (&error);
reread = connection_from_file (priv->path, NULL, NULL);
if (reread) {
same = nm_connection_compare (NM_CONNECTION (connection),
reread,

View file

@ -48,8 +48,7 @@ GType nm_ifcfg_connection_get_type (void);
NMIfcfgConnection *nm_ifcfg_connection_new (NMConnection *source,
const char *full_path,
GError **error,
gboolean *ignore_error);
GError **error);
const char *nm_ifcfg_connection_get_path (NMIfcfgConnection *self);

View file

@ -129,23 +129,13 @@ _internal_new_connection (SCPluginIfcfg *self,
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
NMIfcfgConnection *connection;
const char *cid;
GError *local = NULL;
gboolean ignore_error = FALSE;
if (!source)
nm_log_info (LOGD_SETTINGS, "parsing %s ... ", path);
connection = nm_ifcfg_connection_new (source, path, &local, &ignore_error);
if (!connection) {
if (!ignore_error)
nm_log_warn (LOGD_SETTINGS, " %s", (local && local->message) ? local->message : "(unknown)");
if (local)
g_propagate_error (error, local);
else
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"(unknown)");
connection = nm_ifcfg_connection_new (source, path, error);
if (!connection)
return NULL;
}
cid = nm_connection_get_id (NM_CONNECTION (connection));
g_assert (cid);
@ -248,7 +238,6 @@ connection_new_or_changed (SCPluginIfcfg *self,
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
NMIfcfgConnection *new;
GError *error = NULL;
gboolean ignore_error = FALSE;
const char *new_unmanaged = NULL, *old_unmanaged = NULL;
const char *new_unrecognized = NULL, *old_unrecognized = NULL;
gboolean unmanaged_changed, unrecognized_changed;
@ -285,13 +274,9 @@ connection_new_or_changed (SCPluginIfcfg *self,
return;
}
new = (NMIfcfgConnection *) nm_ifcfg_connection_new (NULL, path, &error, &ignore_error);
new = (NMIfcfgConnection *) nm_ifcfg_connection_new (NULL, path, NULL);
if (!new) {
/* errors reading connection; remove it */
if (!ignore_error)
nm_log_warn (LOGD_SETTINGS, " %s", (error && error->message) ? error->message : "(unknown)");
g_clear_error (&error);
nm_log_info (LOGD_SETTINGS, "removed %s.", path);
remove_connection (self, existing);
return;

View file

@ -4624,16 +4624,13 @@ check_dns_search_domains (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6)
}
}
NMConnection *
connection_from_file (const char *filename,
const char *network_file, /* for unit tests only */
const char *test_type, /* for unit tests only */
char **out_unhandled,
char **out_keyfile,
char **out_routefile,
char **out_route6file,
GError **error,
gboolean *out_ignore_error)
static NMConnection *
connection_from_file_full (const char *filename,
const char *network_file, /* for unit tests only */
const char *test_type, /* for unit tests only */
char **out_unhandled,
GError **error,
gboolean *out_ignore_error)
{
NMConnection *connection = NULL;
shvarFile *parsed;
@ -4644,12 +4641,6 @@ connection_from_file (const char *filename,
g_return_val_if_fail (filename != NULL, NULL);
if (out_unhandled)
g_return_val_if_fail (*out_unhandled == NULL, NULL);
if (out_keyfile)
g_return_val_if_fail (*out_keyfile == NULL, NULL);
if (out_routefile)
g_return_val_if_fail (*out_routefile == NULL, NULL);
if (out_route6file)
g_return_val_if_fail (*out_route6file == NULL, NULL);
/* Non-NULL only for unit tests; normally use /etc/sysconfig/network */
if (!network_file)
@ -4827,15 +4818,40 @@ connection_from_file (const char *filename,
connection = NULL;
}
if (out_keyfile)
*out_keyfile = utils_get_keys_path (filename);
if (out_routefile)
*out_routefile = utils_get_route_path (filename);
if (out_route6file)
*out_route6file = utils_get_route6_path (filename);
done:
svCloseFile (parsed);
return connection;
}
NMConnection *
connection_from_file (const char *filename,
char **out_unhandled,
GError **error)
{
gboolean ignore_error = FALSE;
NMConnection *conn;
conn = connection_from_file_full (filename, NULL, NULL,
out_unhandled,
error,
&ignore_error);
if (error && *error && !ignore_error)
PARSE_WARNING ("%s", (*error)->message);
return conn;
}
NMConnection *
connection_from_file_test (const char *filename,
const char *network_file,
const char *test_type,
char **out_unhandled,
GError **error)
{
return connection_from_file_full (filename,
network_file,
test_type,
out_unhandled,
error,
NULL);
}

View file

@ -27,15 +27,16 @@
#include "shvar.h"
NMConnection *connection_from_file (const char *filename,
const char *network_file, /* for unit tests only */
const char *test_type, /* for unit tests only */
char **out_unhandled,
char **out_keyfile,
char **out_routefile,
char **out_route6file,
GError **error,
gboolean *out_ignore_error);
GError **error);
char *uuid_from_file (const char *filename);
/* for test-ifcfg-rh */
NMConnection *connection_from_file_test (const char *filename,
const char *network_file,
const char *test_type,
char **out_unhandled,
GError **error);
#endif /* __READER_H__ */

File diff suppressed because it is too large Load diff