smbclient deltree with read-only directories

I’m trying to delete files on a NetApp server using smbclient //servername/share -c "deltree directory_to_delete". It works except for folders which have the read-only flag set. In this case, the command aborts with NT_STATUS_CANNOT_DELETE.

I can view the flags with smbclient //servername/share -c "ls directory_to_delete/*" and remove them with smbclient //servername/share -c "setmode directory_to_delete/subdir_with_ro_flag -r", but only per directory.

Is there a way to automate this (remove the read-only flag recursively) or any other way how to recursively delete a directory with read-only subdirectories?

Btw. the Windows explorer does not complain when deleting such directories (using the same credentials). I’m sure it removes the ro-flag silently.

Asked By: Schorschii

||

The solution for NetApp is to enable the option cifs.perm_check_ro_del_ok.

options cifs.perm_check_ro_del_ok on

Source: https://library.netapp.com/ecmdocs/ECMP1196993/html/GUID-627F5269-6DE9-4FC8-BBC1-B1F34101FDFA.html

Btw. the read-only flag on directories has a complete other meaning than one would expect, see here.

Answered By: Schorschii
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.