Reading the access attributes of directories in Windows

vsoler vicente.soler at gmail.com
Fri Aug 20 18:00:56 CEST 2010


On Aug 20, 5:10 pm, Tim Golden <m... at timgolden.me.uk> wrote:
> On 20/08/2010 15:49, vsoler wrote:
>
>
>
> > On Aug 20, 4:26 pm, vsoler<vicente.so... at gmail.com>  wrote:
> >> On Aug 20, 9:36 am, Tim Golden<m... at timgolden.me.uk>  wrote:
>
> >>>> I currently do not have subversion access in my PC. I could try to
> >>>> install a free copy of it. But it you could ptovide an installer, it
> >>>> certainly would do things easier. Please let me know if it is
> >>>> possible.
>
> >>> Vicente, can you just confirm that you received the installer I
> >>> sent offlist? I'll try to put winsys on PyPI with installers;
> >>> just haven't got round to it yes :)
>
> >>> TJG
>
> >> Tim,
>
> >> I just downloaded it, and am going to install it right away.
>
> > Tim,
>
> > It works!!! or at least, should I say, it runs!!! wonderful.
>
> > Now, would it be possible to have a hint/suggestion as to some lines
> > that I should include in my script?
>
> Depends what, exactly, you want your script to do :)
>
> The simplest way to get an ad-hoc look at what permissions are applied to
> a file is:
>
> <code>
> import os, sys
> from winsys import fs
>
> #
> # Just using sys.executable as a file I know will exist;
> # obviously you put your own file name in there...
> #
> fs.file (sys.executable).security ().dump ()
>
> </code>
>
> To get that in the more compact but more esoteric MS SDDL format:
>
> <code>
> import os, sys
> from winsys import fs
>
> print (fs.file (sys.executable).security ())
>
> </code>
>
> To decode the permission bit-strings to vaguely meaningful
> names:
>
> <code>
> import os, sys
> from winsys import fs
>
> dacl = fs.file (sys.executable).security ().dacl
> for permission in dacl:
>    print (d.trustee, " (Inherited )" if d.inherited else "")
>    for name in fs.FILE_ACCESS.names_from_value (d.access):
>      print ("  ", name)
>
> </code>
>
> TJG

Tim,

in your last piece of code, the definition of "d" is missing. missed
anything when copying?

Vicente Soler



More information about the Python-list mailing list