[monit-dev] [monit] r340 committed - * Fix Debian #617259: symbolic links in the filesystem check doesn't w...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[monit-dev] [monit] r340 committed - * Fix Debian #617259: symbolic links in the filesystem check doesn't w...

monit-2
Revision: 340
Author:   [hidden email]
Date:     Tue Mar 22 03:09:08 2011
Log:      * Fix Debian #617259: symbolic links in the filesystem check  
doesn't work.
   Thanks to Sergey B Kirpichev for report.



http://code.google.com/p/monit/source/detail?r=340

Modified:
  /trunk/CHANGES.txt
  /trunk/device/device_common.c
  /trunk/device/sysdep_LINUX.c
  /trunk/validate.c

=======================================
--- /trunk/CHANGES.txt Fri Mar 18 11:15:53 2011
+++ /trunk/CHANGES.txt Tue Mar 22 03:09:08 2011
@@ -14,12 +14,15 @@
    restart and reported start failure (similar on stop). Thanks to
    Kenichi Futatsumori for report and helping to root cause the problem.

-* Fix bug #32583: Multiple SIP OPTIONS messages use the same header data.
-  Thanks to Hugh Waite for patch.
+* Fix Debian #617259: symbolic links in the filesystem check doesn't work.
+  Thanks to Sergey B Kirpichev for report.

  * Fix Debian bug #614984: smtp protocol test issues both EHLO and HELO.
    Thanks to Sergey B Kirpichev for report.

+* Fix bug #32583: Multiple SIP OPTIONS messages use the same header data.
+  Thanks to Hugh Waite for patch.
+
  * AIX: Fix the time display which was off by GMT difference. Thanks to
    Helen Chen for report.

=======================================
--- /trunk/device/device_common.c Wed Jan 19 10:40:32 2011
+++ /trunk/device/device_common.c Tue Mar 22 03:09:08 2011
@@ -78,10 +78,10 @@
   * filesystem information structure for later use. Filesystem must be  
mounted.
   *
   * Valid objects are file or directory that are part of requested
- * filesystem, block special device or mountpoint.
+ * filesystem, device or mountpoint.
   *
   * In the case of file, directory or mountpoint the result is original
- * object, in the case of block special device mountpoint is returned.
+ * object, in the case of device the mountpoint is returned.
   *
   * @param inf     Information structure where resulting data will be stored
   * @param object  Identifies appropriate device object
@@ -105,20 +105,18 @@
      return device_mountpoint_sysdep(inf, object);
    }

-  LogError("%s: Not file, directory or block special device: '%s'", prog,  
object);
+  LogError("%s: Not file, directory or device: '%s'", prog, object);

    return NULL;
  }


  /**
- * Filesystem usage statistics. In the case of success result is stored in
- * given information structure.
+ * Filesystem usage statistics. In the case of success the result is  
stored in the given information structure.
   *
   * @param inf Information structure where resulting data will be stored
- * @param object  Identifies requested filesystem - either file, directory,
- *                block special device or mountpoint
- * @return        TRUE if informations were succesfully read otherwise  
FALSE
+ * @param object Identifies requested filesystem - either file, directory,  
device or mountpoint
+ * @return TRUE if informations were succesfully read otherwise FALSE
   */
  int filesystem_usage(Info_T inf, char *object) {
    int rv;
=======================================
--- /trunk/device/sysdep_LINUX.c Wed Jan 19 10:40:32 2011
+++ /trunk/device/sysdep_LINUX.c Tue Mar 22 03:09:08 2011
@@ -76,8 +76,8 @@
   * @return         NULL in the case of failure otherwise mountpoint
   */
  char *device_mountpoint_sysdep(Info_T inf, char *blockdev) {
+  FILE *mntfd;
    struct mntent *mnt;
-  FILE          *mntfd;

    ASSERT(inf);
    ASSERT(blockdev);
@@ -87,7 +87,9 @@
      return NULL;
    }
    while ((mnt = getmntent(mntfd)) != NULL) {
-    if (IS(blockdev, mnt->mnt_fsname)) {
+    char realpathbuf[PATH_MAX+1];
+    /* Try to compare the the filesystem as is, if failed, try to use the  
symbolic link target */
+    if (IS(blockdev, mnt->mnt_fsname) || (realpath(mnt->mnt_fsname,  
realpathbuf) && ! strcasecmp(blockdev, realpathbuf))) {
        endmntent(mntfd);
        inf->priv.filesystem.mntpath = xstrdup(mnt->mnt_dir);
        return inf->priv.filesystem.mntpath;
=======================================
--- /trunk/validate.c Mon Mar 21 08:32:15 2011
+++ /trunk/validate.c Tue Mar 22 03:09:08 2011
@@ -237,25 +237,24 @@

    p = s->path;

-  /* We need to resolve symbolic link so if it points to device,
-   * we'll be able to find it in mnttab */
+  /* We need to resolve symbolic link so if it points to device, we'll be  
able to find it in mnttab */
    if (lstat(s->path, &stat_buf) != 0) {
      Event_post(s, Event_Nonexist, STATE_FAILED,  
s->action_NONEXIST, "filesystem doesn't exist");
      return FALSE;
    }
    if (S_ISLNK(stat_buf.st_mode)) {
      if (! realpath(s->path, path_buf)) {
-      Event_post(s, Event_Nonexist, STATE_FAILED,  
s->action_NONEXIST, "symbolic filesystem link error -- %s", STRERROR);
+      Event_post(s, Event_Nonexist, STATE_FAILED,  
s->action_NONEXIST, "filesystem symbolic link error -- %s", STRERROR);
        return FALSE;
      }
      p = path_buf;
-    Event_post(s, Event_Nonexist, STATE_SUCCEEDED,  
s->action_NONEXIST, "symbolic filesystem link %s -> %s", s->path, p);
+    Event_post(s, Event_Nonexist, STATE_SUCCEEDED,  
s->action_NONEXIST, "filesystem symbolic link %s -> %s", s->path, p);
      if (stat(p, &stat_buf) != 0) {
        Event_post(s, Event_Nonexist, STATE_FAILED,  
s->action_NONEXIST, "filesystem doesn't exist");
        return FALSE;
      }
    }
-  Event_post(s, Event_Nonexist, STATE_SUCCEEDED,  
s->action_NONEXIST, "filesystem exist");
+  Event_post(s, Event_Nonexist, STATE_SUCCEEDED,  
s->action_NONEXIST, "filesystem exists");

    s->inf->st_mode = stat_buf.st_mode;
    s->inf->st_uid  = stat_buf.st_uid;

_______________________________________________
monit-dev mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monit-dev