Windows – Allow overwriting of open files on a smb share

server-message-blockwindows

We have a smb share on a linux box which is used as network share for windows machines. We put an executable on it for everyone to use. The issue is that if anyone has the application running, we can't update the file on the share.

The strange thing is that if you delete the file from a windows machine, it appears to complete successfully, but when you refresh the directory, it appears again. Additionally, if you try to copy over the file, it simply hangs, it does not give a permission error.

I would expect that either a user is denied permission to delete a file because someone else has it opened or allow you to delete it. The weird thing is that if you delete the file, and then the other user closes the file, it suddenly disappears, not good.

Ideally there would be a way to tell smbd to not allow anyone to take a lock on a file for a particular share. If someone deletes a file, it should get deleted, even if another user has it open.

Best Answer

Samba only supports disabling locking at the service (share) level and not at the individual file level. Disabling locking creates the potential for data corruption and the man page warns against it. (I've never done it so I can't give you any personal anecdotes. It sounds like a bad idea to me.)

What you're asking for isn't something a real Windows-based SMB server would ever do, so I could imagine it creating problems, especially if you're running any kind of "database" applications that use file sharing from that share.

If you have to do this, I'd dedicate an entire service to this one executable just to be sure that you're not going to create data corruption with other files.