From: Thomas Guyot-Sionnest Date: Wed, 19 Nov 2008 05:59:22 +0000 (+0000) Subject: check_disk: rerpopulate the mount list after doing a stat() on paths specified with... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=53058522125ef86a65c241ad0a5f56df01d55d6a;p=nagiosplug.git check_disk: rerpopulate the mount list after doing a stat() on paths specified with -p for better automount support. NB: There's a memory leak here - properly freeing the mount list would invlove much more work - there's many other places where leaks can happen so it should be a project on its own. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2085 f882894a-f735-0410-b71e-b25c423dba1c --- diff --git a/NEWS b/NEWS index 438ab67..5149f91 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ This file documents the major additions and syntax changes between releases. Add missing long options for check_nt (for use with extra-opts) check_icmp now reports min and max round trip time perfdata (Steve Rader) Fixed bug where additional headers with redirection caused a segfault (Dieter Van de Walle - 2089159) + check_disk: make autofs mount paths specified with -p before we determing the mount list (Erik Welch) 1.4.13 25th Sept 2008 Fix Debian bug #460097: check_http --max-age broken (Hilko Bengen) diff --git a/THANKS.in b/THANKS.in index 072cff0..7784be9 100644 --- a/THANKS.in +++ b/THANKS.in @@ -243,3 +243,4 @@ Olivier 'Babar' Raginel Steve Rader Dieter Van de Walle Jan Lipphaus +Erik Welch diff --git a/lib/utils_disk.c b/lib/utils_disk.c index e22d668..3ce4d47 100644 --- a/lib/utils_disk.c +++ b/lib/utils_disk.c @@ -77,19 +77,18 @@ np_add_parameter(struct parameter_list **list, const char *name) struct parameter_list * np_del_parameter(struct parameter_list *item, struct parameter_list *prev) { - struct parameter_list *next; - if (item->name_next) - next = item->name_next; - else - next = NULL; + struct parameter_list *next; - - free(item); - if (prev) - prev->name_next = next; + if (item->name_next) + next = item->name_next; + else + next = NULL; - return next; + free(item); + if (prev) + prev->name_next = next; + return next; } diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 2f8afa6..f0950c9 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -118,9 +118,6 @@ enum #pragma alloca #endif -/* Linked list of mounted filesystems. */ -static struct mount_entry *mount_list; - int process_arguments (int, char **); void print_path (const char *mypath); void set_all_thresholds (struct parameter_list *path); @@ -639,8 +636,12 @@ process_arguments (int argc, char **argv) } se->group = group; set_all_thresholds(se); - np_set_best_match(se, mount_list, exact_match); + + /* With autofs, it is required to stat() the path before populating the mount_list */ stat_path(se); + mount_list = read_file_system_list (0); + np_set_best_match(se, mount_list, exact_match); + path_selected = TRUE; break; case 'x': /* exclude path or partition */ @@ -757,7 +758,6 @@ process_arguments (int argc, char **argv) case 'C': /* add all mount entries to path_select list if no partitions have been explicitly defined using -p */ if (path_selected == FALSE) { - struct mount_entry *me; struct parameter_list *path; for (me = mount_list; me; me = me->me_next) { if (! (path = np_find_parameter(path_select_list, me->me_mountdir)))