From 39e97c9339a189ce378a72025c05192fecbaf58b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 6 Jan 2016 11:20:19 +0100 Subject: [PATCH] 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. --- src/settings/plugins/ifcfg-rh/plugin.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index d8ee6ca2af..cbc3554831 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -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)) {