[monitoring-plugins] check_disk: prevent using stat on inaccessible ...

GitHub git at monitoring-plugins.org
Sat Aug 29 17:00:14 CEST 2026


    Module: monitoring-plugins
    Branch: master
    Commit: 1bca39f4642460bb5ec1d0671b678937a2846b79
    Author: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
 Committer: GitHub <noreply at github.com>
      Date: Sat Aug 29 16:59:07 2026 +0200
       URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=1bca39f4

check_disk: prevent using stat on inaccessible filesystems (#2289)

Co-authored-by: Daniel Jagszent <daniel at jagszent.de>

---

 plugins/check_disk.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index f1bdf9ca..641cbc59 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -753,6 +753,16 @@ check_disk_config_wrapper process_arguments(int argc, char **argv) {
 						se =
 							mp_int_fs_list_append(&result.config.path_select_list, me->me_mountdir);
 					}
+
+					/* This path was selected directly from a specific mount entry, so
+					 * pin it to that entry. Otherwise set_best_match() may re-resolve an
+					 * inaccessible filesystem (e.g. a root-only docker overlay mount whose
+					 * statfs() returns EACCES) to a parent filesystem, which defeats the
+					 * -X/-x/-i exclusion checks and makes the plugin stat() and fail on a
+					 * path the user explicitly excluded.
+					 */
+					se->best_match = me;
+
 					se->group = group;
 					set_all_thresholds(se, warn_freespace_units, crit_freespace_units,
 									   warn_freespace_percent, crit_freespace_percent,



More information about the Commits mailing list