0

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.

2
  • "Is there a way to automate this […]?" - is mounting the filesystem "properly" (i.e. with mount -t cifs //servername/share …) an option so that you can use rm -rf, rather than using smbclient? Commented Mar 5, 2024 at 19:51
  • 1
    Yes, this would be my fallback solution. The thing is that my smbclient command is part of a script which I don't want to rewrite if there is an other solution. Commented Mar 7, 2024 at 15:30

1 Answer 1

0

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.