Bug 9534 - NT_STATUS_INVALID_HANDLE when deleting a directory on a "scannedonly" covered share
NT_STATUS_INVALID_HANDLE when deleting a directory on a "scannedonly" covered...
Status: ASSIGNED
Product: Samba 4.0
Classification: Unclassified
Component: File services
4.0.0
All Linux
: P5 normal
: ---
Assigned To: Jeremy Allison
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-03 12:09 UTC by Kaito Kumashiro
Modified: 2013-03-28 20:04 UTC (History)
0 users

See Also:


Attachments
Do not return private struct on opendir and fdopendir (7.91 KB, patch)
2013-01-16 17:38 UTC, Samuel Cabrero
no flags Details
git-am fix for master and 4.0.next. (29.53 KB, patch)
2013-03-25 20:42 UTC, Jeremy Allison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kaito Kumashiro 2013-01-03 12:09:56 UTC
There seems to be a problem with Samba 4.0 shares covered by scannedonly VFS module. Example configuration of one of those shares:


  path = /foo/bar/baz
  read only = No
  browseable = No
  vfs objects = scannedonly
  scannedonly:domain_socket = True
  scannedonly:socketname = /var/lib/scannedonly/scan
  scannedonly:hide_nonscanned_files = True
  scannedonly:allow_nonscanned_files = False


Whenever I try do delete a directory, I get NT_STATUS_INVALID_HANDLE status, but directory is removed. On Windows, this status spawns an error dialog. Example session:


  smb: \blah\> ls
    .                                   D        0  Mon Dec 31 14:48:38 2012
    ..                                  D        0  Fri Dec 28 11:50:51 2012

          516061624 blocks of size 1024. 489151420 blocks available
  smb: \blah\> mkdir Test
  smb: \blah\> ls
    .                                   D        0  Mon Dec 31 15:48:55 2012
    ..                                  D        0  Fri Dec 28 11:50:51 2012
    Test                                D        0  Mon Dec 31 15:48:55 2012

          516061624 blocks of size 1024. 489151412 blocks available
  smb: \blah\> rmdir Test
  NT_STATUS_INVALID_HANDLE removing remote directory file \blah\Test
  smb: \blah\> ls
    .                                   D        0  Mon Dec 31 15:49:01 2012
    ..                                  D        0  Fri Dec 28 11:50:51 2012

          516061624 blocks of size 1024. 489151420 blocks available
  smb: \blah\>


During this operation, smbd throws those lines into log (timestamps removed for clarity):


  smbd[10578]:  ../source3/smbd/close.c:1255(close_directory)
  smbd[10578]:   Could not close dir! fname=blah/Test, fd=-1, err=9=Bad file descriptor


If I do this on a share without scannedonly VFS, everything works without errors.
There are no problems with removing files. Only directories are affected.
Comment 1 Samuel Cabrero 2013-01-16 17:38:18 UTC
Created attachment 8440 [details]
Do not return private struct on opendir and fdopendir

This patch solves the problem, it would be great if someone can have a look to it.
Comment 2 Kaito Kumashiro 2013-01-16 17:54:34 UTC
(In reply to comment #1)
> Created attachment 8440 [details]
> Do not return private struct on opendir and fdopendir
> 
> This patch solves the problem, it would be great if someone can have a look to
> it.

Great timing. I was just about to upgrade to 4.0.1 :)
Looks like your patch fixed the problem. I can remove a directory without the error showing up. I also don't see any problems in a log file.

Thank you :)
Comment 3 Jeremy Allison 2013-03-22 22:33:50 UTC
Ok, reviewing this now. It makes sense as later versions of Samba expect to be able to call DIRFD on a returned DIR pointer, so it isn't really opaque anymore.

Jeremy.
Comment 4 Jeremy Allison 2013-03-22 23:10:01 UTC
Ok this patch won't work as-is unfortunately (although it probably works in the scenario you're testing).

It attaches an single open directory 'struct scannedonly_DIR' to the data associated with the connection handle. However clients could open more than one directory simultaneously on a single connection handle, so the 'struct scannedonly_DIR' stored in the struct Tscannedonly must be a list of structures, not just a single one.

I'll re-write this and re-submit it for your testing.

Cheers,

Jeremy.
Comment 5 Jeremy Allison 2013-03-25 20:42:40 UTC
Created attachment 8683 [details]
git-am fix for master and 4.0.next.

Can you test this git-am patchset, and see if it fixes the problem ? If you can confirm, I'll submit it to master for review and then get it added to 4.0.next.

Thanks,

Jeremy.
Comment 6 Kaito Kumashiro 2013-03-28 13:05:10 UTC
(In reply to comment #5)
> Can you test this git-am patchset, and see if it fixes the problem ? If you can
> confirm, I'll submit it to master for review and then get it added to 4.0.next.
Currently I cannot do that. I have a Samba upgrade scheduled next week and then I can check it.
Comment 7 Jeremy Allison 2013-03-28 20:04:30 UTC
Thanks. As soon as you can confirm I'll submit it to the mailing list for merge, and we'll get it into 4.0.next.

Jeremy.