summaryrefslogtreecommitdiff
path: root/src/settings/plugins/ifcfg-rh/writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings/plugins/ifcfg-rh/writer.c')
-rw-r--r--src/settings/plugins/ifcfg-rh/writer.c67
1 files changed, 36 insertions, 31 deletions
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),