Chris Murphy
2018-Jan-04 20:52 UTC
[Samba] smbclient, cannot delete non-empty directory, no error message
client: samba-client-4.7.4-0.fc27.x86_64 client: samba-client-4.6.5-0.fc26.x86_64 server: samba-4.7.3-3.fc27.x86_64 Reproduce steps: [chris at 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 why it's not deleted. I'm not sure if directories with items in them can even be deleted with smbclient, but nevertheless there should be an error. 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\> For what it's worth, when I try to remove this same directory on macOS 10.13 or Windows 10, it is deleted. Whereas with GNOME Nautilus, it is likewise not deleted (same results as smbclient, it's not deleted and there's no error.) So I'm not sure yet if there is a wider bug here that affects libsmbclient or what. I've filed a bug about that here: https://bugzilla.gnome.org/show_bug.cgi?id=792147 That bug contains attachments for the server and client smb.conf and some other stuff. -- Chris Murphy
lingpanda101
2018-Jan-05 13:37 UTC
[Samba] smbclient, cannot delete non-empty directory, no error message
On 1/4/2018 3:52 PM, Chris Murphy via samba wrote:> client: samba-client-4.7.4-0.fc27.x86_64 > client: samba-client-4.6.5-0.fc26.x86_64 > server: samba-4.7.3-3.fc27.x86_64 > > Reproduce steps: > > [chris at 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 why it's > not deleted. I'm not sure if directories with items in them can even > be deleted with smbclient, but nevertheless there should be an error. > 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\> > > For what it's worth, when I try to remove this same directory on macOS > 10.13 or Windows 10, it is deleted. Whereas with GNOME Nautilus, it is > likewise not deleted (same results as smbclient, it's not deleted and > there's no error.) So I'm not sure yet if there is a wider bug here > that affects libsmbclient or what. I've filed a bug about that here: > > https://bugzilla.gnome.org/show_bug.cgi?id=792147 > > That bug contains attachments for the server and client smb.conf and > some other stuff. > >Chris, I would assume you would need to use 'rm -r' to remove a directory and it's contents. I would also assume a error message would be expected with 'rmdir' if the dir was not empty. The man page for smbclient also suggests you may use 'deltree'. -- -- James
Chris Murphy
2018-Jan-05 18:15 UTC
[Samba] smbclient, cannot delete non-empty directory, no error message
On Fri, Jan 5, 2018 at 6:37 AM, lingpanda101 <lingpanda101 at gmail.com> wrote:> I would assume you would need to use 'rm -r' to remove a directory and > it's contents.That doesn't work and the man page doesn't list flags for any commands, plus it looks like rm is strictly for files not for directories. smb: \noperms\> rm -r test1 NT_STATUS_NO_SUCH_FILE listing \noperms\-r smb: \noperms\> rm test2 NT_STATUS_NO_SUCH_FILE listing \noperms\test2>I would also assume a error message would be expected with > 'rmdir' if the dir was not empty.This is a problem for gvfs-smb backend for GNOME which uses rmdir. Due to the silent failure, gvfs-smb assumes it succeeds, but it doesn't. gvfs-smb uses libsmbclient and so it really needs an error message to know that the command did not succeed and that it needs to fall back on other commands to complete the user action. Basically right now GNOME users can't delete directories that have files in them, that's pretty remarkable and not in a good way. Should I file a bug? This problem goes back over a year at the least, I'm rather surprised no one has run into this until now.>The man page for smbclient also suggests > you may use 'deltree'.That does work. Is there a reason for rmdir to exist? It sounds like deltree will remove either an empty or full directory, which makes rmdir superfluous/legacy. -- Chris Murphy
Reasonably Related Threads
- smbclient, cannot delete non-empty directory, no error message
- smbclient, cannot delete non-empty directory, no error message
- CLI command 'database deltree' doesn't remove family with space in its name
- smbclient, cannot delete non-empty directory, no error message
- help with permissions