Setting the DenyMode against a file
JANorman opened this issue · 2 comments
Hi there,
Thanks for such a great library and tool. We had a question regarding the libraries ability to pass trough the DenyMode to an underlying SMB server.
We have an SMB connection, mounted like such:
mount -t cifs -o rw,soft,nolock,iocharset=utf8,file_mode=0600,dir_mode=0700,user='admin',password='***',vers=2.0,mapchars,uid=5000,gid=5000 '//IPADDRESS/sambashare' '/mnt/CIFS/77ae37408e5e9d18c5a04987c/'
With portalocker we are running:
import portalocker
import time
file = open('/mnt/CIFS/77ae37408e5e9d18c5a04987c/output.txt', 'r+')
portalocker.lock(file, portalocker.LOCK_EX)
time.sleep(5)
When we inspect the smbstatus
we observe the following:
Locked files:
Pid User(ID) DenyMode Access R/W Oplock SharePath Name Time
--------------------------------------------------------------------------------------------------
3443 1000 DENY_NONE 0x12019f RDWR EXCLUSIVE+BATCH /sambashare output.txt Fri Oct 8 04:50:04 2021
It has essentially set the access mask + oplock, but not the DenyMode.
Is there an additional flag we can set to set DENY_WRITE?
Many thanks in advance.
I've done quite a bit of searching but I can't seem to find any method of setting the DenyMode from Python. I would be happy to add it to the library if I could find a way however.
Thanks @wolph - For reference I have been able to accomplish with this SMB protocol library — https://github.com/jborean93/smbprotocol