From aa6bc2868da43199be001e54385c4230e3efc4ca Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 18 Feb 2020 13:50:16 +0100 Subject: [PATCH] ifcfg-rh: use nm_utils_ifname_valid() for validating interface-name in reader Maybe the reader should not try to add its own validation. It could just read the value, set it in the profile, and let nm_connection_verify() handle it. However: - in this form the code only logs a warning about invalid setting. If we let it come to nm_connection_verify(), the connection profile will be entirely rejected. I think this makes sense, because ifcfg files may be edited by the user and we don't know what is out there. - it's nicer to show a warning that specifically mentions the DEVICE= variable. There error message we get from nm_connection_verify() is no longer aware of ifcfg peculiarities. Instead: use the appropriate validation function. --- src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 06ba11a22e..ab73b153a0 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -399,7 +399,9 @@ make_connection_setting (const char *file, if (v) { GError *error = NULL; - if (nm_utils_ifname_valid_kernel (v, &error)) { + /* Only validate for NMU_IFACE_KERNEL, because ifcfg plugin anyway + * doesn't support OVS types. */ + if (nm_utils_ifname_valid (v, NMU_IFACE_KERNEL, &error)) { g_object_set (s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, v, NULL);