dispatcher: silently ignore empty files

There is already a way to hide/shadow scripts in "/usr/lib/NetworkManager/dispatcher.d":
by putting a file of the same name in "/etc/NetworkManager/dispatcher.d".

There is also the special case that if the file symlinks to "/dev/null", the
file is silently ignored. This is the proper way to hide a script.

I think we should also take a plain empty file as user indication to hide a script.
This way, one can simply hide a file with

  # touch /etc/NetworkManager/dispatcher.d/10-ifcfg-rh-routes.sh

It's an alternative to symlinking to /dev/null.
This commit is contained in:
Thomas Haller 2019-11-28 11:00:32 +01:00
parent f5755259e4
commit a0632c529b

View file

@ -617,9 +617,10 @@ find_scripts (Request *request)
err = stat (path, &st);
if (err)
_LOG_R_W (request, "find-scripts: Failed to stat '%s': %d", path, err);
else if (!S_ISREG (st.st_mode))
; /* silently skip. */
else if (!check_permissions (&st, &err_msg))
else if ( !S_ISREG (st.st_mode)
|| st.st_size == 0) {
/* silently skip. */
} else if (!check_permissions (&st, &err_msg))
_LOG_R_W (request, "find-scripts: Cannot execute '%s': %s", path, err_msg);
else {
/* success */