[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Tue Jul 21 20:08:03 UTC 2015


The branch, master has been updated
       via  c3c024f WHATSNEW: Clear release notes for Samba 4.4.0pre1.
       via  8eb5731 VERSION: Bump version up to 4.4.0pre1
       via  8c8cbd9 VERSION: Release Samba 4.3.0rc1
       via  4d5914b WHATSNEW: Start release notes for Samba 4.3.0rc1.
       via  b2a5949 ldb: version 1.1.21
       via  c7207e7 tdb: version 1.3.7
       via  e05cb33 talloc: version 2.1.3
       via  54ea6ff testsuite/headers: remove unused checks for ntdb.h
       via  b86df6e tdb python binding: raise KeyError(key) when the key doesn't exist
       via  075799a pytdb: Add tests for text interface
       via  d8c1343 pyldb: Add a text-based interface for Python 3
       via  1853a74 pytdb: Use new dict API on Python 3
       via  13c24b3 pytdb: Build for two versions of Python at once
       via  11eb2e4 pytdb: Port to Python 3
       via  d255231 pytdb: Allow nextkey() to be called
       via  5090d49 buildtools: Fix crash on invalid --extra-python option
       via  5a4e5d7 buildtools: Don't configure Python more than once
       via  584adc4 s4-auth: Make sure error_string is correctly initialized
       via  ae607c0 s4-kdc_kpasswd: split out some code to a KPASSWD_GLUE subsystem.
       via  a7705ad s4-kdc: move kdc_check_pac() to a new subsystem KDC-GLUE.
       via  1e64e72 s4-kdc: only use a void* in samba_kdc_entry instead of hdb_entry_ex.
       via  38e5d8d s4-kdc/pac_glue: remove old samba_kdc_build_edata_reply().
       via  893963c s4-kdc/mit_samba: add a copy of samba_kdc_build_edata_reply for MIT.
       via  402b0da s4-kdc/wdc-samba4: add a copy of samba_kdc_build_edata_reply for Heimdal.
       via  52e6d91 waf: Make mit_samba a subsystem and do not build with Heimdal
       via  8147156 s4-kdc: Fix a casting warning
       via  17c8b1a s4-kdc: Fix a typo
       via  da3df2e pdb_tdb: Use fstr_sprintf
      from  6551591 ctdb-daemon: Ignore SIGUSR1

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


- Log -----------------------------------------------------------------
commit c3c024f74e6763299d39cfc60e2fbce2093c517f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 21 13:56:51 2015 +0200

    WHATSNEW: Clear release notes for Samba 4.4.0pre1.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Tue Jul 21 22:07:14 CEST 2015 on sn-devel-104

commit 8eb57316f040a445d47cff8de0ca9bf4e9280acb
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 21 13:56:42 2015 +0200

    VERSION: Bump version up to 4.4.0pre1
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 8c8cbd984f8d1f30c7f2dfe3a4d3b472e3245aee
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 21 13:56:23 2015 +0200

    VERSION: Release Samba 4.3.0rc1
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 4d5914bf534a10e1093a0504aecb2b531102e164
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 21 11:38:18 2015 +0200

    WHATSNEW: Start release notes for Samba 4.3.0rc1.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Signed-off-by: Karolin Seeger <kseeger at samba.org>

commit b2a594926c5bff8b4a60a6ec27524e8e5741d427
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 21 13:55:24 2015 +0200

    ldb: version 1.1.21
    
    * build fixes
    * improved python bindings
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit c7207e73b116b76f6dd681e0c5a872ae2e702616
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 21 13:51:21 2015 +0200

    tdb: version 1.3.7
    
    * first fix deadlock in the interaction between fcntl and mutex locking
      (bug #11381)
    * improved python3 bindings
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit e05cb33511da81a2916b7504308552bcb4cbd587
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 21 13:49:07 2015 +0200

    talloc: version 2.1.3
    
    * improved python3 bindings
    * documentation fixes regarding talloc_reference() and talloc_unlink()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 54ea6ff7888c79d8466240485768e5c3b3cce30e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 21 09:24:42 2015 +0200

    testsuite/headers: remove unused checks for ntdb.h
    
    ntdb is already removed.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Karolin Seeger <kseeger at samba.org>

commit b86df6e47c85fd50125cc99bce6dba0e27650840
Author: Aurelien Aptel <aaptel at suse.com>
Date:   Thu Jul 16 16:55:28 2015 +0200

    tdb python binding: raise KeyError(key) when the key doesn't exist
    
    This change makes tdb dicts more consistent with Python dicts.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=7416
    
    Signed-off-by: Aurelien Aptel <aaptel at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 075799ac173dec49e1a669528eb85265962652d2
Author: Petr Viktorin <pviktori at redhat.com>
Date:   Wed Jun 17 13:02:27 2015 +0200

    pytdb: Add tests for text interface
    
    Signed-off-by: Petr Viktorin <pviktori at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit d8c134327d3af5181a7139769e31560b70848180
Author: Petr Viktorin <pviktori at redhat.com>
Date:   Thu Jun 18 13:43:27 2015 +0200

    pyldb: Add a text-based interface for Python 3
    
    Signed-off-by: Petr Viktorin <pviktori at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 1853a74b4ee171e85409c1209accdba98693f9eb
Author: Petr Viktorin <pviktori at redhat.com>
Date:   Fri May 22 17:57:07 2015 +0200

    pytdb: Use new dict API on Python 3
    
    - Remove has_key() method, add a fast "in" operator
    - Rename iterkeys() to keys()
    
    Signed-off-by: Petr Viktorin <pviktori at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 13c24b3416be61fd150d9ca047aafeeb676c94a3
Author: Petr Viktorin <pviktori at redhat.com>
Date:   Fri May 22 17:12:37 2015 +0200

    pytdb: Build for two versions of Python at once
    
    Signed-off-by: Petr Viktorin <pviktori at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 11eb2e4e3d92cd41236f81ded67735ba9c0ce31b
Author: Petr Viktorin <pviktori at redhat.com>
Date:   Fri May 22 17:10:34 2015 +0200

    pytdb: Port to Python 3
    
    - Use bytes for all data, text strings for repr()
    - Use PyLong instead of PyInt on py3
    - Use new module initialization
    - Update tests
    - Run tests in "make test"
    
    Signed-off-by: Petr Viktorin <pviktori at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit d2552311f1d4962d0dcea0788b1db889d3da7647
Author: Petr Viktorin <pviktori at redhat.com>
Date:   Thu Jun 18 12:35:49 2015 +0200

    pytdb: Allow nextkey() to be called
    
    nextkey() was defined to take no arguments but expected one.
    
    Signed-off-by: Petr Viktorin <pviktori at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 5090d491af1a9247b38eaa7c209e98d96360c938
Author: Petr Viktorin <pviktori at redhat.com>
Date:   Tue Jun 2 13:27:21 2015 +0200

    buildtools: Fix crash on invalid --extra-python option
    
    Signed-off-by: Petr Viktorin <pviktori at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 5a4e5d7cbf1849bba4bd696da1f6959d5f77b333
Author: Petr Viktorin <pviktori at redhat.com>
Date:   Mon Jun 8 19:02:03 2015 +0200

    buildtools: Don't configure Python more than once
    
    Signed-off-by: Petr Viktorin <pviktori at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 584adc4fd5919ae4518c7eb967a244c37e2d0cce
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jul 20 15:07:29 2015 +0200

    s4-auth: Make sure error_string is correctly initialized
    
    This should avoid a possible double free.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit ae607c0d05c1d5a0b57760027ed2852c30f2bda1
Author: Günther Deschner <gd at samba.org>
Date:   Tue Aug 5 17:49:55 2014 +0200

    s4-kdc_kpasswd: split out some code to a KPASSWD_GLUE subsystem.
    
    This can then be easier shared with MIT's kadmin services for kpasswd services.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit a7705ad0600256aee555ec8960ef5de5f30cffcc
Author: Günther Deschner <gd at samba.org>
Date:   Mon May 12 10:21:18 2014 +0200

    s4-kdc: move kdc_check_pac() to a new subsystem KDC-GLUE.
    
    This subsystem should be used to provide shared code between the s4 heimdal kdc
    and the s4 heimdal wdc plugin.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit 1e64e720ae5553f02934f7a758ab83cf9ca577ea
Author: Günther Deschner <gd at samba.org>
Date:   Sat May 10 00:05:23 2014 +0200

    s4-kdc: only use a void* in samba_kdc_entry instead of hdb_entry_ex.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit 38e5d8d4aa5662c2f19da9d60da879b4b88d5c67
Author: Günther Deschner <gd at samba.org>
Date:   Thu May 8 17:06:42 2014 +0200

    s4-kdc/pac_glue: remove old samba_kdc_build_edata_reply().
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit 893963cf7844e455a5b7e9bf5c4802fc2fd25237
Author: Günther Deschner <gd at samba.org>
Date:   Thu May 15 16:43:59 2014 +0200

    s4-kdc/mit_samba: add a copy of samba_kdc_build_edata_reply for MIT.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit 402b0dab67995874451de352eec2fde250f8d216
Author: Günther Deschner <gd at samba.org>
Date:   Thu May 15 09:13:06 2014 +0200

    s4-kdc/wdc-samba4: add a copy of samba_kdc_build_edata_reply for Heimdal.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit 52e6d91d341efba6193a64199fd125b2ad681e79
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Apr 25 11:55:17 2014 +0200

    waf: Make mit_samba a subsystem and do not build with Heimdal
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit 81471560d9b0c92b3dbbbe71a7c4b27aa376b8d0
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 16 12:57:35 2015 +0200

    s4-kdc: Fix a casting warning
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit 17c8b1a821b4ac4509340bfa148f8d1409e3a01d
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 16 12:57:14 2015 +0200

    s4-kdc: Fix a typo
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit da3df2e1bbd2a1aa736c5647c5d2e73f30f096ff
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jul 21 10:36:09 2015 +0200

    pdb_tdb: Use fstr_sprintf
    
    Saves 160 bytes of .text
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

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

Summary of changes:
 VERSION                                            |   2 +-
 WHATSNEW.txt                                       |  27 +--
 buildtools/wafsamba/samba_python.py                |   6 +-
 lib/ldb/ABI/{ldb-1.1.19.sigs => ldb-1.1.21.sigs}   |   0
 ...ldb-util-1.1.10.sigs => pyldb-util-1.1.21.sigs} |   0
 lib/ldb/wscript                                    |   2 +-
 ...oc-util-2.0.6.sigs => pytalloc-util-2.1.3.sigs} |   0
 .../ABI/{talloc-2.1.0.sigs => talloc-2.1.3.sigs}   |   0
 lib/talloc/wscript                                 |   2 +-
 lib/tdb/ABI/{tdb-1.3.5.sigs => tdb-1.3.7.sigs}     |   0
 lib/tdb/_tdb_text.py                               | 138 ++++++++++++
 lib/tdb/pytdb.c                                    | 234 ++++++++++++++------
 lib/tdb/python/tests/simple.py                     | 240 ++++++++++++++++-----
 lib/tdb/wscript                                    |  30 ++-
 source3/passdb/pdb_tdb.c                           |  17 +-
 source4/auth/kerberos/srv_keytab.c                 |  50 +++--
 source4/kdc/db-glue.c                              |   4 +-
 source4/kdc/kdc-glue.c                             |  69 ++++++
 source4/kdc/kdc-glue.h                             |   5 +
 source4/kdc/kpasswd_glue.c                         | 112 ++++++++++
 .../cldap_server.h => kdc/kpasswd_glue.h}          |  35 ++-
 source4/kdc/kpasswdd.c                             |  81 ++-----
 source4/kdc/mit_samba.c                            |  47 ++++
 source4/kdc/pac-glue.c                             |  73 -------
 source4/kdc/pac-glue.h                             |   6 -
 source4/kdc/samba_kdc.h                            |   2 +-
 source4/kdc/wdc-samba4.c                           |  41 ++++
 source4/kdc/wscript_build                          |  63 ++++--
 testsuite/headers/wscript_build                    |   4 -
 29 files changed, 915 insertions(+), 375 deletions(-)
 copy lib/ldb/ABI/{ldb-1.1.19.sigs => ldb-1.1.21.sigs} (100%)
 copy lib/ldb/ABI/{pyldb-util-1.1.10.sigs => pyldb-util-1.1.21.sigs} (100%)
 copy lib/talloc/ABI/{pytalloc-util-2.0.6.sigs => pytalloc-util-2.1.3.sigs} (100%)
 copy lib/talloc/ABI/{talloc-2.1.0.sigs => talloc-2.1.3.sigs} (100%)
 copy lib/tdb/ABI/{tdb-1.3.5.sigs => tdb-1.3.7.sigs} (100%)
 create mode 100644 lib/tdb/_tdb_text.py
 create mode 100644 source4/kdc/kdc-glue.c
 create mode 100644 source4/kdc/kpasswd_glue.c
 copy source4/{cldap_server/cldap_server.h => kdc/kpasswd_glue.h} (57%)


Changeset truncated at 500 lines:

diff --git a/VERSION b/VERSION
index df4a2f1..7966f82 100644
--- a/VERSION
+++ b/VERSION
@@ -24,7 +24,7 @@
 #  ->  "3.0.0"                                         #
 ########################################################
 SAMBA_VERSION_MAJOR=4
-SAMBA_VERSION_MINOR=3
+SAMBA_VERSION_MINOR=4
 SAMBA_VERSION_RELEASE=0
 
 ########################################################
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index cbf73b9..13d7ccb 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,35 +1,23 @@
 Release Announcements
 =====================
 
-This is the first preview release of Samba 4.3.  This is *not*
+This is the first preview release of Samba 4.4.  This is *not*
 intended for production environments and is designed for testing
 purposes only.  Please report any defects via the Samba bug reporting
 system at https://bugzilla.samba.org/.
 
-Samba 4.3 will be the next version of the Samba suite.
+Samba 4.4 will be the next version of the Samba suite.
 
 
 UPGRADING
 =========
 
+Nothing special.
 
 NEW FEATURES
 ============
 
-The logging code now supports logging to multiple backends.  In
-addition to the previously available syslog and file backends, the
-backends for logging to the systemd-journal, lttng and gpfs have been
-added. Please consult the section for the 'logging' parameter in the
-smb.conf manpage for details.
-
-Spotlight
-=========
-
-Support for Apple's Spotlight has been added by integrating with Gnome
-Tracker.
-
-For detailed instructions how to build and setup Samba for Spotlight,
-please see the Samba wiki: <https://wiki.samba.org/index.php/Spotlight>
+TODO...
 
 ######################################################################
 Changes
@@ -38,14 +26,13 @@ Changes
 smb.conf changes
 ----------------
 
-   Parameter Name			Description	Default
-   --------------			-----------	-------
-   logging				New		(empty)
-
+  Parameter Name		Description		Default
+  --------------		-----------		-------
 
 KNOWN ISSUES
 ============
 
+Currently none.
 
 #######################################
 Reporting bugs & Development Discussion
diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py
index 7546bbd..a8f780f 100644
--- a/buildtools/wafsamba/samba_python.py
+++ b/buildtools/wafsamba/samba_python.py
@@ -9,6 +9,10 @@ from Configure import conf
 @conf
 def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)):
     # enable tool to build python extensions
+    if conf.env.HAVE_PYTHON_H:
+        conf.check_python_version(version)
+        return
+
     interpreters = []
 
     if conf.env['EXTRA_PYTHON']:
@@ -21,7 +25,7 @@ def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)):
         try:
             conf.check_python_version((3, 3, 0))
         except Exception:
-            warn('extra-python needs to be Python 3.3 or later')
+            Logs.warn('extra-python needs to be Python 3.3 or later')
             raise
         interpreters.append(conf.env['PYTHON'])
         conf.setenv('default')
diff --git a/lib/ldb/ABI/ldb-1.1.19.sigs b/lib/ldb/ABI/ldb-1.1.21.sigs
similarity index 100%
copy from lib/ldb/ABI/ldb-1.1.19.sigs
copy to lib/ldb/ABI/ldb-1.1.21.sigs
diff --git a/lib/ldb/ABI/pyldb-util-1.1.10.sigs b/lib/ldb/ABI/pyldb-util-1.1.21.sigs
similarity index 100%
copy from lib/ldb/ABI/pyldb-util-1.1.10.sigs
copy to lib/ldb/ABI/pyldb-util-1.1.21.sigs
diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index 65a6843..0e81932 100755
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'ldb'
-VERSION = '1.1.20'
+VERSION = '1.1.21'
 
 blddir = 'bin'
 
diff --git a/lib/talloc/ABI/pytalloc-util-2.0.6.sigs b/lib/talloc/ABI/pytalloc-util-2.1.3.sigs
similarity index 100%
copy from lib/talloc/ABI/pytalloc-util-2.0.6.sigs
copy to lib/talloc/ABI/pytalloc-util-2.1.3.sigs
diff --git a/lib/talloc/ABI/talloc-2.1.0.sigs b/lib/talloc/ABI/talloc-2.1.3.sigs
similarity index 100%
copy from lib/talloc/ABI/talloc-2.1.0.sigs
copy to lib/talloc/ABI/talloc-2.1.3.sigs
diff --git a/lib/talloc/wscript b/lib/talloc/wscript
index 8e61516..bbe0cb1 100644
--- a/lib/talloc/wscript
+++ b/lib/talloc/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'talloc'
-VERSION = '2.1.2'
+VERSION = '2.1.3'
 
 
 blddir = 'bin'
diff --git a/lib/tdb/ABI/tdb-1.3.5.sigs b/lib/tdb/ABI/tdb-1.3.7.sigs
similarity index 100%
copy from lib/tdb/ABI/tdb-1.3.5.sigs
copy to lib/tdb/ABI/tdb-1.3.7.sigs
diff --git a/lib/tdb/_tdb_text.py b/lib/tdb/_tdb_text.py
new file mode 100644
index 0000000..c823bf8
--- /dev/null
+++ b/lib/tdb/_tdb_text.py
@@ -0,0 +1,138 @@
+# Text wrapper for tdb bindings
+#
+# Copyright (C) 2015 Petr Viktorin <pviktori at redhat.com>
+# Published under the GNU LGPLv3 or later
+
+import sys
+import functools
+
+import tdb
+
+
+class TdbTextWrapper(object):
+    """Text interface for a TDB file"""
+
+    def __init__(self, tdb):
+        self._tdb = tdb
+
+    @property
+    def raw(self):
+        return self._tdb
+
+    def get(self, key):
+        key = key.encode('utf-8')
+        result = self._tdb.get(key)
+        if result is not None:
+            return result.decode('utf-8')
+
+    def append(self, key, value):
+        key = key.encode('utf-8')
+        value = value.encode('utf-8')
+        self._tdb.append(key, value)
+
+    def firstkey(self):
+        result = self._tdb.firstkey()
+        if result:
+            return result.decode('utf-8')
+
+    def nextkey(self, key):
+        key = key.encode('utf-8')
+        result = self._tdb.nextkey(key)
+        if result is not None:
+            return result.decode('utf-8')
+
+    def delete(self, key):
+        key = key.encode('utf-8')
+        self._tdb.delete(key)
+
+    def store(self, key, value):
+        key = key.encode('utf-8')
+        value = value.encode('utf-8')
+        self._tdb.store(key, value)
+
+    def __iter__(self):
+        for key in iter(self._tdb):
+            yield key.decode('utf-8')
+
+    def __getitem__(self, key):
+        key = key.encode('utf-8')
+        result = self._tdb[key]
+        return result.decode('utf-8')
+
+    def __contains__(self, key):
+        key = key.encode('utf-8')
+        return key in self._tdb
+
+    def __repr__(self):
+        return '<TdbTextWrapper for %r>' % self._tdb
+
+    def __setitem__(self, key, value):
+        key = key.encode('utf-8')
+        value = value.encode('utf-8')
+        self._tdb[key] = value
+
+    def __delitem__(self, key):
+        key = key.encode('utf-8')
+        del self._tdb[key]
+
+    if sys.version_info > (3, 0):
+        keys = __iter__
+    else:
+        iterkeys = __iter__
+        has_key = __contains__
+
+
+## Add wrappers for functions and getters that don't deal with text
+
+def _add_wrapper(name):
+    orig = getattr(tdb.Tdb, name)
+
+    def wrapper(self, *args, **kwargs):
+        return orig(self._tdb, *args, **kwargs)
+    wrapper.__name__ = orig.__name__
+    wrapper.__doc__ = orig.__doc__
+
+    setattr(TdbTextWrapper, name, wrapper)
+
+for name in ("transaction_cancel",
+             "transaction_commit",
+             "transaction_prepare_commit",
+             "transaction_start",
+             "reopen",
+             "lock_all",
+             "unlock_all",
+             "read_lock_all",
+             "read_unlock_all",
+             "close",
+             "add_flags",
+             "remove_flags",
+             "clear",
+             "repack",
+             "enable_seqnum",
+             "increment_seqnum_nonblock",
+            ):
+    _add_wrapper(name)
+
+
+def _add_getter(name):
+    orig = getattr(tdb.Tdb, name)
+    doc = orig.__doc__
+
+    def getter(self):
+        return getattr(self._tdb, name)
+
+    def setter(self, value):
+        return setattr(self._tdb, name, value)
+
+    setattr(TdbTextWrapper, name, property(getter, setter, doc=doc))
+
+for name in ("hash_size",
+             "map_size",
+             "freelist_size",
+             "flags",
+             "max_dead",
+             "filename",
+             "seqnum",
+             "text",
+            ):
+    _add_getter(name)
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 9320799..c9d3a76 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -31,13 +31,25 @@
 /* Include tdb headers */
 #include <tdb.h>
 
+#if PY_MAJOR_VERSION >= 3
+#define PyStr_FromString PyUnicode_FromString
+#define PyStr_FromFormat PyUnicode_FromFormat
+#define PyInt_FromLong PyLong_FromLong
+#define PyInt_Check PyLong_Check
+#define PyInt_AsLong PyLong_AsLong
+#define Py_TPFLAGS_HAVE_ITER 0
+#else
+#define PyStr_FromString PyString_FromString
+#define PyStr_FromFormat PyString_FromFormat
+#endif
+
 typedef struct {
 	PyObject_HEAD
 	TDB_CONTEXT *ctx;
 	bool closed;
 } PyTdbObject;
 
-staticforward PyTypeObject PyTdb;
+static PyTypeObject PyTdb;
 
 static void PyErr_SetTDBError(TDB_CONTEXT *tdb)
 {
@@ -45,21 +57,21 @@ static void PyErr_SetTDBError(TDB_CONTEXT *tdb)
 		Py_BuildValue("(i,s)", tdb_error(tdb), tdb_errorstr(tdb)));
 }
 
-static TDB_DATA PyString_AsTDB_DATA(PyObject *data)
+static TDB_DATA PyBytes_AsTDB_DATA(PyObject *data)
 {
 	TDB_DATA ret;
-	ret.dptr = (unsigned char *)PyString_AsString(data);
-	ret.dsize = PyString_Size(data);
+	ret.dptr = (unsigned char *)PyBytes_AsString(data);
+	ret.dsize = PyBytes_Size(data);
 	return ret;
 }
 
-static PyObject *PyString_FromTDB_DATA(TDB_DATA data)
+static PyObject *PyBytes_FromTDB_DATA(TDB_DATA data)
 {
 	if (data.dptr == NULL && data.dsize == 0) {
 		Py_RETURN_NONE;
 	} else {
-		PyObject *ret = PyString_FromStringAndSize((const char *)data.dptr, 
-												   data.dsize);
+		PyObject *ret = PyBytes_FromStringAndSize((const char *)data.dptr,
+												  data.dsize);
 		free(data.dptr);
 		return ret;
     }
@@ -233,11 +245,11 @@ static PyObject *obj_get(PyTdbObject *self, PyObject *args)
 	if (!PyArg_ParseTuple(args, "O", &py_key))
 		return NULL;
 
-	key = PyString_AsTDB_DATA(py_key);
+	key = PyBytes_AsTDB_DATA(py_key);
 	if (!key.dptr)
 		return NULL;
 
-	return PyString_FromTDB_DATA(tdb_fetch(self->ctx, key));
+	return PyBytes_FromTDB_DATA(tdb_fetch(self->ctx, key));
 }
 
 static PyObject *obj_append(PyTdbObject *self, PyObject *args)
@@ -251,10 +263,10 @@ static PyObject *obj_append(PyTdbObject *self, PyObject *args)
 	if (!PyArg_ParseTuple(args, "OO", &py_key, &py_data))
 		return NULL;
 
-	key = PyString_AsTDB_DATA(py_key);
+	key = PyBytes_AsTDB_DATA(py_key);
 	if (!key.dptr)
 		return NULL;
-	data = PyString_AsTDB_DATA(py_data);
+	data = PyBytes_AsTDB_DATA(py_data);
 	if (!data.dptr)
 		return NULL;
 
@@ -267,7 +279,7 @@ static PyObject *obj_firstkey(PyTdbObject *self)
 {
 	PyErr_TDB_RAISE_IF_CLOSED(self);
 
-	return PyString_FromTDB_DATA(tdb_firstkey(self->ctx));
+	return PyBytes_FromTDB_DATA(tdb_firstkey(self->ctx));
 }
 
 static PyObject *obj_nextkey(PyTdbObject *self, PyObject *args)
@@ -279,11 +291,11 @@ static PyObject *obj_nextkey(PyTdbObject *self, PyObject *args)
 	if (!PyArg_ParseTuple(args, "O", &py_key))
 		return NULL;
 
-	key = PyString_AsTDB_DATA(py_key);
+	key = PyBytes_AsTDB_DATA(py_key);
 	if (!key.dptr)
 		return NULL;
 	
-	return PyString_FromTDB_DATA(tdb_nextkey(self->ctx, key));
+	return PyBytes_FromTDB_DATA(tdb_nextkey(self->ctx, key));
 }
 
 static PyObject *obj_delete(PyTdbObject *self, PyObject *args)
@@ -296,7 +308,7 @@ static PyObject *obj_delete(PyTdbObject *self, PyObject *args)
 	if (!PyArg_ParseTuple(args, "O", &py_key))
 		return NULL;
 
-	key = PyString_AsTDB_DATA(py_key);
+	key = PyBytes_AsTDB_DATA(py_key);
 	if (!key.dptr)
 		return NULL;
 	ret = tdb_delete(self->ctx, key);
@@ -304,26 +316,42 @@ static PyObject *obj_delete(PyTdbObject *self, PyObject *args)
 	Py_RETURN_NONE;
 }
 
-static PyObject *obj_has_key(PyTdbObject *self, PyObject *args)
+static int obj_contains(PyTdbObject *self, PyObject *py_key)
 {
 	TDB_DATA key;
 	int ret;
+	PyErr_TDB_RAISE_RETURN_MINUS_1_IF_CLOSED(self);
+
+	key = PyBytes_AsTDB_DATA(py_key);
+	if (!key.dptr) {
+		PyErr_BadArgument();
+		return -1;
+	}
+	ret = tdb_exists(self->ctx, key);
+	if (ret)
+		return 1;
+	return 0;
+}
+
+#if PY_MAJOR_VERSION < 3
+static PyObject *obj_has_key(PyTdbObject *self, PyObject *args)
+{
+	int ret;
 	PyObject *py_key;
 	PyErr_TDB_RAISE_IF_CLOSED(self);
 
 	if (!PyArg_ParseTuple(args, "O", &py_key))
 		return NULL;
 
-	key = PyString_AsTDB_DATA(py_key);
-	if (!key.dptr)
+	ret = obj_contains(self, py_key);
+	if (ret == -1)
 		return NULL;
-	ret = tdb_exists(self->ctx, key);
-	if (ret != TDB_ERR_NOEXIST) {
-		PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
-	}
+	if (ret)
+		Py_RETURN_TRUE;
+	Py_RETURN_FALSE;
 
-	return (ret == TDB_ERR_NOEXIST)?Py_False:Py_True;
 }
+#endif
 
 static PyObject *obj_store(PyTdbObject *self, PyObject *args)
 {
@@ -337,10 +365,10 @@ static PyObject *obj_store(PyTdbObject *self, PyObject *args)
 	if (!PyArg_ParseTuple(args, "OO|i", &py_key, &py_value, &flag))
 		return NULL;
 
-	key = PyString_AsTDB_DATA(py_key);
+	key = PyBytes_AsTDB_DATA(py_key);
 	if (!key.dptr)
 		return NULL;
-	value = PyString_AsTDB_DATA(py_value);
+	value = PyBytes_AsTDB_DATA(py_value);
 	if (!value.dptr)
 		return NULL;
 
@@ -389,7 +417,7 @@ static PyObject *tdb_iter_next(PyTdbIteratorObject *self)
 		return NULL;
 	current = self->current;
 	self->current = tdb_nextkey(self->iteratee->ctx, self->current);
-	ret = PyString_FromTDB_DATA(current);
+	ret = PyBytes_FromTDB_DATA(current);
 	return ret;
 }
 
@@ -480,17 +508,23 @@ static PyMethodDef tdb_object_methods[] = {
 		"Append data to an existing key." },
 	{ "firstkey", (PyCFunction)obj_firstkey, METH_NOARGS, "S.firstkey() -> data\n"
 		"Return the first key in this database." },
-	{ "nextkey", (PyCFunction)obj_nextkey, METH_NOARGS, "S.nextkey(key) -> data\n"
+	{ "nextkey", (PyCFunction)obj_nextkey, METH_VARARGS, "S.nextkey(key) -> data\n"
 		"Return the next key in this database." },
 	{ "delete", (PyCFunction)obj_delete, METH_VARARGS, "S.delete(key) -> None\n"
 		"Delete an entry." },
+#if PY_MAJOR_VERSION < 3
 	{ "has_key", (PyCFunction)obj_has_key, METH_VARARGS, "S.has_key(key) -> None\n"
 		"Check whether key exists in this database." },
+#endif
 	{ "store", (PyCFunction)obj_store, METH_VARARGS, "S.store(key, data, flag=REPLACE) -> None"
 		"Store data." },
 	{ "add_flags", (PyCFunction)obj_add_flags, METH_VARARGS, "S.add_flags(flags) -> None" },
 	{ "remove_flags", (PyCFunction)obj_remove_flags, METH_VARARGS, "S.remove_flags(flags) -> None" },
+#if PY_MAJOR_VERSION >= 3
+	{ "keys", (PyCFunction)tdb_object_iter, METH_NOARGS, "S.iterkeys() -> iterator" },
+#else


-- 
Samba Shared Repository



More information about the samba-cvs mailing list