[SCM] Samba Shared Repository - branch v3-2-stable updated - release-3-2-0pre2-712-g559dfd5

Karolin Seeger kseeger at samba.org
Sun Apr 13 11:29:52 GMT 2008


The branch, v3-2-stable has been updated
       via  559dfd57823f4ac3ac897c9ec260ba5889fb34b2 (commit)
       via  400c76d4d7737d2878873401c8f742b71a925c23 (commit)
       via  1f7725e879f15faf30bca111dbb708f702610e1f (commit)
       via  3cfb1d4eefb4391b42f001f3d1580533edcf2e6c (commit)
       via  031d6d0fa0962ec31e123f309ef50b598b2cf219 (commit)
       via  4ceae29e096d04e8a273570ec38b4c15f298c5af (commit)
       via  7841e2b2609f1675eeb7aa9e8f3d03aea30186ef (commit)
       via  f638e1fe7f1f58060e239f6d273ef7528ce0c913 (commit)
       via  76284487645212b05b50cb51d42222456500305b (commit)
       via  5c4eab069a6615101a02fae719a41af2340f74a8 (commit)
       via  338734dd69b88a68f37869faf3c0dd8376374a46 (commit)
       via  1a1515f333e6750efa31562b2bd7be3687c96350 (commit)
       via  252e9cee99650f6eb45f514066f190ddd26f0242 (commit)
       via  3699d1d3d9a3515fbbf711161e74fe463c656881 (commit)
       via  7b6ae7b1661e679a058fea310438951989483bcd (commit)
       via  9e6e6345a88e3cf29eeed754297d343bdceeefd0 (commit)
       via  1adf3126add35a5a5b332b0fa50f238bfe6471da (commit)
       via  d9702e4def99f36fcd98dae8d6f43dcabe7bf0be (commit)
       via  ffa2dc2655a90c2976dbd283a71a494c0bc37db7 (commit)
       via  f46f3e485a7d5dccfcc05c8b4de6c1339f79aa73 (commit)
       via  b8ef2acb4cfd16815f28065cd27549930845cd4e (commit)
       via  e050b5fec9bc64962c79f875d06216f1dacae78a (commit)
       via  081906ea047452b2f1b5010b7f23afa859fa37fd (commit)
       via  e641109c4ff2037dd55c1e3290b5a994cf8c9fec (commit)
       via  ac8921ccd0291aac5991916b73cfa0b1d377c5d1 (commit)
       via  e7f18ab57cab0eacfac516438b186ae6bb3286d7 (commit)
       via  d71d7c8de5db7683e09fdbcb3932ebb0d78611a6 (commit)
       via  72fcc7d9ba467b15637ecfdd339945d6039cfbad (commit)
      from  6c5ebc66a4feea1a92570d847fbef28657d57b46 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-stable


- Log -----------------------------------------------------------------
commit 559dfd57823f4ac3ac897c9ec260ba5889fb34b2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Apr 12 11:13:40 2008 +0200

    WHATSNEW.txt: list my changes
    
    metze
    (cherry picked from commit 55b86c0a13d9f10df533dc6c0a23e290d880edbc)

commit 400c76d4d7737d2878873401c8f742b71a925c23
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Mar 11 22:06:09 2008 +0100

    selftest: samba3 passes RAW-SEARCH now
    
    As the resume key tests are skipped against samba3.
    
    metze
    (cherry picked from commit c765090871ed68a9ba650bca44f5f3b88997ea14)

commit 1f7725e879f15faf30bca111dbb708f702610e1f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Mar 28 08:24:28 2008 +0100

    groupdb: readd groupdb:backend parametric option
    
    This reverts c5adb92c020e38644baf1afc8fc570a518cd6307.
    
    The reason is that ldb doesn't work for cluster setups yet.
    
    metze
    (cherry picked from commit 5f5d90ef76b969ecbe564399368a7450c4e3d155)

commit 3cfb1d4eefb4391b42f001f3d1580533edcf2e6c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 31 11:24:10 2008 +0200

    groupdb: make mapping_tdb compatible to mapping_ldb
    
    mapping_ldb replaces the record if it already exists.
    I'm not sure if that a good thing, but for now
    both backends should provide the same behavior.
    
    metze
    (cherry picked from commit b313acdd31c97d032c3890764addf66c6b9a4d89)

commit 031d6d0fa0962ec31e123f309ef50b598b2cf219
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 1 14:01:28 2008 +0200

    dbwrap: wait for tdb2 change notifies in smbd, nmbd and winbindd
    
    metze
    (cherry picked from commit 64450cc1e441355aa8925b7183e90872eeab20b1)

commit 4ceae29e096d04e8a273570ec38b4c15f298c5af
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Mar 26 10:08:10 2008 +0100

    dbwrap: use db_open_tdb2() in for db_open_trans() if "dbwrap:use_tdb2=yes"
    
    For clustered setups you need to disable the ctdb backend for each
    tdb which should use the tdb2 backend (e.g. ctdb:registry.tdb=no).
    
    To disable tdb2 per tdb use something like "tdb2:passdb.tdb=no"
    
    metze
    (cherry picked from commit 5cea2bf3673c982bafeef4a8bbd3bd2ab73cc0c5)

commit 7841e2b2609f1675eeb7aa9e8f3d03aea30186ef
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Mar 19 19:40:10 2008 +0100

    dbwrap: add dbwrap_tdb2 backend
    
    This backend can be used untill ctdb knows about real
    transactions.
    
    It stores a master tdb in a shared location and a readonly copy
    on the local harddisk. Reads are always on the local tdb
    and writes always on both. Change notify messages are send
    to all message context, which ask for them. With the notifies
    it's possible to just update the changed records, instead of
    copying all records (which is the fallback).
    
    You need to configure:
    
    dbwrap:use_tdb2=yes
    dbwrap_tdb2:master directory=/some/shared/path
    dbwrap_tdb2:local directory=/var/lib/samba
    
    metze
    (cherry picked from commit aa6230de0d5f1875aa8c12c4fc017d3a40f90890)

commit f638e1fe7f1f58060e239f6d273ef7528ce0c913
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 31 11:18:12 2008 +0200

    rerun 'make idl'
    
    metze
    (cherry picked from commit f34dad2b4ad97a845729ea0fb5beba7fd6cb7265)

commit 76284487645212b05b50cb51d42222456500305b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 31 11:17:15 2008 +0200

    messaging.idl: add structure to marshall dbwrap_tdb2 changes
    
    metze
    (cherry picked from commit 46a0d8e872af1ab420705a514c1d7b1b21459f82)

commit 5c4eab069a6615101a02fae719a41af2340f74a8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 31 12:50:23 2008 +0200

    messaging: add MSG_DBWRAP_TDB2_CHANGES flag
    
    metze
    (cherry picked from commit 7418c3ab1d8f18403f5a43817b2cc14e15090fca)

commit 338734dd69b88a68f37869faf3c0dd8376374a46
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 31 12:50:23 2008 +0200

    messaging: add FLAG_MSG_DBWRAP message class flag
    
    metze
    (cherry picked from commit ee6325495f48bab43a37d740a6eca57192004d57)

commit 1a1515f333e6750efa31562b2bd7be3687c96350
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 11 21:38:06 2008 +0200

    registry: move normalize_dbkey() from lib/util_reg.c to registry/reg_util.c
    
    This function is only used inside registry code.
    
    Michael
    (cherry picked from commit 48745e3fbd6b38f39678938b8c3f145769065e7b)

commit 252e9cee99650f6eb45f514066f190ddd26f0242
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Mar 28 12:05:54 2008 +0100

    Fix a confusing variable name
    (cherry picked from commit 32c992e9573c9af34cd142393287e2f3538d2dd9)

commit 3699d1d3d9a3515fbbf711161e74fe463c656881
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Mar 28 10:34:37 2008 +0100

    Fix a segfault
    (cherry picked from commit 40d1d64c6a2ae128eb3fce0e7f5351b0c5942f30)

commit 7b6ae7b1661e679a058fea310438951989483bcd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Mar 28 07:56:20 2008 +0100

    libreplace(samba4): let LIBREPLACE depend on LIBREPLACE_NETWORK for now
    
    This should fix the build on solaris.
    Later this needs better fixing...
    
    metze
    (cherry picked from commit 89b7955733c34e9699a3b43ee54de92cb9469b90)
    (cherry picked from commit fcb497951a86551ce9c4be7b352335dad3be127a)

commit 9e6e6345a88e3cf29eeed754297d343bdceeefd0
Author: Michael Adam <obnox at samba.org>
Date:   Tue Mar 18 17:50:23 2008 +0100

    libreplace: replace.c does not need system/network.h anymore.
    
    Michael
    (cherry picked from commit 2d3c2f34f33338ff422047dae9cc262522689328)
    (cherry picked from commit 03a980d8f67ee1516c357807c23a405f07a006b3)

commit 1adf3126add35a5a5b332b0fa50f238bfe6471da
Author: Michael Adam <obnox at samba.org>
Date:   Tue Mar 18 17:20:47 2008 +0100

    libreplace: move rep_socketpair() to its own module.
    
    Prototype is now in system/network.h,
    implementation in socketpair.c, and
    check in socketpair.m4.
    
    Now the last networking function has vanished from replace.c.
    
    Michael
    (cherry picked from commit 94ac8a25be15b55f66eff96fdddc2fdc71a43b1e)
    (cherry picked from commit 6c53753246b8108fe1277b34958e122bd800c4e7)

commit d9702e4def99f36fcd98dae8d6f43dcabe7bf0be
Author: Michael Adam <obnox at samba.org>
Date:   Tue Mar 18 16:31:15 2008 +0100

    libreplace: remove duplicate entry of inet_ntoa from README.
    
    Michael
    (cherry picked from commit 98ee8c84300757d778733a458c6ca3e6022b40ea)
    (cherry picked from commit a4f22d6e2b3fc198327deabf4a724cd476e4144c)

commit ffa2dc2655a90c2976dbd283a71a494c0bc37db7
Author: Michael Adam <obnox at samba.org>
Date:   Tue Mar 18 13:10:22 2008 +0100

    libreplace: remove trailing white spaces.
    
    Michael
    (cherry picked from commit 1f9ca7eed965904f67cf78fbac007432b8a057fd)
    (cherry picked from commit a1d24f110b3edff636174e017eb56ba5b10df590)

commit f46f3e485a7d5dccfcc05c8b4de6c1339f79aa73
Author: Michael Adam <obnox at samba.org>
Date:   Tue Mar 18 12:16:47 2008 +0100

    libreplace: replace inet_ntoa() when it is missing
    
    ...not only replace it when it is broken.
    
    This moves the defintion of rep_inet_ntoa from replace.c
    to inet_ntoa.c and adds configure checks for existence
    of inet_ntoa(). Checks are moved to an include file of its own.
    
    NOTE: The original rep_inet_ntoa in replace.c was wrapped
    into a "#ifndef WITH_PTHREADS" but the prototype in replace.h
    and the define in system/network.h were not. I removed that
    ifndef since the inet_ntoa() function is usually not thread safe
    anyways, since it returns a pointer to a static buffer.
    
    So whoever calls inet_ntoa() should be aware that it is not
    thread safe anyways.
    
    Michael
    (cherry picked from commit 974c0c45ad42644348e0b55454715b12158f1028)
    (cherry picked from commit edcf2712bcdedabbfdd9ee8b9a18f46126930636)

commit b8ef2acb4cfd16815f28065cd27549930845cd4e
Author: Michael Adam <obnox at samba.org>
Date:   Fri Mar 14 15:53:38 2008 +0100

    libreplace: put inet_aton.c under LGPL instead of GPL.
    
    Michael
    (cherry picked from commit cca5d6626fe395f08fd4c8b2344e4e43646cb987)
    (cherry picked from commit f69e51f56f111d9bd5db69e191f45567aacf8c3d)

commit e050b5fec9bc64962c79f875d06216f1dacae78a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Mar 18 15:01:34 2008 +0100

    libreplace: remove unused SOCKET_LIBS and NSL_LIBS
    
    metze
    (cherry picked from commit 62bb177a6e4a3e1f949b78c7cd7583f2e1271739)
    (cherry picked from commit f27d5e0cf80c49d81091a385cbfd0801b5483825)

commit 081906ea047452b2f1b5010b7f23afa859fa37fd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Mar 18 14:55:05 2008 +0100

    libreplace: for samba4 create LIBREPLACE_NETWORK as EXT_LIB
    
    metze
    (cherry picked from commit 79037c31334e271a718fcac234148038814b591e)
    (cherry picked from commit b141fce01dd40b25cce52852cd93f0f907c3b008)

commit e641109c4ff2037dd55c1e3290b5a994cf8c9fec
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Mar 18 14:53:59 2008 +0100

    libreplace: use LIBREPLACE_NETWORK_LIBS within some configure checks
    
    ...instead of using SOCKET_LIBS and NSL_LIBS.
    
    metze
    (cherry picked from commit cef2e8d748756f61c248ad6660e85dd1ac36308a)
    (cherry picked from commit 7854ed24a57162fa7569d8f36633f3c156067b0b)

commit ac8921ccd0291aac5991916b73cfa0b1d377c5d1
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Mar 18 14:52:36 2008 +0100

    libreplace: combine SOCKET_LIBS and NSL_LIBS to LIBREPLACE_NETWORK_LIBS
    
    But keep the old ones untill the callers are fixed.
    
    metze
    (cherry picked from commit e7115dcc8a0a4f420de7a901e3a21d4f35a6fcf9)
    (cherry picked from commit 2dee62ed12910a4d22381677bcf884dca0d999ea)

commit e7f18ab57cab0eacfac516438b186ae6bb3286d7
Author: Michael Adam <obnox at samba.org>
Date:   Fri Mar 14 09:39:58 2008 +0100

    libreplace: fix samba4 build (by not setting global LIBS).
    
    This corrects the earlier fix of the standalone build, by setting
    LIBS to the desired value only in configure.ac but not in getifaddrs.m4.
    
    Not that this changes the standalone build in that it adds these libs
    undconditionally and not only if they are needed by the getifaddrs
    replacement functions.
    
    Michael
    (cherry picked from commit ff3af1703ddc9e5383f32156bc5be8351f795e76)
    (cherry picked from commit 2546da817f666914c1c220ec1fedc19aa41b25ad)

commit d71d7c8de5db7683e09fdbcb3932ebb0d78611a6
Author: Michael Adam <obnox at samba.org>
Date:   Fri Mar 14 08:52:16 2008 +0100

    libreplace: add -I$libreplacedir to CPPFLAGS for getifaddrs tests.
    
    This is needed, otherwise $libreplacedir/system/network.h does not
    find $libreplacedir/getaddrinfo.h on some systems (solaris, e.g.).
    
    Michael
    (cherry picked from commit 297c3bece094ddb5f268b02e61e33f512ccfe6f5)
    (cherry picked from commit ddd564e8bf2b115aa5dbcbebd4be30b749ad8752)

commit 72fcc7d9ba467b15637ecfdd339945d6039cfbad
Author: Michael Adam <obnox at samba.org>
Date:   Fri Mar 14 08:49:34 2008 +0100

    libreplace: add an inet_aton() function that calls inet_pton().
    
    inet_aton() is even needed inside libreplace, in the implementation
    of rep_getaddrinfo().
    
    Michael
    (cherry picked from commit bcb2f3a880f8da8f9bedb7a8e61d7d7b533f1919)
    (cherry picked from commit 83baff78ce752a9129554a456cc24d043d419cd1)

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

Summary of changes:
 WHATSNEW.txt                          |   21 +
 source/Makefile.in                    |    8 +-
 source/groupdb/mapping.c              |   22 +-
 source/groupdb/mapping_tdb.c          |    4 +-
 source/include/dbwrap.h               |   12 +-
 source/include/messages.h             |    5 +
 source/lib/dbwrap.c                   |   59 ++-
 source/lib/dbwrap_tdb2.c              | 1265 +++++++++++++++++++++++++++++++++
 source/lib/messages.c                 |    2 +
 source/lib/replace/README             |    2 +-
 source/lib/replace/configure.ac       |    3 +
 source/lib/replace/getifaddrs.m4      |   11 +-
 source/lib/replace/inet_aton.c        |   33 +
 source/lib/replace/inet_aton.m4       |    1 +
 source/lib/replace/inet_ntoa.c        |   39 +
 source/lib/replace/inet_ntoa.m4       |   19 +
 source/lib/replace/libreplace.m4      |   23 +-
 source/lib/replace/replace.c          |   37 -
 source/lib/replace/replace.h          |    9 +-
 source/lib/replace/samba.m4           |    5 +-
 source/lib/replace/socket.m4          |   15 +-
 source/lib/replace/socketpair.c       |   46 ++
 source/lib/replace/socketpair.m4      |    1 +
 source/lib/replace/system/network.h   |   12 +-
 source/lib/util_reg.c                 |    7 -
 source/librpc/gen_ndr/messaging.h     |   11 +
 source/librpc/gen_ndr/ndr_messaging.c |   81 +++
 source/librpc/gen_ndr/ndr_messaging.h |    3 +
 source/librpc/idl/messaging.idl       |   15 +
 source/nmbd/nmbd.c                    |    8 +
 source/registry/reg_util.c            |   10 +
 source/script/tests/test_posix_s3.sh  |    2 +-
 source/smbd/server.c                  |    6 +-
 source/winbindd/winbindd.c            |    7 +
 34 files changed, 1710 insertions(+), 94 deletions(-)
 create mode 100644 source/lib/dbwrap_tdb2.c
 create mode 100644 source/lib/replace/inet_aton.c
 create mode 100644 source/lib/replace/inet_aton.m4
 create mode 100644 source/lib/replace/inet_ntoa.c
 create mode 100644 source/lib/replace/inet_ntoa.m4
 create mode 100644 source/lib/replace/socketpair.c
 create mode 100644 source/lib/replace/socketpair.m4


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 7687c0d..745c5d3 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -260,6 +260,27 @@ o   Derrell Lipman <derrell at samba.org>
     * Fix use of AuthDataWithContext capability.
 
 
+o   Stefan Metzmacher <metze at samba.org>
+    * Add dbwrap_tdb2 backend, useful for cluster setups.
+    * Add more functions to libwbclient:
+      - wbcGetGroups()
+      - wbcInterfaceDetails()
+      - wbcListUsers()
+      - wbcListGroups()
+      - wbcLookupUserSids()
+      - wbcSetUidMapping()
+      - wbcSetGidMapping()
+      - wbcSetUidHwm()
+      - wbcSetGidHwm()
+    * Let wbinfo use libwbclient where possible.
+    * Let net use only libwbclient to access winbindd.
+    * Make socket wrapper pcap support more portable.
+    * Some libreplace backports from v4-0-test.
+    * Store the write time in the locking.tdb,
+      so that smbd passes the BASE-DELAYWRITE test.
+    * Run RAW-SEARCH and BASE-DELAYWRITE by 'make test'.
+
+
 o   Karolin Seeger <kseeger at samba.org>
     * Fix usage message for "net idmap dump".
 
diff --git a/source/Makefile.in b/source/Makefile.in
index 7bcb9c9..5e70bdf 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -244,7 +244,8 @@ LIBTDB_OBJ0 = @TDB_OBJS@
 LIBTDB_OBJ = $(LIBTDB_OBJ0) $(LIBREPLACE_OBJ)
 
 TDB_OBJ = lib/util_tdb.o \
-	  lib/dbwrap.o lib/dbwrap_tdb.o lib/dbwrap_ctdb.o \
+	  lib/dbwrap.o lib/dbwrap_tdb.o \
+	  lib/dbwrap_tdb2.o lib/dbwrap_ctdb.o \
 	  lib/dbwrap_rbt.o @LIBTDB_STATIC@
 
 SMBLDAP_OBJ = @SMBLDAP@ @SMBLDAPUTIL@
@@ -690,7 +691,7 @@ NMBD_OBJ1 = nmbd/asyncdns.o nmbd/nmbd.o nmbd/nmbd_become_dmb.o \
             nmbd/nmbd_processlogon.o nmbd/nmbd_responserecordsdb.o \
             nmbd/nmbd_sendannounce.o nmbd/nmbd_serverlistdb.o \
             nmbd/nmbd_subnetdb.o nmbd/nmbd_winsproxy.o nmbd/nmbd_winsserver.o \
-            nmbd/nmbd_workgroupdb.o nmbd/nmbd_synclists.o
+            nmbd/nmbd_workgroupdb.o nmbd/nmbd_synclists.o smbd/connection.o
 
 NMBD_OBJ = $(NMBD_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
            $(PROFILE_OBJ) $(LIB_NONSMBD_OBJ) $(SECRETS_OBJ) $(POPT_LIB_OBJ)
@@ -1022,7 +1023,8 @@ WINBINDD_OBJ1 = \
 		winbindd/winbindd_idmap.o \
 		winbindd/winbindd_locator.o \
 		winbindd/winbindd_ndr.o \
-		auth/token_util.o
+		auth/token_util.o \
+		smbd/connection.o
 
 WINBINDD_OBJ = \
 		$(WINBINDD_OBJ1) $(PASSDB_OBJ) @LIBWBCLIENT_STATIC@ $(GROUPDB_OBJ) \
diff --git a/source/groupdb/mapping.c b/source/groupdb/mapping.c
index 1ddda58..ce66bfa 100644
--- a/source/groupdb/mapping.c
+++ b/source/groupdb/mapping.c
@@ -30,12 +30,30 @@ static const struct mapping_backend *backend;
  */
 static bool init_group_mapping(void)
 {
+	const char *backend_string;
+
 	if (backend != NULL) {
 		/* already initialised */
 		return True;
 	}
-	
-	backend = groupdb_ldb_init();
+
+	/*
+	 * default to using the ldb backend. This parameter should
+	 * disappear in future versions of Samba3.
+	 *
+	 * But it's needed for cluster setups, because it's
+	 * not yet possible to distribute a ldb inside a cluster.
+	 */
+	backend_string = lp_parm_const_string(-1, "groupdb", "backend", "ldb");
+
+	if (strcmp(backend_string, "ldb") == 0) {
+		backend = groupdb_ldb_init();
+	} else if (strcmp(backend_string, "tdb") == 0) {
+		backend = groupdb_tdb_init();
+	} else {
+		DEBUG(0,("Unknown groupdb backend '%s'\n", backend_string));
+		smb_panic("Unknown groupdb backend");
+	}
 
 	return backend != NULL;
 }
diff --git a/source/groupdb/mapping_tdb.c b/source/groupdb/mapping_tdb.c
index aadab6a..c6d9735 100644
--- a/source/groupdb/mapping_tdb.c
+++ b/source/groupdb/mapping_tdb.c
@@ -130,7 +130,7 @@ static bool add_mapping_entry(GROUP_MAP *map, int flag)
 		return NULL;
 	}
 
-	len = tdb_pack(NULL, sizeof(buf), "ddff",
+	len = tdb_pack(NULL, 0, "ddff",
 		map->gid, map->sid_name_use, map->nt_name, map->comment);
 
 	buf = TALLOC_ARRAY(key, char, len);
@@ -143,7 +143,7 @@ static bool add_mapping_entry(GROUP_MAP *map, int flag)
 
 	status = dbwrap_trans_store(
 		db, string_term_tdb_data(key),
-		make_tdb_data((uint8_t *)buf, len), flag);
+		make_tdb_data((uint8_t *)buf, len), TDB_REPLACE);
 
 	TALLOC_FREE(key);
 
diff --git a/source/include/dbwrap.h b/source/include/dbwrap.h
index 654c7a4..1f38816 100644
--- a/source/include/dbwrap.h
+++ b/source/include/dbwrap.h
@@ -34,11 +34,11 @@ struct db_context {
 	int (*fetch)(struct db_context *db, TALLOC_CTX *mem_ctx,
 		     TDB_DATA key, TDB_DATA *data);
 	int (*traverse)(struct db_context *db,
-			int (*f)(struct db_record *db,
+			int (*f)(struct db_record *rec,
 				 void *private_data),
 			void *private_data);
 	int (*traverse_read)(struct db_context *db,
-			     int (*f)(struct db_record *db,
+			     int (*f)(struct db_record *rec,
 				      void *private_data),
 			     void *private_data);
 	int (*get_seqnum)(struct db_context *db);
@@ -66,6 +66,14 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
 			       int hash_size, int tdb_flags,
 			       int open_flags, mode_t mode);
 
+struct db_context *db_open_tdb2(TALLOC_CTX *mem_ctx,
+			        const char *name,
+			        int hash_size, int tdb_flags,
+			        int open_flags, mode_t mode);
+
+struct messaging_context;
+void db_tdb2_setup_messaging(struct messaging_context *msg_ctx, bool server);
+
 #ifdef CLUSTER_SUPPORT
 struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
 				const char *name,
diff --git a/source/include/messages.h b/source/include/messages.h
index c97ad98..8f0112a 100644
--- a/source/include/messages.h
+++ b/source/include/messages.h
@@ -102,6 +102,9 @@
 /* event messages */
 #define MSG_DUMP_EVENT_LIST		0x0500
 
+/* dbwrap messages 4001-4999 */
+#define MSG_DBWRAP_TDB2_CHANGES		4001
+
 /*
  * Special flags passed to message_send. Allocated from the top, lets see when
  * it collides with the message types in the lower 16 bits :-)
@@ -122,6 +125,8 @@
 #define FLAG_MSG_NMBD			0x0004
 #define FLAG_MSG_PRINT_NOTIFY		0x0008
 #define FLAG_MSG_PRINT_GENERAL		0x0010
+/* dbwrap messages 4001-4999 */
+#define FLAG_MSG_DBWRAP			0x0020
 
 
 /*
diff --git a/source/lib/dbwrap.c b/source/lib/dbwrap.c
index fd92463..d688b83 100644
--- a/source/lib/dbwrap.c
+++ b/source/lib/dbwrap.c
@@ -104,8 +104,63 @@ struct db_context *db_open_trans(TALLOC_CTX *mem_ctx,
 				 int hash_size, int tdb_flags,
 				 int open_flags, mode_t mode)
 {
-	/* TODO: implement this differently */
-	return db_open(mem_ctx, name, hash_size, tdb_flags, open_flags, mode);
+	bool use_tdb2 = lp_parm_bool(-1, "dbwrap", "use_tdb2", false);
+#ifdef CLUSTER_SUPPORT
+	const char *sockname = lp_ctdbd_socket();
+#endif
+
+	if (tdb_flags & TDB_CLEAR_IF_FIRST) {
+		DEBUG(0,("db_open_trans: called with TDB_CLEAR_IF_FIRST: %s\n",
+			 name));
+		smb_panic("db_open_trans: called with TDB_CLEAR_IF_FIRST");
+	}
+
+#ifdef CLUSTER_SUPPORT
+	if(!sockname || !*sockname) {
+		sockname = CTDB_PATH;
+	}
+
+	if (lp_clustering() && socket_exist(sockname)) {
+		const char *partname;
+		/* ctdb only wants the file part of the name */
+		partname = strrchr(name, '/');
+		if (partname) {
+			partname++;
+		} else {
+			partname = name;
+		}
+		/* allow ctdb for individual databases to be disabled */
+		if (lp_parm_bool(-1, "ctdb", partname, true)) {
+			result = db_open_ctdb(mem_ctx, partname, hash_size,
+					      tdb_flags, open_flags, mode);
+			if (result == NULL) {
+				DEBUG(0,("failed to attach to ctdb %s\n",
+					 partname));
+				smb_panic("failed to attach to a ctdb "
+					  "database");
+			}
+		}
+	}
+#endif
+
+	if (use_tdb2) {
+		const char *partname;
+		/* tdb2 only wants the file part of the name */
+		partname = strrchr(name, '/');
+		if (partname) {
+			partname++;
+		} else {
+			partname = name;
+		}
+		/* allow ctdb for individual databases to be disabled */
+		if (lp_parm_bool(-1, "tdb2", partname, true)) {
+			return db_open_tdb2(mem_ctx, partname, hash_size,
+					    tdb_flags, open_flags, mode);
+		}
+	}
+
+	return db_open_tdb(mem_ctx, name, hash_size,
+			   tdb_flags, open_flags, mode);
 }
 
 NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key)
diff --git a/source/lib/dbwrap_tdb2.c b/source/lib/dbwrap_tdb2.c
new file mode 100644
index 0000000..cbcbe71
--- /dev/null
+++ b/source/lib/dbwrap_tdb2.c
@@ -0,0 +1,1265 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Database interface wrapper around tdb/ctdb
+
+   Copyright (C) Volker Lendecke 2005-2007
+   Copyright (C) Stefan Metzmacher 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 "includes.h"
+#include "librpc/gen_ndr/ndr_messaging.h"
+
+struct db_tdb2_ctx {
+	struct db_context *db;
+	const char *name;
+	struct tdb_wrap *mtdb;
+	const char *mtdb_path;
+	bool master_transaction;
+	struct {
+		int hash_size;
+		int tdb_flags;
+		int open_flags;
+		mode_t mode;
+	} open;
+	struct tdb_wrap *ltdb;
+	const char *ltdb_path;
+	bool local_transaction;
+	int transaction;
+	bool out_of_sync;
+	uint32_t lseqnum;
+	uint32_t mseqnum;
+#define DB_TDB2_MASTER_SEQNUM_KEYSTR "DB_TDB2_MASTER_SEQNUM_KEYSTR"
+	TDB_DATA mseqkey;
+	uint32_t max_buffer_size;
+	uint32_t current_buffer_size;
+	struct dbwrap_tdb2_changes changes;
+};
+
+
+static NTSTATUS db_tdb2_store(struct db_record *rec, TDB_DATA data, int flag);
+static NTSTATUS db_tdb2_delete(struct db_record *rec);
+
+static void db_tdb2_queue_change(struct db_tdb2_ctx *db_ctx, const TDB_DATA key);
+static void db_tdb2_send_notify(struct db_tdb2_ctx *db_ctx);
+
+static struct db_context *db_open_tdb2_ex(TALLOC_CTX *mem_ctx,
+					  const char *name,
+					  int hash_size, int tdb_flags,
+					  int open_flags, mode_t mode,
+					  const struct dbwrap_tdb2_changes *chgs);
+
+static int db_tdb2_sync_from_master(struct db_tdb2_ctx *db_ctx,
+				    const struct dbwrap_tdb2_changes *changes);
+
+static int db_tdb2_open_master(struct db_tdb2_ctx *db_ctx, bool transaction,
+			       const struct dbwrap_tdb2_changes *changes);
+static int db_tdb2_commit_local(struct db_tdb2_ctx *db_ctx, uint32_t mseqnum);
+static int db_tdb2_close_master(struct db_tdb2_ctx *db_ctx);
+static int db_tdb2_transaction_cancel(struct db_context *db);
+
+static void db_tdb2_receive_changes(struct messaging_context *msg,
+				    void *private_data,
+				    uint32_t msg_type,
+				    struct server_id server_id,
+				    DATA_BLOB *data);
+
+static struct messaging_context *global_tdb2_msg_ctx;
+static bool global_tdb2_msg_ctx_initialized;
+
+void db_tdb2_setup_messaging(struct messaging_context *msg_ctx, bool server)
+{
+	global_tdb2_msg_ctx = msg_ctx;
+
+	global_tdb2_msg_ctx_initialized = true;
+
+	if (!server) {
+		return;
+	}
+
+	if (!lp_parm_bool(-1, "dbwrap", "use_tdb2", false)) {
+		return;
+	}
+
+	messaging_register(msg_ctx, NULL, MSG_DBWRAP_TDB2_CHANGES,
+			   db_tdb2_receive_changes);
+}
+
+static struct messaging_context *db_tdb2_get_global_messaging_context(void)
+{
+	struct messaging_context *msg_ctx;
+
+	if (global_tdb2_msg_ctx_initialized) {
+		return global_tdb2_msg_ctx;
+	}
+
+	msg_ctx = messaging_init(NULL, procid_self(),
+				 event_context_init(NULL));
+
+	db_tdb2_setup_messaging(msg_ctx, false);
+
+	return global_tdb2_msg_ctx;
+}
+
+struct tdb_fetch_locked_state {
+	TALLOC_CTX *mem_ctx;
+	struct db_record *result;
+};
+
+static int db_tdb2_fetchlock_parse(TDB_DATA key, TDB_DATA data,
+				  void *private_data)
+{
+	struct tdb_fetch_locked_state *state =
+		(struct tdb_fetch_locked_state *)private_data;
+
+	state->result = (struct db_record *)talloc_size(
+		state->mem_ctx,
+		sizeof(struct db_record) + key.dsize + data.dsize);
+
+	if (state->result == NULL) {
+		return 0;
+	}
+
+	state->result->key.dsize = key.dsize;
+	state->result->key.dptr = ((uint8 *)state->result)
+		+ sizeof(struct db_record);
+	memcpy(state->result->key.dptr, key.dptr, key.dsize);
+
+	state->result->value.dsize = data.dsize;
+
+	if (data.dsize > 0) {
+		state->result->value.dptr = state->result->key.dptr+key.dsize;
+		memcpy(state->result->value.dptr, data.dptr, data.dsize);
+	}
+	else {
+		state->result->value.dptr = NULL;
+	}
+
+	return 0;
+}
+
+static struct db_record *db_tdb2_fetch_locked(struct db_context *db,
+					      TALLOC_CTX *mem_ctx, TDB_DATA key)
+{
+	struct db_tdb2_ctx *ctx = talloc_get_type_abort(db->private_data,
+							struct db_tdb2_ctx);
+	struct tdb_fetch_locked_state state;
+
+	/* Do not accidently allocate/deallocate w/o need when debug level is lower than needed */
+	if(DEBUGLEVEL >= 10) {
+		char *keystr = hex_encode(NULL, (unsigned char*)key.dptr, key.dsize);
+		DEBUG(10, (DEBUGLEVEL > 10
+			   ? "Locking key %s\n" : "Locking key %.20s\n",
+			   keystr));
+		TALLOC_FREE(keystr);
+	}
+
+	/*
+	 * we only support modifications within a
+	 * started transaction.
+	 */
+	if (ctx->transaction == 0) {
+		DEBUG(0, ("db_tdb2_fetch_locked[%s]: no transaction started\n",
+			  ctx->name));
+		smb_panic("no transaction");
+		return NULL;
+	}
+
+	state.mem_ctx = mem_ctx;
+	state.result = NULL;
+
+	tdb_parse_record(ctx->mtdb->tdb, key, db_tdb2_fetchlock_parse, &state);
+
+	if (state.result == NULL) {
+		db_tdb2_fetchlock_parse(key, tdb_null, &state);
+	}
+
+	if (state.result == NULL) {
+		return NULL;
+	}
+
+	state.result->private_data = talloc_reference(state.result, ctx);
+	state.result->store = db_tdb2_store;
+	state.result->delete_rec = db_tdb2_delete;
+
+	DEBUG(10, ("Allocated locked data 0x%p\n", state.result));
+
+	return state.result;
+}
+
+struct tdb_fetch_state {
+	TALLOC_CTX *mem_ctx;
+	int result;
+	TDB_DATA data;
+};
+
+static int db_tdb2_fetch_parse(TDB_DATA key, TDB_DATA data,
+			       void *private_data)
+{
+	struct tdb_fetch_state *state =
+		(struct tdb_fetch_state *)private_data;
+
+	state->data.dptr = (uint8 *)talloc_memdup(state->mem_ctx, data.dptr,
+						  data.dsize);
+	if (state->data.dptr == NULL) {
+		state->result = -1;
+		return 0;
+	}
+
+	state->data.dsize = data.dsize;
+	return 0;
+}
+
+static void db_tdb2_resync_before_read(struct db_tdb2_ctx *db_ctx, TDB_DATA *kbuf)
+{
+	if (db_ctx->mtdb) {
+		return;
+	}
+
+	if (!db_ctx->out_of_sync) {
+		return;
+	}
+
+	/*
+	 * this function operates on the local copy,
+	 * so hide the DB_TDB2_MASTER_SEQNUM_KEYSTR from the caller.
+	 */
+	if (kbuf && (db_ctx->mseqkey.dsize == kbuf->dsize) &&
+	    (memcmp(db_ctx->mseqkey.dptr, kbuf->dptr, kbuf->dsize) == 0)) {
+		return;
+	}
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list