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.
This commit is contained in:
Thomas Haller
2020-02-18 13:50:16 +01:00
parent de19631e9f
commit aa6bc2868d

View File

@@ -399,7 +399,9 @@ make_connection_setting (const char *file,
if (v) { if (v) {
GError *error = NULL; 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, g_object_set (s_con,
NM_SETTING_CONNECTION_INTERFACE_NAME, v, NM_SETTING_CONNECTION_INTERFACE_NAME, v,
NULL); NULL);