diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index 1f9ed4726d..5fda59da09 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -646,7 +646,7 @@ plugin_get_hostname (SCPluginIfcfg *plugin) return hostname; } - network = svNewFile (SC_NETWORK_FILE); + network = svOpenFile (SC_NETWORK_FILE); if (!network) { PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Could not get hostname: failed to read " SC_NETWORK_FILE); return NULL; @@ -708,7 +708,7 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) g_free (hostname_eol); /* Remove "HOSTNAME" from SC_NETWORK_FILE, if present */ - network = svNewFile (SC_NETWORK_FILE); + network = svOpenFile (SC_NETWORK_FILE); if (network) { svSetValue (network, "HOSTNAME", NULL, FALSE); svWriteFile (network, 0644); diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 70e58e9e03..7a0a41649e 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -682,7 +682,7 @@ read_full_ip4_address (shvarFile *ifcfg, gboolean read_success; /* If no gateway in the ifcfg, try /etc/sysconfig/network instead */ - network_ifcfg = svNewFile (network_file); + network_ifcfg = svOpenFile (network_file); if (network_ifcfg) { read_success = read_ip4_address (network_ifcfg, "GATEWAY", &tmp, error); svCloseFile (network_ifcfg); @@ -1066,7 +1066,7 @@ parse_full_ip6_address (shvarFile *ifcfg, } if (!value) { /* If no gateway in the ifcfg, try global /etc/sysconfig/network instead */ - network_ifcfg = svNewFile (network_file); + network_ifcfg = svOpenFile (network_file); if (network_ifcfg) { value = svGetValue (network_ifcfg, "IPV6_DEFAULTGW", FALSE); svCloseFile (network_ifcfg); @@ -1281,7 +1281,7 @@ make_ip4_setting (shvarFile *ifcfg, never_default = !svTrueValue (ifcfg, "DEFROUTE", TRUE); /* Then check if GATEWAYDEV; it's global and overrides DEFROUTE */ - network_ifcfg = svNewFile (network_file); + network_ifcfg = svOpenFile (network_file); if (network_ifcfg) { char *gatewaydev; @@ -1645,7 +1645,7 @@ make_ip6_setting (shvarFile *ifcfg, * they are global and override IPV6_DEFROUTE * When both are set, the device specified in IPV6_DEFAULTGW takes preference. */ - network_ifcfg = svNewFile (network_file); + network_ifcfg = svOpenFile (network_file); if (network_ifcfg) { char *ipv6_defaultgw, *ipv6_defaultdev; char *default_dev = NULL; @@ -1680,7 +1680,7 @@ make_ip6_setting (shvarFile *ifcfg, str_value = svGetValue (ifcfg, "IPV6INIT", FALSE); ipv6init = svTrueValue (ifcfg, "IPV6INIT", FALSE); if (!str_value) { - network_ifcfg = svNewFile (network_file); + network_ifcfg = svOpenFile (network_file); if (network_ifcfg) { ipv6init = svTrueValue (network_ifcfg, "IPV6INIT", FALSE); svCloseFile (network_ifcfg); @@ -4991,7 +4991,7 @@ uuid_from_file (const char *filename) if (!ifcfg_name) return NULL; - ifcfg = svNewFile (filename); + ifcfg = svOpenFile (filename); if (!ifcfg) return NULL; @@ -5077,7 +5077,7 @@ connection_from_file (const char *filename, return NULL; } - parsed = svNewFile (filename); + parsed = svOpenFile (filename); if (!parsed) { g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Couldn't parse file '%s'", filename); diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 3af20eda89..630e9b6fd1 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -39,7 +39,7 @@ * (actually, return a structure anyway) if it doesn't exist. */ static shvarFile * -svOpenFile (const char *name, gboolean create) +svOpenFileInternal (const char *name, gboolean create) { shvarFile *s = NULL; gboolean closefd = FALSE; @@ -106,9 +106,9 @@ svOpenFile (const char *name, gboolean create) /* Open the file , return shvarFile on success, NULL on failure */ shvarFile * -svNewFile (const char *name) +svOpenFile (const char *name) { - return svOpenFile (name, FALSE); + return svOpenFileInternal (name, FALSE); } /* Create a new file structure, returning actual data if the file exists, @@ -117,7 +117,7 @@ svNewFile (const char *name) shvarFile * svCreateFile (const char *name) { - return svOpenFile (name, TRUE); + return svOpenFileInternal (name, TRUE); } /* remove escaped characters in place */ diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index 3062a0d5cd..d28bc6d7d5 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -45,11 +45,11 @@ struct _shvarFile { }; -/* Create the file , return shvarFile on success, NULL on failure */ +/* Create the file , return a shvarFile (never fails) */ shvarFile *svCreateFile (const char *name); /* Open the file , return shvarFile on success, NULL on failure */ -shvarFile *svNewFile (const char *name); +shvarFile *svOpenFile (const char *name); /* Get the value associated with the key, and leave the current pointer * pointing at the line containing the value. The char* returned MUST 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 f45d788ece..4d774fa967 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -6106,7 +6106,7 @@ test_write_wifi_hidden (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile, &error); - f = svNewFile (testfile); + f = svOpenFile (testfile); g_assert (f); g_assert_no_error (error); @@ -7340,7 +7340,7 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data) { /* re-read the file to check that what key was written. */ - shvarFile *ifcfg = svNewFile (testfile); + shvarFile *ifcfg = svOpenFile (testfile); g_assert (ifcfg); written_ifcfg_gateway = svGetValue (ifcfg, "IPV6_DEFAULTGW", FALSE); @@ -8382,7 +8382,7 @@ test_write_wifi_open (void) &ignore_error); /* Now make sure that the ESSID item isn't double-quoted (rh #606518) */ - ifcfg = svNewFile (testfile); + ifcfg = svOpenFile (testfile); ASSERT (ifcfg != NULL, "wifi-open-write-reread", "failed to load %s as shvarfile", testfile); @@ -10869,7 +10869,7 @@ test_write_wifi_dynamic_wep_leap (void) * did not get written. Check first that the auth alg is not set to "LEAP" * and next that the only IEEE 802.1x EAP method is "LEAP". */ - ifcfg = svNewFile (testfile); + ifcfg = svOpenFile (testfile); g_assert (ifcfg); tmp = svGetValue (ifcfg, "SECURITYMODE", FALSE); g_assert_cmpstr (tmp, ==, NULL); @@ -11487,7 +11487,7 @@ test_write_wired_ctc_dhcp (void) g_assert (testfile != NULL); /* Ensure the CTCPROT item gets written out as it's own option */ - ifcfg = svNewFile (testfile); + ifcfg = svOpenFile (testfile); g_assert (ifcfg); tmp = svGetValue (ifcfg, "CTCPROT", TRUE); @@ -13864,7 +13864,7 @@ test_write_fcoe_mode (gconstpointer user_data) g_assert (testfile); { - shvarFile *ifcfg = svNewFile (testfile); + shvarFile *ifcfg = svOpenFile (testfile); char *written_mode; g_assert (ifcfg); @@ -13975,7 +13975,7 @@ test_write_team_master (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile, &error); - f = svNewFile (testfile); + f = svOpenFile (testfile); g_assert (f); g_assert_no_error (error); @@ -14092,7 +14092,7 @@ test_write_team_port (void) TEST_SCRATCH_DIR "/network-scripts/", &testfile, &error); - f = svNewFile (testfile); + f = svOpenFile (testfile); g_assert (f); g_assert_no_error (error); diff --git a/src/settings/plugins/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/utils.c index 5abb4282e5..07efa5cc53 100644 --- a/src/settings/plugins/ifcfg-rh/utils.c +++ b/src/settings/plugins/ifcfg-rh/utils.c @@ -296,7 +296,7 @@ utils_get_extra_ifcfg (const char *parent, const char *tag, gboolean should_crea ifcfg = svCreateFile (path); if (!ifcfg) - ifcfg = svNewFile (path); + ifcfg = svOpenFile (path); g_free (path); return ifcfg; diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index ca8b2d79da..9c7b3037a3 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -2529,7 +2529,7 @@ write_connection (NMConnection *connection, if (filename) { /* For existing connections, 'filename' should be full path to ifcfg file */ - ifcfg = svNewFile (filename); + ifcfg = svOpenFile (filename); ifcfg_name = g_strdup (filename); } else { char *escaped;