From 5b8ffcca53d40c8067531f75c658f856886ee095 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 10 Jan 2008 17:53:56 +0100 Subject: python: Update STATUS. (This used to be commit bcd82a9ae3cb01b3d8ed0c36999f7a1c0bbab19a) --- source4/scripting/python/STATUS | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/STATUS b/source4/scripting/python/STATUS index c82275fff8d..f2f1641658e 100644 --- a/source4/scripting/python/STATUS +++ b/source4/scripting/python/STATUS @@ -1,7 +1,6 @@ -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 failing tests +provisioning in LDAP mode(TEST_LDAP=yes PROVISION_PYTHON=yes make test) command-line vampire provisioning: combine some of the python dictionaries hierarchy @@ -21,3 +20,4 @@ DCE/RPC bindings not important before making Python the default: - scripting/python/samba/upgrade.py - install python modules into system +- SWAT -- cgit From 63bbb9239848beb376d8ffacd787e3fde7cd77e7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 11 Jan 2008 04:07:14 +0100 Subject: Python: Update STATUS. (This used to be commit cbf3b74e5f5076d864b08c772f21b20751ea5163) --- source4/scripting/python/STATUS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/STATUS b/source4/scripting/python/STATUS index f2f1641658e..5972027f592 100644 --- a/source4/scripting/python/STATUS +++ b/source4/scripting/python/STATUS @@ -1,5 +1,5 @@ dsdb/samdb/ldb_modules/tests/samba3sam.py: Fix remaining failing tests -lib/ldb/tests/python/ldap.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 -- cgit From 7c3e8c838f0ada9ebae9dbb2bc5d84320c8431f2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 11 Jan 2008 16:13:46 +0100 Subject: Python: Simplify code in a couple of places. Copy Andrew's changes from g53b5166. (This used to be commit f056f624958af79204c972eba3f85e36e93daed7) --- source4/scripting/python/samba/__init__.py | 12 ++++++------ source4/scripting/python/samba/provision.py | 8 ++++---- source4/scripting/python/samba/samdb.py | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index e0b9e1d4104..e8581801692 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -112,15 +112,15 @@ 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)))", + "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", ["dn"]): try: self.delete(msg.dn) @@ -128,12 +128,12 @@ class Ldb(ldb.Ldb): # 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=*))(!(distinguisedName=@BASEINFO)))", ["dn"]) 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..1607cb343bf 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 @@ -766,9 +766,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) 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) -- cgit From 378dff1365801b2dd23677a38f2fb20828cbbf39 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 11 Jan 2008 16:28:17 +0100 Subject: python: Fix typo. (This used to be commit d6b06fc03e37781f5f59b15cff8fe3ee8df63444) --- source4/scripting/python/samba/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index e8581801692..483929661da 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -121,14 +121,14 @@ class Ldb(ldb.Ldb): # and the rest for msg in self.search(basedn, ldb.SCOPE_SUBTREE, "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", - ["dn"]): + ["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=*)(distinguishedName=*))(!(distinguisedName=@BASEINFO)))", ["dn"]) + res = self.search(basedn, ldb.SCOPE_SUBTREE, "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", ["distinguishedName"]) assert len(res) == 0 def erase_partitions(self): -- cgit From 53c33aa2b42732304f247798a4dbe3bcae14e407 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 03:32:44 +0100 Subject: python: Avoid PyDoc_STRVAR() macro which doesn't exist in Python2.2. (This used to be commit dec3f421be5d7fd4ead3b71f8b69921c41bad39a) --- source4/scripting/python/uuidmodule.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/uuidmodule.c b/source4/scripting/python/uuidmodule.c index 02c929d4a54..9b952d31b9b 100644 --- a/source4/scripting/python/uuidmodule.c +++ b/source4/scripting/python/uuidmodule.c @@ -18,7 +18,7 @@ */ #include "includes.h" -#include "Python.h" +#include #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) { - PyObject *mod = Py_InitModule3((char *)"uuid", methods, param_doc); + PyObject *mod = Py_InitModule3((char *)"uuid", methods, "UUID helper routines"); if (mod == NULL) return; } -- cgit From c264fb4bde955ede94b82b5e98308553ecab93f2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 04:17:04 +0100 Subject: python: Try more possible flags. The flags returned by python-config may be for gcc and may not work for other compilers. (This used to be commit 1fbc3a9f47a33f785d935e39345021d9ca455bb9) --- source4/scripting/python/config.m4 | 65 ++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 31 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4 index 326cef8440f..6cf667a338e 100644 --- a/source4/scripting/python/config.m4 +++ b/source4/scripting/python/config.m4 @@ -13,6 +13,30 @@ 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 + #include + ],[ + Py_InitModule(NULL, NULL); + ],[ + PYTHON_LDFLAGS="$1" + PYTHON_CFLAGS="$2" + working_python=yes + ]) + LIBS="$ac_save_LIBS" + CFLAGS="$ac_save_CFLAGS" + fi +]) + + if test -z "$PYTHON_VERSION"; then AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config]) else @@ -23,50 +47,29 @@ 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 + TRY_LINK_PYTHON($PYTHON_LDFLAGS, $PYTHON_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 - #include - ],[ - 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 SMB_ENABLE(EXT_LIB_PYTHON,NO) SMB_ENABLE(LIBPYTHONyy,NO) SMB_ENABLE(smbpython,NO) AC_MSG_RESULT([no]) fi + -- cgit From 2c90e6fc7a2c0858babaa45f3bf969238739aabf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 04:23:09 +0100 Subject: python: Fix initialization of variable. (This used to be commit 620ec696657558dbad2a6c7d4231deabcaeaaef1) --- source4/scripting/python/config.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4 index 6cf667a338e..b0884478c15 100644 --- a/source4/scripting/python/config.m4 +++ b/source4/scripting/python/config.m4 @@ -36,6 +36,8 @@ AC_DEFUN([TRY_LINK_PYTHON], 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]) @@ -44,7 +46,6 @@ else fi if test -z "$PYTHON_CONFIG"; then - working_python=no AC_MSG_WARN([No python-config found]) else TRY_LINK_PYTHON([`$PYTHON_CONFIG --ldflags`], [`$PYTHON_CONFIG --includes`]) -- cgit From 6ef36c1f82fa9d48a3418f25202cab55b2f54d2f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 06:07:20 +0100 Subject: python: Avoid PyMODINIT_FUNC because it doesn't exist in older pythons. (This used to be commit e179db6d0fcf093082f2ad441980a2bb77ac6b17) --- source4/scripting/python/uuidmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/uuidmodule.c b/source4/scripting/python/uuidmodule.c index 9b952d31b9b..e05b286dd01 100644 --- a/source4/scripting/python/uuidmodule.c +++ b/source4/scripting/python/uuidmodule.c @@ -47,7 +47,7 @@ static PyMethodDef methods[] = { { NULL, NULL } }; -PyMODINIT_FUNC inituuid(void) +void inituuid(void) { PyObject *mod = Py_InitModule3((char *)"uuid", methods, "UUID helper routines"); if (mod == NULL) -- cgit From ecf52b2bc7c55fdc574f8dc58e90a9f52bdf1925 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 14:59:16 +0100 Subject: python: Avoid overwriting flags for already found version of Python. (This used to be commit 9041e385fe666c16d9a5b9a030b54a856f17e5e5) --- source4/scripting/python/config.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4 index b0884478c15..4f46f92682e 100644 --- a/source4/scripting/python/config.m4 +++ b/source4/scripting/python/config.m4 @@ -54,9 +54,9 @@ fi 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'))"` - TRY_LINK_PYTHON($PYTHON_LDFLAGS, $PYTHON_CFLAGS) + 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]) -- cgit From 252675a5788059dbcc49b175b56fa6c6a35ef74a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 16:44:42 +0100 Subject: python: Add some utility functions for working with Python objects based on talloc pointers. (This used to be commit 9366ddba92e192cd88e12eafba4a90af8c266f1c) --- source4/scripting/python/pytalloc.c | 34 +++++++++++++++++++++++++++++ source4/scripting/python/pytalloc.h | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 source4/scripting/python/pytalloc.c create mode 100644 source4/scripting/python/pytalloc.h (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c new file mode 100644 index 00000000000..55ed56a6278 --- /dev/null +++ b/source4/scripting/python/pytalloc.c @@ -0,0 +1,34 @@ +/* + Unix SMB/CIFS implementation. + Python/Talloc glue + Copyright (C) Jelmer Vernooij 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 . +*/ + +#include "includes.h" + +void py_talloc_dealloc(PyObject* self) +{ + py_talloc_Object *obj = (py_talloc_Object *)self; + talloc_free(obj->object); + PyObject_Del(self); +} + +PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr) +{ + PyObject *ret = PyObject_New(py_talloc_Object, &py_type); + ret->talloc_ptr = talloc_reference(NULL, ptr); + return ret; +} diff --git a/source4/scripting/python/pytalloc.h b/source4/scripting/python/pytalloc.h new file mode 100644 index 00000000000..93f6b48d829 --- /dev/null +++ b/source4/scripting/python/pytalloc.h @@ -0,0 +1,43 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij 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 . +*/ + +#ifndef _PY_TALLOC_H_ +#define _PY_TALLOC_H_ + +#include + +typedef struct { + PyObject_HEAD + void *talloc_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_Object *)py_obj)->talloc_ptr, type) + +PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr); + +#endif /* _PY_TALLOC_H_ */ -- cgit From f7a0ef04f00cd44845bcee0a171e4cc05a545350 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 18:38:12 +0100 Subject: pidl/python: Support repr() for python types. (This used to be commit cf3664594d3540db20d32bc844f18e20abfa0d96) --- source4/scripting/python/pytalloc.c | 10 +++++++++- source4/scripting/python/pytalloc.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c index 55ed56a6278..4032ff75a4b 100644 --- a/source4/scripting/python/pytalloc.c +++ b/source4/scripting/python/pytalloc.c @@ -22,7 +22,7 @@ void py_talloc_dealloc(PyObject* self) { py_talloc_Object *obj = (py_talloc_Object *)self; - talloc_free(obj->object); + talloc_free(obj->talloc_ptr); PyObject_Del(self); } @@ -32,3 +32,11 @@ PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr) ret->talloc_ptr = talloc_reference(NULL, ptr); return ret; } + +PyObject *py_talloc_default_repr(PyObject *py_obj) +{ + py_talloc_Object *obj = (py_talloc_Object *)py_obj; + + return PyString_FromFormat("", + talloc_get_name(obj->talloc_ptr)); +} diff --git a/source4/scripting/python/pytalloc.h b/source4/scripting/python/pytalloc.h index 93f6b48d829..735829bfcba 100644 --- a/source4/scripting/python/pytalloc.h +++ b/source4/scripting/python/pytalloc.h @@ -40,4 +40,7 @@ void py_talloc_dealloc(PyObject* self); PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr); +/* Sane default implementation of reprfunc. */ +PyObject *py_talloc_default_repr(PyObject *py_obj); + #endif /* _PY_TALLOC_H_ */ -- cgit From bfab9862fcdd657a1bddafde49cdd182f89fcf8b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Jan 2008 20:41:34 +0100 Subject: python: Allow wrapping pointers within talloc'ed memory that are not talloc contexts. (This used to be commit 9c038a74113fb55ed5eb12a7d0ae4a46bad9050c) --- source4/scripting/python/pytalloc.c | 10 ++++++---- source4/scripting/python/pytalloc.h | 11 ++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c index 4032ff75a4b..d0b8cb83f20 100644 --- a/source4/scripting/python/pytalloc.c +++ b/source4/scripting/python/pytalloc.c @@ -22,14 +22,16 @@ void py_talloc_dealloc(PyObject* self) { py_talloc_Object *obj = (py_talloc_Object *)self; - talloc_free(obj->talloc_ptr); + talloc_free(obj->talloc_ctx); PyObject_Del(self); } -PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr) +PyObject *py_talloc_import(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, + void *ptr) { PyObject *ret = PyObject_New(py_talloc_Object, &py_type); - ret->talloc_ptr = talloc_reference(NULL, ptr); + ret->talloc_ctx = talloc_reference(mem_ctx, ptr); + ret->ptr = ptr; return ret; } @@ -38,5 +40,5 @@ PyObject *py_talloc_default_repr(PyObject *py_obj) py_talloc_Object *obj = (py_talloc_Object *)py_obj; return PyString_FromFormat("", - talloc_get_name(obj->talloc_ptr)); + talloc_get_name(obj->talloc_ctx)); } diff --git a/source4/scripting/python/pytalloc.h b/source4/scripting/python/pytalloc.h index 735829bfcba..aad5840a672 100644 --- a/source4/scripting/python/pytalloc.h +++ b/source4/scripting/python/pytalloc.h @@ -24,7 +24,8 @@ typedef struct { PyObject_HEAD - void *talloc_ptr; + TALLOC_CTX *talloc_ctx; + void *ptr; } py_talloc_Object; /* Deallocate a py_talloc_Object */ @@ -36,9 +37,13 @@ void py_talloc_dealloc(PyObject* self); /* 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_Object *)py_obj)->talloc_ptr, type) + talloc_get_type(py_talloc_get_ptr(py_obj), type) -PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr); +#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); -- cgit From d5903fd75e9640831f0e78fc04d3ffa5ea3b1b4a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 02:48:50 +0100 Subject: pidl/python: Fix compilation of py_echo. (This used to be commit 5ee99ff31c80ece6861b2a0323d71170ef9346b9) --- source4/scripting/python/config.mk | 2 +- source4/scripting/python/pytalloc.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index cfd179aff5c..f00b4779199 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 diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c index d0b8cb83f20..dc61a0a13d7 100644 --- a/source4/scripting/python/pytalloc.c +++ b/source4/scripting/python/pytalloc.c @@ -18,6 +18,7 @@ */ #include "includes.h" +#include "scripting/python/pytalloc.h" void py_talloc_dealloc(PyObject* self) { @@ -26,13 +27,13 @@ void py_talloc_dealloc(PyObject* self) PyObject_Del(self); } -PyObject *py_talloc_import(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, +PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr) { - PyObject *ret = PyObject_New(py_talloc_Object, &py_type); + py_talloc_Object *ret = PyObject_New(py_talloc_Object, py_type); ret->talloc_ctx = talloc_reference(mem_ctx, ptr); ret->ptr = ptr; - return ret; + return (PyObject *)ret; } PyObject *py_talloc_default_repr(PyObject *py_obj) -- cgit From db4ee4cce5f1fd84f3f0a331e769a70394126ca5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 03:59:36 +0100 Subject: python: Fix rpcecho tests. (This used to be commit ebb78ea4232c1614755844849580e3697b0a53fa) --- source4/scripting/python/STATUS | 5 --- .../python/samba/tests/dcerpc/__init__.py | 0 .../scripting/python/samba/tests/dcerpc/rpcecho.py | 39 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 source4/scripting/python/samba/tests/dcerpc/__init__.py create mode 100644 source4/scripting/python/samba/tests/dcerpc/rpcecho.py (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/STATUS b/source4/scripting/python/STATUS index 5972027f592..9a1c5b1b646 100644 --- a/source4/scripting/python/STATUS +++ b/source4/scripting/python/STATUS @@ -9,11 +9,6 @@ DCE/RPC bindings 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 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 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..cedd0cc2fee --- /dev/null +++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py @@ -0,0 +1,39 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij 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 . +# + +import echo +import unittest + +class RpcEchoTests(unittest.TestCase): + def setUp(self): + self.conn = echo.rpcecho("ncalrpc:") + + def test_addone(self): + self.assertEquals(2, conn.AddOne(1)) + + def test_echodata(self): + self.assertEquals("bla", conn.EchoData(3, "bla")) + + def test_call(self): + self.assertEquals("foobar", conn.TestCall("foobar")) + + def test_surrounding(self): + somearray = [1,2,3,4] + (y,) = conn.TestSurrounding(echo.Surrounding(4, somearray)) + self.assertEquals(8 * [0], y.surrounding) -- cgit From 3b16c532f21202696d54ef87f8fa74d066812898 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 05:16:51 +0100 Subject: pidl/python: Pass credentials and loadparm context when connecting using DCE/RPC. (This used to be commit 4c87af95310e4aaee3f2e2da02d0ea70ed1ec25b) --- source4/scripting/python/samba/tests/dcerpc/rpcecho.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py index cedd0cc2fee..52a4f49bb49 100644 --- a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py +++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py @@ -18,22 +18,25 @@ # import echo +from param import LoadParm import unittest class RpcEchoTests(unittest.TestCase): def setUp(self): - self.conn = echo.rpcecho("ncalrpc:") + lp_ctx = LoadParm() + lp_ctx.load("st/client/client.conf") + self.conn = echo.rpcecho("ncalrpc:", lp_ctx) def test_addone(self): - self.assertEquals(2, conn.AddOne(1)) + self.assertEquals(2, self.conn.AddOne(1)) def test_echodata(self): - self.assertEquals("bla", conn.EchoData(3, "bla")) + self.assertEquals("bla", self.conn.EchoData(3, "bla")) def test_call(self): - self.assertEquals("foobar", conn.TestCall("foobar")) + self.assertEquals("foobar", self.conn.TestCall("foobar")) def test_surrounding(self): somearray = [1,2,3,4] - (y,) = conn.TestSurrounding(echo.Surrounding(4, somearray)) + (y,) = self.conn.TestSurrounding(echo.Surrounding(4, somearray)) self.assertEquals(8 * [0], y.surrounding) -- cgit From aca6bd5a2a2c5fe266509499be624bbab7b5c3c0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 06:03:33 +0100 Subject: python: Fix deallocation bug in pytalloc. (This used to be commit b849b4a6c4c9b03a9704449a69f00a59fc0df9c5) --- source4/scripting/python/pytalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c index dc61a0a13d7..d8d3efe69c1 100644 --- a/source4/scripting/python/pytalloc.c +++ b/source4/scripting/python/pytalloc.c @@ -31,7 +31,7 @@ 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(mem_ctx, ptr); + ret->talloc_ctx = talloc_reference(NULL, mem_ctx); ret->ptr = ptr; return (PyObject *)ret; } -- cgit From 271f5f18f2c871cfba256f7088839e4eb195e289 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 06:05:28 +0100 Subject: python: Fix last bugs in rpcecho test. It passes now! (This used to be commit 25a0cd091bb24e579ceb34472d9c213aae157ba9) --- source4/scripting/python/samba/tests/dcerpc/rpcecho.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py index 52a4f49bb49..52c2bb8c72b 100644 --- a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py +++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py @@ -31,12 +31,14 @@ class RpcEchoTests(unittest.TestCase): self.assertEquals(2, self.conn.AddOne(1)) def test_echodata(self): - self.assertEquals("bla", self.conn.EchoData(3, "bla")) + self.assertEquals([1,2,3], self.conn.EchoData(3, [1, 2, 3])) def test_call(self): - self.assertEquals("foobar", self.conn.TestCall("foobar")) + self.assertEquals(u"foobar", self.conn.TestCall(u"foobar")) def test_surrounding(self): - somearray = [1,2,3,4] - (y,) = self.conn.TestSurrounding(echo.Surrounding(4, somearray)) + 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) -- cgit From e42322848b81a36528a0af88138acb3ec997bf01 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 13:26:21 +0100 Subject: python: Start building winreg module. (This used to be commit f1a9fad83cee7754304b3422aa273d5f64868e40) --- source4/scripting/python/modules.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index 55df51d881e..5e53aadb943 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -35,6 +35,7 @@ extern void init_events(void); extern void inituuid(void); extern void init_net(void); extern void initecho(void); +extern void initwinreg(void); static struct _inittab py_modules[] = { STATIC_LIBPYTHON_MODULES }; -- cgit From 7dd468ff2e5a4c4ce503e1b8e024bf91dcf7a412 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 14:48:59 +0100 Subject: python: Fix python code for winreg, add test. (This used to be commit bd3e6c41c42738fcfcc5cef4e65f0e219d358260) --- source4/scripting/python/STATUS | 1 - .../python/samba/tests/dcerpc/registry.py | 53 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 source4/scripting/python/samba/tests/dcerpc/registry.py (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/STATUS b/source4/scripting/python/STATUS index 9a1c5b1b646..0e88b4041c1 100644 --- a/source4/scripting/python/STATUS +++ b/source4/scripting/python/STATUS @@ -10,7 +10,6 @@ DCE/RPC bindings - wrap struct/bitmap/enum/union types - __ndr_pack__/__ndr_unpack__ members - scripting/bin/smbstatus.py - - scripting/bin/winreg.py not important before making Python the default: - scripting/python/samba/upgrade.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..7979592a400 --- /dev/null +++ b/source4/scripting/python/samba/tests/dcerpc/registry.py @@ -0,0 +1,53 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij 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 . +# + + +#!/usr/bin/python + +# Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij 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 . +# + +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 test_hklm(self): + (handle, _) = self.conn.OpenHKLM(None, + winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS) + self.conn.CloseKey(handle) -- cgit From 035599fa651409502a6894179d5cd8a026110ba1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 15:25:09 +0100 Subject: python: Be more pythonic - turn WERROR and NTSTATUS return codes into exceptions. (This used to be commit 16fc69b843e92ae62b15caf927335cc117156499) --- .../python/samba/tests/dcerpc/registry.py | 39 ++++++++++------------ 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/tests/dcerpc/registry.py b/source4/scripting/python/samba/tests/dcerpc/registry.py index 7979592a400..f3f0b0fb1af 100644 --- a/source4/scripting/python/samba/tests/dcerpc/registry.py +++ b/source4/scripting/python/samba/tests/dcerpc/registry.py @@ -17,26 +17,6 @@ # along with this program. If not, see . # - -#!/usr/bin/python - -# Unix SMB/CIFS implementation. -# Copyright (C) Jelmer Vernooij 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 . -# - import winreg from param import LoadParm import unittest @@ -47,7 +27,24 @@ class WinregTests(unittest.TestCase): 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, + 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) -- cgit From fa5397fbeda759ac66fc5d0a6bdfb60a070a7962 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 16:11:58 +0100 Subject: python: Build epmapper module. (This used to be commit 6cb78c7634de0f9ab327583844d7860d384356eb) --- source4/scripting/python/modules.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index 5e53aadb943..d8a5fdeeaee 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -36,6 +36,9 @@ 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) {} static struct _inittab py_modules[] = { STATIC_LIBPYTHON_MODULES }; -- cgit From a896c8940ca372808c0725bc4f2725f6cb8467b8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 16:48:27 +0100 Subject: python: Enable python bindings for samr and lsa interfaces. (This used to be commit 3dfcefd8ac640ef1539185f19f7414fbcea9e741) --- source4/scripting/python/modules.c | 3 +++ source4/scripting/python/pyrpc.h | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 source4/scripting/python/pyrpc.h (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index d8a5fdeeaee..8c5115efca0 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -39,6 +39,9 @@ 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 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..d7b64dbe935 --- /dev/null +++ b/source4/scripting/python/pyrpc.h @@ -0,0 +1,27 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij 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 . +*/ + +#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 -- cgit From 860106b3f426a06eed6a681fa839dd89f339ba9a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 16:49:19 +0100 Subject: python: Move some convenience macros to a separate header rather than putting them in every generated py_* file. (This used to be commit 712274b9bdf524da125cbbe6e4bb475b21b1da66) --- source4/scripting/python/pyrpc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/pyrpc.h b/source4/scripting/python/pyrpc.h index d7b64dbe935..5390c6923da 100644 --- a/source4/scripting/python/pyrpc.h +++ b/source4/scripting/python/pyrpc.h @@ -25,3 +25,5 @@ #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 -- cgit From d28eb21a984a733e8f1de51170e41ae7c879f7e9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 18:59:11 +0100 Subject: python: Compile security module, handle uint. (This used to be commit dee64344fb13aaed38a550ebb4048d0fa526d5b6) --- source4/scripting/python/modules.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index 8c5115efca0..1728f166bdc 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -42,6 +42,8 @@ static void initdcerpc_misc(void) {} extern void initmgmt(void); extern void initatsvc(void); extern void initsamr(void); +extern void initsecurity(void); +extern void initlsa(void); static struct _inittab py_modules[] = { STATIC_LIBPYTHON_MODULES }; -- cgit From 001b2435f0a47f75f82a32f2ccead2759596a09d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 19:05:08 +0100 Subject: python: Add simple test for samr python code. (This used to be commit 0a039fabcba9510ab600b2e4becbf75a58d2134d) --- source4/scripting/python/samba/tests/dcerpc/sam.py | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 source4/scripting/python/samba/tests/dcerpc/sam.py (limited to 'source4/scripting/python') 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 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 . +# + +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()) -- cgit From 2aa8cbca8baf1159544c2f3c0ce316da03035d71 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 19:49:52 +0100 Subject: python: Work around the fact that there are two "security" modules now. This well demonstrates the fact we need hierarchy. (This used to be commit df7e3498824e27f8a6d61b8b6f52577eab248d2c) --- source4/scripting/python/modules.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index 1728f166bdc..c953e9866cb 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -42,7 +42,7 @@ static void initdcerpc_misc(void) {} extern void initmgmt(void); extern void initatsvc(void); extern void initsamr(void); -extern void initsecurity(void); +static void initdcerpc_security(void) {} extern void initlsa(void); static struct _inittab py_modules[] = { STATIC_LIBPYTHON_MODULES }; -- cgit From 506f6432882804ed62fd3b8c1ddc2a4ac80fa08d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 20:08:04 +0100 Subject: python: Compile in svcctl Python bindings. (This used to be commit 567099b66d0369715f8e0a083a5ce160faaf4da2) --- source4/scripting/python/modules.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index c953e9866cb..dc6e79fe1a3 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -44,6 +44,7 @@ extern void initatsvc(void); extern void initsamr(void); static void initdcerpc_security(void) {} extern void initlsa(void); +extern void initsvcctl(void); static struct _inittab py_modules[] = { STATIC_LIBPYTHON_MODULES }; -- cgit From d869de531c9f6b81c7eca43c3bfaab294c14cab1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 20:14:53 +0100 Subject: python: Enable building of the wkssvc python bindings. (This used to be commit 7a00d48a478be84e9f38c5e6cb57739063d0d613) --- source4/scripting/python/modules.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index dc6e79fe1a3..b2dd50b5079 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -45,6 +45,7 @@ extern void initsamr(void); static void initdcerpc_security(void) {} extern void initlsa(void); extern void initsvcctl(void); +extern void initwkssvc(void); static struct _inittab py_modules[] = { STATIC_LIBPYTHON_MODULES }; -- cgit From 0c7f4c23b7c98b41dce1919aca78bc7b760659fe Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 15 Jan 2008 01:08:30 +0100 Subject: python: Update status. (This used to be commit b4b12f00a7eb952024795ddc5ab3481fd4ba03fc) --- source4/scripting/python/STATUS | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/STATUS b/source4/scripting/python/STATUS index 0e88b4041c1..6e6475bfdea 100644 --- a/source4/scripting/python/STATUS +++ b/source4/scripting/python/STATUS @@ -3,15 +3,13 @@ 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 - - scripting/bin/smbstatus.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 -- cgit From ad5bb10f707dddc0cea159af09393520128157d7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 23:04:57 +0100 Subject: python: Build shared python modules for generic use. (This used to be commit 502424955237ace5a276d4c91c62e95233ecd978) --- source4/scripting/python/config.mk | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index f00b4779199..450da0e90a6 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -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/* -- cgit From 064eb82870596e72373c290dfaf0e6b8289303de Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 18 Jan 2008 13:25:01 +1100 Subject: Remove --ldap-base from the python provision script (This is a merge from the ejs script) Andrew Bartlett (This used to be commit d822dfa017b84895222ace8c44935fb872930548) --- source4/scripting/python/samba/provision.py | 32 ----------------------------- 1 file changed, 32 deletions(-) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 1607cb343bf..d59cea121e8 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -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, }) @@ -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. -- cgit From 42a793107e79624644ddfcac960b23eae3362002 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 20 Jan 2008 18:04:19 +0100 Subject: python: Fix init functions. (This used to be commit 4b057b9bffcef9ecc61fe016746f5ce6f17f6d06) --- source4/scripting/python/modules.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/scripting/python') diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c index b2dd50b5079..fff981e9417 100644 --- a/source4/scripting/python/modules.c +++ b/source4/scripting/python/modules.c @@ -46,6 +46,8 @@ 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 }; -- cgit