ifcfg-rh: only accept ifcfg base paths in impl_ifcfgrh_get_ifcfg_details()

Previously, we directly passed the @in_ifcfg path to find_by_path().
That means, @in_ifcfg must be the path to the base "ifcfg-" file,
not an alias or route file.

Add an additional pre-check, that the provided file name is really a
ifcfg base file.

This results in a more detailed error message when calling
GetIfcfgDetails not on the ifcfg base file. It's not that previously
the lookup would have succeeded.
This commit is contained in:
Thomas Haller 2016-01-06 11:20:19 +01:00
parent 5bf0697f65
commit 39e97c9339

View file

@ -694,6 +694,7 @@ impl_ifcfgrh_get_ifcfg_details (SettingsPluginIfcfg *plugin,
NMSettingConnection *s_con;
const char *uuid;
const char *path;
gs_free char *ifcfg_path = NULL;
if (!g_path_is_absolute (in_ifcfg)) {
g_dbus_method_invocation_return_error (context,
@ -703,7 +704,16 @@ impl_ifcfgrh_get_ifcfg_details (SettingsPluginIfcfg *plugin,
return;
}
connection = find_by_path (plugin, in_ifcfg);
ifcfg_path = utils_detect_ifcfg_path (path, TRUE);
if (!ifcfg_path) {
g_dbus_method_invocation_return_error (context,
NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_INVALID_CONNECTION,
"ifcfg path '%s' is not an ifcfg base file", in_ifcfg);
return;
}
connection = find_by_path (plugin, ifcfg_path);
if ( !connection
|| nm_ifcfg_connection_get_unmanaged_spec (connection)
|| nm_ifcfg_connection_get_unrecognized_spec (connection)) {