From a0632c529b2158a851444732f5437e8465a8794f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 28 Nov 2019 11:00:32 +0100 Subject: [PATCH] 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. --- dispatcher/nm-dispatcher.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dispatcher/nm-dispatcher.c b/dispatcher/nm-dispatcher.c index 3f9c24b446..c38ea00f29 100644 --- a/dispatcher/nm-dispatcher.c +++ b/dispatcher/nm-dispatcher.c @@ -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 */