I think file_generic_write will have the same problem.
You may want to check out:
Note they explicitly say you can't deny generic_write without causing
Blocking access like this can get pretty fiddly. I can only suggest
starting by blocking the bare minimum that you can. Check those consts on
msdn & avoid the generic ones.
On Tue, 20 Sep 2016, 4:42 PM Goku Balu <tfa.signup.te...@gmail.com> wrote:
> Hi Christopher,
> Thanks for responding. Forgot to mention that I did test this with
> FILE_GENERIC_WRITE also but the result is the same. If this
> is applied on a folder it leaves the folder unopenable. If it's applied on
> a file(say a.txt file), Notepad shows warning informing "Access Denied" but
> can be edited and can be saved in a different location.
> FYI I'm using Python 3.2 with Pywin32 ver 219.
> On Tue, Sep 20, 2016 at 3:51 AM, Christopher Nilsson <ch...@slort.org>
>> Hi Goku,
>> That doesn't seem like a bug to me. GENERIC_WRITE represents several
>> permissions mashed together, including FILE_WRITE and read control.
>> Perhaps try with just FILE_WRITE on its own?
>> On Tue, 20 Sep 2016, 8:03 AM Goku Balu <tfa.signup.te...@gmail.com>
>>> If I deny GENERIC_WRITE it denies Rc as well (Rc - Read Control). I
>>> can't even open the folder in explorer. Here is the sample code. Is this a
>>> import win32security,win32api,win32con
>>> import ntsecuritycon as con
>>> import os
>>> def show_cacls (filename):
>>> for line in os.popen ("Icacls %s" % filename).read ().splitlines ():
>>> def denyWrite():
>>> everyone, everyone_domain, everyone_type =
>>> win32security.LookupAccountName ("", "Everyone")
>>> print(everyone, everyone_domain, everyone_type)
>>> sd = win32security.GetFileSecurity(FILENAME,
>>> dacl = sd.GetSecurityDescriptorDacl()
>>> sd.SetSecurityDescriptorDacl(1, dacl, 0) # may not be necessary
>>> win32security.DACL_SECURITY_INFORMATION, sd)
>>> show_cacls (FILENAME)
>>> FILENAME = "D:\\test"
>>> Any help regarding this would be welcomed. Thanks
>>> python-win32 mailing list
python-win32 mailing list