[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Wed Nov 8 20:55:03 UTC 2017


The branch, master has been updated
       via  de5e23c python: tests: Add tests for samba.posix_eadb module
       via  e00ba05 python: Port ntvfs posix bindings to Python 3 compatible form
      from  aed7fae ctdb-tests: Fix some harmless CIDs

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


- Log -----------------------------------------------------------------
commit de5e23c236013d35625d296ea00c6206d55330aa
Author: Lumir Balhar <lbalhar at redhat.com>
Date:   Tue Oct 24 09:01:16 2017 +0200

    python: tests: Add tests for samba.posix_eadb module
    
    Signed-off-by: Lumir Balhar <lbalhar at redhat.com>
    Reviewed-by: Andrew Bartlet <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Wed Nov  8 21:54:59 CET 2017 on sn-devel-144

commit e00ba05d33af9d922fcad7f24bc5814d9145d71a
Author: Lumir Balhar <lbalhar at redhat.com>
Date:   Tue Oct 24 09:00:11 2017 +0200

    python: Port ntvfs posix bindings to Python 3 compatible form
    
    Signed-off-by: Lumir Balhar <lbalhar at redhat.com>
    Reviewed-by: Andrew Bartlet <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 python/samba/tests/xattr.py                 | 30 ++++++++++++++++++++++++++++-
 selftest/tests.py                           |  2 +-
 source4/ntvfs/posix/python/pyposix_eadb.c   | 23 +++++++++++++++-------
 source4/ntvfs/posix/python/pyxattr_native.c | 23 ++++++++++++++--------
 source4/ntvfs/posix/python/pyxattr_tdb.c    | 23 +++++++++++++++-------
 source4/ntvfs/posix/wscript_build           | 24 ++++++++++++-----------
 6 files changed, 90 insertions(+), 35 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/tests/xattr.py b/python/samba/tests/xattr.py
index 6387452..b024175 100644
--- a/python/samba/tests/xattr.py
+++ b/python/samba/tests/xattr.py
@@ -17,7 +17,7 @@
 
 """Tests for samba.xattr_native and samba.xattr_tdb."""
 
-import samba.xattr_native, samba.xattr_tdb
+import samba.xattr_native, samba.xattr_tdb, samba.posix_eadb
 from samba.xattr import copytree_with_xattrs
 from samba.dcerpc import xattr
 from samba.ndr import ndr_pack
@@ -108,6 +108,34 @@ class XattrTests(TestCase):
             os.unlink(tempf)
         os.unlink(eadb_path)
 
+    def test_set_posix_eadb(self):
+        tempf = self._tmpfilename()
+        eadb_path = self._eadbpath()
+        ntacl = xattr.NTACL()
+        ntacl.version = 1
+        open(tempf, 'w').write("empty")
+        try:
+            samba.posix_eadb.wrap_setxattr(eadb_path,
+                tempf, "user.unittests", ndr_pack(ntacl))
+        finally:
+            os.unlink(tempf)
+        os.unlink(eadb_path)
+
+    def test_set_and_get_posix_eadb(self):
+        tempf = self._tmpfilename()
+        eadb_path = self._eadbpath()
+        reftxt = "this is a test"
+        open(tempf, 'w').write("empty")
+        try:
+            samba.posix_eadb.wrap_setxattr(eadb_path, tempf, "user.unittests",
+                reftxt)
+            text = samba.posix_eadb.wrap_getxattr(eadb_path, tempf,
+                "user.unittests")
+            self.assertEquals(text, reftxt)
+        finally:
+            os.unlink(tempf)
+        os.unlink(eadb_path)
+
 
 class TestCopyTreeWithXattrs(TestCaseInTempDir):
 
diff --git a/selftest/tests.py b/selftest/tests.py
index 704dbad..181313e 100644
--- a/selftest/tests.py
+++ b/selftest/tests.py
@@ -126,7 +126,7 @@ plantestsuite(
      os.path.join(bbdir, "dbcheck-links.sh"),
      '$PREFIX_ABS/provision', 'release-4-5-0-pre1', configuration])
 planpythontestsuite("none", "samba.tests.upgradeprovision")
-planpythontestsuite("none", "samba.tests.xattr")
+planpythontestsuite("none", "samba.tests.xattr", py3_compatible=True)
 planpythontestsuite("none", "samba.tests.ntacls")
 planpythontestsuite("none", "samba.tests.policy")
 planpythontestsuite("none", "samba.tests.kcc.graph")
diff --git a/source4/ntvfs/posix/python/pyposix_eadb.c b/source4/ntvfs/posix/python/pyposix_eadb.c
index a94440b..d43c7c4 100644
--- a/source4/ntvfs/posix/python/pyposix_eadb.c
+++ b/source4/ntvfs/posix/python/pyposix_eadb.c
@@ -19,6 +19,7 @@
 */
 
 #include <Python.h>
+#include "python/py3compat.h"
 #include "includes.h"
 #include "system/filesys.h"
 #include <tdb.h>
@@ -28,8 +29,6 @@
 #include "libcli/util/pyerrors.h"
 #include "param/pyparam.h"
 
-void initposix_eadb(void);
-
 static PyObject *py_is_xattr_supported(PyObject *self)
 {
 	return Py_True;
@@ -102,7 +101,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
 		talloc_free(mem_ctx);
 		return NULL;
 	}
-	ret = PyString_FromStringAndSize((char *)blob.data, blob.length);
+	ret = PyStr_FromStringAndSize((char *)blob.data, blob.length);
 	talloc_free(mem_ctx);
 	return ret;
 }
@@ -119,12 +118,22 @@ static PyMethodDef py_posix_eadb_methods[] = {
 	{ NULL }
 };
 
-void initposix_eadb(void)
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    .m_name = "posix_eadb",
+    .m_doc = "Python bindings for xattr manipulation.",
+    .m_size = -1,
+    .m_methods = py_posix_eadb_methods,
+};
+
+MODULE_INIT_FUNC(posix_eadb)
 {
 	PyObject *m;
 
-	m = Py_InitModule3("posix_eadb", py_posix_eadb_methods,
-			   "Python bindings for xattr manipulation.");
+	m = PyModule_Create(&moduledef);
+
 	if (m == NULL)
-		return;
+		return NULL;
+
+	return m;
 }
diff --git a/source4/ntvfs/posix/python/pyxattr_native.c b/source4/ntvfs/posix/python/pyxattr_native.c
index 6758996..c5e740f 100644
--- a/source4/ntvfs/posix/python/pyxattr_native.c
+++ b/source4/ntvfs/posix/python/pyxattr_native.c
@@ -19,13 +19,12 @@
 */
 
 #include <Python.h>
+#include "python/py3compat.h"
 #include "includes.h"
 #include "librpc/ndr/libndr.h"
 #include "system/filesys.h"
 #include "lib/util/base64.h"
 
-void initxattr_native(void);
-
 static PyObject *py_is_xattr_supported(PyObject *self)
 {
 #if !defined(HAVE_XATTR_SUPPORT)
@@ -91,7 +90,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
 		talloc_free(mem_ctx);
 		return NULL;
 	}
-	ret = PyString_FromStringAndSize(buf, len);
+	ret = PyStr_FromStringAndSize(buf, len);
 	talloc_free(mem_ctx);
 	return ret;
 }
@@ -108,14 +107,22 @@ static PyMethodDef py_xattr_methods[] = {
 	{ NULL }
 };
 
-void initxattr_native(void)
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    .m_name = "xattr_native",
+    .m_doc = "Python bindings for xattr manipulation.",
+    .m_size = -1,
+    .m_methods = py_xattr_methods,
+};
+
+MODULE_INIT_FUNC(xattr_native)
 {
 	PyObject *m;
 
-	m = Py_InitModule3("xattr_native", py_xattr_methods,
-			   "Python bindings for xattr manipulation.");
+	m = PyModule_Create(&moduledef);
 
 	if (m == NULL)
-		return;
-}
+		return NULL;
 
+	return m;
+}
diff --git a/source4/ntvfs/posix/python/pyxattr_tdb.c b/source4/ntvfs/posix/python/pyxattr_tdb.c
index 56beedb..05303b6 100644
--- a/source4/ntvfs/posix/python/pyxattr_tdb.c
+++ b/source4/ntvfs/posix/python/pyxattr_tdb.c
@@ -19,6 +19,7 @@
 */
 
 #include <Python.h>
+#include "python/py3compat.h"
 #include "includes.h"
 #include "system/filesys.h"
 #include <tdb.h>
@@ -32,8 +33,6 @@
 #include "lib/dbwrap/dbwrap_tdb.h"
 #include "source3/lib/xattr_tdb.h"
 
-void initxattr_tdb(void);
-
 static PyObject *py_is_xattr_supported(PyObject *self)
 {
 	return Py_True;
@@ -138,7 +137,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
 		talloc_free(mem_ctx);
 		return NULL;
 	}
-	ret_obj = PyString_FromStringAndSize((char *)blob.data, xattr_size);
+	ret_obj = PyStr_FromStringAndSize((char *)blob.data, xattr_size);
 	talloc_free(mem_ctx);
 	return ret_obj;
 }
@@ -155,13 +154,23 @@ static PyMethodDef py_xattr_methods[] = {
 	{ NULL }
 };
 
-void initxattr_tdb(void)
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    .m_name = "xattr_tdb",
+    .m_doc = "Python bindings for xattr manipulation.",
+    .m_size = -1,
+    .m_methods = py_xattr_methods,
+};
+
+MODULE_INIT_FUNC(xattr_tdb)
 {
 	PyObject *m;
 
-	m = Py_InitModule3("xattr_tdb", py_xattr_methods,
-			   "Python bindings for xattr manipulation.");
+	m = PyModule_Create(&moduledef);
+
 	if (m == NULL)
-		return;
+		return NULL;
+
+	return m;
 }
 
diff --git a/source4/ntvfs/posix/wscript_build b/source4/ntvfs/posix/wscript_build
index a07da33..eac2dfc 100644
--- a/source4/ntvfs/posix/wscript_build
+++ b/source4/ntvfs/posix/wscript_build
@@ -41,27 +41,29 @@ if bld.CONFIG_SET('WITH_NTVFS_FILESERVER'):
     )
 
 
-bld.SAMBA_PYTHON('python_xattr_native',
-	source='python/pyxattr_native.c',
-	deps='ndr ldb samdb samba-credentials pyparam_util attr',
-	realname='samba/xattr_native.so'
-	)
-
 bld.SAMBA_LIBRARY('posix_eadb',
                   source='posix_eadb.c',
                   deps='tdb tdb-wrap samba-util',
                   autoproto='posix_eadb_proto.h',
                   private_library=True)
 
-bld.SAMBA_PYTHON('python_posix_eadb',
+for env in bld.gen_python_environments():
+    pyparam_util = bld.pyembed_libname('pyparam_util')
+
+    bld.SAMBA_PYTHON('python_xattr_native',
+        source='python/pyxattr_native.c',
+        deps='ndr ldb samdb samba-credentials %s attr' % pyparam_util,
+        realname='samba/xattr_native.so'
+        )
+
+    bld.SAMBA_PYTHON('python_posix_eadb',
 	source='python/pyposix_eadb.c',
-	deps='pyparam_util posix_eadb tdb',
+	deps='%s posix_eadb tdb' % pyparam_util,
 	realname='samba/posix_eadb.so'
 	)
 
-bld.SAMBA_PYTHON('python_xattr_tdb',
+    bld.SAMBA_PYTHON('python_xattr_tdb',
 	source='python/pyxattr_tdb.c',
-	deps='pyparam_util xattr_tdb',
+	deps='%s xattr_tdb' % pyparam_util,
 	realname='samba/xattr_tdb.so'
 	)
-


-- 
Samba Shared Repository



More information about the samba-cvs mailing list