summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-10-15 11:14:00 -0400
committerDan Winship <danw@gnome.org>2014-10-22 08:29:09 -0400
commitd13bfe3cf8f2f8714f12949a2dfdc0bbd16a59e2 (patch)
treefe527cede531e65c7b0db0d787f7d19b1e9b90fb
parent3be53899faaa11dd0094626acccff72d93872e79 (diff)
settings: drop plugin-specific error domains
Each plugin defined its own error domain, though none actually defined any errors. Replace these with appropriate uses of NM_SETTINGS_ERROR_INVALID_CONNECTION and NM_SETTINGS_ERROR_FAILED.
-rw-r--r--src/Makefile.am1
-rw-r--r--src/settings/plugins/example/Makefile.am1
-rw-r--r--src/settings/plugins/example/common.h11
-rw-r--r--src/settings/plugins/example/errors.c40
-rw-r--r--src/settings/plugins/example/nm-example-connection.c2
-rw-r--r--src/settings/plugins/ibft/Makefile.am4
-rw-r--r--src/settings/plugins/ibft/errors.c34
-rw-r--r--src/settings/plugins/ibft/errors.h29
-rw-r--r--src/settings/plugins/ibft/nm-ibft-connection.c1
-rw-r--r--src/settings/plugins/ibft/plugin.c1
-rw-r--r--src/settings/plugins/ibft/reader.c32
-rw-r--r--src/settings/plugins/ibft/tests/Makefile.am1
-rw-r--r--src/settings/plugins/ibft/tests/test-ibft.c3
-rw-r--r--src/settings/plugins/ifcfg-rh/Makefile.am1
-rw-r--r--src/settings/plugins/ifcfg-rh/common.h4
-rw-r--r--src/settings/plugins/ifcfg-rh/errors.c35
-rw-r--r--src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c24
-rw-r--r--src/settings/plugins/ifcfg-rh/plugin.c3
-rw-r--r--src/settings/plugins/ifcfg-rh/reader.c214
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/Makefile.am1
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c20
-rw-r--r--src/settings/plugins/ifcfg-rh/writer.c67
-rw-r--r--src/settings/plugins/ifcfg-suse/plugin.c11
-rw-r--r--src/settings/plugins/ifcfg-suse/plugin.h2
-rw-r--r--src/settings/plugins/ifnet/Makefile.am4
-rw-r--r--src/settings/plugins/ifnet/connection_parser.c123
-rw-r--r--src/settings/plugins/ifnet/errors.c35
-rw-r--r--src/settings/plugins/ifnet/errors.h30
-rw-r--r--src/settings/plugins/ifnet/tests/Makefile.am3
-rw-r--r--src/settings/plugins/ifupdown/parser.c23
-rw-r--r--src/settings/plugins/ifupdown/plugin.h2
-rw-r--r--src/settings/plugins/keyfile/Makefile.am1
-rw-r--r--src/settings/plugins/keyfile/common.h3
-rw-r--r--src/settings/plugins/keyfile/errors.c35
-rw-r--r--src/settings/plugins/keyfile/nm-keyfile-connection.c2
-rw-r--r--src/settings/plugins/keyfile/plugin.h2
-rw-r--r--src/settings/plugins/keyfile/reader.c6
-rw-r--r--src/settings/plugins/keyfile/tests/Makefile.am1
-rw-r--r--src/settings/plugins/keyfile/writer.c18
39 files changed, 271 insertions, 559 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 4a1da5c421..8ea71c313e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -169,7 +169,6 @@ nm_sources = \
settings/nm-system-config-interface.h \
\
settings/plugins/keyfile/common.h \
- settings/plugins/keyfile/errors.c \
settings/plugins/keyfile/nm-keyfile-connection.c \
settings/plugins/keyfile/nm-keyfile-connection.h \
settings/plugins/keyfile/plugin.c \
diff --git a/src/settings/plugins/example/Makefile.am b/src/settings/plugins/example/Makefile.am
index 8fc4aa92b1..b98f66ef44 100644
--- a/src/settings/plugins/example/Makefile.am
+++ b/src/settings/plugins/example/Makefile.am
@@ -24,7 +24,6 @@ libnm_settings_plugin_example_la_SOURCES = \
nm-example-connection.h \
plugin.c \
plugin.h \
- errors.c \
common.h \
reader.c \
writer.c
diff --git a/src/settings/plugins/example/common.h b/src/settings/plugins/example/common.h
index ed0be9a7f7..cf209fe0a8 100644
--- a/src/settings/plugins/example/common.h
+++ b/src/settings/plugins/example/common.h
@@ -33,17 +33,6 @@
#define EXAMPLE_DIR NMCONFDIR "/example-plugin"
-/* Boilerplate stuff for the plugin's error domain. Bits of the code that
- * create new errors in the plugin's domain will create errors of
- * type EXAMPLE_PLUGIN_ERROR like so:
- *
- * error = g_error_new_literal (EXAMPLE_PLUGIN_ERROR,
- * <specific error number>,
- * "This is a really bad error.");
- */
-#define EXAMPLE_PLUGIN_ERROR (example_plugin_error_quark ())
-GQuark example_plugin_error_quark (void);
-
/* Prototypes for the reader/writer functions */
NMConnection *connection_from_file (const char *filename, GError **error);
diff --git a/src/settings/plugins/example/errors.c b/src/settings/plugins/example/errors.c
deleted file mode 100644
index 8181f8a3a0..0000000000
--- a/src/settings/plugins/example/errors.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2012 Red Hat, Inc.
- */
-
-#include <glib.h>
-#include "common.h"
-
-/* This is boilerplate code for defining the error domain that the plugin may
- * return to NetworkManager for various operations. It just registers a
- * GObject "quark" (a UUID really) for the error which allows glib to keep
- * track of all the different error domains.
- */
-GQuark
-example_plugin_error_quark (void)
-{
- static GQuark error_quark = 0;
-
- if (G_UNLIKELY (error_quark == 0))
- error_quark = g_quark_from_static_string ("example-plugin-error-quark");
-
- return error_quark;
-}
-
-
diff --git a/src/settings/plugins/example/nm-example-connection.c b/src/settings/plugins/example/nm-example-connection.c
index c634388e9f..858c67f216 100644
--- a/src/settings/plugins/example/nm-example-connection.c
+++ b/src/settings/plugins/example/nm-example-connection.c
@@ -89,7 +89,7 @@ nm_example_connection_new (const char *full_path,
/* Make sure we have a UUID; just a sanity check */
uuid = nm_connection_get_uuid (NM_CONNECTION (object));
if (!uuid) {
- g_set_error (error, EXAMPLE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Connection in file %s had no UUID", full_path);
g_object_unref (object);
object = NULL;
diff --git a/src/settings/plugins/ibft/Makefile.am b/src/settings/plugins/ibft/Makefile.am
index c687cf3008..00a5d175f0 100644
--- a/src/settings/plugins/ibft/Makefile.am
+++ b/src/settings/plugins/ibft/Makefile.am
@@ -8,9 +8,7 @@ noinst_LTLIBRARIES = libibft-io.la
libibft_io_la_SOURCES = \
reader.c \
- reader.h \
- errors.c \
- errors.h
+ reader.h
AM_CPPFLAGS = \
-I$(top_srcdir)/src/ \
diff --git a/src/settings/plugins/ibft/errors.c b/src/settings/plugins/ibft/errors.c
deleted file mode 100644
index ead26867bb..0000000000
--- a/src/settings/plugins/ibft/errors.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2014 Red Hat, Inc.
- */
-
-#include <glib.h>
-#include "errors.h"
-
-GQuark
-ibft_plugin_error_quark (void)
-{
- static GQuark error_quark = 0;
-
- if (G_UNLIKELY (error_quark == 0))
- error_quark = g_quark_from_static_string ("ibft-plugin-error-quark");
- return error_quark;
-}
-
-
diff --git a/src/settings/plugins/ibft/errors.h b/src/settings/plugins/ibft/errors.h
deleted file mode 100644
index cb3756775b..0000000000
--- a/src/settings/plugins/ibft/errors.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Copyright 2014 Red Hat, Inc.
- */
-
-#ifndef __ERRORS_H__
-#define __ERRORS_H__
-
-#define IBFT_PLUGIN_ERROR (ibft_plugin_error_quark ())
-GQuark ibft_plugin_error_quark (void);
-
-
-#endif /* __ERRORS_H__ */
-
diff --git a/src/settings/plugins/ibft/nm-ibft-connection.c b/src/settings/plugins/ibft/nm-ibft-connection.c
index 2ed4679e59..5558f0e7ab 100644
--- a/src/settings/plugins/ibft/nm-ibft-connection.c
+++ b/src/settings/plugins/ibft/nm-ibft-connection.c
@@ -25,7 +25,6 @@
#include <glib/gstdio.h>
#include "nm-ibft-connection.h"
-#include "errors.h"
#include "reader.h"
G_DEFINE_TYPE (NMIbftConnection, nm_ibft_connection, NM_TYPE_SETTINGS_CONNECTION)
diff --git a/src/settings/plugins/ibft/plugin.c b/src/settings/plugins/ibft/plugin.c
index 329e6071a9..0fa19dab9a 100644
--- a/src/settings/plugins/ibft/plugin.c
+++ b/src/settings/plugins/ibft/plugin.c
@@ -36,7 +36,6 @@
#include "NetworkManagerUtils.h"
#include "plugin.h"
-#include "errors.h"
#include "reader.h"
#include "nm-ibft-connection.h"
diff --git a/src/settings/plugins/ibft/reader.c b/src/settings/plugins/ibft/reader.c
index 57fdb34536..f7e845231f 100644
--- a/src/settings/plugins/ibft/reader.c
+++ b/src/settings/plugins/ibft/reader.c
@@ -45,7 +45,6 @@
#include "NetworkManagerUtils.h"
#include "nm-logging.h"
-#include "errors.h"
#include "reader.h"
#define PARSE_WARNING(msg...) nm_log_warn (LOGD_SETTINGS, " " msg)
@@ -136,13 +135,13 @@ read_ibft_blocks (const char *iscsiadm_path,
goto done;
if (!WIFEXITED (status)) {
- g_set_error (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"iBFT: %s exited abnormally.", iscsiadm_path);
goto done;
}
if (WEXITSTATUS (status) != 0) {
- g_set_error (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"iBFT: %s exited with error %d. Message: '%s'",
iscsiadm_path, WEXITSTATUS (status), err ? err : "(none)");
goto done;
@@ -263,7 +262,7 @@ parse_ibft_config (const GPtrArray *data, GError **error, ...)
va_end (ap);
if (!success) {
- g_set_error_literal (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: failed to match at least one iscsiadm block field");
}
return success;
@@ -302,7 +301,7 @@ ip4_setting_add_from_block (const GPtrArray *block,
goto error;
if (!s_method) {
- g_set_error_literal (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: missing " ISCSI_BOOTPROTO_TAG);
goto error;
}
@@ -313,7 +312,7 @@ ip4_setting_add_from_block (const GPtrArray *block,
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
goto success;
} else if (g_ascii_strcasecmp (s_method, "static") != 0) {
- g_set_error (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: unknown " ISCSI_BOOTPROTO_TAG " '%s'.",
s_method);
goto error;
@@ -324,7 +323,7 @@ ip4_setting_add_from_block (const GPtrArray *block,
/* IP address */
if (!s_ipaddr || inet_pton (AF_INET, s_ipaddr, &ipaddr) != 1) {
- g_set_error (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: invalid IP address '%s'.",
s_ipaddr);
goto error;
@@ -332,7 +331,7 @@ ip4_setting_add_from_block (const GPtrArray *block,
/* Subnet/prefix */
if (!s_netmask || inet_pton (AF_INET, s_netmask, &netmask) != 1) {
- g_set_error (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: invalid subnet mask '%s'.",
s_netmask);
goto error;
@@ -340,21 +339,21 @@ ip4_setting_add_from_block (const GPtrArray *block,
prefix = nm_utils_ip4_netmask_to_prefix (netmask);
if (s_gateway && inet_pton (AF_INET, s_gateway, &gateway) != 1) {
- g_set_error (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: invalid IP gateway '%s'.",
s_gateway);
goto error;
}
if (s_dns1 && inet_pton (AF_INET, s_dns1, &dns1) != 1) {
- g_set_error (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: invalid DNS1 address '%s'.",
s_dns1);
goto error;
}
if (s_dns2 && inet_pton (AF_INET, s_dns2, &dns2) != 1) {
- g_set_error (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: invalid DNS2 address '%s'.",
s_dns2);
goto error;
@@ -400,7 +399,7 @@ connection_setting_add (const GPtrArray *block,
NULL))
return FALSE;
if (!s_hwaddr) {
- g_set_error_literal (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: missing " ISCSI_HWADDR_TAG);
return FALSE;
}
@@ -472,7 +471,8 @@ vlan_setting_add_from_block (const GPtrArray *block,
/* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it means "no VLAN" */
vlan_id = nm_utils_ascii_str_to_int64 (vlan_id_str, 10, 1, 4095, -1);
if (vlan_id == -1) {
- g_set_error (error, IBFT_PLUGIN_ERROR, 0, "Invalid VLAN_ID '%s'", vlan_id_str);
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Invalid VLAN_ID '%s'", vlan_id_str);
return FALSE;
}
@@ -495,13 +495,13 @@ wired_setting_add_from_block (const GPtrArray *block,
g_assert (connection);
if (!parse_ibft_config (block, NULL, ISCSI_HWADDR_TAG, &hwaddr, NULL)) {
- g_set_error_literal (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: missing " ISCSI_HWADDR_TAG);
return FALSE;
}
if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) {
- g_set_error (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: invalid " ISCSI_HWADDR_TAG " '%s'.",
hwaddr);
return FALSE;
@@ -524,7 +524,7 @@ connection_from_block (const GPtrArray *block, GError **error)
g_assert (block);
if (!parse_ibft_config (block, error, ISCSI_IFACE_TAG, &iface, NULL)) {
- g_set_error_literal (error, IBFT_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"iBFT: malformed iscsiadm record: missing " ISCSI_IFACE_TAG);
return NULL;
}
diff --git a/src/settings/plugins/ibft/tests/Makefile.am b/src/settings/plugins/ibft/tests/Makefile.am
index 62011759fa..9946d20859 100644
--- a/src/settings/plugins/ibft/tests/Makefile.am
+++ b/src/settings/plugins/ibft/tests/Makefile.am
@@ -27,7 +27,6 @@ noinst_PROGRAMS = test-ibft
test_ibft_SOURCES = \
test-ibft.c \
- ../errors.c \
../reader.c
test_ibft_LDADD = \
diff --git a/src/settings/plugins/ibft/tests/test-ibft.c b/src/settings/plugins/ibft/tests/test-ibft.c
index 8252dda769..8cf705a05a 100644
--- a/src/settings/plugins/ibft/tests/test-ibft.c
+++ b/src/settings/plugins/ibft/tests/test-ibft.c
@@ -35,7 +35,6 @@
#include "NetworkManagerUtils.h"
-#include "errors.h"
#include "reader.h"
#include "nm-logging.h"
@@ -208,7 +207,7 @@ test_read_ibft_bad_address (gconstpointer user_data)
block = read_block (iscsiadm_path, expected_mac_address);
connection = connection_from_block (block, &error);
- g_assert_error (error, IBFT_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
g_assert (strstr (error->message, "iBFT: malformed iscsiadm record: invalid"));
g_clear_error (&error);
g_assert (connection == NULL);
diff --git a/src/settings/plugins/ifcfg-rh/Makefile.am b/src/settings/plugins/ifcfg-rh/Makefile.am
index 10064812d0..4989f4ba77 100644
--- a/src/settings/plugins/ifcfg-rh/Makefile.am
+++ b/src/settings/plugins/ifcfg-rh/Makefile.am
@@ -19,7 +19,6 @@ libifcfg_rh_io_la_SOURCES = \
reader.h \
writer.c \
writer.h \
- errors.c \
common.h \
utils.c \
utils.h
diff --git a/src/settings/plugins/ifcfg-rh/common.h b/src/settings/plugins/ifcfg-rh/common.h
index d9627bddeb..d78f375250 100644
--- a/src/settings/plugins/ifcfg-rh/common.h
+++ b/src/settings/plugins/ifcfg-rh/common.h
@@ -78,9 +78,5 @@
#define KEY_DCB_PG_STRICT "DCB_PG_STRICT"
#define KEY_DCB_PG_UP2TC "DCB_PG_UP2TC"
-#define IFCFG_PLUGIN_ERROR (ifcfg_plugin_error_quark ())
-GQuark ifcfg_plugin_error_quark (void);
-
-
#endif /* __COMMON_H__ */
diff --git a/src/settings/plugins/ifcfg-rh/errors.c b/src/settings/plugins/ifcfg-rh/errors.c
deleted file mode 100644
index 25039104a4..0000000000
--- a/src/settings/plugins/ifcfg-rh/errors.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2008 - 2009 Red Hat, Inc.
- */
-
-#include <glib.h>
-#include "common.h"
-
-GQuark
-ifcfg_plugin_error_quark (void)
-{
- static GQuark error_quark = 0;
-
- if (G_UNLIKELY (error_quark == 0))
- error_quark = g_quark_from_static_string ("ifcfg-plugin-error-quark");
-
- return error_quark;
-}
-
-
diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
index c933ed8484..a10743d64b 100644
--- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
+++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c
@@ -143,20 +143,16 @@ nm_ifcfg_connection_new (NMConnection *source,
NM_IFCFG_CONNECTION_UNMANAGED_SPEC, unmanaged_spec,
NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, unrecognized_spec,
NULL);
- if (object) {
- /* Update our settings with what was read from the file */
- if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
- tmp,
- update_unsaved,
- error)) {
- /* Set the path and start monitoring */
- if (full_path)
- nm_ifcfg_connection_set_path (NM_IFCFG_CONNECTION (object), full_path);
- } else {
- g_object_unref (object);
- object = NULL;
- }
- }
+ /* Update our settings with what was read from the file */
+ if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
+ tmp,
+ update_unsaved,
+ error)) {
+ /* Set the path and start monitoring */
+ if (full_path)
+ nm_ifcfg_connection_set_path (NM_IFCFG_CONNECTION (object), full_path);
+ } else
+ g_clear_object (&object);
g_object_unref (tmp);
g_free (unhandled_spec);
diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c
index 7398d9e158..097ad0c902 100644
--- a/src/settings/plugins/ifcfg-rh/plugin.c
+++ b/src/settings/plugins/ifcfg-rh/plugin.c
@@ -141,7 +141,8 @@ _internal_new_connection (SCPluginIfcfg *self,
if (local)
g_propagate_error (error, local);
else
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "(unknown)");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "(unknown)");
return NULL;
}
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
index 1c6aa70cb2..60ca5b52c6 100644
--- a/src/settings/plugins/ifcfg-rh/reader.c
+++ b/src/settings/plugins/ifcfg-rh/reader.c
@@ -278,7 +278,7 @@ read_ip4_address (shvarFile *ifcfg,
*out_addr = ip4_addr;
success = TRUE;
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid %s IP4 address '%s'", tag, value);
}
g_free (value);
@@ -300,7 +300,7 @@ parse_ip6_address (const char *value,
*out_addr = in6addr_any;
if (inet_pton (AF_INET6, value, &ip6_addr) <= 0) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IP6 address '%s'", value);
return FALSE;
}
@@ -416,7 +416,7 @@ read_full_ip4_address (shvarFile *ifcfg,
errno = 0;
prefix = strtol (value, NULL, 10);
if (errno || prefix <= 0 || prefix > 32) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IP4 prefix '%s'", value);
g_free (value);
goto done;
@@ -447,7 +447,7 @@ read_full_ip4_address (shvarFile *ifcfg,
/* Validate the prefix */
if (nm_ip4_address_get_prefix (addr) > 32) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing or invalid IP4 prefix '%d'",
nm_ip4_address_get_prefix (addr));
goto done;
@@ -523,7 +523,7 @@ read_one_ip4_route (shvarFile *ifcfg,
/* Validate the prefix */
if ( !nm_ip4_route_get_prefix (route)
|| nm_ip4_route_get_prefix (route) > 32) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing or invalid IP4 prefix '%d'",
nm_ip4_route_get_prefix (route));
goto out;
@@ -537,7 +537,7 @@ read_one_ip4_route (shvarFile *ifcfg,
errno = 0;
metric = strtol (value, NULL, 10);
if (errno || metric < 0) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IP4 route metric '%s'", value);
g_free (value);
goto out;
@@ -617,8 +617,8 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
g_regex_match (regex_to2, *iter, 0, &match_info);
if (!g_match_info_matches (match_info)) {
g_match_info_free (match_info);
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
- "Missing IP4 route destination address in record: '%s'", *iter);
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Missing IP4 route destination address in record: '%s'", *iter);
goto error;
}
}
@@ -626,8 +626,8 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
if (!strcmp (dest, "default"))
strcpy (dest, "0.0.0.0");
if (inet_pton (AF_INET, dest, &ip4_addr) != 1) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
- "Invalid IP4 route destination address '%s'", dest);
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Invalid IP4 route destination address '%s'", dest);
g_free (dest);
goto error;
}
@@ -642,8 +642,8 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
errno = 0;
prefix_int = strtol (prefix, NULL, 10);
if (errno || prefix_int <= 0 || prefix_int > 32) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
- "Invalid IP4 route destination prefix '%s'", prefix);
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Invalid IP4 route destination prefix '%s'", prefix);
g_free (prefix);
goto error;
}
@@ -656,7 +656,7 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
if (g_match_info_matches (match_info)) {
char *next_hop = g_match_info_fetch (match_info, 1);
if (inet_pton (AF_INET, next_hop, &ip4_addr) != 1) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IP4 route gateway address '%s'",
next_hop);
g_match_info_free (match_info);
@@ -680,7 +680,7 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
metric_int = strtol (metric, NULL, 10);
if (errno || metric_int < 0) {
g_match_info_free (match_info);
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IP4 route metric '%s'", metric);
g_free (metric);
goto error;
@@ -735,7 +735,7 @@ parse_full_ip6_address (shvarFile *ifcfg,
/* Split the address and prefix */
list = g_strsplit_set (addr_str, "/", 2);
if (g_strv_length (list) < 1) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IP6 address '%s'", addr_str);
goto error;
}
@@ -748,7 +748,7 @@ parse_full_ip6_address (shvarFile *ifcfg,
if (!parse_ip6_address (ip_val, &tmp, error))
goto error;
if (IN6_IS_ADDR_UNSPECIFIED (&tmp)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IP6 address '%s'", ip_val);
goto error;
}
@@ -761,7 +761,7 @@ parse_full_ip6_address (shvarFile *ifcfg,
errno = 0;
prefix = strtol (prefix_val, NULL, 10);
if (errno || prefix <= 0 || prefix > 128) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IP6 prefix '%s'", prefix_val);
goto error;
}
@@ -873,8 +873,8 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro
g_regex_match (regex_to2, *iter, 0, &match_info);
if (!g_match_info_matches (match_info)) {
g_match_info_free (match_info);
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
- "Missing IP6 route destination address in record: '%s'", *iter);
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Missing IP6 route destination address in record: '%s'", *iter);
goto error;
}
}
@@ -887,8 +887,8 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro
continue;
}
if (inet_pton (AF_INET6, dest, &ip6_addr) != 1) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
- "Invalid IP6 route destination address '%s'", dest);
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Invalid IP6 route destination address '%s'", dest);
g_free (dest);
goto error;
}
@@ -903,8 +903,8 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro
errno = 0;
prefix_int = strtol (prefix, NULL, 10);
if (errno || prefix_int <= 0 || prefix_int > 128) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
- "Invalid IP6 route destination prefix '%s'", prefix);
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Invalid IP6 route destination prefix '%s'", prefix);
g_free (prefix);
goto error;
}
@@ -917,7 +917,7 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro
if (g_match_info_matches (match_info)) {
char *next_hop = g_match_info_fetch (match_info, 1);
if (inet_pton (AF_INET6, next_hop, &ip6_addr) != 1) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IPv6 route nexthop address '%s'",
next_hop);
g_match_info_free (match_info);
@@ -941,7 +941,7 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro
metric_int = strtol (metric, NULL, 10);
if (errno || metric_int < 0 || metric_int > G_MAXUINT32) {
g_match_info_free (match_info);
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IP6 route metric '%s'", metric);
g_free (metric);
goto error;
@@ -1040,7 +1040,7 @@ make_ip4_setting (shvarFile *ifcfg,
NULL);
return NM_SETTING (s_ip4);
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown BOOTPROTO '%s'", value);
g_free (value);
goto done;
@@ -1158,7 +1158,7 @@ make_ip4_setting (shvarFile *ifcfg,
/* Static routes - route-<name> file */
route_path = utils_get_route_path (ifcfg->fileName);
if (!route_path) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Could not get route file path for '%s'", ifcfg->fileName);
goto done;
}
@@ -1527,7 +1527,7 @@ make_ip6_setting (shvarFile *ifcfg,
/* Read static routes from route6-<interface> file */
route6_path = utils_get_route6_path (ifcfg->fileName);
if (!route6_path) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Could not get route6 file path for '%s'", ifcfg->fileName);
goto error;
}
@@ -1648,7 +1648,7 @@ read_dcb_app (shvarFile *ifcfg,
if (success)
success = (priority >= 0 && priority <= 7);
if (!success) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid %s value '%s' (expected 0 - 7)",
tmp, val);
}
@@ -1697,7 +1697,8 @@ read_dcb_bool_array (shvarFile *ifcfg,
val = g_strstrip (val);
if (strlen (val) != 8) {
PARSE_WARNING ("%s value '%s' must be 8 characters long", prop, val);
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "boolean array must be 8 characters");
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "boolean array must be 8 characters");
goto out;
}
@@ -1705,7 +1706,8 @@ read_dcb_bool_array (shvarFile *ifcfg,
for (i = 0; i < 8; i++) {
if (val[i] != '0' && val[i] != '1') {
PARSE_WARNING ("invalid %s value '%s': not all 0s and 1s", prop, val);
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid boolean digit");
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "invalid boolean digit");
goto out;
}
set_func (s_dcb, i, (val[i] == '1'));
@@ -1746,7 +1748,8 @@ read_dcb_uint_array (shvarFile *ifcfg,
val = g_strstrip (val);
if (strlen (val) != 8) {
PARSE_WARNING ("%s value '%s' must be 8 characters long", prop, val);
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "uint array must be 8 characters");
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "uint array must be 8 characters");
goto out;
}
@@ -1759,7 +1762,8 @@ read_dcb_uint_array (shvarFile *ifcfg,
else {
PARSE_WARNING ("invalid %s value '%s': not 0 - 7%s",
prop, val, f_allowed ? " or 'f'" : "");
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid uint digit");
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "invalid uint digit");
goto out;
}
}
@@ -1800,14 +1804,16 @@ read_dcb_percent_array (shvarFile *ifcfg,
split = g_strsplit_set (val, ",", 0);
if (!split || (g_strv_length (split) != 8)) {
PARSE_WARNING ("invalid %s percentage list value '%s'", prop, val);
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "percent array must be 8 elements");
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "percent array must be 8 elements");
goto out;
}
for (iter = split, i = 0; iter && *iter; iter++, i++) {
if (!get_int (*iter, &tmp) || tmp < 0 || tmp > 100) {
PARSE_WARNING ("invalid %s percentage value '%s'", prop, *iter);
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid percent element");
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "invalid percent element");
goto out;
}
set_func (s_dcb, i, (guint) tmp);
@@ -1816,7 +1822,8 @@ read_dcb_percent_array (shvarFile *ifcfg,
if (sum_pct && (sum != 100)) {
PARSE_WARNING ("%s percentages do not equal 100%%", prop);
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid percentage sum");
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "invalid percentage sum");
goto out;
}
@@ -1865,7 +1872,8 @@ make_dcb_setting (shvarFile *ifcfg,
g_object_set (G_OBJECT (s_dcb), NM_SETTING_DCB_APP_FCOE_MODE, val, NULL);
else {
PARSE_WARNING ("invalid FCoE mode '%s'", val);
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "invalid FCoE mode");
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "invalid FCoE mode");
g_free (val);
g_object_unref (s_dcb);
return FALSE;
@@ -2016,7 +2024,7 @@ add_one_wep_key (shvarFile *ifcfg,
while (*p) {
if (!g_ascii_isxdigit (*p)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid hexadecimal WEP key.");
goto out;
}
@@ -2030,7 +2038,7 @@ add_one_wep_key (shvarFile *ifcfg,
while (*p) {
if (!g_ascii_isprint ((int) (*p))) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid ASCII WEP key.");
goto out;
}
@@ -2052,7 +2060,8 @@ add_one_wep_key (shvarFile *ifcfg,
g_free (key);
success = TRUE;
} else
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Invalid WEP key length.");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Invalid WEP key length.");
out:
g_free (value);
@@ -2137,7 +2146,7 @@ make_wep_setting (shvarFile *ifcfg,
default_key_idx--; /* convert to [0...3] */
g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, default_key_idx, NULL);
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid default WEP key '%s'", value);
g_free (value);
goto error;
@@ -2178,7 +2187,7 @@ make_wep_setting (shvarFile *ifcfg,
} else if (!strcmp (lcase, "restricted")) {
g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", NULL);
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid WEP authentication algorithm '%s'",
lcase);
g_free (lcase);
@@ -2200,7 +2209,7 @@ make_wep_setting (shvarFile *ifcfg,
auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec);
if (auth_alg && !strcmp (auth_alg, "shared")) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"WEP Shared Key authentication is invalid for "
"unencrypted connections.");
goto error;
@@ -2328,7 +2337,7 @@ parse_wpa_psk (shvarFile *ifcfg,
/* Verify the hex PSK; 64 digits */
while (*p) {
if (!g_ascii_isxdigit (*p++)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid WPA_PSK (contains non-hexadecimal characters)");
goto out;
}
@@ -2346,7 +2355,7 @@ parse_wpa_psk (shvarFile *ifcfg,
/* Length check */
if (strlen (hashed) < 8 || strlen (hashed) > 63) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid WPA_PSK (passphrases must be between "
"8 and 63 characters long (inclusive))");
g_free (hashed);
@@ -2356,7 +2365,7 @@ parse_wpa_psk (shvarFile *ifcfg,
}
if (!hashed) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid WPA_PSK (doesn't look like a passphrase or hex key)");
goto out;
}
@@ -2379,7 +2388,7 @@ eap_simple_reader (const char *eap_method,
value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE);
if (!value) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_IDENTITY for EAP method '%s'.",
eap_method);
return FALSE;
@@ -2399,7 +2408,7 @@ eap_simple_reader (const char *eap_method,
}
if (!value) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_PASSWORD for EAP method '%s'.",
eap_method);
return FALSE;
@@ -2460,7 +2469,7 @@ eap_tls_reader (const char *eap_method,
value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE);
if (!value) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_IDENTITY for EAP method '%s'.",
eap_method);
return FALSE;
@@ -2507,7 +2516,7 @@ eap_tls_reader (const char *eap_method,
}
if (!privkey_password) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing %s for EAP method '%s'.",
pk_pw_key,
eap_method);
@@ -2518,7 +2527,7 @@ eap_tls_reader (const char *eap_method,
/* The private key itself */
privkey = svGetValue (ifcfg, pk_key, FALSE);
if (!privkey) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing %s for EAP method '%s'.",
pk_key,
eap_method);
@@ -2555,7 +2564,7 @@ eap_tls_reader (const char *eap_method,
|| privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) {
client_cert = svGetValue (ifcfg, cli_cert_key, FALSE);
if (!client_cert) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing %s for EAP method '%s'.",
cli_cert_key,
eap_method);
@@ -2631,7 +2640,7 @@ eap_peap_reader (const char *eap_method,
else if (!strcmp (peapver, "1"))
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER, "1", NULL);
else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown IEEE_8021X_PEAP_VERSION value '%s'",
peapver);
goto done;
@@ -2647,7 +2656,7 @@ eap_peap_reader (const char *eap_method,
inner_auth = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE);
if (!inner_auth) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_INNER_AUTH_METHODS.");
goto done;
}
@@ -2667,7 +2676,7 @@ eap_peap_reader (const char *eap_method,
if (!eap_tls_reader (*iter, ifcfg, keys, s_8021x, TRUE, error))
goto done;
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.",
*iter);
goto done;
@@ -2680,7 +2689,7 @@ eap_peap_reader (const char *eap_method,
}
if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"No valid IEEE_8021X_INNER_AUTH_METHODS found.");
goto done;
}
@@ -2734,7 +2743,7 @@ eap_ttls_reader (const char *eap_method,
tmp = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE);
if (!tmp) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_INNER_AUTH_METHODS.");
goto done;
}
@@ -2766,7 +2775,7 @@ eap_ttls_reader (const char *eap_method,
goto done;
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, (*iter + STRLEN ("eap-")), NULL);
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.",
*iter);
goto done;
@@ -2834,7 +2843,7 @@ eap_fast_reader (const char *eap_method,
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, pac_prov_str, NULL);
if (!pac_file && !(allow_unauth || allow_auth)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"IEEE_8021X_PAC_FILE not provided and EAP-FAST automatic PAC provisioning disabled.");
goto done;
}
@@ -2845,7 +2854,7 @@ eap_fast_reader (const char *eap_method,
inner_auth = svGetValue (ifcfg, "IEEE_8021X_INNER_AUTH_METHODS", FALSE);
if (!inner_auth) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_INNER_AUTH_METHODS.");
goto done;
}
@@ -2861,7 +2870,7 @@ eap_fast_reader (const char *eap_method,
if (!eap_simple_reader (*iter, ifcfg, keys, s_8021x, TRUE, error))
goto done;
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.",
*iter);
goto done;
@@ -2874,7 +2883,7 @@ eap_fast_reader (const char *eap_method,
}
if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"No valid IEEE_8021X_INNER_AUTH_METHODS found.");
goto done;
}
@@ -2955,7 +2964,7 @@ fill_8021x (shvarFile *ifcfg,
value = svGetValue (ifcfg, "IEEE_8021X_EAP_METHODS", FALSE);
if (!value) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_EAP_METHODS for key management '%s'",
key_mgmt);
return NULL;
@@ -3009,7 +3018,7 @@ fill_8021x (shvarFile *ifcfg,
}
if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"No valid EAP methods found in IEEE_8021X_EAP_METHODS.");
goto error;
}
@@ -3119,7 +3128,7 @@ make_wpa_setting (shvarFile *ifcfg,
} else if (!strcmp (value, "WPA-EAP") || !strcmp (value, "IEEE8021X")) {
/* Adhoc mode is mutually exclusive with any 802.1x-based authentication */
if (adhoc) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Ad-Hoc mode cannot be used with KEY_MGMT type '%s'", value);
goto error;
}
@@ -3132,7 +3141,7 @@ make_wpa_setting (shvarFile *ifcfg,
g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, lower, NULL);
g_free (lower);
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown wireless KEY_MGMT type '%s'", value);
goto error;
}
@@ -3191,7 +3200,7 @@ make_leap_setting (shvarFile *ifcfg,
value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE);
if (!value || !strlen (value)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing LEAP identity");
goto error;
}
@@ -3320,7 +3329,7 @@ make_wireless_setting (shvarFile *ifcfg,
} else if ((value_len > 2) && (strncmp (value, "0x", 2) == 0)) {
/* Hex representation */
if (value_len % 2) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid SSID '%s' size (looks like hex but length not multiple of 2)",
value);
g_free (value);
@@ -3330,7 +3339,7 @@ make_wireless_setting (shvarFile *ifcfg,
p = value + 2;
while (*p) {
if (!g_ascii_isxdigit (*p)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid SSID '%s' character (looks like hex SSID but '%c' isn't a hex digit)",
value, *p);
g_free (value);
@@ -3347,7 +3356,7 @@ make_wireless_setting (shvarFile *ifcfg,
}
if (ssid_len > 32 || ssid_len == 0) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)",
value, ssid_len);
g_free (value);
@@ -3373,7 +3382,7 @@ make_wireless_setting (shvarFile *ifcfg,
} else if (!strcmp (lcase, "managed") || !strcmp (lcase, "auto")) {
mode = "infrastructure";
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid mode '%s' (not 'Ad-Hoc', 'Managed', or 'Auto')",
lcase);
g_free (lcase);
@@ -3396,7 +3405,7 @@ make_wireless_setting (shvarFile *ifcfg,
errno = 0;
chan = nm_utils_ascii_str_to_int64 (value, 10, 1, 196, 0);
if (errno || (chan == 0)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid wireless channel '%s'", value);
g_free (value);
goto error;
@@ -3409,20 +3418,20 @@ make_wireless_setting (shvarFile *ifcfg,
if (value) {
if (!strcmp (value, "a")) {
if (chan && chan <= 14) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Band '%s' invalid for channel %u", value, (guint32) chan);
g_free (value);
goto error;
}
} else if (!strcmp (value, "bg")) {
if (chan && chan > 14) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Band '%s' invalid for channel %u", value, (guint32) chan);
g_free (value);
goto error;
}
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid wireless band '%s'", value);
g_free (value);
goto error;
@@ -3443,7 +3452,7 @@ make_wireless_setting (shvarFile *ifcfg,
errno = 0;
mtu = strtol (value, NULL, 10);
if (errno || mtu < 0 || mtu > 50000) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid wireless MTU '%s'", value);
g_free (value);
goto error;
@@ -3525,7 +3534,7 @@ wireless_connection_from_ifcfg (const char *file,
printable_ssid, NULL);
g_free (printable_ssid);
if (!con_setting) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Failed to create connection setting.");
g_object_unref (connection);
return NULL;
@@ -3663,7 +3672,7 @@ make_wired_setting (shvarFile *ifcfg,
if (!*s_8021x)
goto error;
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown wired KEY_MGMT type '%s'", value);
goto error;
}
@@ -3695,7 +3704,7 @@ wired_connection_from_ifcfg (const char *file,
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_WIRED_SETTING_NAME, NULL, NULL);
if (!con_setting) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Failed to create connection setting.");
g_object_unref (connection);
return NULL;
@@ -3776,7 +3785,7 @@ parse_infiniband_p_key (shvarFile *ifcfg,
g_free (ifname);
if (!ret) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Failed to create InfiniBand setting.");
}
return ret;
@@ -3852,7 +3861,7 @@ infiniband_connection_from_ifcfg (const char *file,
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_INFINIBAND_SETTING_NAME, NULL, NULL);
if (!con_setting) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Failed to create connection setting.");
g_object_unref (connection);
return NULL;
@@ -3908,7 +3917,8 @@ make_bond_setting (shvarFile *ifcfg,
value = svGetValue (ifcfg, "DEVICE", FALSE);
if (!value || !strlen (value)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "mandatory DEVICE keyword missing");
goto error;
}
g_free (value);
@@ -3962,7 +3972,7 @@ bond_connection_from_ifcfg (const char *file,
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BOND_SETTING_NAME, NULL, _("Bond"));
if (!con_setting) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Failed to create connection setting.");
g_object_unref (connection);
return NULL;
@@ -4007,7 +4017,8 @@ read_team_config (shvarFile *ifcfg, const char *key, GError **error)
*/
l = strlen (value);
if (l > 20000) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "%s too long (size %zd)", key, l);
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "%s too long (size %zd)", key, l);
g_free (value);
return NULL;
}
@@ -4028,7 +4039,8 @@ make_team_setting (shvarFile *ifcfg,
value = svGetValue (ifcfg, "DEVICE", FALSE);
if (!value || !strlen (value)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "mandatory DEVICE keyword missing");
goto error;
}
g_free (value);
@@ -4066,7 +4078,7 @@ team_connection_from_ifcfg (const char *file,
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_TEAM_SETTING_NAME, NULL, _("Team"));
if (!con_setting) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Failed to create connection setting.");
g_object_unref (connection);
return NULL;
@@ -4178,7 +4190,8 @@ make_bridge_setting (shvarFile *ifcfg,
value = svGetValue (ifcfg, "DEVICE", FALSE);
if (!value || !strlen (value)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "mandatory DEVICE keyword missing");
goto error;
}
g_free (value);
@@ -4250,7 +4263,7 @@ bridge_connection_from_ifcfg (const char *file,
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BRIDGE_SETTING_NAME, NULL, _("Bridge"));
if (!con_setting) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Failed to create connection setting.");
g_object_unref (connection);
return NULL;
@@ -4424,7 +4437,8 @@ make_vlan_setting (shvarFile *ifcfg,
errno = 0;
vlan_id = (gint) g_ascii_strtoll (value, NULL, 10);
if (vlan_id < 0 || vlan_id > 4096 || errno) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Invalid VLAN_ID '%s'", value);
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Invalid VLAN_ID '%s'", value);
g_free (value);
return NULL;
}
@@ -4434,7 +4448,7 @@ make_vlan_setting (shvarFile *ifcfg,
/* Need DEVICE if we don't have a separate VLAN_ID property */
iface_name = svGetValue (ifcfg, "DEVICE", FALSE);
if (!iface_name && vlan_id < 0) {
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing DEVICE property; cannot determine VLAN ID.");
return NULL;
}
@@ -4471,7 +4485,7 @@ make_vlan_setting (shvarFile *ifcfg,
*/
vlan_id = (gint) g_ascii_strtoll (p, &end, 10);
if (vlan_id < 0 || vlan_id > 4095 || end == p || *end) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Failed to determine VLAN ID from DEVICE '%s'",
iface_name);
goto error;
@@ -4480,14 +4494,14 @@ make_vlan_setting (shvarFile *ifcfg,
}
if (vlan_id < 0) {
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Failed to determine VLAN ID from DEVICE or VLAN_ID.");
goto error;
}
g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL);
if (parent == NULL) {
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Failed to determine VLAN parent from DEVICE or PHYSDEV");
goto error;
}
@@ -4537,8 +4551,8 @@ vlan_connection_from_ifcfg (const char *file,
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_VLAN_SETTING_NAME, NULL, "Vlan");
if (!con_setting) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
- "Failed to create connection setting.");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Failed to create connection setting.");
g_object_unref (connection);
return NULL;
}
@@ -4706,7 +4720,7 @@ connection_from_file (const char *filename,
ifcfg_name = utils_get_ifcfg_name (filename, TRUE);
if (!ifcfg_name) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Ignoring connection '%s' because it's not an ifcfg file.", filename);
return NULL;
}
@@ -4729,7 +4743,7 @@ connection_from_file (const char *filename,
if (bootproto && !g_ascii_strcasecmp (bootproto, "ibft")) {
if (out_ignore_error)
*out_ignore_error = TRUE;
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Ignoring iBFT configuration");
g_free (bootproto);
goto done;
@@ -4754,7 +4768,7 @@ connection_from_file (const char *filename,
device = svGetValue (parsed, "DEVICE", FALSE);
if (!device) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"File '%s' had neither TYPE nor DEVICE keys.", filename);
goto done;
}
@@ -4762,7 +4776,7 @@ connection_from_file (const char *filename,
if (!strcmp (device, "lo")) {
if (out_ignore_error)
*out_ignore_error = TRUE;
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Ignoring loopback device config.");
g_free (device);
goto done;
@@ -4796,7 +4810,7 @@ connection_from_file (const char *filename,
if (svTrueValue (parsed, "BONDING_MASTER", FALSE) &&
strcasecmp (type, TYPE_BOND)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"BONDING_MASTER=yes key only allowed in TYPE=bond connections");
goto done;
}
diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/Makefile.am
index e3eae46609..5a17ed9bb6 100644
--- a/src/settings/plugins/ifcfg-rh/tests/Makefile.am
+++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.am
@@ -31,7 +31,6 @@ noinst_PROGRAMS = test-ifcfg-rh test-ifcfg-rh-utils
test_ifcfg_rh_SOURCES = \
test-ifcfg-rh.c \
- ../errors.c \
../reader.c \
../shvar.c \
../utils.c \
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index 03caff5f81..3558f825c5 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -5952,7 +5952,7 @@ test_read_wifi_band_a_channel_mismatch (void)
connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-a-channel-mismatch",
NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL);
g_assert (connection == NULL);
- g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
}
static void
@@ -5964,7 +5964,7 @@ test_read_wifi_band_bg_channel_mismatch (void)
connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-band-bg-channel-mismatch",
NULL, TYPE_WIRELESS, NULL, NULL, NULL, NULL, &error, NULL);
g_assert (connection == NULL);
- g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
}
#define TEST_IFCFG_WIRED_QETH_STATIC TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-qeth-static"
@@ -12287,7 +12287,7 @@ test_read_ibft_ignored (void)
connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-ibft",
NULL, TYPE_ETHERNET,
NULL, NULL, NULL, NULL, &error, NULL);
- g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
g_assert (connection == NULL);
}
@@ -13169,7 +13169,7 @@ test_read_dcb_bad_booleans (void)
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
g_test_assert_expected_messages ();
- g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
g_assert (strstr (error->message, "invalid boolean digit"));
g_assert (connection == NULL);
}
@@ -13186,7 +13186,7 @@ test_read_dcb_short_booleans (void)
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
g_test_assert_expected_messages ();
- g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
g_assert (strstr (error->message, "boolean array must be 8 characters"));
g_assert (connection == NULL);
}
@@ -13203,7 +13203,7 @@ test_read_dcb_bad_uints (void)
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
g_test_assert_expected_messages ();
- g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
g_assert (strstr (error->message, "invalid uint digit"));
g_assert (connection == NULL);
}
@@ -13220,7 +13220,7 @@ test_read_dcb_short_uints (void)
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
g_test_assert_expected_messages ();
- g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
g_assert (strstr (error->message, "uint array must be 8 characters"));
g_assert (connection == NULL);
}
@@ -13237,7 +13237,7 @@ test_read_dcb_bad_percent (void)
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
g_test_assert_expected_messages ();
- g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
g_assert (strstr (error->message, "invalid percent element"));
g_assert (connection == NULL);
}
@@ -13254,7 +13254,7 @@ test_read_dcb_short_percent (void)
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
g_test_assert_expected_messages ();
- g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
g_assert (strstr (error->message, "percent array must be 8 elements"));
g_assert (connection == NULL);
}
@@ -13271,7 +13271,7 @@ test_read_dcb_pgpct_not_100 (void)
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, &error, NULL);
g_test_assert_expected_messages ();
- g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
+ g_assert_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION);
g_assert (strstr (error->message, "invalid percentage sum"));
g_assert (connection == NULL);
}
diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c
index 70c0e1b024..90bbe71eb2 100644
--- a/src/settings/plugins/ifcfg-rh/writer.c
+++ b/src/settings/plugins/ifcfg-rh/writer.c
@@ -148,7 +148,7 @@ write_secret_file (const char *path,
errno = 0;
fd = mkstemp (tmppath);
if (fd < 0) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not create temporary file for '%s': %d",
path, errno);
goto out;
@@ -159,7 +159,7 @@ write_secret_file (const char *path,
if (fchmod (fd, S_IRUSR | S_IWUSR)) {
close (fd);
unlink (tmppath);
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not set permissions for temporary file '%s': %d",
path, errno);
goto out;
@@ -170,7 +170,7 @@ write_secret_file (const char *path,
if (written != len) {
close (fd);
unlink (tmppath);
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not write temporary file for '%s': %d",
path, errno);
goto out;
@@ -181,7 +181,7 @@ write_secret_file (const char *path,
errno = 0;
if (rename (tmppath, path)) {
unlink (tmppath);
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not rename temporary file to '%s': %d",
path, errno);
goto out;
@@ -337,7 +337,7 @@ write_object (NMSetting8021x *s_8021x,
new_file = utils_cert_path (ifcfg->fileName, objtype->suffix);
if (!new_file) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not create file path for %s / %s",
NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key);
return FALSE;
@@ -356,7 +356,7 @@ write_object (NMSetting8021x *s_8021x,
g_free (new_file);
return TRUE;
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not write certificate/key for %s / %s: %s",
NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key,
(write_error && write_error->message) ? write_error->message : "(unknown)");
@@ -609,7 +609,7 @@ write_wireless_security_setting (NMConnection *connection,
s_wsec = nm_connection_get_setting_wireless_security (connection);
if (!s_wsec) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing '%s' setting", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
return FALSE;
}
@@ -815,7 +815,7 @@ write_wireless_setting (NMConnection *connection,
s_wireless = nm_connection_get_setting_wireless (connection);
if (!s_wireless) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
}
@@ -853,13 +853,13 @@ write_wireless_setting (NMConnection *connection,
ssid = nm_setting_wireless_get_ssid (s_wireless);
if (!ssid) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
}
ssid_data = g_bytes_get_data (ssid, &ssid_len);
if (!ssid_len || ssid_len > 32) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Invalid SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
}
@@ -909,7 +909,7 @@ write_wireless_setting (NMConnection *connection,
svSetValue (ifcfg, "MODE", "Ad-Hoc", FALSE);
adhoc = TRUE;
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Invalid mode '%s' in '%s' setting",
mode, NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
@@ -992,7 +992,7 @@ write_infiniband_setting (NMConnection *connection, shvarFile *ifcfg, GError **e
s_infiniband = nm_connection_get_setting_infiniband (connection);
if (!s_infiniband) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing '%s' setting", NM_SETTING_INFINIBAND_SETTING_NAME);
return FALSE;
}
@@ -1044,7 +1044,7 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
s_wired = nm_connection_get_setting_wired (connection);
if (!s_wired) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing '%s' setting", NM_SETTING_WIRED_SETTING_NAME);
return FALSE;
}
@@ -1169,13 +1169,15 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired,
s_con = nm_connection_get_setting_connection (connection);
if (!s_con) {
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "Missing connection setting");
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
+ "Missing connection setting");
return FALSE;
}
s_vlan = nm_connection_get_setting_vlan (connection);
if (!s_vlan) {
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0, "Missing VLAN setting");
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
+ "Missing VLAN setting");
return FALSE;
}
@@ -1250,14 +1252,15 @@ write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, GError **erro
s_bond = nm_connection_get_setting_bond (connection);
if (!s_bond) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing '%s' setting", NM_SETTING_BOND_SETTING_NAME);
return FALSE;
}
iface = nm_connection_get_interface_name (connection);
if (!iface) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
+ "Missing interface name");
return FALSE;
}
@@ -1301,14 +1304,15 @@ write_team_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
s_team = nm_connection_get_setting_team (connection);
if (!s_team) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing '%s' setting", NM_SETTING_TEAM_SETTING_NAME);
return FALSE;
}
iface = nm_connection_get_interface_name (connection);
if (!iface) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
+ "Missing interface name");
return FALSE;
}
@@ -1349,14 +1353,15 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error
s_bridge = nm_connection_get_setting_bridge (connection);
if (!s_bridge) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing '%s' setting", NM_SETTING_BRIDGE_SETTING_NAME);
return FALSE;
}
iface = nm_connection_get_interface_name (connection);
if (!iface) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
+ "Missing interface name");
return FALSE;
}
@@ -1793,7 +1798,7 @@ write_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
g_strfreev (route_items);
if (!g_file_set_contents (filename, route_contents, -1, NULL)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Writing route file '%s' failed", filename);
goto error;
}
@@ -2037,7 +2042,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
/* Static routes - route-<name> file */
route_path = utils_get_route_path (ifcfg->fileName);
if (!route_path) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not get route file path for '%s'", ifcfg->fileName);
goto out;
}
@@ -2047,7 +2052,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
routefile = utils_get_route_ifcfg (ifcfg->fileName, TRUE);
if (!routefile) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not create route file '%s'", route_path);
g_free (route_path);
goto out;
@@ -2265,7 +2270,7 @@ write_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **err
g_strfreev (route_items);
if (!g_file_set_contents (filename, route_contents, -1, NULL)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Writing route6 file '%s' failed", filename);
goto error;
}
@@ -2451,7 +2456,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
/* Static routes go to route6-<dev> file */
route6_path = utils_get_route6_path (ifcfg->fileName);
if (!route6_path) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not get route6 file path for '%s'", ifcfg->fileName);
goto error;
}
@@ -2539,7 +2544,7 @@ write_connection (NMConnection *connection,
g_free (escaped);
if (ifcfg_name == NULL) {
- g_set_error_literal (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Failed to find usable ifcfg file name");
return FALSE;
}
@@ -2549,7 +2554,7 @@ write_connection (NMConnection *connection,
type = nm_setting_connection_get_connection_type (s_con);
if (!type) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Missing connection type!");
goto out;
}
@@ -2557,7 +2562,7 @@ write_connection (NMConnection *connection,
if (!strcmp (type, NM_SETTING_WIRED_SETTING_NAME)) {
// FIXME: can't write PPPoE at this time
if (nm_connection_get_setting_pppoe (connection)) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Can't write connection type '%s'",
NM_SETTING_PPPOE_SETTING_NAME);
goto out;
@@ -2585,7 +2590,7 @@ write_connection (NMConnection *connection,
if (!write_bridge_setting (connection, ifcfg, error))
goto out;
} else {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Can't write connection type '%s'", type);
goto out;
}
@@ -2650,7 +2655,7 @@ writer_can_write_connection (NMConnection *connection, GError **error)
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"The ifcfg-rh plugin cannot write the connection '%s' (type '%s' pppoe %d)",
nm_connection_get_id (connection),
nm_setting_connection_get_connection_type (s_con),
diff --git a/src/settings/plugins/ifcfg-suse/plugin.c b/src/settings/plugins/ifcfg-suse/plugin.c
index d6aa79fb57..cf73548d8e 100644
--- a/src/settings/plugins/ifcfg-suse/plugin.c
+++ b/src/settings/plugins/ifcfg-suse/plugin.c
@@ -55,17 +55,6 @@ typedef struct {
char *hostname;
} SCPluginIfcfgPrivate;
-GQuark
-ifcfg_plugin_error_quark (void)
-{
- static GQuark error_quark = 0;
-
- if (G_UNLIKELY (error_quark == 0))
- error_quark = g_quark_from_static_string ("ifcfg-plugin-error-quark");
-
- return error_quark;
-}
-
typedef void (*FileChangedFn) (gpointer user_data);
typedef struct {
diff --git a/src/settings/plugins/ifcfg-suse/plugin.h b/src/settings/plugins/ifcfg-suse/plugin.h
index 4090a11e16..24dbff9533 100644
--- a/src/settings/plugins/ifcfg-suse/plugin.h
+++ b/src/settings/plugins/ifcfg-suse/plugin.h
@@ -46,7 +46,5 @@ struct _SCPluginIfcfgClass {
GType sc_plugin_ifcfg_get_type (void);
-GQuark ifcfg_plugin_error_quark (void);
-
#endif /* _PLUGIN_H_ */
diff --git a/src/settings/plugins/ifnet/Makefile.am b/src/settings/plugins/ifnet/Makefile.am
index 02b5207b8e..b0cfd9a11e 100644
--- a/src/settings/plugins/ifnet/Makefile.am
+++ b/src/settings/plugins/ifnet/Makefile.am
@@ -38,6 +38,4 @@ lib_ifnet_io_la_SOURCES = \
net_utils.h\
net_utils.c\
wpa_parser.h\
- wpa_parser.c \
- errors.h \
- errors.c
+ wpa_parser.c
diff --git a/src/settings/plugins/ifnet/connection_parser.c b/src/settings/plugins/ifnet/connection_parser.c
index 25b958fd4f..8fcc6a62b8 100644
--- a/src/settings/plugins/ifnet/connection_parser.c
+++ b/src/settings/plugins/ifnet/connection_parser.c
@@ -43,7 +43,6 @@
#include "wpa_parser.h"
#include "connection_parser.h"
#include "nm-ifnet-connection.h"
-#include "errors.h"
static char *
connection_id_from_ifnet_name (const char *conn_name)
@@ -124,7 +123,7 @@ eap_simple_reader (const char *eap_method,
/* identity */
value = wpa_get_value (ssid, "identity");
if (!value) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_IDENTITY for EAP method '%s'.",
eap_method);
return FALSE;
@@ -134,7 +133,7 @@ eap_simple_reader (const char *eap_method,
/* password */
value = wpa_get_value (ssid, "password");
if (!value) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_PASSWORD for EAP method '%s'.",
eap_method);
return FALSE;
@@ -176,7 +175,7 @@ eap_tls_reader (const char *eap_method,
/* identity */
value = wpa_get_value (ssid, "identity");
if (!value) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_IDENTITY for EAP method '%s'.",
eap_method);
return FALSE;
@@ -211,7 +210,7 @@ eap_tls_reader (const char *eap_method,
"private_key_passwd");
if (!privkey_password) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing %s for EAP method '%s'.",
phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD" :
"IEEE_8021X_PRIVATE_KEY_PASSWORD", eap_method);
@@ -221,7 +220,7 @@ eap_tls_reader (const char *eap_method,
/* The private key itself */
privkey = get_cert (ssid, phase2 ? "private_key2" : "private_key", basepath);
if (!privkey) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing %s for EAP method '%s'.",
phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY" :
"IEEE_8021X_PRIVATE_KEY", eap_method);
@@ -254,7 +253,7 @@ eap_tls_reader (const char *eap_method,
|| privkey_format == NM_SETTING_802_1X_CK_FORMAT_X509) {
client_cert = get_cert (ssid, phase2 ? "client_cert2" : "client_cert", basepath);
if (!client_cert) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing %s for EAP method '%s'.",
phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" :
"IEEE_8021X_CLIENT_CERT", eap_method);
@@ -322,7 +321,7 @@ eap_peap_reader (const char *eap_method,
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPVER,
"1", NULL);
else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown IEEE_8021X_PEAP_VERSION value '%s'",
peapver);
goto done;
@@ -336,7 +335,7 @@ eap_peap_reader (const char *eap_method,
inner_auth = wpa_get_value (ssid, "phase2");
if (!inner_auth) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_INNER_AUTH_METHODS.");
goto done;
}
@@ -357,7 +356,7 @@ eap_peap_reader (const char *eap_method,
if (!eap_tls_reader (pos, ssid, s_8021x, TRUE, basepath, error))
goto done;
} else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.",
*iter);
goto done;
@@ -373,7 +372,7 @@ eap_peap_reader (const char *eap_method,
}
if (!nm_setting_802_1x_get_phase2_auth (s_8021x)) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"No valid IEEE_8021X_INNER_AUTH_METHODS found.");
goto done;
}
@@ -422,7 +421,7 @@ eap_ttls_reader (const char *eap_method,
tmp = wpa_get_value (ssid, "phase2");
if (!tmp) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_INNER_AUTH_METHODS.");
goto done;
}
@@ -457,7 +456,7 @@ eap_ttls_reader (const char *eap_method,
g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP,
pos, NULL);
} else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.",
*iter);
goto done;
@@ -506,7 +505,7 @@ read_mac_address (const char *conn_name, const char **mac, GError **error)
return TRUE;
if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"The MAC address '%s' was invalid.", value);
return FALSE;
}
@@ -577,7 +576,7 @@ make_ip4_setting (NMConnection *connection,
if (!is_static_block) {
method = ifnet_get_data (conn_name, "config");
if (!method){
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown config for %s", conn_name);
g_object_unref (ip4_setting);
return;
@@ -602,7 +601,7 @@ make_ip4_setting (NMConnection *connection,
nm_connection_add_setting (connection, NM_SETTING (ip4_setting));
return;
} else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown config for %s", conn_name);
g_object_unref (ip4_setting);
return;
@@ -611,7 +610,7 @@ make_ip4_setting (NMConnection *connection,
}else {
iblock = convert_ip4_config_block (conn_name);
if (!iblock) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Ifnet plugin: can't aquire ip configuration for %s",
conn_name);
g_object_unref (ip4_setting);
@@ -789,7 +788,7 @@ make_ip6_setting (NMConnection *connection,
iblock = convert_ip6_config_block (conn_name);
if (!iblock) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Ifnet plugin: can't aquire ip6 configuration for %s",
conn_name);
goto error;
@@ -919,8 +918,7 @@ make_wireless_connection_setting (const char *conn_name,
if ((value_len > 2) && (g_str_has_prefix (conn_name, "0x"))) {
/* Hex representation */
if (value_len % 2) {
- g_set_error (error, ifnet_plugin_error_quark (),
- 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid SSID '%s' size (looks like hex but length not multiple of 2)",
conn_name);
goto error;
@@ -928,9 +926,7 @@ make_wireless_connection_setting (const char *conn_name,
// ignore "0x"
p = conn_name + 2;
if (!is_hex (p)) {
- g_set_error (error,
- ifnet_plugin_error_quark (),
- 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid SSID '%s' character (looks like hex SSID but '%c' isn't a hex digit)",
conn_name, *p);
goto error;
@@ -944,7 +940,7 @@ make_wireless_connection_setting (const char *conn_name,
}
if (ssid_len > 32 || ssid_len == 0) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)",
conn_name, ssid_len);
goto error;
@@ -954,7 +950,7 @@ make_wireless_connection_setting (const char *conn_name,
g_bytes_unref (bytes);
g_free (converted);
} else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing SSID");
goto error;
}
@@ -977,7 +973,7 @@ make_wireless_connection_setting (const char *conn_name,
value = wpa_get_value (conn_name, "bssid");
if (value) {
if (!nm_utils_hwaddr_valid (value, ETH_ALEN)) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid BSSID '%s'", value);
goto error;
}
@@ -1035,7 +1031,7 @@ make_leap_setting (const char *ssid, GError **error)
value = wpa_get_value (ssid, "identity");
if (!value || !strlen (value)) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing LEAP identity");
goto error;
}
@@ -1077,8 +1073,8 @@ add_one_wep_key (const char *ssid,
if (strlen (value) == 10 || strlen (value) == 26) {
/* Hexadecimal WEP key */
if (!is_hex (value)) {
- g_set_error (error, ifnet_plugin_error_quark (),
- 0, "Invalid hexadecimal WEP key.");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Invalid hexadecimal WEP key.");
goto out;
}
converted = g_strdup (value);
@@ -1089,8 +1085,8 @@ add_one_wep_key (const char *ssid,
char *p = strip_string (tmp, '"');
if (!is_ascii (p)) {
- g_set_error (error, ifnet_plugin_error_quark (),
- 0, "Invalid ASCII WEP passphrase.");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Invalid ASCII WEP passphrase.");
g_free (tmp);
goto out;
@@ -1099,7 +1095,7 @@ add_one_wep_key (const char *ssid,
converted = nm_utils_bin2hexstr (tmp, strlen (tmp), strlen (tmp) * 2);
g_free (tmp);
} else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid WEP key length. Key: %s", value);
goto out;
}
@@ -1153,7 +1149,7 @@ make_wep_setting (const char *ssid, GError **error)
default_key_idx, NULL);
nm_log_info (LOGD_SETTINGS, "Default key index: %d", default_key_idx);
} else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid default WEP key '%s'", value);
goto error;
}
@@ -1165,19 +1161,19 @@ make_wep_setting (const char *ssid, GError **error)
/* If there's a default key, ensure that key exists */
if ((default_key_idx == 1)
&& !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1)) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Default WEP key index was 2, but no valid KEY2 exists.");
goto error;
} else if ((default_key_idx == 2)
&& !nm_setting_wireless_security_get_wep_key (s_wireless_sec,
2)) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Default WEP key index was 3, but no valid KEY3 exists.");
goto error;
} else if ((default_key_idx == 3)
&& !nm_setting_wireless_security_get_wep_key (s_wireless_sec,
3)) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Default WEP key index was 4, but no valid KEY4 exists.");
goto error;
}
@@ -1196,7 +1192,7 @@ make_wep_setting (const char *ssid, GError **error)
"shared", NULL);
nm_log_info (LOGD_SETTINGS, "WEP: Use shared system authentication");
} else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid WEP authentication algorithm '%s'",
auth_alg);
goto error;
@@ -1210,7 +1206,7 @@ make_wep_setting (const char *ssid, GError **error)
&& !nm_setting_wireless_security_get_wep_key (s_wireless_sec, 3)
&& !nm_setting_wireless_security_get_wep_tx_keyidx (s_wireless_sec)) {
if (auth_alg && !strcmp (auth_alg, "shared")) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"WEP Shared Key authentication is invalid for "
"unencrypted connections.");
goto error;
@@ -1234,7 +1230,7 @@ parse_wpa_psk (const char *psk, GError **error)
gboolean quoted = FALSE;
if (!psk) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing WPA_PSK for WPA-PSK key management");
return NULL;
}
@@ -1250,9 +1246,8 @@ parse_wpa_psk (const char *psk, GError **error)
if (!quoted && (strlen (psk) == 64)) {
/* Verify the hex PSK; 64 digits */
if (!is_hex (psk)) {
- g_set_error (error, ifnet_plugin_error_quark (),
- 0,
- "Invalid WPA_PSK (contains non-hexadecimal characters)");
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
+ "Invalid WPA_PSK (contains non-hexadecimal characters)");
goto out;
}
hashed = g_strdup (psk);
@@ -1263,7 +1258,7 @@ parse_wpa_psk (const char *psk, GError **error)
/* Length check */
if (strlen (stripped) < 8 || strlen (stripped) > 63) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid WPA_PSK (passphrases must be between "
"8 and 63 characters long (inclusive))");
g_free (stripped);
@@ -1275,7 +1270,7 @@ parse_wpa_psk (const char *psk, GError **error)
}
if (!hashed) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid WPA_PSK (doesn't look like a passphrase or hex key)");
goto out;
}
@@ -1359,7 +1354,7 @@ fill_8021x (const char *ssid,
value = wpa_get_value (ssid, "eap");
if (!value) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IEEE_8021X_EAP_METHODS for key management '%s'",
key_mgmt);
return NULL;
@@ -1410,7 +1405,7 @@ fill_8021x (const char *ssid,
g_strfreev (list);
if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"No valid EAP methods found in IEEE_8021X_EAP_METHODS.");
goto error;
}
@@ -1434,7 +1429,7 @@ make_wpa_setting (const char *ssid,
gboolean adhoc = FALSE;
if (!exist_ssid (ssid)) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"No security info found for ssid: %s", ssid);
return NULL;
}
@@ -1486,7 +1481,7 @@ make_wpa_setting (const char *ssid,
"wpa-psk", NULL);
} else if (!strcmp (value, "WPA-EAP") || !strcmp (value, "IEEE8021X")) {
if (adhoc) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Ad-Hoc mode cannot be used with KEY_MGMT type '%s'",
value);
goto error;
@@ -1500,7 +1495,7 @@ make_wpa_setting (const char *ssid,
lower, NULL);
g_free (lower);
} else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Unknown wireless KEY_MGMT type '%s'", value);
goto error;
}
@@ -1551,7 +1546,7 @@ make_wireless_security_setting (const char *conn_name,
}
if (!wsec) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Can't handle security information for ssid: %s",
conn_name);
}
@@ -1576,7 +1571,7 @@ make_pppoe_connection_setting (NMConnection *connection,
/* username */
value = ifnet_get_data (conn_name, "username");
if (!value) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"ppp requires at lease a username");
return;
}
@@ -2070,7 +2065,7 @@ write_wireless_security_setting (NMConnection * connection,
s_wsec = nm_connection_get_setting_wireless_security (connection);
if (!s_wsec) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing '%s' setting",
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
return FALSE;
@@ -2238,7 +2233,7 @@ write_wireless_setting (NMConnection *connection,
s_wireless = nm_connection_get_setting_wireless (connection);
if (!s_wireless) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing '%s' setting",
NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
@@ -2246,14 +2241,14 @@ write_wireless_setting (NMConnection *connection,
ssid = nm_setting_wireless_get_ssid (s_wireless);
if (!ssid) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing SSID in '%s' setting",
NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
}
ssid_data = g_bytes_get_data (ssid, &ssid_len);
if (!ssid_len || ssid_len > 32) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid SSID in '%s' setting",
NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
@@ -2345,7 +2340,7 @@ write_wired_setting (NMConnection *connection,
s_wired = nm_connection_get_setting_wired (connection);
if (!s_wired) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing '%s' setting",
NM_SETTING_WIRED_SETTING_NAME);
return FALSE;
@@ -2385,7 +2380,7 @@ write_ip4_setting (NMConnection *connection, const char *conn_name, GError **err
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (!s_ip4) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing '%s' setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
return FALSE;
@@ -2584,7 +2579,7 @@ write_ip6_setting (NMConnection *connection, const char *conn_name, GError **err
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (!s_ip6) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing '%s' setting",
NM_SETTING_IP6_CONFIG_SETTING_NAME);
return FALSE;
@@ -2743,7 +2738,7 @@ ifnet_update_parsers_by_connection (NMConnection *connection,
type = nm_setting_connection_get_connection_type (s_con);
if (!type) {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing connection type!");
goto out;
}
@@ -2769,7 +2764,7 @@ ifnet_update_parsers_by_connection (NMConnection *connection,
wired = TRUE;
no_8021x = TRUE;
} else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
"Can't write connection type '%s'", type);
goto out;
}
@@ -2865,7 +2860,7 @@ ifnet_can_write_connection (NMConnection *connection, GError **error)
/* If the connection is not available for all users, ignore
* it as this plugin only deals with System Connections */
if (nm_setting_connection_get_num_permissions (s_con)) {
- g_set_error_literal (error, IFNET_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
"The ifnet plugin does not support non-system-wide connections.");
return FALSE;
}
@@ -2874,7 +2869,7 @@ ifnet_can_write_connection (NMConnection *connection, GError **error)
if ( !nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME)
&& !nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME)
&& !nm_connection_is_type (connection, NM_SETTING_PPPOE_SETTING_NAME)) {
- g_set_error (error, IFNET_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
"The ifnet plugin cannot write the connection '%s' (type '%s')",
nm_connection_get_id (connection),
nm_setting_connection_get_connection_type (s_con));
@@ -2887,7 +2882,7 @@ ifnet_can_write_connection (NMConnection *connection, GError **error)
check_unsupported_secrets,
&has_unsupported_secrets);
if (has_unsupported_secrets) {
- g_set_error_literal (error, IFNET_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
"The ifnet plugin only supports persistent system secrets.");
return FALSE;
}
@@ -3019,7 +3014,7 @@ ifnet_add_new_connection (NMConnection *connection,
goto out;
new_type = "ppp";
} else {
- g_set_error (error, ifnet_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED,
"Can't write connection type '%s'", type);
goto out;
}
diff --git a/src/settings/plugins/ifnet/errors.c b/src/settings/plugins/ifnet/errors.c
deleted file mode 100644
index 295db18bae..0000000000
--- a/src/settings/plugins/ifnet/errors.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2013 Red Hat, Inc.
- */
-
-#include <glib.h>
-#include "errors.h"
-
-GQuark
-ifnet_plugin_error_quark (void)
-{
- static GQuark error_quark = 0;
-
- if (G_UNLIKELY (error_quark == 0))
- error_quark = g_quark_from_static_string ("ifnet-plugin-error-quark");
-
- return error_quark;
-}
-
-
diff --git a/src/settings/plugins/ifnet/errors.h b/src/settings/plugins/ifnet/errors.h
deleted file mode 100644
index 52517d007e..0000000000
--- a/src/settings/plugins/ifnet/errors.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2013 Red Hat, Inc.
- */
-
-#ifndef __ERRORS_H__
-#define __ERRORS_H__
-
-#include <glib.h>
-
-#define IFNET_PLUGIN_ERROR (ifnet_plugin_error_quark ())
-GQuark ifnet_plugin_error_quark (void);
-
-#endif /* __ERRORS_H__ */
-
diff --git a/src/settings/plugins/ifnet/tests/Makefile.am b/src/settings/plugins/ifnet/tests/Makefile.am
index 90d7243020..a842a206ec 100644
--- a/src/settings/plugins/ifnet/tests/Makefile.am
+++ b/src/settings/plugins/ifnet/tests/Makefile.am
@@ -25,8 +25,7 @@ check_ifnet_SOURCES = \
../connection_parser.c \
../net_parser.c \
../net_utils.c \
- ../wpa_parser.c \
- ../errors.c
+ ../wpa_parser.c
check_ifnet_LDFLAGS = \
$(CODE_COVERAGE_LDFLAGS)
diff --git a/src/settings/plugins/ifupdown/parser.c b/src/settings/plugins/ifupdown/parser.c
index 097fe7b64e..18b8932494 100644
--- a/src/settings/plugins/ifupdown/parser.c
+++ b/src/settings/plugins/ifupdown/parser.c
@@ -417,17 +417,6 @@ update_wired_setting_from_if_block(NMConnection *connection,
nm_connection_add_setting(connection, NM_SETTING(s_wired));
}
-static GQuark
-eni_plugin_error_quark() {
- static GQuark error_quark = 0;
-
- if(!error_quark) {
- error_quark = g_quark_from_static_string ("eni-plugin-error-quark");
- }
-
- return error_quark;
-}
-
static void
ifupdown_ip4_add_dns (NMSettingIP4Config *s_ip4, const char *dns)
{
@@ -480,7 +469,7 @@ update_ip4_setting_from_if_block(NMConnection *connection,
/* Address */
address_v = ifparser_getkey (block, "address");
if (!address_v || !inet_pton (AF_INET, address_v, &tmp_addr)) {
- g_set_error (error, eni_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IPv4 address '%s'",
address_v ? address_v : "(none)");
goto error;
@@ -492,12 +481,12 @@ update_ip4_setting_from_if_block(NMConnection *connection,
if (strlen (netmask_v) < 7) {
netmask_int = atoi (netmask_v);
if (netmask_int > 32) {
- g_set_error (error, eni_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IPv4 netmask '%s'", netmask_v);
goto error;
}
} else if (!inet_pton (AF_INET, netmask_v, &tmp_mask)) {
- g_set_error (error, eni_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IPv4 netmask '%s'", netmask_v);
goto error;
} else {
@@ -510,7 +499,7 @@ update_ip4_setting_from_if_block(NMConnection *connection,
if (!gateway_v)
gateway_v = address_v; /* dcbw: whaaa?? */
if (!inet_pton (AF_INET, gateway_v, &tmp_gw)) {
- g_set_error (error, eni_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IPv4 gateway '%s'", gateway_v);
goto error;
}
@@ -615,7 +604,7 @@ update_ip6_setting_from_if_block(NMConnection *connection,
/* Address */
address_v = ifparser_getkey(block, "address");
if (!address_v || !inet_pton (AF_INET6, address_v, &tmp_addr)) {
- g_set_error (error, eni_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Missing IPv6 address '%s'",
address_v ? address_v : "(none)");
goto error;
@@ -631,7 +620,7 @@ update_ip6_setting_from_if_block(NMConnection *connection,
if (!gateway_v)
gateway_v = address_v; /* dcbw: whaaa?? */
if (!inet_pton (AF_INET6, gateway_v, &tmp_gw)) {
- g_set_error (error, eni_plugin_error_quark (), 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid IPv6 gateway '%s'", gateway_v);
goto error;
}
diff --git a/src/settings/plugins/ifupdown/plugin.h b/src/settings/plugins/ifupdown/plugin.h
index ed7732b887..943b8b9f6e 100644
--- a/src/settings/plugins/ifupdown/plugin.h
+++ b/src/settings/plugins/ifupdown/plugin.h
@@ -48,6 +48,4 @@ struct _SCPluginIfupdownClass {
GType sc_plugin_ifupdown_get_type (void);
-GQuark ifupdown_plugin_error_quark (void);
-
#endif /* _PLUGIN_H_ */
diff --git a/src/settings/plugins/keyfile/Makefile.am b/src/settings/plugins/keyfile/Makefile.am
index bf89b06796..079c45c39e 100644
--- a/src/settings/plugins/keyfile/Makefile.am
+++ b/src/settings/plugins/keyfile/Makefile.am
@@ -26,7 +26,6 @@ libkeyfile_io_la_SOURCES = \
reader.h \
writer.c \
writer.h \
- errors.c \
utils.c \
utils.h \
common.h
diff --git a/src/settings/plugins/keyfile/common.h b/src/settings/plugins/keyfile/common.h
index 4faa5a848b..db6569e54a 100644
--- a/src/settings/plugins/keyfile/common.h
+++ b/src/settings/plugins/keyfile/common.h
@@ -30,8 +30,5 @@
#define VPN_SECRETS_GROUP "vpn-secrets"
-#define KEYFILE_PLUGIN_ERROR (keyfile_plugin_error_quark ())
-GQuark keyfile_plugin_error_quark (void);
-
#endif /* __COMMON_H__ */
diff --git a/src/settings/plugins/keyfile/errors.c b/src/settings/plugins/keyfile/errors.c
deleted file mode 100644
index e2e97690f1..0000000000
--- a/src/settings/plugins/keyfile/errors.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager system settings service
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * (C) Copyright 2008 - 2010 Red Hat, Inc.
- */
-
-#include <glib.h>
-#include "common.h"
-
-GQuark
-keyfile_plugin_error_quark (void)
-{
- static GQuark error_quark = 0;
-
- if (G_UNLIKELY (error_quark == 0))
- error_quark = g_quark_from_static_string ("keyfile-plugin-error-quark");
-
- return error_quark;
-}
-
-
diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.c b/src/settings/plugins/keyfile/nm-keyfile-connection.c
index c078b6de09..661b6745e0 100644
--- a/src/settings/plugins/keyfile/nm-keyfile-connection.c
+++ b/src/settings/plugins/keyfile/nm-keyfile-connection.c
@@ -63,7 +63,7 @@ nm_keyfile_connection_new (NMConnection *source,
uuid = nm_connection_get_uuid (NM_CONNECTION (tmp));
if (!uuid) {
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Connection in file %s had no UUID", full_path);
g_object_unref (tmp);
return NULL;
diff --git a/src/settings/plugins/keyfile/plugin.h b/src/settings/plugins/keyfile/plugin.h
index 5f43739055..48579785d8 100644
--- a/src/settings/plugins/keyfile/plugin.h
+++ b/src/settings/plugins/keyfile/plugin.h
@@ -41,8 +41,6 @@ typedef struct {
GType sc_plugin_keyfile_get_type (void);
-GQuark keyfile_plugin_error_quark (void);
-
GObject *nm_settings_keyfile_plugin_new (void);
#endif /* _PLUGIN_H_ */
diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c
index 9ec6d94d24..4be044c716 100644
--- a/src/settings/plugins/keyfile/reader.c
+++ b/src/settings/plugins/keyfile/reader.c
@@ -1297,7 +1297,7 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
GError *verify_error = NULL;
if (stat (filename, &statbuf) != 0 || !S_ISREG (statbuf.st_mode)) {
- g_set_error_literal (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"File did not exist or was not a regular file");
return NULL;
}
@@ -1305,7 +1305,7 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
bad_permissions = statbuf.st_mode & 0077;
if (bad_permissions) {
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"File permissions (%o) were insecure",
statbuf.st_mode);
return NULL;
@@ -1384,7 +1384,7 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
/* Normalize and verify the connection */
if (!nm_connection_normalize (connection, NULL, NULL, &verify_error)) {
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"invalid connection: %s",
verify_error->message);
g_clear_error (&verify_error);
diff --git a/src/settings/plugins/keyfile/tests/Makefile.am b/src/settings/plugins/keyfile/tests/Makefile.am
index 1cd6ab91cd..20b9820c9e 100644
--- a/src/settings/plugins/keyfile/tests/Makefile.am
+++ b/src/settings/plugins/keyfile/tests/Makefile.am
@@ -27,7 +27,6 @@ test_keyfile_SOURCES = \
test-keyfile.c \
../reader.c \
../writer.c \
- ../errors.c \
../utils.c
test_keyfile_LDADD = \
diff --git a/src/settings/plugins/keyfile/writer.c b/src/settings/plugins/keyfile/writer.c
index 7404d54e13..17d4d9581a 100644
--- a/src/settings/plugins/keyfile/writer.c
+++ b/src/settings/plugins/keyfile/writer.c
@@ -552,7 +552,7 @@ write_cert_key_file (const char *path,
errno = 0;
fd = mkstemp (tmppath);
if (fd < 0) {
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not create temporary file for '%s': %d",
path, errno);
goto out;
@@ -563,7 +563,7 @@ write_cert_key_file (const char *path,
if (fchmod (fd, S_IRUSR | S_IWUSR) != 0) {
close (fd);
unlink (tmppath);
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not set permissions for temporary file '%s': %d",
path, errno);
goto out;
@@ -574,7 +574,7 @@ write_cert_key_file (const char *path,
if (written != data_len) {
close (fd);
unlink (tmppath);
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not write temporary file for '%s': %d",
path, errno);
goto out;
@@ -587,7 +587,7 @@ write_cert_key_file (const char *path,
success = TRUE;
else {
unlink (tmppath);
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not rename temporary file to '%s': %d",
path, errno);
}
@@ -922,7 +922,7 @@ _internal_write_connection (NMConnection *connection,
id = nm_connection_get_id (connection);
if (!id) {
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"%s.%d: connection had no ID", __FILE__, __LINE__);
return FALSE;
}
@@ -965,7 +965,7 @@ _internal_write_connection (NMConnection *connection,
* is edited to contain the same ID as the other one.
* Give up.
*/
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"%s.%d: could not find suitable keyfile file name (%s already used)",
__FILE__, __LINE__, path);
g_free (path);
@@ -982,7 +982,7 @@ _internal_write_connection (NMConnection *connection,
g_file_set_contents (path, data, len, &local_err);
if (local_err) {
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"%s.%d: error writing to file '%s': %s", __FILE__, __LINE__,
path, local_err->message);
g_error_free (local_err);
@@ -991,13 +991,13 @@ _internal_write_connection (NMConnection *connection,
}
if (chown (path, owner_uid, owner_grp) < 0) {
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"%s.%d: error chowning '%s': %d", __FILE__, __LINE__,
path, errno);
unlink (path);
} else {
if (chmod (path, S_IRUSR | S_IWUSR) < 0) {
- g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"%s.%d: error setting permissions on '%s': %d", __FILE__,
__LINE__, path, errno);
unlink (path);