Is there any sample Python scripts that create Security Descriptors?

Jelmer Vernooij jelmer at samba.org
Sat Mar 24 17:47:46 MDT 2012


Am 25/03/12 00:41, schrieb Richard Sharpe:
> 2012/3/24 Jelmer Vernooij <jelmer at samba.org>:
>> Am 25/03/12 00:24, schrieb Richard Sharpe:
>>> 2012/3/7 Amitay Isaacs <amitay at gmail.com>:
>>>> You can look at provision code which creates Security descriptors from SDDL in
>>>>  source4/scripting/python/samba/provision/
>>>>
>>>> For file ACLs, you can check
>>>>  source4/scripting/python/samba/netcmd/ntacl.py
>>>>
>>>> And misc SD utilities
>>>>  source4/scripting/python/samba/sd_utils.py
>>>>
>>>> Python interface for SD is provided by samba.dcerpc.security module.
>>>> You can get python documentation on these modules using pydoc.
>>>>
>>>> PYTHONPATH=<samba-dir>/bin/python pydoc samba.dcerpc.security
>>> OK, that has been very useful.
>>>
>>> If I write my own python tests (as a class, presumably) how do I get
>>> access to all the existing classes?
>>>
>>> Do I run it as: PYTHONPATH=<samba-dir>/bin/python python my-test-set.py
>> You want pydoc rather than python to view the documentation.
>>
>> The documentation is viewed by specifying the python path to the object
>> you want to view the documentation of. The build system makes sure that
>> all python modules are installed in our standard python path, in
>> <samba-dir>/bin/python.
>>
>> Roughly speaking, bin/python/samba/foo.py will translate to the python
>> module path "samba.foo". E.g. to view the docs for
>> bin/python/samba/my_test_set.py, run:
>>
>> PYTHONPATH=<samba-dir>/bin/python pydoc samba.my_test_set
>>
>> Of course, to be able to do this, your tests need to be installed into
>> bin/python by the build system. Most plain python files are linked from
>> source4/scripting/python/... (this would apply to your tests) The
>> compiled extensions (.so files) live all over the tree.
> Yeah, but when I am testing my python code, how do I tell Python how
> to pick up all the existing classes?
I'm not sure what you mean by "pick up all the existing classes" ?

If you want to have your tests run by "make test", then you will want to
edit source{3,4}/selftest/tests.py and add a call to planpythontestsuite.

To just run the tests manually, use something like:

PYTHONPATH=<samba-dir>/bin/python -m unittest samba.my_test_set

Cheers,

Jelmer

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20120325/d37339a7/attachment.pgp>


More information about the samba-technical mailing list