Permalink
Browse files

* Fix Debian #617259: symbolic links in the filesystem check doesn't …

…work.

  Thanks to Sergey B Kirpichev for report.




git-svn-id: http://monit.googlecode.com/svn/trunk@340 808b68a2-07de-11de-a1f0-819f45317607
  • Loading branch information...
1 parent 8696a0f commit 268fcf0ba7defe30556742fd9f40ec0976250363 mmonit@tildeslash.com committed Mar 22, 2011
Showing with 19 additions and 17 deletions.
  1. +5 −2 CHANGES.txt
  2. +6 −8 device/device_common.c
  3. +4 −2 device/sysdep_LINUX.c
  4. +4 −5 validate.c
View
@@ -14,12 +14,15 @@ Version 5.2.5
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.
View
@@ -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 @@ char *device_path(Info_T inf, char *object) {
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;
View
@@ -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 @@ char *device_mountpoint_sysdep(Info_T inf, char *blockdev) {
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;
View
@@ -237,25 +237,24 @@ int check_filesystem(Service_T s) {
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;

0 comments on commit 268fcf0

Please sign in to comment.