The branch, master has been updated via 13bbfa3... pydsdb: Fix memory leak on invalid parameters, formatting, trivial typos. via ce28f85... s4 python: add a unit test for function dsdb_get_oid_from_attid via 634caed... s4 python: make the function dsdb_get_oid_from_attid reachable from a samDB object via d784ece... s4 python: Add a function to get the oid of an attribute when the attid is known via 9c2aed8... s4: Add python binding to waf so that the drsblobs.so is also built in waf via 6d9ce1f... s4: Fix python binding for drsblobs via b8d6f1c... s4 provision: Remove hard coded ACL for GPO objects from f1ecdb9... s4:setup/wscript_build: install dns_update_list into ${SETUPDIR}
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 13bbfa3fcabfc97a57ae56ef916bf13137fb5290 Author: Jelmer Vernooij <jel...@samba.org> Date: Thu Apr 15 18:41:56 2010 +0200 pydsdb: Fix memory leak on invalid parameters, formatting, trivial typos. commit ce28f854c0c8c62c6f13989ec4d2f9e890ffd0e1 Author: Matthieu Patou <m...@matws.net> Date: Wed Apr 14 00:46:51 2010 +0400 s4 python: add a unit test for function dsdb_get_oid_from_attid Signed-off-by: Jelmer Vernooij <jel...@samba.org> commit 634caed116d7e369d5a0002ab93d03744b2e0b1d Author: Matthieu Patou <m...@matws.net> Date: Sun Apr 11 02:02:50 2010 +0400 s4 python: make the function dsdb_get_oid_from_attid reachable from a samDB object Signed-off-by: Jelmer Vernooij <jel...@samba.org> commit d784ecec555a3d9737e6f4b3894f27904d2b833c Author: Matthieu Patou <m...@matws.net> Date: Tue Apr 13 00:51:00 2010 +0400 s4 python: Add a function to get the oid of an attribute when the attid is known This function is mainly to help decoding replPropertyMetaData in python Signed-off-by: Jelmer Vernooij <jel...@samba.org> commit 9c2aed862d2ecbc4047cd0326250096767731c05 Author: Matthieu Patou <m...@matws.net> Date: Tue Apr 13 01:00:08 2010 +0400 s4: Add python binding to waf so that the drsblobs.so is also built in waf Signed-off-by: Jelmer Vernooij <jel...@samba.org> commit 6d9ce1fee3a87ed0961c3d9e009008a98efd10c2 Author: Matthieu Patou <m...@matws.net> Date: Tue Apr 13 00:58:50 2010 +0400 s4: Fix python binding for drsblobs This binding needs symbols in drsblobs_c.c otherwise we have unresolved symbols Signed-off-by: Jelmer Vernooij <jel...@samba.org> commit b8d6f1ce892c36840d392021b528e8c3bdb875dd Author: Matthieu Patou <m...@matws.net> Date: Thu Apr 8 01:44:22 2010 +0400 s4 provision: Remove hard coded ACL for GPO objects It is no longer needed to hard code ACL for GPO object as we have now code that calculate ACL from defaultSecurityDescriptor and inheritance correctly. In fact the resulting ACL returned by this hard coded value is a bit wrong as some ACE are duplicated. Signed-off-by: Jelmer Vernooij <jel...@samba.org> ----------------------------------------------------------------------- Summary of changes: source4/dsdb/pydsdb.c | 44 ++++++++++++++++++++++++++ source4/librpc/config.mk | 2 +- source4/librpc/wscript_build | 6 +++ source4/scripting/python/samba/__init__.py | 3 ++ source4/scripting/python/samba/tests/dsdb.py | 42 ++++++++++++++++++++++++ source4/selftest/tests.sh | 1 + source4/setup/provision_group_policy.ldif | 2 - 7 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 source4/scripting/python/samba/tests/dsdb.py Changeset truncated at 500 lines: diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index 1d71c6b..88c6208 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -19,6 +19,7 @@ #include <Python.h> #include "includes.h" +#include "libcli/util/pyerrors.h" #include "dsdb/samdb/samdb.h" #include "lib/ldb/pyldb.h" #include "libcli/security/security.h" @@ -183,6 +184,47 @@ static PyObject *py_samdb_ntds_invocation_id(PyObject *self, PyObject *args) return result; } +static PyObject *py_dsdb_get_oid_from_attid(PyObject *self, PyObject *args) +{ + PyObject *py_ldb; + struct ldb_context *ldb; + uint32_t attid; + struct dsdb_schema *schema; + const char *oid; + PyObject *ret; + TALLOC_CTX *mem_ctx; + WERROR status; + + if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid)) + return NULL; + + mem_ctx = talloc_new(NULL); + if (mem_ctx == NULL) { + PyErr_NoMemory(); + return NULL; + } + + PyErr_LDB_OR_RAISE(py_ldb, ldb); + + schema = dsdb_get_schema(ldb, NULL); + + if (!schema) { + PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb \n"); + talloc_free(mem_ctx); + return NULL; + } + + status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attid, + mem_ctx, &oid); + PyErr_WERROR_IS_ERR_RAISE(status); + + ret = PyString_FromString(oid); + + talloc_free(mem_ctx); + + return ret; +} + static PyObject *py_dsdb_set_ntds_invocation_id(PyObject *self, PyObject *args) { PyObject *py_ldb, *py_guid; @@ -314,6 +356,8 @@ static PyMethodDef py_dsdb_methods[] = { "Get SID of domain in use." }, { "samdb_ntds_invocation_id", (PyCFunction)py_samdb_ntds_invocation_id, METH_VARARGS, "get the NTDS invocation ID GUID as a string"}, + { "dsdb_get_oid_from_attid", (PyCFunction)py_dsdb_get_oid_from_attid, + METH_VARARGS, NULL }, { "dsdb_set_ntds_invocation_id", (PyCFunction)py_dsdb_set_ntds_invocation_id, METH_VARARGS, NULL }, diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index c555ffc..650604b 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -721,7 +721,7 @@ python_drsuapi_OBJ_FILES = ../librpc/gen_ndr/py_drsuapi.o LIBRARY_REALNAME = samba/dcerpc/drsblobs.$(SHLIBEXT) PRIVATE_DEPENDENCIES = RPC_NDR_DRSBLOBS PYTALLOC pyparam_util pycredentials python_dcerpc -python_drsblobs_OBJ_FILES = ../librpc/gen_ndr/py_drsblobs.o +python_drsblobs_OBJ_FILES = ../librpc/gen_ndr/py_drsblobs.o ../librpc/gen_ndr/ndr_drsblobs.o [PYTHON::python_dcerpc_security] LIBRARY_REALNAME = samba/dcerpc/security.$(SHLIBEXT) diff --git a/source4/librpc/wscript_build b/source4/librpc/wscript_build index 6bcfac5..fb062e6 100644 --- a/source4/librpc/wscript_build +++ b/source4/librpc/wscript_build @@ -749,6 +749,12 @@ bld.SAMBA_PYTHON('python_dcerpc_security', realname='samba/dcerpc/security.so' ) +bld.SAMBA_PYTHON('python_dcerpc_drsblobs', + source='../../librpc/gen_ndr/py_drsblobs.c ../../librpc/gen_ndr/ndr_drsblobs_c.c', + deps='PYTALLOC python_dcerpc_misc python_dcerpc NDR_SECURITY', + realname='samba/dcerpc/drsblobs.so' + ) + bld.SAMBA_PYTHON('python_dcerpc_xattr', source='../../librpc/gen_ndr/py_xattr.c', diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index 682f400..67aac86 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -277,6 +277,9 @@ class Ldb(_Ldb): def set_schema_from_ldif(self, pf, df): _glue.dsdb_set_schema_from_ldif(self, pf, df) + def get_oid_from_attid(self, attid): + return dsdb.dsdb_get_oid_from_attid(self, attid) + def set_schema_from_ldb(self, ldb): _glue.dsdb_set_schema_from_ldb(self, ldb) diff --git a/source4/scripting/python/samba/tests/dsdb.py b/source4/scripting/python/samba/tests/dsdb.py new file mode 100644 index 0000000..86ec3ec --- /dev/null +++ b/source4/scripting/python/samba/tests/dsdb.py @@ -0,0 +1,42 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. Tests for dsdb +# Copyright (C) Matthieu Patou <m...@matws.net> 2010 +# +# 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 samba.dsdb +from samba.credentials import Credentials +from samba import Ldb +from samba.auth import system_session +from testtools.testcase import TestCase +import os + + +class DsdbTests(TestCase): + + def _baseprovpath(self): + return os.path.join(os.environ['SELFTEST_PREFIX'], "dc") + + def test_get_oid_from_attrid(self): + lp = samba.param.LoadParm() + lp.load(os.path.join(os.path.join(self._baseprovpath(), "etc"), "smb.conf")) + creds = Credentials() + creds.guess(lp) + session = system_session() + test_ldb = Ldb(os.path.join(self._baseprovpath(), "private", "sam.ldb"), + session_info=session, credentials=creds,lp=lp) + oid = samba.dsdb.dsdb_get_oid_from_attid(test_ldb, 591614) + self.assertEquals(oid, "1.2.840.113556.1.4.1790") diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index da0b4e3..f34612c 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -473,6 +473,7 @@ plantestsuite "samba.python" none $SUBUNITRUN samba.tests plantestsuite "provision.python" none $SUBUNITRUN samba.tests.provision plantestsuite "samba3.python" none $SUBUNITRUN samba.tests.samba3 plantestsuite "samr.python" dc:local $SUBUNITRUN samba.tests.dcerpc.sam +plantestsuite "dsdb.python" dc:local $SUBUNITRUN samba.tests.dsdb plantestsuite "netcmd.python" none $SUBUNITRUN samba.tests.netcmd plantestsuite "dcerpc.bare.python" dc:local $SUBUNITRUN samba.tests.dcerpc.bare plantestsuite "unixinfo.python" dc:local $SUBUNITRUN samba.tests.dcerpc.unix diff --git a/source4/setup/provision_group_policy.ldif b/source4/setup/provision_group_policy.ldif index 05981d8..20b162e 100644 --- a/source4/setup/provision_group_policy.ldif +++ b/source4/setup/provision_group_policy.ldif @@ -15,7 +15,6 @@ gPCUserExtensionNames: [{3060E8D0-7020-11D2-842D-00C04FA372D4}{3060E8CE-7020-1 1D2-842D-00C04FA372D4}][{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{0F6B957E-509E- 11D1-A7CC-0000F87571E3}] isCriticalSystemObject: TRUE -nTSecurityDescriptor: O:${DOMAINSID}-512G:${DOMAINSID}-512D:PAI(A;CI;RPWPCCDCLCLORCWOWDSDDTSW;;;${DOMAINSID}-512)(A;CI;RPWPCCDCLCLORCWOWDSDDTSW;;;${DOMAINSID}-519)(A;;RPWPCCDCLCLORCWOWDSDDTSW;;;${DOMAINSID}-512)(A;CIIO;RPWPCCDCLCLORCWOWDSDDTSW;;;CO)(A;CI;RPWPCCDCLCLORCWOWDSDDTSW;;;SY)(A;CI;RPLCLORC;;;AU)(OA;CI;CR;edacfd8f-ffb3-11d1-b41d-00a0c968f939;;AU)(A;CI;RPLCLORC;;;ED)S:AI(OU;CIIDSA;WPWD;;f30e3bc2-9ff0-11d1-b603-0000f80367c1;WD)(OU;CIIOIDSA;WP;f30e3bbe-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)(OU;CIIOIDSA;WP;f30e3bbf-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD) systemFlags: -1946157056 dn: CN=User,CN={${POLICYGUID}},CN=Policies,CN=System,${DOMAINDN} @@ -42,7 +41,6 @@ flags: 0 gPCMachineExtensionNames: [{827D319E-6EAC-11D2-A4EA-00C04F79F83A}{803E14A0-B4 FB-11D0-A0D0-00A0C90F574B}] isCriticalSystemObject: TRUE -nTSecurityDescriptor: O:${DOMAINSID}-512G:${DOMAINSID}-512D:PAI(A;CI;RPWPCCDCLCLORCWOWDSDDTSW;;;${DOMAINSID}-512)(A;CI;RPWPCCDCLCLORCWOWDSDDTSW;;;${DOMAINSID}-519)(A;;RPWPCCDCLCLORCWOWDSDDTSW;;;${DOMAINSID}-512)(A;CIIO;RPWPCCDCLCLORCWOWDSDDTSW;;;CO)(A;CI;RPWPCCDCLCLORCWOWDSDDTSW;;;SY)(A;CI;RPLCLORC;;;AU)(OA;CI;CR;edacfd8f-ffb3-11d1-b41d-00a0c968f939;;AU)(A;CI;RPLCLORC;;;ED)S:AI(OU;CIIDSA;WPWD;;f30e3bc2-9ff0-11d1-b603-0000f80367c1;WD)(OU;CIIOIDSA;WP;f30e3bbe-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)(OU;CIIOIDSA;WP;f30e3bbf-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD) systemFlags: -1946157056 dn: CN=User,CN={${POLICYGUID_DC}},CN=Policies,CN=System,${DOMAINDN} -- Samba Shared Repository