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

Michael Tokarev mjt at tls.msk.ru
Sat Mar 16 13:18:02 UTC 2024


16.03.2024 16:06, Ralph Boehme wrote:
> On 3/16/24 06:59, Michael Tokarev via samba wrote:
>> How to prevent rm and mv from touching a locked file?
> 
> cf man smb.conf "kernel share modes" and
> 
> git diff d40f57321a12~9..d40f57321a12

Hello Ralph!

I'm not sure we understand each other here.

Yes I'm aware of "kernel share modes" and turning off support of these
by default. I never bothered to find where exactly it has been removed.

But I'm talking - hopefully - about something very different.

With "kernel share modes", it is the host kernel (on top of which samba
accesses files for the clients) is doing the concurrency checks.

This does not work because kernel does not support this anymore.

So I'm trying to go exactly the opposite route: I'm mounting a samba
share on linux (with cifs, see $subject).  So it is now samba who should
prevent concurrent access, on top of whatever filesystem it uses, - exactly
the same way as it does for windows clients.  For one, a windows client
can not remove a locked file from a samba-exported share.

However, when linux tries to remove a locked file from a samba-exported
share, samba allows it to do that, despite it knows the file is locked.

This operation should not depend on the kernel share modes or kernel
locking at all, it is solely within samba, - one client has this file
locked, another client removes this file and should receive an error.

Exactly the same this is done by samba when (linux) client is trying to
open a locked file in write mode - it receives EBUSY error from samba,
without "kernel share modes".

What I'm missing?

Thanks,

/mjt



More information about the samba mailing list