Saturday, March 26, 2011

Fix: Windows 7 unable to delete read-only files in Samba share

Using the same Samba share, Windows XP would delete read-only files, and directories with read-only files in them.  It would, of course, prompt you with a "Are you sure you want to delete the read-only file" message.

Windows 7, for some unfathomable reason, did not do this with the same Samba share.  Instead, it came up with a very irritating message that said "File access denied", "You need permission to perform this action" message.  It would not progress past that.

This affected file moving and (I think) copying as well, in at least a few cases.

The simple fix, of course, was just to clear the read-only flag on the file and re-attempt, in which case Windows 7 will delete it quite happily.  This is stupid, however - W7 should behave like XP, and just bloody well do it if I want it to.

Thanks to this post, written by some other poor schmuck with the same problem, I found my solution:

In smb.conf:

[global]
map readonly = no
delete readonly = yes

In my case, the "delete readonly = yes" line, by itself, did not do the trick. 

I don't know what the map option does, but the combination appears to have fixed my difficulty.  Windows 7 now correctly deletes read-only files - oddly enough, without any confirmation or warning. 

(This is neat but I wonder why; I may have, at some point, turned off the confirmation messages.  You do a lot of tweaking in the first 48 hours of having a new machine.)

I suspect the problem comes about by a more robust implementation of the network communication protocols, where Samba is responding with a message that XP interprets one way, and W7 another (possibly better) way.  Looseness of interpretation is the bane of all standards.

1 comment:

  1. Thank You Titam!
    Yes this does work as a workaround.
    Only problem is that you cannot have files flagged "Read-Only" on the Samba share.

    ReplyDelete