Another inconsistency in the paths handed to stat in the VFS

Richard Sharpe realrichardsharpe at gmail.com
Wed Apr 15 12:51:50 MDT 2015


On Wed, Apr 15, 2015 at 11:00 AM, Jeremy Allison <jra at samba.org> wrote:
> On Wed, Apr 15, 2015 at 10:58:20AM -0700, Richard Sharpe wrote:
>> 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) {
>
> We have a standard macro
>
> #ifndef ISDOT
> #define ISDOT(path) ( \
>                         *((const char *)(path)) == '.' && \
>                         *(((const char *)(path)) + 1) == '\0' \
>                     )
> #endif
>
> for part of the above...

Sigh, yes.

I will redo it ...

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)


More information about the samba-technical mailing list