[SCM] Samba Shared Repository - branch master updated - tevent-0-9-8-648-gadf66e7

Jelmer Vernooij jelmer at samba.org
Wed Sep 23 07:24:54 MDT 2009


The branch, master has been updated
       via  adf66e75c060e6462b9f8819944d0f8ff1ef2c1b (commit)
       via  c5615211d436efea992d94b798c7a843cbf076c7 (commit)
      from  0724649a8a7c04d015317d9dc2ae43ee87c1bd25 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit adf66e75c060e6462b9f8819944d0f8ff1ef2c1b
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Sep 23 14:22:36 2009 +0200

    Check for PyString_FromString being NULL.

commit c5615211d436efea992d94b798c7a843cbf076c7
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Sep 23 11:01:52 2009 +0200

    provision: Avoid linking in multiple copies of security python module.

-----------------------------------------------------------------------

Summary of changes:
 source4/librpc/ndr/py_security.c |    5 ---
 source4/librpc/ndr/py_security.h |   23 -----------------
 source4/param/config.mk          |    2 +-
 source4/param/provision.c        |   51 +++++++++++++++++++++++++++++---------
 4 files changed, 40 insertions(+), 41 deletions(-)
 delete mode 100644 source4/librpc/ndr/py_security.h


Changeset truncated at 500 lines:

diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c
index 1b185a5..02dc059 100644
--- a/source4/librpc/ndr/py_security.c
+++ b/source4/librpc/ndr/py_security.c
@@ -23,11 +23,6 @@
 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
 #endif
 
-PyObject *py_dom_sid_FromSid(struct dom_sid *sid)
-{
-	return py_talloc_reference(&dom_sid_Type, sid);
-}
-
 static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods)
 {
 	PyObject *dict;
diff --git a/source4/librpc/ndr/py_security.h b/source4/librpc/ndr/py_security.h
deleted file mode 100644
index 9d200fa..0000000
--- a/source4/librpc/ndr/py_security.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   Samba utility functions
-   Copyright (C) Jelmer Vernooij <jelmer at 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 "libcli/security/security.h"
-
-/* a lone prototype for this function, because it's python */
-PyObject *py_dom_sid_FromSid(struct dom_sid *sid);
diff --git a/source4/param/config.mk b/source4/param/config.mk
index 45eb836..6e5290b 100644
--- a/source4/param/config.mk
+++ b/source4/param/config.mk
@@ -13,7 +13,7 @@ PUBLIC_HEADERS += param/param.h
 PC_FILES += $(paramsrcdir)/samba-hostconfig.pc
 
 [SUBSYSTEM::PROVISION]
-PRIVATE_DEPENDENCIES = LIBPYTHON pyldb pyparam_util python_dcerpc_security
+PRIVATE_DEPENDENCIES = LIBPYTHON pyldb pyparam_util
 
 PROVISION_OBJ_FILES = $(paramsrcdir)/provision.o $(param_OBJ_FILES)
 
diff --git a/source4/param/provision.c b/source4/param/provision.c
index 355af79..cb74f96 100644
--- a/source4/param/provision.c
+++ b/source4/param/provision.c
@@ -1,7 +1,7 @@
 /* 
    Unix SMB/CIFS implementation.
    Samba utility functions
-   Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2008
+   Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2008-2009
    Copyright (C) Andrew Bartlett <abartlet at samba.org> 2005
 
    This program is free software; you can redistribute it and/or modify
@@ -35,7 +35,14 @@
 #include "scripting/python/modules.h"
 #include "lib/ldb/pyldb.h"
 #include "param/pyparam.h"
-#include "librpc/ndr/py_security.h"
+
+static PyObject *provision_module(void)
+{
+	PyObject *name = PyString_FromString("samba.provision");
+	if (name == NULL)
+		return NULL;
+	return PyImport_Import(name);
+}
 
 NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
 			struct provision_settings *settings, 
@@ -50,7 +57,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
 	Py_Initialize();
 	py_update_path("bin"); /* FIXME: Can't assume this is always the case */
 
-	provision_mod = PyImport_Import(PyString_FromString("samba.provision"));
+	provision_mod = provision_module();
 
 	if (provision_mod == NULL) {
 		PyErr_Print();
@@ -153,7 +160,21 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
 }
 
 extern void initldb(void);
-extern void initsecurity(void);
+
+static PyObject *py_dom_sid_FromSid(struct dom_sid *sid)
+{
+	PyObject *mod_security, *dom_sid_Type;
+
+	mod_security = PyImport_ImportModule("samba.dcerpc.security");
+	if (mod_security == NULL)
+		return NULL;
+
+	dom_sid_Type = PyObject_GetAttrString(mod_security, "dom_sid");
+	if (dom_sid_Type == NULL)
+		return NULL;
+
+	return py_talloc_reference((PyTypeObject *)dom_sid_Type, sid);
+}
 
 NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
 				   struct tevent_context *event_ctx,
@@ -192,8 +213,7 @@ NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context
 	Py_Initialize();
 	py_update_path("bin"); /* FIXME: Can't assume this is always the case */
 	initldb();
-	initsecurity();
-	provision_mod = PyImport_Import(PyString_FromString("samba.provision"));
+	provision_mod = provision_module();
 
 	if (provision_mod == NULL) {
 		PyErr_Print();
@@ -237,6 +257,10 @@ NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context
 			     PyString_FromString(settings->netbios_name));
 
 	py_sid = py_dom_sid_FromSid(settings->domain_sid);
+	if (py_sid == NULL) {
+		Py_DECREF(parameters);
+		goto failure;
+	}
 
 	PyDict_SetItemString(parameters, "domainsid", 
 			     py_sid);
@@ -252,12 +276,7 @@ NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context
 	Py_DECREF(parameters);
 
 	if (py_result == NULL) {
-		ldb_transaction_cancel(ldb);
-		talloc_free(tmp_mem);
-
-		PyErr_Print();
-		PyErr_Clear();
-		return NT_STATUS_UNSUCCESSFUL;
+		goto failure;
 	}
 
 	ret = ldb_transaction_commit(ldb);
@@ -272,4 +291,12 @@ NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context
 	talloc_free(tmp_mem);
 
 	return NT_STATUS_OK;
+
+failure:
+	ldb_transaction_cancel(ldb);
+	talloc_free(tmp_mem);
+
+	PyErr_Print();
+	PyErr_Clear();
+	return NT_STATUS_UNSUCCESSFUL;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list