[Samba] file leases and replacing files

Rowland Penny rpenny at samba.org
Tue Dec 27 10:17:01 UTC 2022

On 27/12/2022 09:56, Michael Tokarev via samba wrote:
> Hi!
> What are windows file leases (displayed in smbstatus when
> smbd grants one to a client) and how they work?  I bet
> there's some documentation about this, but so far I
> can't find it.
> The problem is that when one replaces or modifies a file on linux
> which is "leased" on windows, windows client start acting in a
> weird way, for example it can start claiming the file does not
> exist anymore when trying to open it, - up to client reboot.
> This happens not just with executable files which are run from
> the samba shares, but also for regular text files too, sometimes.
> I can think that samba does not "notify" windows about the file
> change "properly" in this case (I'm not saying it "should" here).
> And I also can think that by using smbclient to modify these files
> instead of direct open/write/close calls against the filesystem,
> this problem can be eliminated, - this way, the modifications is
> seen by samba immediately and it can break the leases.
> Is there something I can read about that?
> Thanks,
> /mjt

Leases are a Windows thing, perhaps reading this might help to 
understand them:


As far as I am aware, altering or deleting a file (that has a Windows 
lease on it) directly on Linux, isn't recommended, Linux has no concept 
of 'leases'.

My feelings are, if a file is in a directory shared by Samba, then do 
not touch them directly on the server.


More information about the samba mailing list