Bug 13204 - rmdir on non-empty directory fails silently
Summary: rmdir on non-empty directory fails silently
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: libsmbclient (show other bugs)
Version: 4.7.4
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-06 20:53 UTC by chris
Modified: 2020-01-10 10:19 UTC (History)
4 users (show)

See Also:


Attachments
cherry-picked for v4-9-stable (8.75 KB, patch)
2018-08-13 10:05 UTC, Anoop C S
jra: review+
Details
cherry-picked for v4-8-stable (8.75 KB, patch)
2018-08-13 10:06 UTC, Anoop C S
jra: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description chris 2018-01-06 20:53:16 UTC
Summary: smbclient rmdir on a non-empty directory does not delete the directory and also does not error, even with debug flag enabled. Since GNOME gvfs-smb backend uses libsmbclient, and it uses rmdir to delete directories, the lack of an error is interpreted as success. But the directory is not deleted.

Reproduces always.

Reproduce steps:
[chris@f27h ~]$ smbclient //f27s.local/scratch/
Enter SAMBA\chris's password:
Try "help" to get a list of possible commands.
smb: \> cd noperms
smb: \noperms\> ls
  .                                   D        0  Wed Jan  3 12:00:27 2018
  ..                                  D        0  Wed Jan  3 19:33:01 2018
  test2                               D        0  Wed Jan  3 11:59:55 2018
  test3                               D        0  Wed Jan  3 11:59:55 2018
  test4                               D        0  Wed Jan  3 11:59:55 2018
  test1                               D        0  Wed Jan  3 11:59:55 2018

        1073739776 blocks of size 1024. 503895948 blocks available
smb: \noperms\> rmdir test1
smb: \noperms\> ls
  .                                   D        0  Wed Jan  3 12:00:27 2018
  ..                                  D        0  Wed Jan  3 19:33:01 2018
  test2                               D        0  Wed Jan  3 11:59:55 2018
  test3                               D        0  Wed Jan  3 11:59:55 2018
  test4                               D        0  Wed Jan  3 11:59:55 2018
  test1                               D        0  Wed Jan  3 11:59:55 2018

        1073739776 blocks of size 1024. 503895948 blocks available
smb: \noperms\>

Expected results:

Either test1 should be deleted, or there should be an error.


Additional information:

Even when enabling debug with -d 10, there is no error.

smb: \noperms\> rmdir test1
dos_clean_name [\noperms\test1]
unix_clean_name [\noperms\test1]
smb: \noperms\>


See also:

List discussion (it is a bug):
https://lists.samba.org/archive/samba/2018-January/213048.html

GNOME Nautilus can't delete directories:
https://bugzilla.gnome.org/show_bug.cgi?id=792147
Comment 1 Anoop C S 2018-08-13 10:05:24 UTC
Created attachment 14407 [details]
cherry-picked for v4-9-stable
Comment 2 Anoop C S 2018-08-13 10:06:53 UTC
Created attachment 14408 [details]
cherry-picked for v4-8-stable
Comment 3 Jeremy Allison 2018-08-13 18:57:05 UTC
Re-assigning to Karolin for inclusion in 4.8.next, 4.9.next.
Comment 4 Karolin Seeger 2018-08-14 10:57:34 UTC
(In reply to Jeremy Allison from comment #3)
Pushed to autobuild-v4-{9,8}-test.
Comment 5 Karolin Seeger 2018-08-24 09:49:14 UTC
Pushed to both branches.
Closing out bug report.

Thanks!
Comment 6 Andreas Hasenack 2018-11-07 17:26:22 UTC
Will 4.7.x also get a fix for this? The current patch for 4.8.x applies there, but doesn't fix the issue. With the patch, 4.7.6 and 4.7.11 (the ones I tested) fail to remove even an empty directory, without returning an error.
Comment 7 Jeremy Allison 2018-11-07 17:35:01 UTC
Can you upload a wireshark trace of 4.7.x with the patch failing against Windows ? That will help me understand what might be going on here.
Comment 8 Andreas Hasenack 2018-11-08 18:33:33 UTC
I'm sorry, I made a silly mistake while applying the patch to the 4.7 tree. The fix is correct and it works just fine. Please ignore my previous comment.
Comment 9 Mathieu Parent 2019-01-19 12:51:34 UTC
I need this fix for samba 4.5 (in Debian, see https://bugs.debian.org/915248).

I have also applied https://git.samba.org/?p=samba.git;a=commitdiff;h=8d4005b07b08d5673b75d5d79f9b3d6936596fae. Is this enough?