summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-10-09 15:54:26 +0200
committerThomas Haller <thaller@redhat.com>2016-10-09 15:54:26 +0200
commit960046ce0085eb7ba27b3e8542cebe81fdf8d978 (patch)
tree1f9c897c9de8835b3cd850042651f759f1749872
parentde48d4de8ffa407ecfdebc5d40b45fec7c535815 (diff)
downloadNetworkManager-th/settings-plugins-cleanup-bgo772561.tar.gz
ifcfg-rh: hide shvarFile structth/settings-plugins-cleanup-bgo772561
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c26
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c24
-rw-r--r--src/settings/plugins/ifcfg-rh/shvar.c20
-rw-r--r--src/settings/plugins/ifcfg-rh/shvar.h8
4 files changed, 46 insertions, 32 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
index 3f4556179f..5b9e8f34c0 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
@@ -145,7 +145,7 @@ make_connection_setting (const char *file,
uuid = svGetValue (ifcfg, "UUID", FALSE);
if (!uuid || !strlen (uuid)) {
g_free (uuid);
- uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL);
+ uuid = nm_utils_uuid_generate_from_string (svFileGetName (ifcfg), -1, NM_UTILS_UUID_TYPE_LEGACY, NULL);
}
stable_id = svGetValue (ifcfg, "STABLE_ID", FALSE);
@@ -1130,7 +1130,7 @@ make_ip4_setting (shvarFile *ifcfg,
goto done;
if (gateway && nm_setting_ip_config_get_num_addresses (s_ip4) == 0) {
- gs_free char *f = g_path_get_basename (ifcfg->fileName);
+ gs_free char *f = g_path_get_basename (svFileGetName (ifcfg));
PARSE_WARNING ("ignoring GATEWAY (/etc/sysconfig/network) for %s "
"because the connection has no static addresses", f);
g_clear_pointer (&gateway, g_free);
@@ -1204,13 +1204,13 @@ make_ip4_setting (shvarFile *ifcfg,
NULL);
/* Static routes - route-<name> file */
- route_path = utils_get_route_path (ifcfg->fileName);
+ route_path = utils_get_route_path (svFileGetName (ifcfg));
if (utils_has_complex_routes (route_path)) {
PARSE_WARNING ("'rule-' or 'rule6-' file is present; you will need to use a dispatcher script to apply these routes");
} else if (utils_has_route_file_new_syntax (route_path)) {
/* Parse route file in new syntax */
- route_ifcfg = utils_get_route_ifcfg (ifcfg->fileName, FALSE);
+ route_ifcfg = utils_get_route_ifcfg (svFileGetName (ifcfg), FALSE);
if (route_ifcfg) {
for (i = 0; i < 256; i++) {
NMIPRoute *route = NULL;
@@ -1626,9 +1626,9 @@ make_ip6_setting (shvarFile *ifcfg,
/* DNS searches ('DOMAIN' key) are read by make_ip4_setting() and included in NMSettingIPConfig */
- if (!utils_has_complex_routes (ifcfg->fileName)) {
+ if (!utils_has_complex_routes (svFileGetName (ifcfg))) {
/* Read static routes from route6-<interface> file */
- route6_path = utils_get_route6_path (ifcfg->fileName);
+ route6_path = utils_get_route6_path (svFileGetName (ifcfg));
if (!read_route6_file (route6_path, s_ip6, error))
goto error;
@@ -2596,7 +2596,7 @@ eap_tls_reader (const char *eap_method,
ca_cert = svGetValue (ifcfg, ca_cert_key, FALSE);
if (ca_cert) {
- real_path = get_full_file_path (ifcfg->fileName, ca_cert);
+ real_path = get_full_file_path (svFileGetName (ifcfg), ca_cert);
if (phase2) {
if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x,
real_path,
@@ -2651,7 +2651,7 @@ eap_tls_reader (const char *eap_method,
goto done;
}
- real_path = get_full_file_path (ifcfg->fileName, privkey);
+ real_path = get_full_file_path (svFileGetName (ifcfg), privkey);
if (phase2) {
if (!nm_setting_802_1x_set_phase2_private_key (s_8021x,
real_path,
@@ -2688,7 +2688,7 @@ eap_tls_reader (const char *eap_method,
goto done;
}
- real_path = get_full_file_path (ifcfg->fileName, client_cert);
+ real_path = get_full_file_path (svFileGetName (ifcfg), client_cert);
if (phase2) {
if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x,
real_path,
@@ -2738,7 +2738,7 @@ eap_peap_reader (const char *eap_method,
ca_cert = svGetValue (ifcfg, "IEEE_8021X_CA_CERT", FALSE);
if (ca_cert) {
- real_cert_path = get_full_file_path (ifcfg->fileName, ca_cert);
+ real_cert_path = get_full_file_path (svFileGetName (ifcfg), ca_cert);
if (!nm_setting_802_1x_set_ca_cert (s_8021x,
real_cert_path,
NM_SETTING_802_1X_CK_SCHEME_PATH,
@@ -2842,7 +2842,7 @@ eap_ttls_reader (const char *eap_method,
ca_cert = svGetValue (ifcfg, "IEEE_8021X_CA_CERT", FALSE);
if (ca_cert) {
- real_cert_path = get_full_file_path (ifcfg->fileName, ca_cert);
+ real_cert_path = get_full_file_path (svFileGetName (ifcfg), ca_cert);
if (!nm_setting_802_1x_set_ca_cert (s_8021x,
real_cert_path,
NM_SETTING_802_1X_CK_SCHEME_PATH,
@@ -2933,7 +2933,7 @@ eap_fast_reader (const char *eap_method,
pac_file = svGetValue (ifcfg, "IEEE_8021X_PAC_FILE", FALSE);
if (pac_file) {
- real_pac_path = get_full_file_path (ifcfg->fileName, pac_file);
+ real_pac_path = get_full_file_path (svFileGetName (ifcfg), pac_file);
g_object_set (s_8021x, NM_SETTING_802_1X_PAC_FILE, real_pac_path, NULL);
}
@@ -4971,7 +4971,7 @@ uuid_from_file (const char *filename)
uuid = svGetValue (ifcfg, "UUID", FALSE);
if (!uuid || !strlen (uuid)) {
g_free (uuid);
- uuid = nm_utils_uuid_generate_from_string (ifcfg->fileName, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL);
+ uuid = nm_utils_uuid_generate_from_string (svFileGetName (ifcfg), -1, NM_UTILS_UUID_TYPE_LEGACY, NULL);
}
svCloseFile (ifcfg);
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
index 37a2a27fdd..d43d8e926f 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -119,9 +119,9 @@ set_secret (shvarFile *ifcfg,
/* Save secret flags */
save_secret_flags (ifcfg, flags_key, flags);
- keyfile = utils_get_keys_ifcfg (ifcfg->fileName, TRUE);
+ keyfile = utils_get_keys_ifcfg (svFileGetName (ifcfg), TRUE);
if (!keyfile) {
- _LOGW ("could not create ifcfg file for '%s'", ifcfg->fileName);
+ _LOGW ("could not create ifcfg file for '%s'", svFileGetName (ifcfg));
goto error;
}
@@ -133,7 +133,7 @@ set_secret (shvarFile *ifcfg,
if (!svWriteFile (keyfile, 0600, &error)) {
_LOGW ("could not update ifcfg file '%s': %s",
- keyfile->fileName, error->message);
+ svFileGetName (keyfile), error->message);
g_clear_error (&error);
svCloseFile (keyfile);
goto error;
@@ -321,7 +321,7 @@ write_object (NMSetting8021x *s_8021x,
* /etc/sysconfig/network-scripts/ca-cert-Test_Write_Wifi_WPA_EAP-TLS.der
* will be deleted, but /etc/pki/tls/cert.pem will not.
*/
- standard_file = utils_cert_path (ifcfg->fileName, objtype->suffix);
+ standard_file = utils_cert_path (svFileGetName (ifcfg), objtype->suffix);
if (g_file_test (standard_file, G_FILE_TEST_EXISTS))
ignored = unlink (standard_file);
g_free (standard_file);
@@ -344,7 +344,7 @@ write_object (NMSetting8021x *s_8021x,
char *new_file;
GError *write_error = NULL;
- new_file = utils_cert_path (ifcfg->fileName, objtype->suffix);
+ new_file = utils_cert_path (svFileGetName (ifcfg), objtype->suffix);
if (!new_file) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not create file path for %s / %s",
@@ -997,7 +997,7 @@ write_wireless_setting (NMConnection *connection,
set_secret (ifcfg, "WPA_PSK", NULL, "WPA_PSK_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE);
/* Kill any old keys file */
- keys_path = utils_get_keys_path (ifcfg->fileName);
+ keys_path = utils_get_keys_path (svFileGetName (ifcfg));
(void) unlink (keys_path);
g_free (keys_path);
}
@@ -2107,7 +2107,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
g_free (gw_key);
}
- route_path = utils_get_route_path (ifcfg->fileName);
+ route_path = utils_get_route_path (svFileGetName (ifcfg));
result = unlink (route_path);
g_free (route_path);
return TRUE;
@@ -2283,17 +2283,17 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
g_free (tmp);
/* Static routes - route-<name> file */
- route_path = utils_get_route_path (ifcfg->fileName);
+ route_path = utils_get_route_path (svFileGetName (ifcfg));
if (!route_path) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
- "Could not get route file path for '%s'", ifcfg->fileName);
+ "Could not get route file path for '%s'", svFileGetName (ifcfg));
return FALSE;
}
if (utils_has_route_file_new_syntax (route_path)) {
shvarFile *routefile;
- routefile = utils_get_route_ifcfg (ifcfg->fileName, TRUE);
+ routefile = utils_get_route_ifcfg (svFileGetName (ifcfg), TRUE);
if (!routefile) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"Could not create route file '%s'", route_path);
@@ -2710,10 +2710,10 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
svUnsetValue (ifcfg, "IPV6_DNS_PRIORITY");
/* Static routes go to route6-<dev> file */
- route6_path = utils_get_route6_path (ifcfg->fileName);
+ route6_path = utils_get_route6_path (svFileGetName (ifcfg));
if (!route6_path) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
- "Could not get route6 file path for '%s'", ifcfg->fileName);
+ "Could not get route6 file path for '%s'", svFileGetName (ifcfg));
goto error;
}
write_route6_file (route6_path, s_ip6, error);
diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c
index 3295f5e255..cc0eefeba2 100644
--- a/src/settings/plugins/ifcfg-rh/shvar.c
+++ b/src/settings/plugins/ifcfg-rh/shvar.c
@@ -40,6 +40,16 @@
/*****************************************************************************/
+struct _shvarFile {
+ char *fileName; /* read-only */
+ int fd; /* read-only */
+ GList *lineList; /* read-only */
+ GList *current; /* set implicitly or explicitly, points to element of lineList */
+ gboolean modified; /* ignore */
+};
+
+/*****************************************************************************/
+
/**
* svParseBoolean:
* @value: the input string
@@ -187,6 +197,16 @@ svUnescape (char *s)
/*****************************************************************************/
+const char *
+svFileGetName (const shvarFile *s)
+{
+ nm_assert (s);
+
+ return s->fileName;
+}
+
+/*****************************************************************************/
+
/* Open the file <name>, returning a shvarFile on success and NULL on failure.
* Add a wrinkle to let the caller specify whether or not to create the file
* (actually, return a structure anyway) if it doesn't exist.
diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h
index 573e6413c0..14b2c5e8b4 100644
--- a/src/settings/plugins/ifcfg-rh/shvar.h
+++ b/src/settings/plugins/ifcfg-rh/shvar.h
@@ -32,14 +32,8 @@
#define _SHVAR_H
typedef struct _shvarFile shvarFile;
-struct _shvarFile {
- char *fileName; /* read-only */
- int fd; /* read-only */
- GList *lineList; /* read-only */
- GList *current; /* set implicitly or explicitly, points to element of lineList */
- gboolean modified; /* ignore */
-};
+const char *svFileGetName (const shvarFile *s);
/* Create the file <name>, return a shvarFile (never fails) */
shvarFile *svCreateFile (const char *name);