[Samba] samba allows rename to a locked file (from linux cifs mount)

Michael Tokarev mjt at tls.msk.ru
Sat Mar 16 19:08:34 UTC 2024


16.03.2024 21:26, Ralph Boehme wrote:
> On 3/16/24 18:18, Michael Tokarev wrote:

>> Enabling strict renames does not change anything.  Yes it prevents from
>> renaming a directory if a file is open inside.  But not renaming a plain
>> file which is locked.
> 
> oh, you mean just rename a plain file that is currently opened by some client? That is possible as long as all opens pass FILE_SHARE_DELETE. What kind 
> of "lock" where you referring at in your initial mail?

Exactly, just a plain file.  For example, an executable (.exe) file
which is currently running by some windows client, like this
(from smbstatus):

Locked files:
Pid          User(ID)   DenyMode   Access      R/W        Oplock           SharePath   Name   Time
--------------------------------------------------------------------------------------------------
926452       122        DENY_WRITE 0x1000a1    RDONLY     LEASE(RWH)       /share/files   .rel/ekis1/plan/oraprjplan.exe   Sat Mar 16 21:28:10 2024

 From any another windows machine I can't rename or remove this
file, it says "the file is in use".  While on linux when this
share is mounted using cifs, it removes or renames without any
issues, and this is causing the windows machine to do Bad Things
(exactly as if the file has been replaced on the samba server
behind samba's back).

Mostly this is about writing a new temporary file and renaming
it to final name (oraprjplan.exe in this case), or just removing -
either works without an issue.

smbclient does it a bit different, looks like smbclient's delete just
"marks" the file to be deleted in this case (smbclient doesn't let to
rename-override, "rename" fails due to destination already exists).

I probably should enable trace on the samba server and see why it
allows doing things for linux client but denies the same action for
a windows client.

Thanks,

/mjt



More information about the samba mailing list