[SCM] Samba Shared Repository - branch master updated
Jelmer Vernooij
jelmer at samba.org
Sat Apr 3 17:11:39 MDT 2010
The branch, master has been updated
via 55aeb68... s4-python: Move dsdb_convert_schema_to_openldap to dsdb.
via 2a67eda... s4-python: Move set_opaque_integer -> dsdb.
via ccd954f... s4-python: Avoid importing glue directly.
via aed295b... s4-python: Remove convenience macro PyErr_SetStringError.
via 8afd52a... s4-python: Move samdb_server_site_name to dsdb module.
via 31a517e... s4-python: Move dsdb constants to a separate python module.
from e5b33be... s4-python: Remove remaining constants.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 55aeb682ba157dc02d838381d1b5d9db166beaeb
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Apr 4 00:42:52 2010 +0200
s4-python: Move dsdb_convert_schema_to_openldap to dsdb.
commit 2a67eda98f88f132443bc2b81ca2686bcc1775a6
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Apr 4 00:40:01 2010 +0200
s4-python: Move set_opaque_integer -> dsdb.
commit ccd954f2a7534cc27afd17b23e2fc838e10cf6b3
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Apr 4 00:30:34 2010 +0200
s4-python: Avoid importing glue directly.
commit aed295b97e649ef7db4300cc400bc2bd9b1a03b0
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Apr 4 00:22:29 2010 +0200
s4-python: Remove convenience macro PyErr_SetStringError.
This macro assumed that all errors were runtime errors.
commit 8afd52a6418125100a5e8a6a4312c0460e57ac88
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Apr 4 00:21:09 2010 +0200
s4-python: Move samdb_server_site_name to dsdb module.
commit 31a517e1721fc0080473b376cd59c090cfab6456
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Apr 4 00:14:23 2010 +0200
s4-python: Move dsdb constants to a separate python module.
-----------------------------------------------------------------------
Summary of changes:
source4/auth/credentials/pycredentials.c | 2 +-
source4/dsdb/config.mk | 6 +
source4/dsdb/pydsdb.c | 212 ++++++++++++++++++++
source4/lib/ldb/tests/python/ldap.py | 7 +-
source4/lib/ldb/tests/python/ldap_schema.py | 37 +---
source4/lib/ldb/tests/python/sec_descriptor.py | 6 +-
source4/lib/ldb/tests/python/urgent_replication.py | 6 +-
source4/libcli/util/pyerrors.h | 3 -
source4/scripting/python/pyglue.c | 162 +---------------
source4/scripting/python/samba/__init__.py | 55 +----
.../scripting/python/samba/netcmd/domainlevel.py | 2 +-
source4/scripting/python/samba/provision.py | 21 +-
source4/scripting/python/samba/samdb.py | 5 +-
source4/scripting/python/samba/upgradehelpers.py | 3 +-
source4/setup/provision | 7 +-
15 files changed, 266 insertions(+), 268 deletions(-)
create mode 100644 source4/dsdb/pydsdb.c
Changeset truncated at 500 lines:
diff --git a/source4/auth/credentials/pycredentials.c b/source4/auth/credentials/pycredentials.c
index f5e8029..cd578a5 100644
--- a/source4/auth/credentials/pycredentials.c
+++ b/source4/auth/credentials/pycredentials.c
@@ -272,7 +272,7 @@ static PyObject *py_creds_get_named_ccache(py_talloc_Object *self, PyObject *arg
return PyCredentialCacheContainer_from_ccache_container(ccc);
}
- PyErr_SetStringError(error_string);
+ PyErr_SetString(PyExc_RuntimeError, error_string);
talloc_free(event_ctx);
return NULL;
diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk
index 356f732..69b7227 100644
--- a/source4/dsdb/config.mk
+++ b/source4/dsdb/config.mk
@@ -106,3 +106,9 @@ PRIVATE_DEPENDENCIES = \
DNS_UPDATE_SRV_OBJ_FILES = $(addprefix $(dsdbsrcdir)/dns/, \
dns_update.o)
+
+[PYTHON::python_dsdb]
+LIBRARY_REALNAME = samba/dsdb.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = SAMDB
+
+python_dsdb_OBJ_FILES = $(dsdbsrcdir)/pydsdb.o
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c
new file mode 100644
index 0000000..6e3e50a
--- /dev/null
+++ b/source4/dsdb/pydsdb.c
@@ -0,0 +1,212 @@
+/*
+ Unix SMB/CIFS implementation.
+ Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2007-2010
+ Copyright (C) Matthias Dieter Wallnöfer 2009
+
+ 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 <Python.h>
+#include "includes.h"
+#include "dsdb/samdb/samdb.h"
+#include "lib/ldb/pyldb.h"
+
+/* FIXME: These should be in a header file somewhere, once we finish moving
+ * away from SWIG .. */
+#define PyErr_LDB_OR_RAISE(py_ldb, ldb) \
+/* if (!PyLdb_Check(py_ldb)) { \
+ PyErr_SetString(py_ldb_get_exception(), "Ldb connection object required"); \
+ return NULL; \
+ } */\
+ ldb = PyLdb_AsLdbContext(py_ldb);
+
+static PyObject *py_samdb_server_site_name(PyObject *self, PyObject *args)
+{
+ PyObject *py_ldb, *result;
+ struct ldb_context *ldb;
+ const char *site;
+ TALLOC_CTX *mem_ctx;
+
+ if (!PyArg_ParseTuple(args, "O", &py_ldb))
+ return NULL;
+
+ PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+ mem_ctx = talloc_new(NULL);
+
+ site = samdb_server_site_name(ldb, mem_ctx);
+ if (site == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "Failed to find server site");
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ result = PyString_FromString(site);
+ talloc_free(mem_ctx);
+ return result;
+}
+
+/* XXX: This function really should be in pyldb.c */
+static PyObject *py_dsdb_set_opaque_integer(PyObject *self, PyObject *args)
+{
+ PyObject *py_ldb;
+ int value;
+ int *old_val, *new_val;
+ char *py_opaque_name, *opaque_name_talloc;
+ struct ldb_context *ldb;
+ TALLOC_CTX *tmp_ctx;
+
+ if (!PyArg_ParseTuple(args, "Osi", &py_ldb, &py_opaque_name, &value))
+ return NULL;
+
+ PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+ /* see if we have a cached copy */
+ old_val = (int *)ldb_get_opaque(ldb, py_opaque_name);
+ /* XXX: We shouldn't just blindly assume that the value that is
+ * already present has the size of an int and is not shared
+ * with other code that may rely on it not changing.
+ * JRV 20100403 */
+
+ if (old_val) {
+ *old_val = value;
+ Py_RETURN_NONE;
+ }
+
+ tmp_ctx = talloc_new(ldb);
+ if (tmp_ctx == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ new_val = talloc(tmp_ctx, int);
+ if (new_val == NULL) {
+ talloc_free(tmp_ctx);
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ opaque_name_talloc = talloc_strdup(tmp_ctx, py_opaque_name);
+ if (opaque_name_talloc == NULL) {
+ talloc_free(tmp_ctx);
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ *new_val = value;
+
+ /* cache the domain_sid in the ldb */
+ if (ldb_set_opaque(ldb, opaque_name_talloc, new_val) != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ PyErr_SetString(PyExc_RuntimeError,
+ "Failed to set opaque integer into the ldb");
+ return NULL;
+ }
+
+ talloc_steal(ldb, new_val);
+ talloc_steal(ldb, opaque_name_talloc);
+ talloc_free(tmp_ctx);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *py_dsdb_convert_schema_to_openldap(PyObject *self,
+ PyObject *args)
+{
+ char *target_str, *mapping;
+ PyObject *py_ldb;
+ struct ldb_context *ldb;
+ PyObject *ret;
+ char *retstr;
+
+ if (!PyArg_ParseTuple(args, "Oss", &py_ldb, &target_str, &mapping))
+ return NULL;
+
+ PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+ retstr = dsdb_convert_schema_to_openldap(ldb, target_str, mapping);
+ if (retstr == NULL) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "dsdb_convert_schema_to_openldap failed");
+ return NULL;
+ }
+
+ ret = PyString_FromString(retstr);
+ talloc_free(retstr);
+ return ret;
+}
+
+static PyMethodDef py_dsdb_methods[] = {
+ { "samdb_server_site_name", (PyCFunction)py_samdb_server_site_name,
+ METH_VARARGS, "Get the server site name as a string"},
+ { "dsdb_set_opaque_integer", (PyCFunction)py_dsdb_set_opaque_integer,
+ METH_VARARGS, NULL },
+ { "dsdb_convert_schema_to_openldap",
+ (PyCFunction)py_dsdb_convert_schema_to_openldap, METH_VARARGS,
+ "dsdb_convert_schema_to_openldap(ldb, target_str, mapping) -> str\n"
+ "Create an OpenLDAP schema from a schema." },
+ { NULL }
+};
+
+void initdsdb(void)
+{
+ PyObject *m;
+
+ m = Py_InitModule3("dsdb", py_dsdb_methods,
+ "Python bindings for the directory service databases.");
+ if (m == NULL)
+ return;
+
+ /* "userAccountControl" flags */
+ PyModule_AddObject(m, "UF_NORMAL_ACCOUNT", PyInt_FromLong(UF_NORMAL_ACCOUNT));
+ PyModule_AddObject(m, "UF_TEMP_DUPLICATE_ACCOUNT", PyInt_FromLong(UF_TEMP_DUPLICATE_ACCOUNT));
+ PyModule_AddObject(m, "UF_SERVER_TRUST_ACCOUNT", PyInt_FromLong(UF_SERVER_TRUST_ACCOUNT));
+ PyModule_AddObject(m, "UF_WORKSTATION_TRUST_ACCOUNT", PyInt_FromLong(UF_WORKSTATION_TRUST_ACCOUNT));
+ PyModule_AddObject(m, "UF_INTERDOMAIN_TRUST_ACCOUNT", PyInt_FromLong(UF_INTERDOMAIN_TRUST_ACCOUNT));
+ PyModule_AddObject(m, "UF_PASSWD_NOTREQD", PyInt_FromLong(UF_PASSWD_NOTREQD));
+ PyModule_AddObject(m, "UF_ACCOUNTDISABLE", PyInt_FromLong(UF_ACCOUNTDISABLE));
+
+ /* "groupType" flags */
+ PyModule_AddObject(m, "GTYPE_SECURITY_BUILTIN_LOCAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_BUILTIN_LOCAL_GROUP));
+ PyModule_AddObject(m, "GTYPE_SECURITY_GLOBAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_GLOBAL_GROUP));
+ PyModule_AddObject(m, "GTYPE_SECURITY_DOMAIN_LOCAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_DOMAIN_LOCAL_GROUP));
+ PyModule_AddObject(m, "GTYPE_SECURITY_UNIVERSAL_GROUP", PyInt_FromLong(GTYPE_SECURITY_UNIVERSAL_GROUP));
+ PyModule_AddObject(m, "GTYPE_DISTRIBUTION_GLOBAL_GROUP", PyInt_FromLong(GTYPE_DISTRIBUTION_GLOBAL_GROUP));
+ PyModule_AddObject(m, "GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP", PyInt_FromLong(GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP));
+ PyModule_AddObject(m, "GTYPE_DISTRIBUTION_UNIVERSAL_GROUP", PyInt_FromLong(GTYPE_DISTRIBUTION_UNIVERSAL_GROUP));
+
+ /* "sAMAccountType" flags */
+ PyModule_AddObject(m, "ATYPE_NORMAL_ACCOUNT", PyInt_FromLong(ATYPE_NORMAL_ACCOUNT));
+ PyModule_AddObject(m, "ATYPE_WORKSTATION_TRUST", PyInt_FromLong(ATYPE_WORKSTATION_TRUST));
+ PyModule_AddObject(m, "ATYPE_INTERDOMAIN_TRUST", PyInt_FromLong(ATYPE_INTERDOMAIN_TRUST));
+ PyModule_AddObject(m, "ATYPE_SECURITY_GLOBAL_GROUP", PyInt_FromLong(ATYPE_SECURITY_GLOBAL_GROUP));
+ PyModule_AddObject(m, "ATYPE_SECURITY_LOCAL_GROUP", PyInt_FromLong(ATYPE_SECURITY_LOCAL_GROUP));
+ PyModule_AddObject(m, "ATYPE_SECURITY_UNIVERSAL_GROUP", PyInt_FromLong(ATYPE_SECURITY_UNIVERSAL_GROUP));
+ PyModule_AddObject(m, "ATYPE_DISTRIBUTION_GLOBAL_GROUP", PyInt_FromLong(ATYPE_DISTRIBUTION_GLOBAL_GROUP));
+ PyModule_AddObject(m, "ATYPE_DISTRIBUTION_LOCAL_GROUP", PyInt_FromLong(ATYPE_DISTRIBUTION_LOCAL_GROUP));
+ PyModule_AddObject(m, "ATYPE_DISTRIBUTION_UNIVERSAL_GROUP", PyInt_FromLong(ATYPE_DISTRIBUTION_UNIVERSAL_GROUP));
+
+ /* "domainFunctionality", "forestFunctionality" flags in the rootDSE */
+ PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2000", PyInt_FromLong(DS_DOMAIN_FUNCTION_2000));
+ PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2003_MIXED", PyInt_FromLong(DS_DOMAIN_FUNCTION_2003_MIXED));
+ PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2003", PyInt_FromLong(DS_DOMAIN_FUNCTION_2003));
+ PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2008", PyInt_FromLong(DS_DOMAIN_FUNCTION_2008));
+ PyModule_AddObject(m, "DS_DOMAIN_FUNCTION_2008_R2", PyInt_FromLong(DS_DOMAIN_FUNCTION_2008_R2));
+
+ /* "domainControllerFunctionality" flags in the rootDSE */
+ PyModule_AddObject(m, "DS_DC_FUNCTION_2000", PyInt_FromLong(DS_DC_FUNCTION_2000));
+ PyModule_AddObject(m, "DS_DC_FUNCTION_2003", PyInt_FromLong(DS_DC_FUNCTION_2003));
+ PyModule_AddObject(m, "DS_DC_FUNCTION_2008", PyInt_FromLong(DS_DC_FUNCTION_2008));
+ PyModule_AddObject(m, "DS_DC_FUNCTION_2008_R2", PyInt_FromLong(DS_DC_FUNCTION_2008_R2));
+}
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index 4f35ead..aa1febd 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -24,10 +24,9 @@ from ldb import ERR_UNDEFINED_ATTRIBUTE_TYPE
from ldb import Message, MessageElement, Dn
from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE
from samba import Ldb
-from samba import UF_NORMAL_ACCOUNT
-from samba import UF_WORKSTATION_TRUST_ACCOUNT
-from samba import UF_PASSWD_NOTREQD, UF_ACCOUNTDISABLE
-from samba import ATYPE_NORMAL_ACCOUNT, ATYPE_WORKSTATION_TRUST
+from samba.dsdb import (UF_NORMAL_ACCOUNT, UF_WORKSTATION_TRUST_ACCOUNT,
+ UF_PASSWD_NOTREQD, UF_ACCOUNTDISABLE, ATYPE_NORMAL_ACCOUNT,
+ ATYPE_WORKSTATION_TRUST)
from subunit.run import SubunitTestRunner
import unittest
diff --git a/source4/lib/ldb/tests/python/ldap_schema.py b/source4/lib/ldb/tests/python/ldap_schema.py
index 4ed1d1c..932ef46 100755
--- a/source4/lib/ldb/tests/python/ldap_schema.py
+++ b/source4/lib/ldb/tests/python/ldap_schema.py
@@ -2,12 +2,10 @@
# -*- coding: utf-8 -*-
# This is a port of the original in testprogs/ejs/ldap.js
-import getopt
import optparse
import sys
import time
import random
-import base64
import os
sys.path.append("bin/python")
@@ -15,41 +13,18 @@ sys.path.append("bin/python")
import samba.getopt as options
from samba.auth import system_session
-from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError
-from ldb import ERR_NO_SUCH_OBJECT, ERR_ATTRIBUTE_OR_VALUE_EXISTS
-from ldb import ERR_ENTRY_ALREADY_EXISTS, ERR_UNWILLING_TO_PERFORM
-from ldb import ERR_NOT_ALLOWED_ON_NON_LEAF, ERR_OTHER, ERR_INVALID_DN_SYNTAX
-from ldb import ERR_NO_SUCH_ATTRIBUTE, ERR_INSUFFICIENT_ACCESS_RIGHTS
-from ldb import ERR_OBJECT_CLASS_VIOLATION, ERR_NOT_ALLOWED_ON_RDN
-from ldb import ERR_NAMING_VIOLATION, ERR_CONSTRAINT_VIOLATION
-from ldb import ERR_UNDEFINED_ATTRIBUTE_TYPE
+from ldb import SCOPE_ONELEVEL, SCOPE_BASE, LdbError
+from ldb import ERR_NO_SUCH_OBJECT
+from ldb import ERR_UNWILLING_TO_PERFORM
+from ldb import ERR_CONSTRAINT_VIOLATION
from ldb import Message, MessageElement, Dn
-from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE
+from ldb import FLAG_MOD_REPLACE
from samba import Ldb
-from samba import UF_NORMAL_ACCOUNT, UF_TEMP_DUPLICATE_ACCOUNT
-from samba import UF_SERVER_TRUST_ACCOUNT, UF_WORKSTATION_TRUST_ACCOUNT
-from samba import UF_INTERDOMAIN_TRUST_ACCOUNT
-from samba import UF_PASSWD_NOTREQD, UF_ACCOUNTDISABLE
-from samba import GTYPE_SECURITY_BUILTIN_LOCAL_GROUP
-from samba import GTYPE_SECURITY_GLOBAL_GROUP, GTYPE_SECURITY_DOMAIN_LOCAL_GROUP
-from samba import GTYPE_SECURITY_UNIVERSAL_GROUP
-from samba import GTYPE_DISTRIBUTION_GLOBAL_GROUP
-from samba import GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP
-from samba import GTYPE_DISTRIBUTION_UNIVERSAL_GROUP
-from samba import ATYPE_NORMAL_ACCOUNT, ATYPE_WORKSTATION_TRUST
-from samba import ATYPE_SECURITY_GLOBAL_GROUP, ATYPE_SECURITY_LOCAL_GROUP
-from samba import ATYPE_SECURITY_UNIVERSAL_GROUP
-from samba import ATYPE_DISTRIBUTION_GLOBAL_GROUP
-from samba import ATYPE_DISTRIBUTION_LOCAL_GROUP
-from samba import ATYPE_DISTRIBUTION_UNIVERSAL_GROUP
-from samba import DS_DC_FUNCTION_2003
+from samba.dsdb import DS_DC_FUNCTION_2003
from subunit.run import SubunitTestRunner
import unittest
-from samba.ndr import ndr_pack, ndr_unpack
-from samba.dcerpc import security
-
parser = optparse.OptionParser("ldap [options] <host>")
sambaopts = options.SambaOptions(parser)
parser.add_option_group(sambaopts)
diff --git a/source4/lib/ldb/tests/python/sec_descriptor.py b/source4/lib/ldb/tests/python/sec_descriptor.py
index 8b2a879..30f82e6 100755
--- a/source4/lib/ldb/tests/python/sec_descriptor.py
+++ b/source4/lib/ldb/tests/python/sec_descriptor.py
@@ -13,15 +13,15 @@ sys.path.append("bin/python")
import samba.getopt as options
# Some error messages that are being tested
-from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError
-from ldb import ERR_NO_SUCH_OBJECT
+from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT
# For running the test unit
from samba.ndr import ndr_pack, ndr_unpack
from samba.dcerpc import security
+from samba import Ldb
from samba.auth import system_session
-from samba import Ldb, DS_DOMAIN_FUNCTION_2008
+from samba.dsdb import DS_DOMAIN_FUNCTION_2008
from samba.dcerpc.security import (
SECINFO_OWNER, SECINFO_GROUP, SECINFO_DACL, SECINFO_SACL)
from subunit.run import SubunitTestRunner
diff --git a/source4/lib/ldb/tests/python/urgent_replication.py b/source4/lib/ldb/tests/python/urgent_replication.py
index 28b3a5f..86d6d65 100755
--- a/source4/lib/ldb/tests/python/urgent_replication.py
+++ b/source4/lib/ldb/tests/python/urgent_replication.py
@@ -13,10 +13,8 @@ sys.path.append("../lib/testtools")
import samba.getopt as options
from samba.auth import system_session
-from ldb import SCOPE_BASE, LdbError
-from ldb import ERR_NO_SUCH_OBJECT
-from ldb import Message, MessageElement, Dn
-from ldb import FLAG_MOD_REPLACE
+from ldb import (SCOPE_BASE, LdbError, ERR_NO_SUCH_OBJECT, Message,
+ MessageElement, Dn, FLAG_MOD_REPLACE)
from samba import Ldb
from samba import glue
diff --git a/source4/libcli/util/pyerrors.h b/source4/libcli/util/pyerrors.h
index 3fd2a7c..4c526c6 100644
--- a/source4/libcli/util/pyerrors.h
+++ b/source4/libcli/util/pyerrors.h
@@ -26,9 +26,6 @@
#define PyErr_FromString(str) Py_BuildValue("(s)", discard_const_p(char, str))
-#define PyErr_SetStringError(str) \
- PyErr_SetObject(PyExc_RuntimeError, PyErr_FromString(str))
-
#define PyErr_SetWERROR(err) \
PyErr_SetObject(PyExc_RuntimeError, PyErr_FromWERROR(err))
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c
index 37d75cd..b75d7d3 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -277,63 +277,6 @@ static PyObject *py_dsdb_set_ntds_invocation_id(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-static PyObject *py_dsdb_set_opaque_integer(PyObject *self, PyObject *args)
-{
- PyObject *py_ldb;
- int value;
- int *old_val, *new_val;
- char *py_opaque_name, *opaque_name_talloc;
- struct ldb_context *ldb;
- TALLOC_CTX *tmp_ctx;
-
- if (!PyArg_ParseTuple(args, "Osi", &py_ldb, &py_opaque_name, &value))
- return NULL;
-
- PyErr_LDB_OR_RAISE(py_ldb, ldb);
-
- /* see if we have a cached copy */
- old_val = (int *)ldb_get_opaque(ldb,
- py_opaque_name);
-
- if (old_val) {
- *old_val = value;
- Py_RETURN_NONE;
- }
-
- tmp_ctx = talloc_new(ldb);
- if (tmp_ctx == NULL) {
- goto failed;
- }
-
- new_val = talloc(tmp_ctx, int);
- if (!new_val) {
- goto failed;
- }
-
- opaque_name_talloc = talloc_strdup(tmp_ctx, py_opaque_name);
- if (!opaque_name_talloc) {
- goto failed;
- }
-
- *new_val = value;
-
- /* cache the domain_sid in the ldb */
- if (ldb_set_opaque(ldb, opaque_name_talloc, new_val) != LDB_SUCCESS) {
- goto failed;
- }
-
- talloc_steal(ldb, new_val);
- talloc_steal(ldb, opaque_name_talloc);
- talloc_free(tmp_ctx);
-
- Py_RETURN_NONE;
-
-failed:
- talloc_free(tmp_ctx);
- PyErr_SetString(PyExc_RuntimeError, "Failed to set opaque integer into the ldb!\n");
- return NULL;
-}
-
static PyObject *py_dsdb_set_global_schema(PyObject *self, PyObject *args)
{
PyObject *py_ldb;
@@ -368,29 +311,6 @@ static PyObject *py_dsdb_set_schema_from_ldif(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-static PyObject *py_dsdb_convert_schema_to_openldap(PyObject *self, PyObject *args)
-{
- char *target_str, *mapping;
- PyObject *py_ldb;
- struct ldb_context *ldb;
- PyObject *ret;
- char *retstr;
-
- if (!PyArg_ParseTuple(args, "Oss", &py_ldb, &target_str, &mapping))
- return NULL;
-
- PyErr_LDB_OR_RAISE(py_ldb, ldb);
-
- retstr = dsdb_convert_schema_to_openldap(ldb, target_str, mapping);
- if (!retstr) {
- PyErr_SetString(PyExc_RuntimeError, "dsdb_convert_schema_to_openldap failed");
- return NULL;
- }
- ret = PyString_FromString(retstr);
- talloc_free(retstr);
- return ret;
-}
-
static PyObject *py_dsdb_write_prefixes_from_schema_to_ldb(PyObject *self, PyObject *args)
{
PyObject *py_ldb;
@@ -486,11 +406,8 @@ static PyObject *py_dsdb_load_partition_usn(PyObject *self, PyObject *args)
return result;
-
}
-
-
static PyObject *py_samdb_ntds_invocation_id(PyObject *self, PyObject *args)
{
PyObject *py_ldb, *result;
@@ -513,7 +430,7 @@ static PyObject *py_samdb_ntds_invocation_id(PyObject *self, PyObject *args)
guid = samdb_ntds_invocation_id(ldb);
if (guid == NULL) {
- PyErr_SetStringError("Failed to find NTDS invocation ID");
+ PyErr_SetString(PyExc_RuntimeError, "Failed to find NTDS invocation ID");
talloc_free(mem_ctx);
return NULL;
--
Samba Shared Repository
More information about the samba-cvs
mailing list