ifcfg-rh: use IFCFG_PLUGIN_ERROR instead of ifcfg_plugin_error_quark ()

Trivial cleanup.
This commit is contained in:
Dan Williams 2010-08-04 16:27:34 -05:00
parent 734b649dc7
commit 71679f585a
3 changed files with 106 additions and 105 deletions

View file

@ -43,6 +43,7 @@
#define TYPE_WIRELESS "Wireless"
#define TYPE_BRIDGE "Bridge"
#define IFCFG_PLUGIN_ERROR (ifcfg_plugin_error_quark ())
GQuark ifcfg_plugin_error_quark (void);

View file

@ -205,7 +205,7 @@ read_mac_address (shvarFile *ifcfg, const char *key, GByteArray **array, GError
mac = ether_aton (value);
if (!mac) {
g_free (value);
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"%s: the MAC address '%s' was invalid.", key, value);
return FALSE;
}
@ -282,13 +282,13 @@ fill_ip4_setting_from_ibft (shvarFile *ifcfg,
return FALSE;
if (!WIFEXITED (status)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"%s exited abnormally.", iscsiadm_path);
goto done;
}
if (WEXITSTATUS (status) != 0) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"%s exited with error %d. Message: '%s'",
iscsiadm_path, WEXITSTATUS (status), err ? err : "(none)");
goto done;
@ -298,7 +298,7 @@ fill_ip4_setting_from_ibft (shvarFile *ifcfg,
goto done;
/* Ensure we got a MAC */
if (!ifcfg_mac) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing device MAC address (no HWADDR tag present).");
goto done;
}
@ -488,7 +488,7 @@ read_ip4_address (shvarFile *ifcfg,
*out_addr = ip4_addr.s_addr;
success = TRUE;
} else {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid %s IP4 address '%s'", tag, value);
}
g_free (value);
@ -514,7 +514,7 @@ parse_ip6_address (const char *value,
*out_addr = ip6_addr;
success = TRUE;
} else {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP6 address '%s'", value);
}
return success;
@ -588,7 +588,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP4 prefix '%s'", value);
g_free (value);
goto error;
@ -619,7 +619,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing or invalid IP4 prefix '%d'",
nm_ip4_address_get_prefix (addr));
goto error;
@ -683,7 +683,7 @@ read_one_ip4_route (shvarFile *ifcfg,
if (!read_ip4_address (ifcfg, gw_tag, &tmp, error))
goto out;
if (!tmp) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing or invalid IP4 gateway address '%d'",
tmp);
goto out;
@ -698,7 +698,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing or invalid IP4 prefix '%d'",
nm_ip4_route_get_prefix (route));
goto out;
@ -712,7 +712,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP4 route metric '%s'", value);
g_free (value);
goto out;
@ -796,7 +796,7 @@ 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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing IP4 route destination address in record: '%s'", *iter);
goto error;
}
@ -806,7 +806,7 @@ 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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP4 route destination address '%s'", dest);
g_free (dest);
goto error;
@ -821,7 +821,7 @@ 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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP4 route destination prefix '%s'", prefix);
g_free (prefix);
goto error;
@ -835,14 +835,14 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
g_regex_match (regex_via, *iter, 0, &match_info);
if (!g_match_info_matches (match_info)) {
g_match_info_free (match_info);
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing IP4 route gateway address in record: '%s'", *iter);
goto error;
}
next_hop = g_match_info_fetch (match_info, 1);
g_match_info_free (match_info);
if (inet_pton (AF_INET, next_hop, &ip4_addr) != 1) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP4 route gateway address '%s'", next_hop);
g_free (next_hop);
goto error;
@ -859,7 +859,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP4 route metric '%s'", metric);
g_free (metric);
goto error;
@ -905,7 +905,7 @@ parse_full_ip6_address (const char *addr_str, GError **error)
/* Split the adddress and prefix */
list = g_strsplit_set (addr_str, "/", 2);
if (g_strv_length (list) < 1) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP6 address '%s'", addr_str);
goto error;
}
@ -929,7 +929,7 @@ parse_full_ip6_address (const char *addr_str, GError **error)
errno = 0;
prefix = strtol (prefix_tag, NULL, 10);
if (errno || prefix <= 0 || prefix > 128) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP6 prefix '%s'", prefix_tag);
goto error;
}
@ -1018,7 +1018,7 @@ 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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing IP6 route destination address in record: '%s'", *iter);
goto error;
}
@ -1028,7 +1028,7 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro
if (!strcmp (dest, "default"))
strcpy (dest, "::");
if (inet_pton (AF_INET6, dest, &ip6_addr) != 1) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP6 route destination address '%s'", dest);
g_free (dest);
goto error;
@ -1043,7 +1043,7 @@ 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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP6 route destination prefix '%s'", prefix);
g_free (prefix);
goto error;
@ -1057,14 +1057,14 @@ read_route6_file (const char *filename, NMSettingIP6Config *s_ip6, GError **erro
g_regex_match (regex_via, *iter, 0, &match_info);
if (!g_match_info_matches (match_info)) {
g_match_info_free (match_info);
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing IP6 route gateway address in record: '%s'", *iter);
goto error;
}
next_hop = g_match_info_fetch (match_info, 1);
g_match_info_free (match_info);
if (inet_pton (AF_INET6, next_hop, &ip6_addr) != 1) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP6 route gateway address '%s'", next_hop);
g_free (next_hop);
goto error;
@ -1081,7 +1081,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid IP6 route metric '%s'", metric);
g_free (metric);
goto error;
@ -1129,7 +1129,7 @@ make_ip4_setting (shvarFile *ifcfg,
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
if (!s_ip4) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not allocate IP4 setting");
return NULL;
}
@ -1190,7 +1190,7 @@ make_ip4_setting (shvarFile *ifcfg,
} else if (!g_ascii_strcasecmp (value, "none") || !g_ascii_strcasecmp (value, "static")) {
/* Static IP */
} else if (strlen (value)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Unknown BOOTPROTO '%s'", value);
g_free (value);
goto done;
@ -1317,7 +1317,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not get route file path for '%s'", ifcfg->fileName);
goto done;
}
@ -1397,7 +1397,7 @@ make_ip6_setting (shvarFile *ifcfg,
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
if (!s_ip6) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not allocate IP6 setting");
return NULL;
}
@ -1562,7 +1562,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not get route6 file path for '%s'", ifcfg->fileName);
goto error;
}
@ -1618,7 +1618,7 @@ add_one_wep_key (shvarFile *ifcfg,
while (*p) {
if (!g_ascii_isxdigit (*p)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid hexadecimal WEP key.");
goto out;
}
@ -1632,7 +1632,7 @@ add_one_wep_key (shvarFile *ifcfg,
while (*p) {
if (!isascii ((int) (*p))) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid ASCII WEP key.");
goto out;
}
@ -1653,7 +1653,7 @@ add_one_wep_key (shvarFile *ifcfg,
nm_setting_wireless_security_set_wep_key (s_wsec, key_idx, key);
success = TRUE;
} else
g_set_error (error, ifcfg_plugin_error_quark (), 0, "Invalid WEP key length.");
g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Invalid WEP key length.");
out:
g_free (value);
@ -1713,7 +1713,7 @@ make_wep_setting (shvarFile *ifcfg,
default_key_idx--; /* convert to [0...3] */
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, default_key_idx, NULL);
} else {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid default WEP key '%s'", value);
g_free (value);
goto error;
@ -1738,15 +1738,15 @@ make_wep_setting (shvarFile *ifcfg,
/* 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, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"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, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"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, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Default WEP key index was 4, but no valid KEY4 exists.");
goto error;
}
@ -1763,7 +1763,7 @@ make_wep_setting (shvarFile *ifcfg,
} else if (!strcmp (lcase, "restricted")) {
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", NULL);
} else {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid WEP authentication algorithm '%s'",
lcase);
g_free (lcase);
@ -1781,7 +1781,7 @@ make_wep_setting (shvarFile *ifcfg,
auth_alg = nm_setting_wireless_security_get_auth_alg (s_wireless_sec);
if (auth_alg && !strcmp (auth_alg, "shared")) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"WEP Shared Key authentication is invalid for "
"unencrypted connections.");
goto error;
@ -1895,7 +1895,7 @@ parse_wpa_psk (shvarFile *ifcfg,
psk = svGetValue (ifcfg, "WPA_PSK", TRUE);
if (!psk) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing WPA_PSK for WPA-PSK key management");
return NULL;
}
@ -1909,7 +1909,7 @@ parse_wpa_psk (shvarFile *ifcfg,
/* Verify the hex PSK; 64 digits */
while (*p) {
if (!isxdigit (*p++)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid WPA_PSK (contains non-hexadecimal characters)");
goto out;
}
@ -1930,7 +1930,7 @@ parse_wpa_psk (shvarFile *ifcfg,
/* Length check */
if (strlen (p) < 8 || strlen (p) > 63) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid WPA_PSK (passphrases must be between "
"8 and 63 characters long (inclusive))");
goto out;
@ -1940,7 +1940,7 @@ parse_wpa_psk (shvarFile *ifcfg,
}
if (!hashed) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid WPA_PSK (doesn't look like a passphrase or hex key)");
goto out;
}
@ -1986,7 +1986,7 @@ eap_simple_reader (const char *eap_method,
value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE);
if (!value) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing IEEE_8021X_IDENTITY for EAP method '%s'.",
eap_method);
return FALSE;
@ -2001,7 +2001,7 @@ eap_simple_reader (const char *eap_method,
}
if (!value) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing IEEE_8021X_PASSWORD for EAP method '%s'.",
eap_method);
return FALSE;
@ -2054,7 +2054,7 @@ eap_tls_reader (const char *eap_method,
value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE);
if (!value) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing IEEE_8021X_IDENTITY for EAP method '%s'.",
eap_method);
return FALSE;
@ -2101,7 +2101,7 @@ eap_tls_reader (const char *eap_method,
}
if (!privkey_password) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing %s for EAP method '%s'.",
phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD" : "IEEE_8021X_PRIVATE_KEY_PASSWORD",
eap_method);
@ -2113,7 +2113,7 @@ eap_tls_reader (const char *eap_method,
phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY" : "IEEE_8021X_PRIVATE_KEY",
FALSE);
if (!privkey) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing %s for EAP method '%s'.",
phase2 ? "IEEE_8021X_INNER_PRIVATE_KEY" : "IEEE_8021X_PRIVATE_KEY",
eap_method);
@ -2151,7 +2151,7 @@ eap_tls_reader (const char *eap_method,
phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : "IEEE_8021X_CLIENT_CERT",
FALSE);
if (!client_cert) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing %s for EAP method '%s'.",
phase2 ? "IEEE_8021X_INNER_CLIENT_CERT" : "IEEE_8021X_CLIENT_CERT",
eap_method);
@ -2227,7 +2227,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Unknown IEEE_8021X_PEAP_VERSION value '%s'",
peapver);
goto done;
@ -2239,7 +2239,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing IEEE_8021X_INNER_AUTH_METHODS.");
goto done;
}
@ -2259,7 +2259,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.",
*iter);
goto done;
@ -2272,7 +2272,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"No valid IEEE_8021X_INNER_AUTH_METHODS found.");
goto done;
}
@ -2327,7 +2327,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing IEEE_8021X_INNER_AUTH_METHODS.");
goto done;
}
@ -2357,7 +2357,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Unknown IEEE_8021X_INNER_AUTH_METHOD '%s'.",
*iter);
goto done;
@ -2391,7 +2391,7 @@ fill_8021x (shvarFile *ifcfg,
value = svGetValue (ifcfg, "IEEE_8021X_EAP_METHODS", FALSE);
if (!value) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing IEEE_8021X_EAP_METHODS for key management '%s'",
key_mgmt);
return NULL;
@ -2449,7 +2449,7 @@ fill_8021x (shvarFile *ifcfg,
g_strfreev (list);
if (nm_setting_802_1x_get_num_eap_methods (s_8021x) == 0) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"No valid EAP methods found in IEEE_8021X_EAP_METHODS.");
goto error;
}
@ -2527,7 +2527,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Ad-Hoc mode cannot be used with KEY_MGMT type '%s'", value);
goto error;
}
@ -2540,7 +2540,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Unknown wireless KEY_MGMT type '%s'", value);
goto error;
}
@ -2592,7 +2592,7 @@ make_leap_setting (shvarFile *ifcfg,
value = svGetValue (ifcfg, "IEEE_8021X_IDENTITY", FALSE);
if (!value || !strlen (value)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing LEAP identity");
goto error;
}
@ -2707,7 +2707,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid SSID '%s' size (looks like hex but length not multiple of 2)",
value);
g_free (value);
@ -2717,7 +2717,7 @@ make_wireless_setting (shvarFile *ifcfg,
p = value + 2;
while (*p) {
if (!isxdigit (*p)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid SSID '%s' character (looks like hex SSID but '%c' isn't a hex digit)",
value, *p);
g_free (value);
@ -2733,7 +2733,7 @@ make_wireless_setting (shvarFile *ifcfg,
}
if (ssid_len > 32 || ssid_len == 0) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid SSID '%s' (size %zu not between 1 and 32 inclusive)",
value, ssid_len);
g_free (value);
@ -2748,7 +2748,7 @@ make_wireless_setting (shvarFile *ifcfg,
} else {
/* Only fail on lack of SSID if device is managed */
if (nm_controlled) {
g_set_error (error, ifcfg_plugin_error_quark (), 0, "Missing SSID");
g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing SSID");
goto error;
}
}
@ -2769,7 +2769,7 @@ make_wireless_setting (shvarFile *ifcfg,
} else if (!strcmp (lcase, "managed") || !strcmp (lcase, "auto")) {
mode = "infrastructure";
} else {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid mode '%s' (not 'Ad-Hoc', 'Managed', or 'Auto')",
lcase);
g_free (lcase);
@ -2787,7 +2787,7 @@ make_wireless_setting (shvarFile *ifcfg,
eth = ether_aton (value);
if (!eth) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid BSSID '%s'", value);
goto error;
}
@ -2805,7 +2805,7 @@ make_wireless_setting (shvarFile *ifcfg,
errno = 0;
chan = strtol (value, NULL, 10);
if (errno || chan <= 0 || chan > 196) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid wireless channel '%s'", value);
g_free (value);
goto error;
@ -2824,7 +2824,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid wireless MTU '%s'", value);
g_free (value);
goto error;
@ -2865,7 +2865,7 @@ wireless_connection_from_ifcfg (const char *file,
connection = nm_connection_new ();
if (!connection) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to allocate new connection for %s.", file);
return NULL;
}
@ -2911,7 +2911,7 @@ wireless_connection_from_ifcfg (const char *file,
printable_ssid);
g_free (printable_ssid);
if (!con_setting) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to create connection setting.");
g_object_unref (connection);
return NULL;
@ -3078,7 +3078,7 @@ make_wired_setting (shvarFile *ifcfg,
if (!*s_8021x)
goto error;
} else {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Unknown wired KEY_MGMT type '%s'", value);
goto error;
}
@ -3110,14 +3110,14 @@ wired_connection_from_ifcfg (const char *file,
connection = nm_connection_new ();
if (!connection) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to allocate new connection for %s.", file);
return NULL;
}
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_WIRED_SETTING_NAME, NULL);
if (!con_setting) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to create connection setting.");
g_object_unref (connection);
return NULL;
@ -3223,14 +3223,14 @@ connection_from_file (const char *filename,
ifcfg_name = utils_get_ifcfg_name (filename, TRUE);
if (!ifcfg_name) {
g_set_error (out_error, ifcfg_plugin_error_quark (), 0,
g_set_error (out_error, IFCFG_PLUGIN_ERROR, 0,
"Ignoring connection '%s' because it's not an ifcfg file.", filename);
return NULL;
}
parsed = svNewFile (filename);
if (!parsed) {
g_set_error (out_error, ifcfg_plugin_error_quark (), 0,
g_set_error (out_error, IFCFG_PLUGIN_ERROR, 0,
"Couldn't parse file '%s'", filename);
return NULL;
}
@ -3244,7 +3244,7 @@ connection_from_file (const char *filename,
*/
device = svGetValue (parsed, "DEVICE", FALSE);
if (!device) {
g_set_error (&error, ifcfg_plugin_error_quark (), 0,
g_set_error (&error, IFCFG_PLUGIN_ERROR, 0,
"File '%s' had neither TYPE nor DEVICE keys.", filename);
goto done;
}
@ -3252,7 +3252,7 @@ connection_from_file (const char *filename,
if (!strcmp (device, "lo")) {
if (ignore_error)
*ignore_error = TRUE;
g_set_error (&error, ifcfg_plugin_error_quark (), 0,
g_set_error (&error, IFCFG_PLUGIN_ERROR, 0,
"Ignoring loopback device config.");
g_free (device);
goto done;
@ -3308,10 +3308,10 @@ connection_from_file (const char *filename,
else if (!strcasecmp (type, TYPE_WIRELESS))
connection = wireless_connection_from_ifcfg (filename, parsed, nm_controlled, unmanaged, &error);
else if (!strcasecmp (type, TYPE_BRIDGE)) {
g_set_error (&error, ifcfg_plugin_error_quark (), 0,
g_set_error (&error, IFCFG_PLUGIN_ERROR, 0,
"Bridge connections are not yet supported");
} else {
g_set_error (&error, ifcfg_plugin_error_quark (), 0,
g_set_error (&error, IFCFG_PLUGIN_ERROR, 0,
"Unknown connection type '%s'", type);
}

View file

@ -90,7 +90,7 @@ write_secret_file (const char *path,
tmppath = g_malloc0 (strlen (path) + 10);
if (!tmppath) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not allocate memory for temporary file for '%s'",
path);
return FALSE;
@ -102,7 +102,7 @@ write_secret_file (const char *path,
errno = 0;
fd = mkstemp (tmppath);
if (fd < 0) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not create temporary file for '%s': %d",
path, errno);
goto out;
@ -113,7 +113,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not set permissions for temporary file '%s': %d",
path, errno);
goto out;
@ -124,7 +124,7 @@ write_secret_file (const char *path,
if (written != len) {
close (fd);
unlink (tmppath);
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not write temporary file for '%s': %d",
path, errno);
goto out;
@ -135,7 +135,7 @@ write_secret_file (const char *path,
errno = 0;
if (rename (tmppath, path)) {
unlink (tmppath);
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not rename temporary file to '%s': %d",
path, errno);
goto out;
@ -302,7 +302,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not create file path for %s / %s",
NM_SETTING_802_1X_SETTING_NAME, objtype->setting_key);
return FALSE;
@ -317,7 +317,7 @@ write_object (NMSetting8021x *s_8021x,
svSetValue (ifcfg, objtype->ifcfg_key, new_file, FALSE);
return TRUE;
} else {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"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)");
@ -535,7 +535,7 @@ write_wireless_security_setting (NMConnection *connection,
s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
if (!s_wsec) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing '%s' setting", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
return FALSE;
}
@ -712,7 +712,7 @@ write_wireless_setting (NMConnection *connection,
s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
if (!s_wireless) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
}
@ -747,12 +747,12 @@ write_wireless_setting (NMConnection *connection,
ssid = nm_setting_wireless_get_ssid (s_wireless);
if (!ssid) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
}
if (!ssid->len || ssid->len > 32) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid SSID in '%s' setting", NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
}
@ -802,7 +802,7 @@ write_wireless_setting (NMConnection *connection,
svSetValue (ifcfg, "MODE", "Ad-Hoc", FALSE);
adhoc = TRUE;
} else {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Invalid mode '%s' in '%s' setting",
mode, NM_SETTING_WIRELESS_SETTING_NAME);
return FALSE;
@ -849,7 +849,7 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
if (!s_wired) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing '%s' setting", NM_SETTING_WIRED_SETTING_NAME);
return FALSE;
}
@ -998,7 +998,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Writing route file '%s' failed", filename);
goto error;
}
@ -1181,7 +1181,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not get route file path for '%s'", ifcfg->fileName);
goto out;
}
@ -1192,7 +1192,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
g_free (route_path);
routefile = utils_get_route_ifcfg (ifcfg->fileName, TRUE);
if (!routefile) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not create route file '%s'", routefile->fileName);
goto out;
}
@ -1248,7 +1248,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
g_free (metric_key);
}
if (svWriteFile (routefile, 0644)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not update route file '%s'", routefile->fileName);
svCloseFile (routefile);
goto out;
@ -1314,7 +1314,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Writing route6 file '%s' failed", filename);
goto error;
}
@ -1343,7 +1343,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
s_ip6 = (NMSettingIP6Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
if (!s_ip6) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing '%s' setting", NM_SETTING_IP6_CONFIG_SETTING_NAME);
return FALSE;
}
@ -1471,7 +1471,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_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not get route6 file path for '%s'", ifcfg->fileName);
goto error;
}
@ -1525,7 +1525,7 @@ write_connection (NMConnection *connection,
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
if (!s_con) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing '%s' setting", NM_SETTING_CONNECTION_SETTING_NAME);
return FALSE;
}
@ -1544,14 +1544,14 @@ write_connection (NMConnection *connection,
}
if (!ifcfg) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to open/create ifcfg file '%s'", ifcfg_name);
goto out;
}
type = nm_setting_connection_get_connection_type (s_con);
if (!type) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing connection type!");
goto out;
}
@ -1559,7 +1559,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 (connection, NM_TYPE_SETTING_PPPOE)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Can't write connection type '%s'",
NM_SETTING_PPPOE_SETTING_NAME);
goto out;
@ -1572,7 +1572,7 @@ write_connection (NMConnection *connection,
if (!write_wireless_setting (connection, ifcfg, &no_8021x, error))
goto out;
} else {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Can't write connection type '%s'", type);
goto out;
}
@ -1594,7 +1594,7 @@ write_connection (NMConnection *connection,
write_connection_setting (s_con, ifcfg);
if (svWriteFile (ifcfg, 0644)) {
g_set_error (error, ifcfg_plugin_error_quark (), 0,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Can't write connection '%s'", ifcfg->fileName);
goto out;
}