Ralph Boehme
2024-Mar-16 18:26 UTC
[Samba] samba allows rename to a locked file (from linux cifs mount)
On 3/16/24 18:18, Michael Tokarev wrote:> 16.03.2024 20:11, Ralph Boehme wrote: >> On 3/16/24 14:18, Michael Tokarev wrote: >>> So I'm trying to go exactly the opposite route: I'm mounting a samba >>> share on linux (with cifs, see $subject). >> >> ah, missed that. Had read it as if you were acting on the Samba server >> directly. >> >> This smells like "strict rename" isn't enabled ? it isn't by default. > > Nope, it's not it.? strict rename only applies to dirs. > I'm writing about plain files, not only rename but also delete. > > 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? -slow -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature.asc Type: application/pgp-signature Size: 840 bytes Desc: OpenPGP digital signature URL: <http://lists.samba.org/pipermail/samba/attachments/20240316/904cc41c/OpenPGP_signature.sig>
Michael Tokarev
2024-Mar-16 19:08 UTC
[Samba] samba allows rename to a locked file (from linux cifs mount)
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
Reasonably Related Threads
- samba allows rename to a locked file (from linux cifs mount)
- windows 10 locking profile files
- Avoiding uid conflicts between rfc2307 user/groups and computers
- samba allows rename to a locked file (from linux cifs mount)
- samba allows rename to a locked file (from linux cifs mount)