diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-01-22 16:39:56 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-01-22 16:39:56 +0100 |
commit | 4075a2ba982ea56ff925e0a33839f0760fd71911 (patch) | |
tree | 87d87734257f814b7960a843e54455c447f34a9e /source4/scripting/python | |
parent | 24da29746998de1001d18871dcbe8d37643667d5 (diff) | |
parent | 35c68316442808a135aafa864d19592108a4d879 (diff) | |
download | samba-4075a2ba982ea56ff925e0a33839f0760fd71911.tar.gz samba-4075a2ba982ea56ff925e0a33839f0760fd71911.tar.xz samba-4075a2ba982ea56ff925e0a33839f0760fd71911.zip |
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-python
(This used to be commit 2f57e25f8f692889d9e057e13256f8a24c5ec10c)
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/STATUS | 26 | ||||
-rw-r--r-- | source4/scripting/python/config.m4 | 72 | ||||
-rw-r--r-- | source4/scripting/python/config.mk | 12 | ||||
-rw-r--r-- | source4/scripting/python/modules.c | 13 | ||||
-rw-r--r-- | source4/scripting/python/pyrpc.h | 29 | ||||
-rw-r--r-- | source4/scripting/python/pytalloc.c | 45 | ||||
-rw-r--r-- | source4/scripting/python/pytalloc.h | 51 | ||||
-rw-r--r-- | source4/scripting/python/samba/__init__.py | 14 | ||||
-rw-r--r-- | source4/scripting/python/samba/provision.py | 40 | ||||
-rw-r--r-- | source4/scripting/python/samba/samdb.py | 4 | ||||
-rw-r--r-- | source4/scripting/python/samba/tests/dcerpc/__init__.py | 0 | ||||
-rw-r--r-- | source4/scripting/python/samba/tests/dcerpc/registry.py | 50 | ||||
-rw-r--r-- | source4/scripting/python/samba/tests/dcerpc/rpcecho.py | 44 | ||||
-rw-r--r-- | source4/scripting/python/samba/tests/dcerpc/sam.py | 28 | ||||
-rw-r--r-- | source4/scripting/python/uuidmodule.c | 8 |
15 files changed, 332 insertions, 104 deletions
diff --git a/source4/scripting/python/STATUS b/source4/scripting/python/STATUS index c82275fff8d..6e6475bfdea 100644 --- a/source4/scripting/python/STATUS +++ b/source4/scripting/python/STATUS @@ -1,23 +1,15 @@ -dsdb/samdb/ldb_modules/tests/samba3sam.py -lib/ldb/tests/python/ldap.py -provisioning in LDAP mode -SWAT +dsdb/samdb/ldb_modules/tests/samba3sam.py: Fix remaining failing tests +lib/ldb/tests/python/ldap.py: Fix remaining 3 FIXME's +provisioning in LDAP mode(TEST_LDAP=yes PROVISION_PYTHON=yes make test) command-line vampire provisioning: combine some of the python dictionaries -hierarchy -DCE/RPC bindings - - pidl: - Parse::Pidl::Samba::Python - - wrap struct/bitmap/enum/union types - - __ndr_pack__/__ndr_unpack__ members - Parse::Pidl::Samba::NDR::Python - - pidl generated client fns - - one class per interface - - AddOne() - - - scripting/bin/smbstatus.py - - scripting/bin/winreg.py +finish scripting/bin/smbstatus.py not important before making Python the default: +- hierarchy (rename samr -> dcerpc.samr, misc -> samba.misc, etc) - scripting/python/samba/upgrade.py - install python modules into system +- SWAT +- __ndr_pack__/__ndr_unpack__ members for the NDR struct bindings +- generate docstrings in DCE/RPC bindings +- eliminate some variables from the python interface because they can be induced diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4 index 348f9197f71..908efd1588e 100644 --- a/source4/scripting/python/config.m4 +++ b/source4/scripting/python/config.m4 @@ -13,6 +13,32 @@ if test -z "$PYTHON"; then AC_MSG_WARN([No python found]) fi +AC_DEFUN([TRY_LINK_PYTHON], +[ + if test $working_python = no; then + ac_save_LIBS="$LIBS" + ac_save_CFLAGS="$CFLAGS" + LIBS="$LIBS $1" + CFLAGS="$CFLAGS $2" + + AC_TRY_LINK([ + #include <Python.h> + #include <stdlib.h> + ],[ + Py_InitModule(NULL, NULL); + ],[ + PYTHON_LDFLAGS="$1" + PYTHON_CFLAGS="$2" + working_python=yes + ]) + LIBS="$ac_save_LIBS" + CFLAGS="$ac_save_CFLAGS" + fi +]) + +dnl assume no working python +working_python=no + if test -z "$PYTHON_VERSION"; then AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config]) else @@ -20,50 +46,28 @@ else fi if test -z "$PYTHON_CONFIG"; then - working_python=no AC_MSG_WARN([No python-config found]) else - working_python=yes - PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags` - PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags` + TRY_LINK_PYTHON([`$PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --includes`]) + TRY_LINK_PYTHON([`$PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --cflags`]) fi -if test $working_python = no && test x$PYTHON != x +if test x$PYTHON != x then - PYTHON_CFLAGS=`$PYTHON -c "from distutils import sysconfig; print '-I%s -I%s %s' % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True), sysconfig.get_config_var('CFLAGS'))"` - PYTHON_LDFLAGS=`$PYTHON -c "from distutils import sysconfig; print '%s %s -lpython%s -L%s' % (sysconfig.get_config_var('LIBS'), sysconfig.get_config_var('SYSLIBS'), sysconfig.get_config_var('VERSION'), sysconfig.get_config_var('LIBPL'))"` - working_python=yes + DISTUTILS_CFLAGS=`$PYTHON -c "from distutils import sysconfig; print '-I%s -I%s %s' % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True), sysconfig.get_config_var('CFLAGS'))"` + DISTUTILS_LDFLAGS=`$PYTHON -c "from distutils import sysconfig; print '%s %s -lpython%s -L%s' % (sysconfig.get_config_var('LIBS'), sysconfig.get_config_var('SYSLIBS'), sysconfig.get_config_var('VERSION'), sysconfig.get_config_var('LIBPL'))"` + TRY_LINK_PYTHON($DISTUTILS_LDFLAGS, $DISTUTILS_CFLAGS) fi SMB_EXT_LIB(EXT_LIB_PYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CFLAGS]) AC_MSG_CHECKING(working python module support) -if test x$working_python = xyes -then - ac_save_LIBS="$LIBS" - ac_save_CFLAGS="$CFLAGS" - LIBS="$LIBS $PYTHON_LDFLAGS" - CFLAGS="$CFLAGS $PYTHON_CFLAGS" - - AC_TRY_LINK([ - #include <Python.h> - #include <stdlib.h> - ],[ - Py_InitModule(NULL, NULL); - ],[ - SMB_ENABLE(EXT_LIB_PYTHON,YES) - SMB_ENABLE(smbpython,YES) - SMB_ENABLE(LIBPYTHON,YES) - AC_MSG_RESULT([yes]) - ],[ - SMB_ENABLE(EXT_LIB_PYTHON,NO) - SMB_ENABLE(LIBPYTHON,NO) - SMB_ENABLE(smbpython,NO) - AC_MSG_RESULT([no]) - ]) - - LIBS="$ac_save_LIBS" - CFLAGS="$ac_save_CFLAGS" +if test $working_python = yes; then + SMB_ENABLE(EXT_LIB_PYTHON,YES) + SMB_ENABLE(smbpython,YES) + SMB_ENABLE(LIBPYTHON,YES) + AC_MSG_RESULT([yes]) else AC_MSG_ERROR([Python not found. Please install Python 2.x and its development headers/libraries.]) fi + diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index cfd179aff5c..450da0e90a6 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -5,7 +5,7 @@ OBJ_FILES = smbpython.o [SUBSYSTEM::LIBPYTHON] PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON INIT_FUNCTION_SENTINEL = { NULL, NULL } -OBJ_FILES = modules.o +OBJ_FILES = modules.o pytalloc.o [PYTHON::python_uuid] PRIVATE_DEPENDENCIES = LIBNDR @@ -16,7 +16,7 @@ PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS SWIG_FILE = misc.i # Swig extensions -swig: pythonmods +swig:: pythonmods .SUFFIXES: _wrap.c .i @@ -28,13 +28,19 @@ realdistclean:: @-rm -f bin/python/* # FIXME: Remove _wrap.c files -pythonmods: $(PYTHON_DSOS) +pythonmods:: $(PYTHON_DSOS) $(PYTHON_PYS) PYDOCTOR_MODULES=bin/python/ldb.py bin/python/auth.py bin/python/credentials.py bin/python/registry.py bin/python/tdb.py bin/python/security.py bin/python/events.py bin/python/net.py pydoctor:: pythonmods LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --make-html --docformat=restructuredtext --add-package scripting/python/samba/ $(addprefix --add-module , $(PYDOCTOR_MODULES)) +installpython:: pythonmods + @$(SHELL) $(srcdir)/script/installpython.sh \ + $(INSTALLPERMS) \ + $(DESTDIR)$(PYTHONDIR) \ + scripting/python bin/python + clean:: @echo "Removing python modules" @rm -f bin/python/* diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index 55df51d881e..fff981e9417 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -35,6 +35,19 @@ extern void init_events(void); extern void inituuid(void); extern void init_net(void); extern void initecho(void); +extern void initwinreg(void); +extern void initepmapper(void); +extern void initinitshutdown(void); +static void initdcerpc_misc(void) {} +extern void initmgmt(void); +extern void initatsvc(void); +extern void initsamr(void); +static void initdcerpc_security(void) {} +extern void initlsa(void); +extern void initsvcctl(void); +extern void initwkssvc(void); +extern void init_libcli_nbt(void); +extern void init_libcli_smb(void); static struct _inittab py_modules[] = { STATIC_LIBPYTHON_MODULES }; diff --git a/source4/scripting/python/pyrpc.h b/source4/scripting/python/pyrpc.h new file mode 100644 index 00000000000..5390c6923da --- /dev/null +++ b/source4/scripting/python/pyrpc.h @@ -0,0 +1,29 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#define PY_CHECK_TYPE(type, var, fail) \ + if (!type ## _Check(var)) {\ + PyErr_Format(PyExc_TypeError, "Expected type %s", type ## _Type.tp_name); \ + fail; \ + } + +#define dom_sid2_Type dom_sid_Type +#define dom_sid28_Type dom_sid_Type +#define dom_sid2_Check dom_sid_Check +#define dom_sid28_Check dom_sid28_Check diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c new file mode 100644 index 00000000000..d8d3efe69c1 --- /dev/null +++ b/source4/scripting/python/pytalloc.c @@ -0,0 +1,45 @@ +/* + Unix SMB/CIFS implementation. + Python/Talloc glue + Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "includes.h" +#include "scripting/python/pytalloc.h" + +void py_talloc_dealloc(PyObject* self) +{ + py_talloc_Object *obj = (py_talloc_Object *)self; + talloc_free(obj->talloc_ctx); + PyObject_Del(self); +} + +PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, + void *ptr) +{ + py_talloc_Object *ret = PyObject_New(py_talloc_Object, py_type); + ret->talloc_ctx = talloc_reference(NULL, mem_ctx); + ret->ptr = ptr; + return (PyObject *)ret; +} + +PyObject *py_talloc_default_repr(PyObject *py_obj) +{ + py_talloc_Object *obj = (py_talloc_Object *)py_obj; + + return PyString_FromFormat("<talloc: %s>", + talloc_get_name(obj->talloc_ctx)); +} diff --git a/source4/scripting/python/pytalloc.h b/source4/scripting/python/pytalloc.h new file mode 100644 index 00000000000..aad5840a672 --- /dev/null +++ b/source4/scripting/python/pytalloc.h @@ -0,0 +1,51 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _PY_TALLOC_H_ +#define _PY_TALLOC_H_ + +#include <Python.h> + +typedef struct { + PyObject_HEAD + TALLOC_CTX *talloc_ctx; + void *ptr; +} py_talloc_Object; + +/* Deallocate a py_talloc_Object */ +void py_talloc_dealloc(PyObject* self); + +/* Retrieve the pointer for a py_talloc_object. Like talloc_get_type() + * but for py_talloc_Objects. */ + +/* FIXME: Call PyErr_SetString(PyExc_TypeError, "expected " __STR(type) ") + * when talloc_get_type() returns NULL. */ +#define py_talloc_get_type(py_obj, type) \ + talloc_get_type(py_talloc_get_ptr(py_obj), type) + +#define py_talloc_get_ptr(py_obj) ((py_talloc_Object *)py_obj)->ptr +#define py_talloc_get_mem_ctx(py_obj) ((py_talloc_Object *)py_obj)->talloc_ctx + +PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr); +#define py_talloc_import(py_type, talloc_ptr) py_talloc_import_ex(py_type, talloc_ptr, talloc_ptr) + +/* Sane default implementation of reprfunc. */ +PyObject *py_talloc_default_repr(PyObject *py_obj); + +#endif /* _PY_TALLOC_H_ */ diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index e0b9e1d4104..483929661da 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -112,28 +112,28 @@ class Ldb(ldb.Ldb): for attr in ["@INDEXLIST", "@ATTRIBUTES", "@SUBCLASSES", "@MODULES", "@OPTIONS", "@PARTITION", "@KLUDGEACL"]: try: - self.delete(ldb.Dn(self, attr)) + self.delete(attr) except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _): # Ignore missing dn errors pass - basedn = ldb.Dn(self, "") + basedn = "" # and the rest for msg in self.search(basedn, ldb.SCOPE_SUBTREE, - "(&(|(objectclass=*)(dn=*))(!(dn=@BASEINFO)))", - ["dn"]): + "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", + ["distinguishedName"]): try: self.delete(msg.dn) except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _): # Ignor eno such object errors pass - res = self.search(basedn, ldb.SCOPE_SUBTREE, "(&(|(objectclass=*)(dn=*))(!(dn=@BASEINFO)))", ["dn"]) + res = self.search(basedn, ldb.SCOPE_SUBTREE, "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", ["distinguishedName"]) assert len(res) == 0 def erase_partitions(self): """Erase an ldb, removing all records.""" - res = self.search(ldb.Dn(self, ""), ldb.SCOPE_BASE, "(objectClass=*)", + res = self.search("", ldb.SCOPE_BASE, "(objectClass=*)", ["namingContexts"]) assert len(res) == 1 if not "namingContexts" in res[0]: @@ -145,7 +145,7 @@ class Ldb(ldb.Ldb): k = 0 while ++k < 10 and (previous_remaining != current_remaining): # and the rest - res2 = self.search(ldb.Dn(self, basedn), ldb.SCOPE_SUBTREE, "(|(objectclass=*)(dn=*))", ["dn"]) + res2 = self.search(basedn, ldb.SCOPE_SUBTREE, "(|(objectclass=*)(distinguishedName=*))", ["distinguishedName"]) previous_remaining = current_remaining current_remaining = len(res2) for msg in res2: diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index db3749f7211..d59cea121e8 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -20,7 +20,7 @@ import samba from samba import Ldb, substitute_var, valid_netbios_name from samba.samdb import SamDB import security -from ldb import Dn, SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError, \ +from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError, \ LDB_ERR_NO_SUCH_OBJECT, timestring, CHANGETYPE_MODIFY, CHANGETYPE_NONE """Functions for setting up a Samba configuration.""" @@ -64,7 +64,7 @@ def install_ok(lp, session_info, credentials): return False ldb = Ldb(lp.get("sam database"), session_info=session_info, credentials=credentials, lp=lp) - if len(ldb.search(ldb.Dn("(cn=Administrator)"))) != 1: + if len(ldb.search("(cn=Administrator)")) != 1: return False return True @@ -180,12 +180,6 @@ def provision_paths_from_lp(lp, dnsdomain): paths.dns_keytab = os.path.join(private_dir, "dns.keytab") paths.dns = os.path.join(private_dir, dnsdomain + ".zone") paths.winsdb = os.path.join(private_dir, "wins.ldb") - paths.ldap_basedn_ldif = os.path.join(private_dir, - dnsdomain + ".ldif") - paths.ldap_config_basedn_ldif = os.path.join(private_dir, - dnsdomain + "-config.ldif") - paths.ldap_schema_basedn_ldif = os.path.join(private_dir, - dnsdomain + "-schema.ldif") paths.s4_ldapi_path = os.path.join(private_dir, "ldapi") paths.phpldapadminconfig = os.path.join(private_dir, "phpldapadmin-config.php") @@ -465,7 +459,6 @@ def setup_samdb(path, setup_path, session_info, credentials, lp, setup_add_ldif(samdb, setup_path("provision_basedn.ldif"), { "DOMAINDN": domaindn, "ACI": aci, - "EXTENSIBLEOBJECT": "# no objectClass: extensibleObject for local ldb", "RDN_DC": rdn_dc, }) @@ -766,9 +759,9 @@ def provision(lp, setup_dir, message, blank, paths, session_info, samdb = SamDB(paths.samdb, session_info=session_info, credentials=credentials, lp=lp) - domainguid = samdb.searchone(Dn(samdb, domaindn), "objectGUID") + domainguid = samdb.searchone(domaindn, "objectGUID") assert isinstance(domainguid, str) - hostguid = samdb.searchone(Dn(samdb, domaindn), "objectGUID", + hostguid = samdb.searchone(domaindn, "objectGUID", expression="(&(objectClass=computer)(cn=%s))" % hostname, scope=SCOPE_SUBTREE) assert isinstance(hostguid, str) @@ -823,31 +816,6 @@ def create_zone_file(path, setup_path, samdb, dnsdomain, domaindn, }) -def provision_ldapbase(setup_dir, message, paths): - """Write out a DNS zone file, from the info in the current database.""" - message("Setting up LDAP base entry: %s" % domaindn) - rdns = domaindn.split(",") - - rdn_dc = rdns[0][len("DC="):] - - def setup_path(file): - return os.path.join(setup_dir, file) - - setup_file(setup_path("provision_basedn.ldif"), - paths.ldap_basedn_ldif) - - setup_file(setup_path("provision_configuration_basedn.ldif"), - paths.ldap_config_basedn_ldif) - - setup_file(setup_path("provision_schema_basedn.ldif"), - paths.ldap_schema_basedn_ldif, { - "SCHEMADN": schemadn, - "ACI": "# no aci for local ldb", - "EXTENSIBLEOBJECT": "objectClass: extensibleObject"}) - - message("Please install the LDIF located in " + paths.ldap_basedn_ldif + ", " + paths.ldap_config_basedn_ldif + " and " + paths.ldap_schema_basedn_ldif + " into your LDAP server, and re-run with --ldap-backend=ldap://my.ldap.server") - - def load_schema(setup_path, samdb, schemadn, netbiosname, configdn): """Load schema. diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py index 2af56d8d8eb..353eaee1984 100644 --- a/source4/scripting/python/samba/samdb.py +++ b/source4/scripting/python/samba/samdb.py @@ -60,7 +60,7 @@ description: %s :param sid: SID of the NT-side of the mapping. :param unixname: Unix name to map to. """ - res = self.search(ldb.Dn(self, domaindn), ldb.SCOPE_SUBTREE, + res = self.search(domaindn, ldb.SCOPE_SUBTREE, "objectSid=%s" % sid, ["dn"]) assert len(res) == 1, "Failed to find record for objectSid %s" % sid @@ -103,7 +103,7 @@ userAccountControl: %u res = self.search("", SCOPE_BASE, "defaultNamingContext=*", ["defaultNamingContext"]) assert(len(res) == 1 and res[0].defaultNamingContext is not None) - domain_dn = res[0].defaultNamingContext + domain_dn = res[0]["defaultNamingContext"][0] assert(domain_dn is not None) dom_users = self.searchone(domain_dn, "dn", "name=Domain Users") assert(dom_users is not None) diff --git a/source4/scripting/python/samba/tests/dcerpc/__init__.py b/source4/scripting/python/samba/tests/dcerpc/__init__.py new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/source4/scripting/python/samba/tests/dcerpc/__init__.py diff --git a/source4/scripting/python/samba/tests/dcerpc/registry.py b/source4/scripting/python/samba/tests/dcerpc/registry.py new file mode 100644 index 00000000000..f3f0b0fb1af --- /dev/null +++ b/source4/scripting/python/samba/tests/dcerpc/registry.py @@ -0,0 +1,50 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import winreg +from param import LoadParm +import unittest + +class WinregTests(unittest.TestCase): + def setUp(self): + lp_ctx = LoadParm() + lp_ctx.load("st/client/client.conf") + self.conn = winreg.winreg("ncalrpc:", lp_ctx) + + def get_hklm(self): + return self.conn.OpenHKLM(None, + winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS) + + def test_hklm(self): + handle = self.conn.OpenHKLM(None, + winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS) + self.conn.CloseKey(handle) + + def test_getversion(self): + handle = self.get_hklm() + version = self.conn.GetVersion(handle) + self.assertEquals(int, version.__class__) + self.conn.CloseKey(handle) + + def test_getkeyinfo(self): + handle = self.conn.OpenHKLM(None, + winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS) + x = self.conn.QueryInfoKey(handle, winreg.String()) + self.assertEquals(9, len(x)) # should return a 9-tuple + self.conn.CloseKey(handle) diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py new file mode 100644 index 00000000000..52c2bb8c72b --- /dev/null +++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py @@ -0,0 +1,44 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import echo +from param import LoadParm +import unittest + +class RpcEchoTests(unittest.TestCase): + def setUp(self): + lp_ctx = LoadParm() + lp_ctx.load("st/client/client.conf") + self.conn = echo.rpcecho("ncalrpc:", lp_ctx) + + def test_addone(self): + self.assertEquals(2, self.conn.AddOne(1)) + + def test_echodata(self): + self.assertEquals([1,2,3], self.conn.EchoData(3, [1, 2, 3])) + + def test_call(self): + self.assertEquals(u"foobar", self.conn.TestCall(u"foobar")) + + def test_surrounding(self): + surrounding_struct = echo.Surrounding() + surrounding_struct.x = 4 + surrounding_struct.surrounding = [1,2,3,4] + y = self.conn.TestSurrounding(surrounding_struct) + self.assertEquals(8 * [0], y.surrounding) diff --git a/source4/scripting/python/samba/tests/dcerpc/sam.py b/source4/scripting/python/samba/tests/dcerpc/sam.py new file mode 100644 index 00000000000..50caaf2348a --- /dev/null +++ b/source4/scripting/python/samba/tests/dcerpc/sam.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import samr +import unittest + +class SamrTests(unittest.TestCase): + def setUp(self): + self.conn = samr.samr("ncalrpc:", "st/client/client.conf") + + def test_connect5(self): + (level, info, handle) = self.conn.Connect5(None, 0, 1, samr.ConnectInfo1()) diff --git a/source4/scripting/python/uuidmodule.c b/source4/scripting/python/uuidmodule.c index 02c929d4a54..e05b286dd01 100644 --- a/source4/scripting/python/uuidmodule.c +++ b/source4/scripting/python/uuidmodule.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "Python.h" +#include <Python.h> #include "librpc/ndr/libndr.h" static PyObject *uuid_random(PyObject *self, PyObject *args) @@ -47,11 +47,9 @@ static PyMethodDef methods[] = { { NULL, NULL } }; -PyDoc_STRVAR(param_doc, "UUID helper routines"); - -PyMODINIT_FUNC inituuid(void) +void inituuid(void) { - PyObject *mod = Py_InitModule3((char *)"uuid", methods, param_doc); + PyObject *mod = Py_InitModule3((char *)"uuid", methods, "UUID helper routines"); if (mod == NULL) return; } |