bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bugs #9043] find fails on automounter paths


From: anonymous
Subject: [bugs #9043] find fails on automounter paths
Date: Fri, 26 Nov 2004 00:42:49 -0500
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.4) Gecko/20040414

This mail is an automated notification from the bugs tracker
 of the project: findutils.

/**************************************************************************/
[bugs #9043] Latest Modifications:

Changes by: Anonymous user
Date:  
                Fri 11/26/2004 at 00:36

------------------ Additional Follow-up Comments ----------------------------
I tested out 4.2.8 on Solaris 9 and it indeed fixes the
problem.  Solaris automount points only generate a warning.

$ find make -name foobar
find: Warning: filesystem /net/.../make has recently been mounted.

Now, I am divided on whether a warning should be issued at
all, since the automount mechanism is supposed to be
mostly transparent to users.  Find doesn't issue warnings
when crossing "ordinary" mount points, for example.

I suspect the warnings will get tedious for users on
systems with automounted filesystems, and should default
to OFF.  Detection of directories that have turned into
symlinks is another matter, since it's an indication of
mutation in the underlying data that is likely to be
malicious.

(Martin Buchholz)






/**************************************************************************/
[bugs #9043] Full Item Snapshot:

URL: <http://savannah.gnu.org/bugs/?func=detailitem&item_id=9043>
Project: findutils
Submitted by: VenkateswaraRao
On: Fri 05/21/2004 at 06:25

Category:  find
Severity:  5 - Average
Item Group:  None
Resolution:  Fixed
Privacy:  Public
Assigned to:  None
Originator Name:  
Originator Email:  
Status:  Closed
Release:  None
Fixed Release:  4.2.8


Summary:  find fails on automounter paths

Original Submission:  The stat checks causing the find to quit where:
    * The find path is an SUN automounter directory and
    * It's not already mounted

<<SNIP>>
~> find /proj/test
find: /proj/test changed during execution of find 
~> sudo umount /proj/test
~> gnu find /proj/test/.
/proj/test
/proj/test/file
...
<<>>

Thanks.

Follow-up Comments
------------------


-------------------------------------------------------
Date: Fri 11/26/2004 at 00:36       By: 0 <None>
I tested out 4.2.8 on Solaris 9 and it indeed fixes the
problem.  Solaris automount points only generate a warning.

$ find make -name foobar
find: Warning: filesystem /net/.../make has recently been mounted.

Now, I am divided on whether a warning should be issued at
all, since the automount mechanism is supposed to be
mostly transparent to users.  Find doesn't issue warnings
when crossing "ordinary" mount points, for example.

I suspect the warnings will get tedious for users on
systems with automounted filesystems, and should default
to OFF.  Detection of directories that have turned into
symlinks is another matter, since it's an indication of
mutation in the underlying data that is likely to be
malicious.

(Martin Buchholz)

-------------------------------------------------------
Date: Wed 11/24/2004 at 14:32       By: James Youngman <jay>
Thanks, Martin.  I agree with your concern about the warning (though it was a 
useful diagnostic during development).  I have modified the CVS code to silence 
this warning for nfs or autofs filesystems. 

-------------------------------------------------------
Date: Wed 11/24/2004 at 12:49       By: 0 <None>
I tested out 4.2.8 on Solaris 9 and it indeed fixes the
problem.  Solaris automount points only generate a warning.

$ find make -name foobar
find: Warning: filesystem /net/.../make has recently been mounted.

Now, I am divided on whether a warning should be issued at
all, since the automount mechanism is supposed to be
mostly transparent to users.  Find doesn't issue warnings
when crossing "ordinary" mount points, for example.

I suspect the warnings will get tedious for users on
systems with automounted filesystems, and should default
to OFF.  Detection of directories that have turned into
symlinks is another matter, since it's an indication of
mutation in the underlying data that is likely to be
malicious.

(Martin Buchholz)

-------------------------------------------------------
Date: Wed 11/24/2004 at 10:00       By: James Youngman <jay>
I have implemented the change Martin suggests in findutils (and tested it on a 
Solaris 9 box with automount running).   Some other changes were required, but 
it now seems to work.   The code has been released as findutils-4.2.8 on 
alpha.gnu.org.   Could you confirm please Martin that this works for you?

-------------------------------------------------------
Date: Sun 11/21/2004 at 21:56       By: 0 <None>
Unfortunately, the recently released 4.2.7 did not
resolve this problem. (martin.buchholz at sun.com)

If collecting a list of currently mounted filesystems,
you want to collect a list of dev_t, not strings,
which are much harder to deal with, esp. wrt. uniqueness.

Here is a sample program on Solaris 9 to get all dev_t
for all mounted filesystems:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mntio.h>
#include <sys/mkdev.h>

int main (int argc, char *argv[])
{
    int fd = open("/etc/mnttab", O_RDONLY);
    int nmnts = -1;
    uint32_t *devlist;
    ioctl(fd, MNTIOC_NMNTS, &nmnts);
    devlist = (uint32_t*) calloc(2 * nmnts, sizeof(uint32_t));
    ioctl(fd, MNTIOC_GETDEVLIST, devlist);
    printf("fd=%d nmnts=%dn", fd, nmnts);
    for (int i = 0; i < nmnts; ++i)
      printf("device number=%dn", makedev(devlist[2*i], devlist[2*i+1]));
    return 0;
}

Of course, this is non-portable, but can be 
(tediously but straightforwardly) autoconfiscated.

I don't know if there's a more portable way to get
a list of dev_t for all mounted filesystems.

If was_mounted == is_mounted == 0, then
find knows that it cannot determine the mount history.

I re-instrumented 4.2.7 with similar debugging
code as in 4.2.6, and this time got
was_mounted == is_mounted == 1, defeating an assumption
in the new code.
(patch available on request)

mount_points= / /proc .../
get_mount_point_state: dir=/net/SOMEHOST/export/disk7/jdk1.6.0/j2se/src 
was_mounted=1 is_mounted=1
wd_sanity: stateChange=MountPointStateUnchanged
wd_sanity: direction=down
find: /net/SOMEHOST/export/disk7/jdk1.6.0/j2se/src changed during execution of 
find (old device number 81032647, new device number 80744662, filesystem type 
is nfs) [ref 831]

So get_mounted_filesystems() now correctly returns
a list of mounted filesystems on Solaris, but this does
not solve the problem, since the automounter seems to
be a mounted filesystem that replaces itself with the
"real" filesystem (with a different dev_t) later.

To be reliable, I think we'll have to do the autoconfigury
to determine the list of dev_t's, or give up on this
error check.

Another approach is to give up on this check if the
filesystem involved is NFS (but determining that portably
might be another configure nightmare).  Well, this is
why we concentrate such arcane knowledge in utilities
like find.

-------------------------------------------------------
Date: Sun 11/21/2004 at 18:33       By: James Youngman <jay>
I believe that thsi problem has been addressed in findutils-4.2.7 in a way that 
should work on Solaris.

-------------------------------------------------------
Date: Sun 11/21/2004 at 17:24       By: James Youngman <jay>
I will shortly issue a release in which get_mounted_filesystems() does not 
return NULL on Solaris.    I've also addressed the issue of relative pathnames 
(in a failrly simplistic way).

-------------------------------------------------------
Date: Sun 11/21/2004 at 16:52       By: 0 <None>
I (martin.buchholz at sun.com) tried the fix as of 
2004-11-21, but it didn't work.  I instrumented the code as 
below to print debug info.

$ find test -name foobar
get_mount_point_state: dir=test was_mounted=0 is_mounted=0
mount_points=
wd_sanity: stateChange=MountPointStateUnchanged
wd_sanity: direction=down
find: test changed during execution of find (old device number 81032649, new 
device number 80744648, filesystem type is nfs) [ref 827]

$ find -version; uname -a
GNU find version 4.2.6
SunOS suttles 5.9 Generic_112233-05 sun4u sparc SUNW,Sun-Blade-1000

I see two serious problems with the fix in 4.2.6:
1. get_mounted_filesystems does not always return useful
   information.  On Solaris it appears to return NULL.
   FSTYPE_MNTENT is not defined in config.h.
2. Even if mount_points contained a complete list of mounted
   filesystems, the call to list_item_present might pass
   in a relative name, and thus not be found.  Some kind
   of complicated canonicalization would be required to
   check whether the filesystem in question was recently
   mounted or unmounted.

--- find/find.c~        2004-11-21 04:18:59.000000000 -0800
+++ find/find.c 2004-11-21 13:26:56.133944000 -0800
@@ -586,6 +586,18 @@
   return 0;
 }
 
+static void
+print_mount_points(void)
+{
+  const char *s = mount_points;
+  fprintf(stderr, "mount_points=");
+  while (s && *s) {
+    fprintf(stderr, " %s", s);
+    s+=strlen(s);
+  }
+  fprintf(stderr,"n");
+}
+
 
 /* Determine if a directory has recently had a filesystem 
  * mounted on it or unmounted from it.
@@ -605,6 +617,9 @@
   
   is_mounted = list_item_present(dir, mount_points);
 
+  fprintf(stderr, "get_mount_point_state: dir=%s was_mounted=%d 
is_mounted=%dn",
+         dir, was_mounted, is_mounted);
+  print_mount_points();
   if (was_mounted == is_mounted)
     return MountPointStateUnchanged;
   else if (is_mounted)
@@ -689,6 +704,7 @@
          switch (transition)
            {
            case MountPointRecentlyUnmounted:
+             fprintf(stderr, "wd_sanity: 
stateChange=MountPointRecentlyUnmountedn");
              isfatal = 0;
              error (0, 0,
                     _("Filesystem %s has recently been unmounted."),
@@ -696,6 +712,7 @@
              break;
              
            case MountPointRecentlyMounted:
+             fprintf(stderr, "wd_sanity: 
stateChange=MountPointRecentlyMountedn");
              isfatal = 0;
              error (0, 0,
                     _("Filesystem %s has recently been mounted."),
@@ -703,6 +720,7 @@
              break;
 
            case MountPointStateUnchanged:
+             fprintf(stderr, "wd_sanity: 
stateChange=MountPointStateUnchangedn");
              isfatal = 1;
              break;
            }
@@ -710,6 +728,8 @@
 
       if (isfatal)
        {
+         fprintf(stderr, "wd_sanity: direction=%sn",
+                 direction == TraversingDown ? "down" : "up");
          fstype = filesystem_type(thing_to_stat, ".", newinfo);
          error (isfatal, 0,
                 _("%s%s changed during execution of %s (old device number %ld, 
new device number %ld, filesystem type is %s) [ref %ld]"),


-------------------------------------------------------
Date: Sun 11/21/2004 at 05:38       By: James Youngman <jay>
I think that automountd is the common factor here.  When you chdir() into an 
aoutomounted directory, that directory is mounted which causes the device 
number (and inode of course) to change.  This alarms the csanity check that we 
do.

-------------------------------------------------------
Date: Mon 11/08/2004 at 16:47       By: James Youngman <jay>
findutils-4.2.4 has some extra diagnostics for this situation,  could you 
retest with that version and let me know what error message is produced?   
Thanks. 

(marked postponed, pending a response)





CC List
-------

CC Address                          | Comment
------------------------------------+-----------------------------
martin --DOT-- buchholz --AT-- sun --DOT-- com | 
levon --AT-- movementarian --DOT-- org | 









For detailed info, follow this link:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=9043>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/







reply via email to

[Prev in Thread] Current Thread [Next in Thread]