Another inconsistency in the paths handed to stat in the VFS

Richard Sharpe realrichardsharpe at gmail.com
Wed Apr 15 11:58:20 MDT 2015


Hi folks,

Here is the log from a recent test:

  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with /home/shares/share1
  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with /
  my_test_vfs_stat called with .
  my_test_vfs_stat called with /home/shares/share1
  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with ./.
  my_test_vfs_stat called with ./..
  my_test_vfs_stat called with ./testdir2
  my_test_vfs_stat called with ./testdir6
  my_test_vfs_stat called with ./testdir13
  my_test_vfs_stat called with ./testdir8
  my_test_vfs_stat called with ./testdir4
  my_test_vfs_stat called with ./testdir11
  my_test_vfs_stat called with ./somefunnydir
  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with test6
  my_test_vfs_stat called with test6
  my_test_vfs_stat called with test6
  my_test_vfs_stat called with test6
  my_test_vfs_stat called with test6
  my_test_vfs_stat called with test6
  my_test_vfs_stat called with test6
  my_test_vfs_stat called with test6
  my_test_vfs_stat called with test6
  my_test_vfs_stat called with test6/.
  my_test_vfs_stat called with test6/..
  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with .
  my_test_vfs_stat called with /

Now, there are some problems here that I am working with Jeremy, but
the inconsistency I wanted to mention is that in some cases
SMB_VFS_STAT is called with ./ on the front of the path and in other
cases it is not.

The following patch seems to fix this problem:

diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 36d95d5..c9c6850 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1135,10 +1135,20 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
                        return false;
                }

-               memcpy(pathreal, dirptr->path, pathlen);
-               pathreal[pathlen] = '/';
-               memcpy(pathreal + slashlen + pathlen, dname,
-                      talloc_get_size(dname));
+               /*
+                * We don't want to pass ./xxx to modules below us so don't
+                * add the path if it is just . by itself. Not sure if we
+                * will ever see ./xxx as a dirpath ...
+                */
+               if (dirptr->path && dirptr->path[0] &&
+                   dirptr->path[0] == '.' && pathlen == 1) {
+                       memcpy(pathreal, dname, talloc_get_size(dname));
+               } else {
+                       memcpy(pathreal, dirptr->path, pathlen);
+                       pathreal[pathlen] = '/';
+                       memcpy(pathreal + slashlen + pathlen, dname,
+                              talloc_get_size(dname));
+               }

                /* Create smb_fname with NULL stream_name. */
                ZERO_STRUCT(smb_fname);



-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-dir-listing-stat.patch
Type: application/octet-stream
Size: 1065 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150415/299bd828/attachment.obj>


More information about the samba-technical mailing list