1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-25 00:51:21 +00:00

Update samba42 and samba43 to the latest versions. A lot of fixes are made to fix the fixes in the previous security fixes :)

* BUG 11841: Fix NT_STATUS_ACCESS_DENIED when accessing Windows
  public share.
* BUG 11847: Only validate MIC if "map to guest" is not being used.
* BUG 11849: auth/ntlmssp: Add ntlmssp_{client,server}:force_old_spnego
  option for testing.
* BUG 11850: NetAPP SMB servers don't negotiate NTLMSSP_SIGN.
* BUG 11858: Allow anonymous smb connections.
* BUG 11870: Fix ads_sasl_spnego_gensec_bind(KRB5).
* BUG 11872: Fix 'wbinfo -u' and 'net ads search'.
This commit is contained in:
Timur I. Bakeyev 2016-05-07 00:28:25 +00:00
parent a744a1eabf
commit d99b609d21
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=414751
10 changed files with 69 additions and 478 deletions

View File

@ -13,13 +13,13 @@ COMMENT?= Free SMB/CIFS and AD/DC server and client for Unix
LICENSE= GPLv3
CONFLICTS?= *samba3[2-6]-3.* samba4-4.0.* samba41-4.1.* samba43-4.3.*
CONFLICTS?= *samba3[2-6]-3.* samba4-4.0.* samba41-4.1.* samba43-4.3.* samba44-4.4.*
#EXTRA_PATCHES= ${PATCHDIR}/extra-patch-security:-p1
EXTRA_PATCHES= ${PATCHDIR}/extra-patch-progress:-p1
SAMBA4_BASENAME= samba
SAMBA4_PORTNAME= ${SAMBA4_BASENAME}4
SAMBA4_VERSION= 4.2.11
SAMBA4_VERSION= 4.2.12
SAMBA4_DISTNAME= ${SAMBA4_BASENAME}-${SAMBA4_VERSION:S|.p|pre|:S|.r|rc|:S|.t|tp|:S|.a|alpha|}
WRKSRC?= ${WRKDIR}/${DISTNAME}
@ -75,10 +75,7 @@ PLIST_SUB+= PKGCONFIGDIR=${PKGCONFIGDIR:S;${PREFIX}/;;}
LIB_DEPENDS+= libpopt.so:devel/popt
# inotify
LIB_DEPENDS+= libinotify.so:devel/libinotify
# SASL
LIB_DEPENDS+= libsasl2.so:security/cyrus-sasl2
# GNUTLS
LIB_DEPENDS+= libgcrypt.so:security/libgcrypt
LIB_DEPENDS+= libgnutls.so:security/gnutls
# NFS4 ACL glue
LIB_DEPENDS+= libsunacl.so:sysutils/libsunacl
@ -97,8 +94,8 @@ BUILD_DEPENDS+= talloc>=2.1.5:devel/talloc
RUN_DEPENDS+= talloc>=2.1.5:devel/talloc
SAMBA4_BUNDLED_LIBS+= !talloc
# tevent
BUILD_DEPENDS+= tevent>=0.9.25:devel/tevent
RUN_DEPENDS+= tevent>=0.9.25:devel/tevent
BUILD_DEPENDS+= tevent>=0.9.28:devel/tevent
RUN_DEPENDS+= tevent>=0.9.28:devel/tevent
SAMBA4_BUNDLED_LIBS+= !tevent
# tdb
BUILD_DEPENDS+= tdb>=1.3.8:databases/tdb
@ -281,8 +278,10 @@ CONFIGURE_ARGS+= --disable-dnssd
.if ${PORT_OPTIONS:MCUPS}
LIB_DEPENDS+= libcups.so:print/cups
CONFIGURE_ARGS+= --enable-cups --enable-iprint
PLIST_SUB+= CUPS=""
.else
CONFIGURE_ARGS+= --disable-cups --disable-iprint
PLIST_SUB+= CUPS="@comment "
.endif
.if ${PORT_OPTIONS:MDNSUPDATE}
@ -433,7 +432,7 @@ SAMBA_MAN7+= samba.7 winbind_krb5_locator.7
SAMBA_MAN8+= eventlogadm.8 idmap_ad.8 idmap_autorid.8 idmap_hash.8 \
idmap_ldap.8 idmap_nss.8 idmap_rfc2307.8 idmap_rid.8 \
idmap_tdb.8 idmap_tdb2.8 net.8 nmbd.8 pam_winbind.8 pdbedit.8 \
idmap_tdb.8 idmap_tdb2.8 net.8 nmbd.8 pam_winbind.8 pdbedit.8 smbspool_krb5_wrapper.8 \
samba-regedit.8 samba-tool.8 samba.8 smbd.8 smbpasswd.8 \
smbspool.8 smbta-util.8 vfs_acl_tdb.8 vfs_acl_xattr.8 \
vfs_aio_fork.8 vfs_aio_linux.8 vfs_aio_pthread.8 \

View File

@ -1,2 +1,2 @@
SHA256 (samba-4.2.11.tar.gz) = 75bce53c922e51352933c9846f2c4b1e251fabb80927adb426a773a321ee01f8
SIZE (samba-4.2.11.tar.gz) = 20875348
SHA256 (samba-4.2.12.tar.gz) = b334a86a92a1c2759c0b3dce20965e7fe820f0abafee38e6fd82eb9c5cd80514
SIZE (samba-4.2.12.tar.gz) = 20878216

View File

@ -0,0 +1,31 @@
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index c65fb08..13713fc 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -1005,7 +1005,7 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
entry,
"gecos",
ctx);
- if (unix_pw.pw_gecos) {
+ if (unix_pw.pw_gecos==NULL) {
unix_pw.pw_gecos = fullname;
}
unix_pw.pw_dir = smbldap_talloc_single_attribute(
@@ -1013,7 +1013,7 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
entry,
"homeDirectory",
ctx);
- if (unix_pw.pw_dir) {
+ if (unix_pw.pw_dir==NULL) {
unix_pw.pw_dir = discard_const_p(char, "");
}
unix_pw.pw_shell = smbldap_talloc_single_attribute(
@@ -1021,7 +1021,7 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
entry,
"loginShell",
ctx);
- if (unix_pw.pw_shell) {
+ if (unix_pw.pw_shell==NULL) {
unix_pw.pw_shell = discard_const_p(char, "");
}

View File

@ -1,6 +1,6 @@
--- source3/wscript_build.orig 2015-02-24 18:59:51.000000000 +0000
+++ source3/wscript_build 2015-03-25 01:00:04.143487619 +0000
@@ -601,6 +601,7 @@
--- source3/wscript_build.orig 2016-05-02 07:48:32.000000000 +0000
+++ source3/wscript_build 2016-05-05 08:40:07.413511000 +0000
@@ -619,6 +619,7 @@
smbd_conn
param_service
AVAHI
@ -8,7 +8,7 @@
PRINTBASE
PROFILE
LOCKING
@@ -1043,6 +1044,7 @@
@@ -1072,6 +1073,7 @@
msrpc3
RPC_NDR_SRVSVC
cli_smb_common
@ -16,12 +16,3 @@
''' + bld.env['archive_lib'])
bld.SAMBA3_BINARY('net',
@@ -1457,7 +1459,7 @@
bld.SAMBA3_PYTHON('pylibsmb',
source='libsmb/pylibsmb.c',
- deps='smbclient samba-credentials',
+ deps='smbclient samba-credentials libsmb errors',
realname='samba/samba3/libsmb_samba_internal.so'
)

View File

@ -0,0 +1,11 @@
--- source3/client/smbspool_krb5_wrapper.c.orig 2016-04-21 00:26:35.874203000 +0000
+++ source3/client/smbspool_krb5_wrapper.c 2016-04-21 00:47:23.148722000 +0000
@@ -195,7 +195,7 @@
* Make sure we do not have LD_PRELOAD or other security relevant
* environment variables set.
*/
- clearenv();
+ environ = NULL;
CUPS_SMB_DEBUG("Setting KRB5CCNAME to '%s'", gen_cc);
setenv("KRB5CCNAME", gen_cc, 1);

View File

@ -25,6 +25,7 @@ bin/smbcontrol
bin/smbcquotas
bin/smbget
bin/smbpasswd
%%CUPS%%bin/smbspool_krb5_wrapper
bin/smbspool
bin/smbstatus
bin/smbta-util
@ -868,6 +869,7 @@ man/man8/samba-tool.8.gz
man/man8/samba.8.gz
man/man8/smbd.8.gz
man/man8/smbpasswd.8.gz
man/man8/smbspool_krb5_wrapper.8.gz
man/man8/smbspool.8.gz
man/man8/smbta-util.8.gz
man/man8/vfs_acl_tdb.8.gz

View File

@ -3,7 +3,7 @@
PORTNAME?= ${SAMBA4_BASENAME}43
PORTVERSION?= ${SAMBA4_VERSION}
PORTREVISION?= 1
PORTREVISION?= 0
CATEGORIES?= net
MASTER_SITES= SAMBA/samba/stable SAMBA/samba/rc
DISTNAME= ${SAMBA4_DISTNAME}
@ -15,11 +15,11 @@ LICENSE= GPLv3
CONFLICTS?= *samba3[2-6]-3.* samba4-4.0.* samba41-4.1.* samba42-4.2.* samba44-4.4.*
EXTRA_PATCHES= ${PATCHDIR}/extra-patch-progress:-p1 ${PATCHDIR}/extra-patch-talloc:-p1
EXTRA_PATCHES= ${PATCHDIR}/extra-patch-progress:-p1
SAMBA4_BASENAME= samba
SAMBA4_PORTNAME= ${SAMBA4_BASENAME}4
SAMBA4_VERSION= 4.3.8
SAMBA4_VERSION= 4.3.9
SAMBA4_DISTNAME= ${SAMBA4_BASENAME}-${SAMBA4_VERSION:S|.p|pre|:S|.r|rc|:S|.t|tp|:S|.a|alpha|}
WRKSRC?= ${WRKDIR}/${DISTNAME}
@ -75,10 +75,7 @@ PLIST_SUB+= PKGCONFIGDIR=${PKGCONFIGDIR:S;${PREFIX}/;;}
LIB_DEPENDS+= libpopt.so:devel/popt
# inotify
LIB_DEPENDS+= libinotify.so:devel/libinotify
# SASL
LIB_DEPENDS+= libsasl2.so:security/cyrus-sasl2
# GNUTLS
LIB_DEPENDS+= libgcrypt.so:security/libgcrypt
LIB_DEPENDS+= libgnutls.so:security/gnutls
# NFS4 ACL glue
LIB_DEPENDS+= libsunacl.so:sysutils/libsunacl
@ -97,8 +94,8 @@ BUILD_DEPENDS+= talloc>=2.1.5:devel/talloc
RUN_DEPENDS+= talloc>=2.1.5:devel/talloc
SAMBA4_BUNDLED_LIBS+= !talloc
# tevent
BUILD_DEPENDS+= tevent>=0.9.25:devel/tevent
RUN_DEPENDS+= tevent>=0.9.25:devel/tevent
BUILD_DEPENDS+= tevent>=0.9.28:devel/tevent
RUN_DEPENDS+= tevent>=0.9.28:devel/tevent
SAMBA4_BUNDLED_LIBS+= !tevent
# tdb
BUILD_DEPENDS+= tdb>=1.3.8:databases/tdb

View File

@ -1,2 +1,2 @@
SHA256 (samba-4.3.8.tar.gz) = 379dc66c3a0a483bf5bed37be6e5d182934db7c4102b21929a6c4602b32b2b10
SIZE (samba-4.3.8.tar.gz) = 20568773
SHA256 (samba-4.3.9.tar.gz) = 1f22c61a7f24c5357a9ef4d10833a2cd161f40f3db03bcbe586d7cd3a56139f3
SIZE (samba-4.3.9.tar.gz) = 20570849

View File

@ -1,431 +0,0 @@
From 6108281171db83394a0a814b5f272c5afb9c4f51 Mon Sep 17 00:00:00 2001
From: Andrew Bartlett <abartlet@samba.org>
Date: Tue, 22 Sep 2015 15:25:30 +1200
Subject: [PATCH 1/3] pydsdb: Also accept ldb.MessageElement values to dsdb
routines
This shows the correct way to accept a value that may be a list of strings
or a proper ldb.MessageElement.
Andrew Bartlett
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
(cherry picked from commit b48776d78b446ad4abd4a6bc2ba6b488a29b11d2)
---
python/samba/dbchecker.py | 4 +-
source4/dsdb/pydsdb.c | 113 +++++++++++++++++++++++++---------------------
2 files changed, 63 insertions(+), 54 deletions(-)
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
index 4fb9d12..69b4c61 100644
--- a/python/samba/dbchecker.py
+++ b/python/samba/dbchecker.py
@@ -1286,8 +1286,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
continue
if str(attrname).lower() == 'objectclass':
- normalised = self.samdb.dsdb_normalise_attributes(self.samdb_schema, attrname, list(obj[attrname]))
- if list(normalised) != list(obj[attrname]):
+ normalised = self.samdb.dsdb_normalise_attributes(self.samdb_schema, attrname, obj[attrname])
+ if normalised != obj[attrname]:
self.err_normalise_mismatch_replace(dn, attrname, list(obj[attrname]))
error_count += 1
continue
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c
index 9a3b509..4d38c4a 100644
--- a/source4/dsdb/pydsdb.c
+++ b/source4/dsdb/pydsdb.c
@@ -529,11 +529,6 @@ static PyObject *py_dsdb_DsReplicaAttribute(PyObject *self, PyObject *args)
PyErr_LDB_OR_RAISE(py_ldb, ldb);
- if (!PyList_Check(el_list)) {
- PyErr_Format(PyExc_TypeError, "ldif_elements must be a list");
- return NULL;
- }
-
schema = dsdb_get_schema(ldb, NULL);
if (!schema) {
PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
@@ -555,32 +550,42 @@ static PyObject *py_dsdb_DsReplicaAttribute(PyObject *self, PyObject *args)
return NULL;
}
- el = talloc_zero(tmp_ctx, struct ldb_message_element);
- if (el == NULL) {
- PyErr_NoMemory();
- talloc_free(tmp_ctx);
- return NULL;
- }
-
- el->name = ldap_display_name;
- el->num_values = PyList_Size(el_list);
+ /* If we were not given an LdbMessageElement */
+ if (!PyList_Check(el_list)) {
+ if (!py_check_dcerpc_type(el_list, "ldb", "MessageElement")) {
+ PyErr_SetString(py_ldb_get_exception(),
+ "list of strings or ldb MessageElement object required");
+ return NULL;
+ }
+ el = pyldb_MessageElement_AsMessageElement(el_list);
+ } else {
+ el = talloc_zero(tmp_ctx, struct ldb_message_element);
+ if (el == NULL) {
+ PyErr_NoMemory();
+ talloc_free(tmp_ctx);
+ return NULL;
+ }
- el->values = talloc_array(el, struct ldb_val, el->num_values);
- if (el->values == NULL) {
- PyErr_NoMemory();
- talloc_free(tmp_ctx);
- return NULL;
- }
+ el->name = ldap_display_name;
+ el->num_values = PyList_Size(el_list);
- for (i = 0; i < el->num_values; i++) {
- PyObject *item = PyList_GetItem(el_list, i);
- if (!PyString_Check(item)) {
- PyErr_Format(PyExc_TypeError, "ldif_elements should be strings");
+ el->values = talloc_array(el, struct ldb_val, el->num_values);
+ if (el->values == NULL) {
+ PyErr_NoMemory();
talloc_free(tmp_ctx);
return NULL;
}
- el->values[i].data = (uint8_t *)PyString_AsString(item);
- el->values[i].length = PyString_Size(item);
+
+ for (i = 0; i < el->num_values; i++) {
+ PyObject *item = PyList_GetItem(el_list, i);
+ if (!PyString_Check(item)) {
+ PyErr_Format(PyExc_TypeError, "ldif_elements should be strings");
+ talloc_free(tmp_ctx);
+ return NULL;
+ }
+ el->values[i].data = (uint8_t *)PyString_AsString(item);
+ el->values[i].length = PyString_Size(item);
+ }
}
attr = talloc_zero(tmp_ctx, struct drsuapi_DsReplicaAttribute);
@@ -624,11 +629,6 @@ static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
PyErr_LDB_OR_RAISE(py_ldb, ldb);
- if (!PyList_Check(el_list)) {
- PyErr_Format(PyExc_TypeError, "ldif_elements must be a list");
- return NULL;
- }
-
schema = dsdb_get_schema(ldb, NULL);
if (!schema) {
PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb");
@@ -650,32 +650,41 @@ static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
return NULL;
}
- el = talloc_zero(tmp_ctx, struct ldb_message_element);
- if (el == NULL) {
- PyErr_NoMemory();
- talloc_free(tmp_ctx);
- return NULL;
- }
-
- el->name = ldap_display_name;
- el->num_values = PyList_Size(el_list);
+ if (!PyList_Check(el_list)) {
+ if (!py_check_dcerpc_type(el_list, "ldb", "MessageElement")) {
+ PyErr_SetString(py_ldb_get_exception(),
+ "list of strings or ldb MessageElement object required");
+ return NULL;
+ }
+ el = pyldb_MessageElement_AsMessageElement(el_list);
+ } else {
+ el = talloc_zero(tmp_ctx, struct ldb_message_element);
+ if (el == NULL) {
+ PyErr_NoMemory();
+ talloc_free(tmp_ctx);
+ return NULL;
+ }
- el->values = talloc_array(el, struct ldb_val, el->num_values);
- if (el->values == NULL) {
- PyErr_NoMemory();
- talloc_free(tmp_ctx);
- return NULL;
- }
+ el->name = ldap_display_name;
+ el->num_values = PyList_Size(el_list);
- for (i = 0; i < el->num_values; i++) {
- PyObject *item = PyList_GetItem(el_list, i);
- if (!PyString_Check(item)) {
- PyErr_Format(PyExc_TypeError, "ldif_elements should be strings");
+ el->values = talloc_array(el, struct ldb_val, el->num_values);
+ if (el->values == NULL) {
+ PyErr_NoMemory();
talloc_free(tmp_ctx);
return NULL;
}
- el->values[i].data = (uint8_t *)PyString_AsString(item);
- el->values[i].length = PyString_Size(item);
+
+ for (i = 0; i < el->num_values; i++) {
+ PyObject *item = PyList_GetItem(el_list, i);
+ if (!PyString_Check(item)) {
+ PyErr_Format(PyExc_TypeError, "ldif_elements should be strings");
+ talloc_free(tmp_ctx);
+ return NULL;
+ }
+ el->values[i].data = (uint8_t *)PyString_AsString(item);
+ el->values[i].length = PyString_Size(item);
+ }
}
/* Normalise "objectClass" attribute if needed */
--
1.9.1
From 34f741104e4212fb28d9fc06f60c0503e02fb556 Mon Sep 17 00:00:00 2001
From: Andrew Bartlett <abartlet@samba.org>
Date: Mon, 4 Jan 2016 13:23:50 +1300
Subject: [PATCH 2/3] python: Remove Python 2.4 support macros
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We require Python 2.6
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jelmer Vernoo <jelmer@samba.org>
(cherry picked from commit 0e58705a5bc11a9556d0774f9cb2fbb3897839c8)
---
source3/passdb/py_passdb.c | 7 -------
source4/auth/pyauth.c | 7 -------
source4/dsdb/pydsdb.c | 7 -------
source4/param/pyparam.c | 6 ------
source4/web_server/wsgi.c | 7 -------
5 files changed, 34 deletions(-)
diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c
index ca43f70..0d4ca3b 100644
--- a/source3/passdb/py_passdb.c
+++ b/source3/passdb/py_passdb.c
@@ -27,13 +27,6 @@
#include "secrets.h"
#include "idmap.h"
-/* There's no Py_ssize_t in 2.4, apparently */
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
-typedef int Py_ssize_t;
-typedef inquiry lenfunc;
-typedef intargfunc ssizeargfunc;
-#endif
-
#ifndef Py_TYPE /* Py_TYPE is only available on Python > 2.6 */
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#endif
diff --git a/source4/auth/pyauth.c b/source4/auth/pyauth.c
index d79d417..37f19fa 100644
--- a/source4/auth/pyauth.c
+++ b/source4/auth/pyauth.c
@@ -36,13 +36,6 @@ void initauth(void);
staticforward PyTypeObject PyAuthContext;
-/* There's no Py_ssize_t in 2.4, apparently */
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
-typedef int Py_ssize_t;
-typedef inquiry lenfunc;
-typedef intargfunc ssizeargfunc;
-#endif
-
static PyObject *PyAuthSession_FromSession(struct auth_session_info *session)
{
return py_return_ndr_struct("samba.dcerpc.auth", "session_info", session, session);
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c
index 4d38c4a..ea30898 100644
--- a/source4/dsdb/pydsdb.c
+++ b/source4/dsdb/pydsdb.c
@@ -31,13 +31,6 @@
void initdsdb(void);
-/* There's no Py_ssize_t in 2.4, apparently */
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
-typedef int Py_ssize_t;
-typedef inquiry lenfunc;
-typedef intargfunc ssizeargfunc;
-#endif
-
/* FIXME: These should be in a header file somewhere */
#define PyErr_LDB_OR_RAISE(py_ldb, ldb) \
if (!py_check_dcerpc_type(py_ldb, "ldb", "Ldb")) { \
diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c
index 14ffb2d..d1ba009 100644
--- a/source4/param/pyparam.c
+++ b/source4/param/pyparam.c
@@ -26,12 +26,6 @@
void initparam(void);
-/* There's no Py_ssize_t in 2.4, apparently */
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
-typedef int Py_ssize_t;
-typedef inquiry lenfunc;
-#endif
-
#define PyLoadparmContext_AsLoadparmContext(obj) pytalloc_get_type(obj, struct loadparm_context)
#define PyLoadparmService_AsLoadparmService(obj) pytalloc_get_type(obj, struct loadparm_service)
diff --git a/source4/web_server/wsgi.c b/source4/web_server/wsgi.c
index f0e7bd5..0b1c5d2 100644
--- a/source4/web_server/wsgi.c
+++ b/source4/web_server/wsgi.c
@@ -28,13 +28,6 @@
#include "lib/tsocket/tsocket.h"
#include "python/modules.h"
-/* There's no Py_ssize_t in 2.4, apparently */
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
-typedef int Py_ssize_t;
-typedef inquiry lenfunc;
-typedef intargfunc ssizeargfunc;
-#endif
-
typedef struct {
PyObject_HEAD
struct websrv_context *web;
--
1.9.1
From 259b7ff44095214e80615f5dad946f09b2d33f6f Mon Sep 17 00:00:00 2001
From: Andrew Bartlett <abartlet@samba.org>
Date: Tue, 16 Feb 2016 15:15:44 +1300
Subject: [PATCH 3/3] pydsdb: Fix returning of ldb.MessageElement.
This object is not based on pytalloc_Object and so this causes
a segfault (later a failure) when the struct definitions diverge.
We must also not reuse the incoming ldb_message_element as a talloc
context and overwrite the values, instead we should create a new
object and return that.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
(cherry picked from commit b96b1e88f760c92c7d9bb7e732f72d7e73a68907)
---
source4/dsdb/pydsdb.c | 49 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 43 insertions(+), 6 deletions(-)
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c
index ea30898..e6055d9 100644
--- a/source4/dsdb/pydsdb.c
+++ b/source4/dsdb/pydsdb.c
@@ -550,6 +550,11 @@ static PyObject *py_dsdb_DsReplicaAttribute(PyObject *self, PyObject *args)
"list of strings or ldb MessageElement object required");
return NULL;
}
+ /*
+ * NOTE:
+ * el may not be a valid talloc context, it
+ * could be part of an array
+ */
el = pyldb_MessageElement_AsMessageElement(el_list);
} else {
el = talloc_zero(tmp_ctx, struct ldb_message_element);
@@ -604,17 +609,20 @@ static PyObject *py_dsdb_DsReplicaAttribute(PyObject *self, PyObject *args)
*/
static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
{
- PyObject *py_ldb, *el_list, *ret;
+ PyObject *py_ldb, *el_list, *py_ret;
struct ldb_context *ldb;
char *ldap_display_name;
const struct dsdb_attribute *a;
struct dsdb_schema *schema;
struct dsdb_syntax_ctx syntax_ctx;
- struct ldb_message_element *el;
+ struct ldb_message_element *el, *new_el;
struct drsuapi_DsReplicaAttribute *attr;
+ PyLdbMessageElementObject *ret;
TALLOC_CTX *tmp_ctx;
WERROR werr;
Py_ssize_t i;
+ PyTypeObject *py_type = NULL;
+ PyObject *module = NULL;
if (!PyArg_ParseTuple(args, "OsO", &py_ldb, &ldap_display_name, &el_list)) {
return NULL;
@@ -649,6 +657,11 @@ static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
"list of strings or ldb MessageElement object required");
return NULL;
}
+ /*
+ * NOTE:
+ * el may not be a valid talloc context, it
+ * could be part of an array
+ */
el = pyldb_MessageElement_AsMessageElement(el_list);
} else {
el = talloc_zero(tmp_ctx, struct ldb_message_element);
@@ -680,10 +693,17 @@ static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
}
}
+ new_el = talloc_zero(tmp_ctx, struct ldb_message_element);
+ if (new_el == NULL) {
+ PyErr_NoMemory();
+ talloc_free(tmp_ctx);
+ return NULL;
+ }
+
/* Normalise "objectClass" attribute if needed */
if (ldb_attr_cmp(a->lDAPDisplayName, "objectClass") == 0) {
int iret;
- iret = dsdb_sort_objectClass_attr(ldb, schema, el, tmp_ctx, el);
+ iret = dsdb_sort_objectClass_attr(ldb, schema, el, new_el, new_el);
if (iret != LDB_SUCCESS) {
PyErr_SetString(PyExc_RuntimeError, ldb_errstring(ldb));
talloc_free(tmp_ctx);
@@ -706,14 +726,31 @@ static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
PyErr_WERROR_NOT_OK_RAISE(werr);
/* now convert back again */
- werr = a->syntax->drsuapi_to_ldb(&syntax_ctx, a, attr, el, el);
+ werr = a->syntax->drsuapi_to_ldb(&syntax_ctx, a, attr, new_el, new_el);
PyErr_WERROR_NOT_OK_RAISE(werr);
- ret = py_return_ndr_struct("ldb", "MessageElement", el, el);
+ module = PyImport_ImportModule("ldb");
+ if (module == NULL) {
+ return NULL;
+ }
+
+ py_type = (PyTypeObject *)PyObject_GetAttrString(module, "MessageElement");
+ if (py_type == NULL) {
+ return NULL;
+ }
+ py_ret = py_type->tp_alloc(py_type, 0);
+ ret = (PyLdbMessageElementObject *)py_ret;
+
+ ret->mem_ctx = talloc_new(NULL);
+ if (talloc_reference(ret->mem_ctx, new_el) == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ ret->el = new_el;
talloc_free(tmp_ctx);
- return ret;
+ return py_ret;
}
--
1.9.1

View File

@ -1,6 +1,6 @@
--- source3/wscript_build.orig 2015-02-24 18:59:51.000000000 +0000
+++ source3/wscript_build 2015-03-25 01:00:04.143487619 +0000
@@ -601,6 +601,7 @@
--- source3/wscript_build.orig 2016-05-02 07:48:32.000000000 +0000
+++ source3/wscript_build 2016-05-05 08:40:07.413511000 +0000
@@ -619,6 +619,7 @@
smbd_conn
param_service
AVAHI
@ -8,7 +8,7 @@
PRINTBASE
PROFILE
LOCKING
@@ -1043,6 +1044,7 @@
@@ -1072,6 +1073,7 @@
msrpc3
RPC_NDR_SRVSVC
cli_smb_common
@ -16,12 +16,3 @@
''' + bld.env['archive_lib'])
bld.SAMBA3_BINARY('net',
@@ -1457,7 +1459,7 @@
bld.SAMBA3_PYTHON('pylibsmb',
source='libsmb/pylibsmb.c',
- deps='smbclient samba-credentials',
+ deps='smbclient samba-credentials libsmb errors',
realname='samba/samba3/libsmb_samba_internal.so'
)