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.

Thanks,
Jeba

On Tue, Sep 20, 2016 at 3:51 AM, Christopher Nilsson <ch...@slort.org>
wrote:

> 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> wrote:
>
>> 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 bug?
>>
>> import win32security,win32api,win32con
>> import ntsecuritycon as con
>> import os
>>
>> def show_cacls (filename):
>>     for line in os.popen ("Icacls %s" % filename).read ().splitlines ():
>>         print(line)
>>
>> def denyWrite():
>>     everyone, everyone_domain, everyone_type = 
>> win32security.LookupAccountName
>> ("", "Everyone")
>>     print(everyone, everyone_domain, everyone_type)
>>
>>     sd = win32security.GetFileSecurity(FILENAME,
>> win32security.DACL_SECURITY_INFORMATION)
>>     dacl = sd.GetSecurityDescriptorDacl()
>>
>>     masks=con.GENERIC_WRITE
>>     dacl.AddAccessDeniedAce(win32security.ACL_REVISION_DS,masks,everyone)
>>     sd.SetSecurityDescriptorDacl(1, dacl, 0)   # may not be necessary
>>     win32security.SetFileSecurity(FILENAME, 
>> win32security.DACL_SECURITY_INFORMATION,
>> sd)
>>     show_cacls (FILENAME)
>>
>>
>> try:
>>
>>     FILENAME = "D:\\test"
>>     denyWrite()
>>
>> Any help regarding this would be welcomed. Thanks
>> _______________________________________________
>> python-win32 mailing list
>> python-win32@python.org
>> https://mail.python.org/mailman/listinfo/python-win32
>>
>
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to