Pārlūkot izejas kodu

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
Thomas Guyot-Sionnest 17 gadi atpakaļ
vecāks
revīzija
5305852212
4 mainītis faili ar 16 papildinājumiem un 15 dzēšanām
  1. 1 0
      NEWS
  2. 1 0
      THANKS.in
  3. 9 10
      lib/utils_disk.c
  4. 5 5
      plugins/check_disk.c

+ 1 - 0
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)

+ 1 - 0
THANKS.in

@@ -243,3 +243,4 @@ Olivier 'Babar' Raginel
 Steve Rader
 Dieter Van de Walle
 Jan Lipphaus
+Erik Welch

+ 9 - 10
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;
 }
 
   

+ 5 - 5
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)))