r26003: Split up DB_WRAP, as first step in an attempt to sanitize dependencies.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 16 Nov 2007 19:12:00 +0000 (20:12 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:45:40 +0000 (05:45 +0100)
62 files changed:
source/auth/auth_sam.c
source/auth/config.mk
source/auth/credentials/credentials_files.c
source/auth/gensec/schannel_state.c
source/auth/sam.c
source/cldap_server/cldap_server.c
source/cldap_server/netlogon.c
source/cldap_server/rootdse.c
source/cluster/ctdb/brlock_ctdb.c
source/cluster/ctdb/client/ctdb_client.c
source/cluster/ctdb/common/ctdb_ltdb.c
source/cluster/ctdb/ctdb_cluster.c
source/cluster/ctdb/opendb_ctdb.c
source/cluster/local.c
source/dsdb/common/sidmap.c
source/dsdb/samdb/cracknames.c
source/dsdb/samdb/ldb_modules/samldb.c
source/dsdb/samdb/samdb.c
source/dsdb/samdb/samdb_privilege.c
source/kdc/hdb-ldb.c
source/ldap_server/ldap_backend.c
source/lib/basic.mk
source/lib/dbwrap/dbwrap_tdb.c
source/lib/ldb/tools/cmdline.c
source/lib/ldb_wrap.c [moved from source/lib/db_wrap.c with 70% similarity]
source/lib/ldb_wrap.h [new file with mode: 0644]
source/lib/messaging/config.mk
source/lib/messaging/messaging.c
source/lib/registry/ldb.c
source/lib/tdb_wrap.c [new file with mode: 0644]
source/lib/tdb_wrap.h [moved from source/lib/db_wrap.h with 78% similarity]
source/lib/util/config.mk
source/lib/util/util_ldb.c [moved from source/lib/gendb.c with 96% similarity]
source/lib/util/util_ldb.h [new file with mode: 0644]
source/libnet/libnet_become_dc.c
source/libnet/libnet_join.c
source/libnet/libnet_samsync_ldb.c
source/libnet/libnet_unbecome_dc.c
source/nbt_server/dgram/netlogon.c
source/nbt_server/wins/winsdb.c
source/ntptr/simple_ldb/ntptr_simple_ldb.c
source/ntvfs/common/brlock.c
source/ntvfs/common/notify.c
source/ntvfs/common/opendb_tdb.c
source/ntvfs/posix/vfs_posix.c
source/ntvfs/posix/xattr_tdb.c
source/param/config.mk
source/param/secrets.c
source/param/share_ldb.c
source/rpc_server/lsa/dcesrv_lsa.c
source/rpc_server/lsa/lsa.h
source/rpc_server/netlogon/dcerpc_netlogon.c
source/rpc_server/samr/dcesrv_samr.c
source/rpc_server/samr/samr_password.c
source/scripting/ejs/smbcalls_ldb.c
source/scripting/ejs/smbcalls_reg.c
source/torture/ldap/schema.c
source/torture/ldap/uptodatevector.c
source/torture/libnet/libnet_BecomeDC.c
source/torture/local/dbspeed.c
source/torture/rpc/spoolss_notify.c
source/wrepl_server/wrepl_server.c

index da1ffb5c851ffeb5e8f7f89baf8d19b8f16e6bbc..fd92f3ae12635d4314b31c1aaa4ebc579006b215 100644 (file)
@@ -22,7 +22,8 @@
 #include "includes.h"
 #include "librpc/gen_ndr/ndr_netlogon.h"
 #include "system/time.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
+#include "util/util_ldb.h"
 #include "lib/ldb/include/ldb.h"
 #include "auth/auth.h"
 #include "auth/auth_sam.h"
index c34a941d1210f4c91cf7493dcadd022702648563..497fccbc965173047e24c60d298004c4fd21b7f6 100644 (file)
@@ -7,7 +7,7 @@ include credentials/config.mk
 [SUBSYSTEM::auth_sam]
 PRIVATE_PROTO_HEADER = auth_sam.h
 OBJ_FILES = sam.o auth_sam_reply.o ntlm_check.o 
-PUBLIC_DEPENDENCIES = SAMDB
+PUBLIC_DEPENDENCIES = SAMDB UTIL_LDB
 
 #######################
 # Start MODULE auth_sam
index 1708fa5841d123ef596ae63c731d2d9df447361a..db69fc1cb4f3ac2c4deca1665a9cc67bb3ef8dbf 100644 (file)
@@ -26,7 +26,7 @@
 #include "librpc/gen_ndr/samr.h" /* for struct samrPassword */
 #include "param/secrets.h"
 #include "system/filesys.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 #include "auth/credentials/credentials.h"
 #include "auth/credentials/credentials_krb5.h"
 #include "param/param.h"
index 808240c4f4b3e4e923e64b5b21e8c309516ff692..1bb71d8fc9171f99b79d45baa08324f137250e10 100644 (file)
@@ -23,7 +23,8 @@
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
 #include "dsdb/samdb/samdb.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
+#include "util/util_ldb.h"
 #include "libcli/auth/libcli_auth.h"
 #include "auth/auth.h"
 #include "param/param.h"
index ad8d77ecf86049ca0e4ba1da31316728b4ba67c8..6a212b8cfe75bb4d77bb5a214650f0dad3857b8f 100644 (file)
@@ -22,7 +22,8 @@
 #include "includes.h"
 #include "system/time.h"
 #include "auth/auth.h"
-#include "db_wrap.h"
+#include <ldb.h>
+#include "util/util_ldb.h"
 #include "dsdb/samdb/samdb.h"
 #include "libcli/security/security.h"
 #include "libcli/ldap/ldap.h"
index 454beb3ae228b3c52e363376dcbb866be1500e96..ed78f45ca700839aed6c3b670e48e84f12977097 100644 (file)
@@ -31,7 +31,7 @@
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
 #include "dsdb/samdb/samdb.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "auth/auth.h"
 #include "param/param.h"
 
index c6b1fc376b9db510cf06300506d3b2babb45922d..2031f58e7b996a7e9724d7667b2d55548cb285a8 100644 (file)
@@ -30,7 +30,7 @@
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "dsdb/samdb/samdb.h"
 #include "auth/auth.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "system/network.h"
 #include "lib/socket/netif.h"
 #include "param/param.h"
index 10b2d2cdad37129d5b1c8918b6e573660e3ff37d..4ff71c086342225f14c0b9bbfacff53f1d819026 100644 (file)
@@ -30,7 +30,7 @@
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "dsdb/samdb/samdb.h"
 #include "auth/auth.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "system/network.h"
 #include "lib/socket/netif.h"
 
index 8b633358a3b02bed17d433e26807b3d0b431e567..c38d666c3c60f7e1cf039a506faf6ba0b724b38f 100644 (file)
@@ -23,7 +23,6 @@
 #include "system/filesys.h"
 #include "lib/tdb/include/tdb.h"
 #include "messaging/messaging.h"
-#include "db_wrap.h"
 #include "lib/messaging/irpc.h"
 #include "libcli/libcli.h"
 #include "cluster/cluster.h"
index 84c095ec8a63bd7237c90ce7a3f1a7a3833e9c56..2af0d418a8be1057272f2e61418990c53f0aac7d 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 #include "lib/tdb/include/tdb.h"
 #include "lib/util/dlinklist.h"
 #include "lib/events/events.h"
index 8d8b4fd24a22765e3cf15a2dec87a00e986f6bb6..92adc4a12af7aa7190db286459b355a86ac52252 100644 (file)
@@ -23,7 +23,7 @@
 #include "system/network.h"
 #include "system/filesys.h"
 #include "../include/ctdb_private.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 #include "lib/util/dlinklist.h"
 
 /*
index d8860aabd085451186d7078dde14ddec3b2041ff..e4a9742401d591509c9c273973926405627c9520 100644 (file)
@@ -26,7 +26,7 @@
 #include "cluster/cluster_private.h"
 #include "lib/tdb/include/tdb.h"
 #include "include/ctdb.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 #include "lib/util/dlinklist.h"
 #include "param/param.h"
 #include "librpc/gen_ndr/misc.h"
index 53febecb694b5ffad95d5d7c1dd7f34cdf76f65b..c8b673e74d22d755c45c8a643100c76372d7f4b9 100644 (file)
@@ -42,7 +42,7 @@
 #include "system/filesys.h"
 #include "lib/tdb/include/tdb.h"
 #include "messaging/messaging.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 #include "lib/messaging/irpc.h"
 #include "librpc/gen_ndr/ndr_opendb.h"
 #include "ntvfs/ntvfs.h"
index 2abe422d5a9478e3d0617170c8759833cc5564c2..110bc295eb22b1df695177a6bc2588093cb9437f 100644 (file)
@@ -23,7 +23,7 @@
 #include "cluster/cluster.h"
 #include "cluster/cluster_private.h"
 #include "lib/tdb/include/tdb.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 #include "system/filesys.h"
 #include "param/param.h"
 #include "librpc/gen_ndr/misc.h"
index de1f3f3c7a13af5bbfc7583da684b34bc01dbeb1..46052ac2a028d7d12da07a4ccba547a96003f914 100644 (file)
@@ -25,7 +25,7 @@
 #include "dsdb/samdb/samdb.h"
 #include "auth/auth.h"
 #include "libcli/ldap/ldap.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 #include "libcli/security/security.h"
 
 /*
index a4565844ec6cb55dec1b8ce4fb3d36f0ab4d0cdc..e607dbc5deed50b42594099bdcbab34c054806fb 100644 (file)
@@ -31,7 +31,7 @@
 #include "libcli/security/security.h"
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "auth/auth.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 #include "dsdb/samdb/samdb.h"
 
 static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx,
index b1366fd99439c69d82f8b53191784f36cb25d07a..85ca1a7f4bf13f9817c458f4017ed4daadcf16bc 100644 (file)
@@ -39,7 +39,7 @@
 #include "dsdb/samdb/samdb.h"
 #include "libcli/security/security.h"
 #include "librpc/gen_ndr/ndr_security.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 
 int samldb_notice_sid(struct ldb_module *module, 
                      TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
index 8b1c00dc90e9fc08a8fb6f600195020f2de44a50..6eb2ecffaed247e1f1c18fea8f7f866e84ae8843 100644 (file)
@@ -32,7 +32,8 @@
 #include "libcli/ldap/ldap.h"
 #include "system/time.h"
 #include "system/filesys.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
+#include "util/util_ldb.h"
 #include "dsdb/samdb/samdb.h"
 #include "dsdb/common/flags.h"
 #include "param/param.h"
index 23133856045659c6a3451f55ffb5e3f65d0602b1..7fe840fca9fc43cf28e934fdade21ef08fb29f0c 100644 (file)
@@ -24,7 +24,7 @@
 #include "dsdb/samdb/samdb.h"
 #include "auth/auth.h"
 #include "libcli/security/security.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 
 /*
   add privilege bits for one sid to a security_token
index 52f7da25bf3643e99843e053b2bf3e68a6abd674..125852cfa17f65e45f7eb4bf5f55e3005756953a 100644 (file)
@@ -44,7 +44,7 @@
 #include "auth/auth.h"
 #include "auth/credentials/credentials.h"
 #include "auth/auth_sam.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 #include "dsdb/samdb/samdb.h"
 #include "librpc/ndr/libndr.h"
 #include "librpc/gen_ndr/ndr_drsblobs.h"
index 62fe6270dcb33d4ff0041b3d7b95ab4a60569570..5a953947f320d538db3f028b37a0ba3a3d48d4c5 100644 (file)
@@ -23,7 +23,7 @@
 #include "libcli/ldap/ldap.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
-#include "lib/db_wrap.h"
+#include "lib/ldb_wrap.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
 #include "param/param.h"
index d1ed7ede0dcc45f4e1c0bfed7f4bb5130dd20d78..0a0c8237ee64c212e10d4e0838de9e23b58324b3 100644 (file)
@@ -29,9 +29,13 @@ OBJ_FILES = compression/mszip.o
 PRIVATE_PROTO_HEADER = gencache/gencache.h
 OBJ_FILES = gencache/gencache.o \
 
-[SUBSYSTEM::DB_WRAP]
-PUBLIC_PROTO_HEADER = db_wrap_proto.h
-PUBLIC_HEADERS = db_wrap.h
-OBJ_FILES = db_wrap.o gendb.o
-PUBLIC_DEPENDENCIES = LIBTDB LIBLDB
+[SUBSYSTEM::LDB_WRAP]
+PUBLIC_HEADERS = ldb_wrap.h
+OBJ_FILES = ldb_wrap.o
+PUBLIC_DEPENDENCIES = LIBLDB
 PRIVATE_DEPENDENCIES = LDBSAMBA
+
+[SUBSYSTEM::TDB_WRAP]
+PUBLIC_HEADERS = tdb_wrap.h
+OBJ_FILES = tdb_wrap.o
+PUBLIC_DEPENDENCIES = LIBTDB
index b256b6ccc4d2f9c18983111261acc98d8fab58cf..621b19532d80b9ee374fc87b461cec0f0e227307 100644 (file)
@@ -24,7 +24,7 @@
 #include "lib/tdb/include/tdb.h"
 #include "lib/dbwrap/dbwrap.h"
 #include "system/filesys.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 #include "param/param.h"
 
 struct db_tdb_ctx {
index a713f54e685f3e6d6f395e09566b743db94bddb6..01ef04f5d2d230737a1d53f51ee8cf76029d5240 100644 (file)
@@ -30,7 +30,7 @@
 #include "lib/ldb-samba/ldif_handlers.h"
 #include "auth/gensec/gensec.h"
 #include "auth/auth.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #endif
 
 
similarity index 70%
rename from source/lib/db_wrap.c
rename to source/lib/ldb_wrap.c
index c33786a1e43a8c0b83b8259c9972357e23ff33d6..659b91d2547311a39c211cc73f22e1b0f2fe4b25 100644 (file)
@@ -1,7 +1,7 @@
 /* 
    Unix SMB/CIFS implementation.
 
-   database wrap functions
+   LDB wrap functions
 
    Copyright (C) Andrew Tridgell 2004
    
 */
 
 #include "includes.h"
-#include "lib/util/dlinklist.h"
 #include "lib/events/events.h"
-#include "lib/tdb/include/tdb.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
 #include "lib/ldb-samba/ldif_handlers.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "dsdb/samdb/samdb.h"
+#include "dsdb/schema/proto.h"
 #include "param/param.h"
 
-static struct tdb_wrap *tdb_list;
-
 /*
   this is used to catch debug messages from ldb
 */
@@ -71,11 +68,6 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level,
        free(s);
 }
 
-char *wrap_casefold(void *context, void *mem_ctx, const char *s)
-{
-       return strupper_talloc(mem_ctx, s);
-}
-
 /* check for memory leaks on the ldb context */
 static int ldb_wrap_destructor(struct ldb_context *ldb)
 {
@@ -192,91 +184,4 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
 }
 
 
-/*
- Log tdb messages via DEBUG().
-*/
-static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, 
-                        const char *format, ...) PRINTF_ATTRIBUTE(3,4);
-
-static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, 
-                        const char *format, ...)
-{
-       va_list ap;
-       char *ptr = NULL;
-       int debug_level;
-
-       va_start(ap, format);
-       vasprintf(&ptr, format, ap);
-       va_end(ap);
-       
-       switch (level) {
-       case TDB_DEBUG_FATAL:
-               debug_level = 0;
-               break;
-       case TDB_DEBUG_ERROR:
-               debug_level = 1;
-               break;
-       case TDB_DEBUG_WARNING:
-               debug_level = 2;
-               break;
-       case TDB_DEBUG_TRACE:
-               debug_level = 5;
-               break;
-       default:
-               debug_level = 0;
-       }               
-
-       if (ptr != NULL) {
-               const char *name = tdb_name(tdb);
-               DEBUG(debug_level, ("tdb(%s): %s", name ? name : "unnamed", ptr));
-               free(ptr);
-       }
-}
 
-
-/* destroy the last connection to a tdb */
-static int tdb_wrap_destructor(struct tdb_wrap *w)
-{
-       tdb_close(w->tdb);
-       DLIST_REMOVE(tdb_list, w);
-       return 0;
-}                               
-
-/*
-  wrapped connection to a tdb database
-  to close just talloc_free() the tdb_wrap pointer
- */
-struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
-                              const char *name, int hash_size, int tdb_flags,
-                              int open_flags, mode_t mode)
-{
-       struct tdb_wrap *w;
-       struct tdb_logging_context log_ctx;
-       log_ctx.log_fn = tdb_wrap_log;
-
-       for (w=tdb_list;w;w=w->next) {
-               if (strcmp(name, w->name) == 0) {
-                       return talloc_reference(mem_ctx, w);
-               }
-       }
-
-       w = talloc(mem_ctx, struct tdb_wrap);
-       if (w == NULL) {
-               return NULL;
-       }
-
-       w->name = talloc_strdup(w, name);
-
-       w->tdb = tdb_open_ex(name, hash_size, tdb_flags, 
-                            open_flags, mode, &log_ctx, NULL);
-       if (w->tdb == NULL) {
-               talloc_free(w);
-               return NULL;
-       }
-
-       talloc_set_destructor(w, tdb_wrap_destructor);
-
-       DLIST_ADD(tdb_list, w);
-
-       return w;
-}
diff --git a/source/lib/ldb_wrap.h b/source/lib/ldb_wrap.h
new file mode 100644 (file)
index 0000000..d3ff04b
--- /dev/null
@@ -0,0 +1,41 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   database wrap headers
+
+   Copyright (C) Andrew Tridgell 2004
+   
+   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/>.
+*/
+
+#ifndef _LDB_WRAP_H_
+#define _LDB_WRAP_H_
+
+struct auth_session_info;
+struct ldb_message;
+struct ldb_dn;
+struct cli_credentials;
+struct loadparm_context;
+
+char *wrap_casefold(void *context, void *mem_ctx, const char *s);
+
+struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
+                                    struct loadparm_context *lp_ctx,
+                                    const char *url,
+                                    struct auth_session_info *session_info,
+                                    struct cli_credentials *credentials,
+                                    unsigned int flags,
+                                    const char *options[]);
+
+#endif /* _LDB_WRAP_H_ */
index 85a57917032a8f36e154585b6c95429b454d3fe1..843851e8531830bd891f759f66d6e59ab9117c49 100644 (file)
@@ -6,7 +6,7 @@ OBJ_FILES = \
                messaging.o
 PUBLIC_DEPENDENCIES = \
                LIBSAMBA-UTIL \
-               DB_WRAP \
+               TDB_WRAP \
                NDR_IRPC \
                UNIX_PRIVS \
                UTIL_TDB \
index 963dfe4f0c4fb54a812210cc140b68fa07f5f373..df0bfa32a69f5c03344782a104948212e19f0812 100644 (file)
@@ -27,7 +27,7 @@
 #include "lib/socket/socket.h"
 #include "librpc/gen_ndr/ndr_irpc.h"
 #include "lib/messaging/irpc.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 #include "lib/util/unix_privs.h"
 #include "librpc/rpc/dcerpc.h"
 #include "lib/tdb/include/tdb.h"
index 4a6ef65bc4da988282ca1cab73d52f402ce5470b..fdd4c2759986ba1b9142a2c045713631ab65981f 100644 (file)
@@ -21,7 +21,7 @@
 #include "registry.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "librpc/gen_ndr/winreg.h"
 #include "param/param.h"
 
diff --git a/source/lib/tdb_wrap.c b/source/lib/tdb_wrap.c
new file mode 100644 (file)
index 0000000..37095df
--- /dev/null
@@ -0,0 +1,117 @@
+/* 
+   Unix SMB/CIFS implementation.
+   TDB wrap functions
+
+   Copyright (C) Andrew Tridgell 2004
+   Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
+   
+   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 "lib/tdb/include/tdb.h"
+#include "lib/util/dlinklist.h"
+#include "tdb_wrap.h"
+#include "tdb.h"
+
+static struct tdb_wrap *tdb_list;
+
+/* destroy the last connection to a tdb */
+static int tdb_wrap_destructor(struct tdb_wrap *w)
+{
+       tdb_close(w->tdb);
+       DLIST_REMOVE(tdb_list, w);
+       return 0;
+}                               
+
+/*
+ Log tdb messages via DEBUG().
+*/
+static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, 
+                        const char *format, ...) PRINTF_ATTRIBUTE(3,4);
+
+static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, 
+                        const char *format, ...)
+{
+       va_list ap;
+       char *ptr = NULL;
+       int debug_level;
+
+       va_start(ap, format);
+       vasprintf(&ptr, format, ap);
+       va_end(ap);
+       
+       switch (level) {
+       case TDB_DEBUG_FATAL:
+               debug_level = 0;
+               break;
+       case TDB_DEBUG_ERROR:
+               debug_level = 1;
+               break;
+       case TDB_DEBUG_WARNING:
+               debug_level = 2;
+               break;
+       case TDB_DEBUG_TRACE:
+               debug_level = 5;
+               break;
+       default:
+               debug_level = 0;
+       }               
+
+       if (ptr != NULL) {
+               const char *name = tdb_name(tdb);
+               DEBUG(debug_level, ("tdb(%s): %s", name ? name : "unnamed", ptr));
+               free(ptr);
+       }
+}
+
+
+/*
+  wrapped connection to a tdb database
+  to close just talloc_free() the tdb_wrap pointer
+ */
+struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
+                              const char *name, int hash_size, int tdb_flags,
+                              int open_flags, mode_t mode)
+{
+       struct tdb_wrap *w;
+       struct tdb_logging_context log_ctx;
+       log_ctx.log_fn = tdb_wrap_log;
+
+       for (w=tdb_list;w;w=w->next) {
+               if (strcmp(name, w->name) == 0) {
+                       return talloc_reference(mem_ctx, w);
+               }
+       }
+
+       w = talloc(mem_ctx, struct tdb_wrap);
+       if (w == NULL) {
+               return NULL;
+       }
+
+       w->name = talloc_strdup(w, name);
+
+       w->tdb = tdb_open_ex(name, hash_size, tdb_flags, 
+                            open_flags, mode, &log_ctx, NULL);
+       if (w->tdb == NULL) {
+               talloc_free(w);
+               return NULL;
+       }
+
+       talloc_set_destructor(w, tdb_wrap_destructor);
+
+       DLIST_ADD(tdb_list, w);
+
+       return w;
+}
similarity index 78%
rename from source/lib/db_wrap.h
rename to source/lib/tdb_wrap.h
index b45a05c24f5741f1566e4924d0148ab76b06e7fb..bb36cabd40fc4aeb48c61bb40548eb67fb9415bf 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifndef _TDB_WRAP_H_
+#define _TDB_WRAP_H_
+
+#include "tdb.h"
 
 struct tdb_wrap {
        struct tdb_context *tdb;
@@ -27,10 +31,8 @@ struct tdb_wrap {
        struct tdb_wrap *next, *prev;
 };
 
-struct auth_session_info;
-struct ldb_message;
-struct ldb_dn;
-struct cli_credentials;
-struct loadparm_context;
+struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
+                              const char *name, int hash_size, int tdb_flags,
+                              int open_flags, mode_t mode);
 
-#include "lib/db_wrap_proto.h"
+#endif /* _TDB_WRAP_H_ */
index 0691bd7889df6aaca8175501c64609fd5c592618..01ad14aa95be880e86999515b603165e037e2175 100644 (file)
@@ -49,12 +49,14 @@ PUBLIC_DEPENDENCIES = XATTR
 # End SUBSYSTEM WRAP_XATTR
 ################################################
 
-################################################
-# Start SUBSYSTEM UTIL_TDB
 [SUBSYSTEM::UTIL_TDB]
 PUBLIC_PROTO_HEADER = util_tdb.h
 OBJ_FILES = \
                util_tdb.o
 PUBLIC_DEPENDENCIES = LIBTDB
-# End SUBSYSTEM UTIL_TDB
-################################################
+
+[SUBSYSTEM::UTIL_LDB]
+PUBLIC_PROTO_HEADER = util_ldb.h
+OBJ_FILES = \
+                       util_ldb.o
+PUBLIC_DEPENDENCIES = LIBLDB
similarity index 96%
rename from source/lib/gendb.c
rename to source/lib/util/util_ldb.c
index 35b55a1fd75e911f228e845bd200064fd9bfa0d4..ba8443c23642fc576ea16db5dba1593e5e10cb21 100644 (file)
@@ -23,7 +23,6 @@
 #include "includes.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
-#include "lib/db_wrap.h"
 
 /*
   search the sam for the specified attributes - va_list variant
@@ -123,3 +122,10 @@ int gendb_add_ldif(struct ldb_context *ldb, const char *ldif_string)
        talloc_free(ldif);
        return ret;
 }
+
+char *wrap_casefold(void *context, void *mem_ctx, const char *s)
+{
+       return strupper_talloc(mem_ctx, s);
+}
+
+
diff --git a/source/lib/util/util_ldb.h b/source/lib/util/util_ldb.h
new file mode 100644 (file)
index 0000000..f4f56d6
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef __LIB_UTIL_UTIL_LDB_H__
+#define __LIB_UTIL_UTIL_LDB_H__
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
+/* This file was automatically generated by mkproto.pl. DO NOT EDIT */
+
+#ifndef _PUBLIC_
+#define _PUBLIC_
+#endif
+
+#ifndef _PURE_
+#define _PURE_
+#endif
+
+#ifndef _NORETURN_
+#define _NORETURN_
+#endif
+
+#ifndef _DEPRECATED_
+#define _DEPRECATED_
+#endif
+
+#ifndef _WARN_UNUSED_RESULT_
+#define _WARN_UNUSED_RESULT_
+#endif
+
+
+/* The following definitions come from lib/util/util_ldb.c  */
+
+int gendb_search_v(struct ldb_context *ldb, 
+                  TALLOC_CTX *mem_ctx,
+                  struct ldb_dn *basedn,
+                  struct ldb_message ***msgs,
+                  const char * const *attrs,
+                  const char *format, 
+                  va_list ap)  _PRINTF_ATTRIBUTE(6,0);
+int gendb_search(struct ldb_context *ldb,
+                TALLOC_CTX *mem_ctx, 
+                struct ldb_dn *basedn,
+                struct ldb_message ***res,
+                const char * const *attrs,
+                const char *format, ...) _PRINTF_ATTRIBUTE(6,7);
+int gendb_search_dn(struct ldb_context *ldb,
+                TALLOC_CTX *mem_ctx, 
+                struct ldb_dn *dn,
+                struct ldb_message ***res,
+                const char * const *attrs);
+int gendb_add_ldif(struct ldb_context *ldb, const char *ldif_string);
+char *wrap_casefold(void *context, void *mem_ctx, const char *s);
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2)
+
+#endif /* __LIB_UTIL_UTIL_LDB_H__ */
+
index 7cf2eca1dbbe06b66cffaa25f5c6ea2fef98c97a..2673af8e0fdd0c04710c76ae5aa2a60e965588d3 100644 (file)
@@ -23,7 +23,7 @@
 #include "libcli/cldap/cldap.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
-#include "lib/db_wrap.h"
+#include "lib/ldb_wrap.h"
 #include "dsdb/samdb/samdb.h"
 #include "dsdb/common/flags.h"
 #include "librpc/gen_ndr/ndr_drsuapi_c.h"
index 4abd2954f88e64d98ed71494355ed1a61d9dd504..215217bfef425bf9c5c0ee5717933262b2e30ff5 100644 (file)
@@ -26,7 +26,8 @@
 #include "lib/ldb/include/ldb_errors.h"
 #include "param/secrets.h"
 #include "dsdb/samdb/samdb.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
+#include "util/util_ldb.h"
 #include "libcli/security/security.h"
 #include "auth/credentials/credentials.h"
 #include "auth/credentials/credentials_krb5.h"
index 72b6a3923990e680b9847bc9aa825597a3395307..86e5af2d6ede3151829143504316382d557dbe85 100644 (file)
@@ -27,8 +27,9 @@
 #include "libcli/ldap/ldap.h"
 #include "dsdb/samdb/samdb.h"
 #include "auth/auth.h"
+#include "util/util_ldb.h"
 #include "librpc/gen_ndr/ndr_misc.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "libcli/security/security.h"
 #include "librpc/rpc/dcerpc.h"
 #include "param/param.h"
index 40b1aab2152e0bac7eca0c471b1bcaeb8cbf8b6d..8b27d8571883c8c140432a572bef74d99b51235c 100644 (file)
@@ -23,7 +23,7 @@
 #include "libcli/cldap/cldap.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
-#include "lib/db_wrap.h"
+#include "lib/ldb_wrap.h"
 #include "dsdb/samdb/samdb.h"
 #include "dsdb/common/flags.h"
 #include "librpc/gen_ndr/ndr_drsuapi_c.h"
index 2f96970a65eee17bed67892222c4349bca69bd4c..86720283488c97be904b437748bb3d1d8e1bc470 100644 (file)
@@ -25,7 +25,7 @@
 #include "lib/ldb/include/ldb.h"
 #include "dsdb/samdb/samdb.h"
 #include "auth/auth.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
 #include "param/param.h"
 
index 91996b24d38cf1366be5ff2877a356df0c6bc37c..6ba03638245e59bb2982bddee59237c71e6cac51 100644 (file)
@@ -27,7 +27,7 @@
 #include "lib/ldb/include/ldb_errors.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
 #include "system/time.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "system/network.h"
 #include "lib/socket/netif.h"
 #include "param/param.h"
index 2544e9eb9727ddc3ba3aed4a4f438fd1d37fcfa4..e59d84ff919d6dd94299a8c887c932e603fa9b17 100644 (file)
@@ -33,7 +33,8 @@
 #include "lib/ldb/include/ldb.h"
 #include "auth/auth.h"
 #include "dsdb/samdb/samdb.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
+#include "util/util_ldb.h"
 #include "rpc_server/common/common.h"
 #include "param/param.h"
 
index 27d7437f4ff11e8a032462119a9486e0bf0fcb8d..ddf3219a9a0ebc337deb503b91736b4a6e23e282 100644 (file)
@@ -28,7 +28,6 @@
 #include "system/filesys.h"
 #include "lib/tdb/include/tdb.h"
 #include "messaging/messaging.h"
-#include "db_wrap.h"
 #include "lib/messaging/irpc.h"
 #include "libcli/libcli.h"
 #include "cluster/cluster.h"
index 4578dfbf100e30e2dfd9df8daadabc19eb80596c..16cf4e4b5421c739e080e6538aea6c4b4562d5fe 100644 (file)
@@ -28,7 +28,7 @@
 #include "lib/tdb/include/tdb.h"
 #include "lib/util/util_tdb.h"
 #include "messaging/messaging.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 #include "lib/messaging/irpc.h"
 #include "librpc/gen_ndr/ndr_notify.h"
 #include "lib/util/dlinklist.h"
index 07eef829e1313a56d1bfa4c1e7b0e03941308a42..9926bf8d3ef908ba12aed40ef7a46f42e9e36384 100644 (file)
@@ -41,7 +41,7 @@
 #include "system/filesys.h"
 #include "lib/tdb/include/tdb.h"
 #include "messaging/messaging.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 #include "lib/messaging/irpc.h"
 #include "librpc/gen_ndr/ndr_opendb.h"
 #include "ntvfs/ntvfs.h"
index 208c9e62b70e9117727c6b71ebcd6786f54c8880..24aa023de5f40fed23f67986104c6e255eb3f44f 100644 (file)
@@ -27,7 +27,8 @@
 #include "vfs_posix.h"
 #include "librpc/gen_ndr/security.h"
 #include "lib/tdb/include/tdb.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
+#include "util/util_ldb.h"
 #include "libcli/security/security.h"
 #include "lib/events/events.h"
 
index b49b11a72dad6811cfd207dcb6cdd3c6ff5e09d6..1113ac1739cd37eaf225b06e6d9797a15dd14ab0 100644 (file)
@@ -22,7 +22,7 @@
 #include "includes.h"
 #include "vfs_posix.h"
 #include "lib/tdb/include/tdb.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 
 #define XATTR_LIST_ATTR ".xattr_list"
 
index 5ed10972960ed63e12b19ac7dc54ba67ebb43205..7082a8bca3d3684f95405acfdd34d87ef056d8b4 100644 (file)
@@ -47,4 +47,4 @@ PRIVATE_DEPENDENCIES = LIBLDB
 
 [SUBSYSTEM::SECRETS]
 OBJ_FILES = secrets.o
-PRIVATE_DEPENDENCIES = DB_WRAP UTIL_TDB
+PRIVATE_DEPENDENCIES = LDB_WRAP UTIL_TDB
index 6640fd473d9156382aa9ca44413b81ceb7c2ed95..aea27d1cfc1a181bc1bacf234e8b304c72607ce7 100644 (file)
 #include "secrets.h"
 #include "param/param.h"
 #include "system/filesys.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
+#include "ldb_wrap.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/tdb/include/tdb.h"
 #include "lib/util/util_tdb.h"
+#include "lib/util/util_ldb.h"
 #include "dsdb/samdb/samdb.h"
 
 static struct tdb_wrap *tdb;
index 019b1616391ae185861a36c3fd6069829797ed29..ece9c0544b22bf727ea4d3adeebeb7acd09d2929 100644 (file)
@@ -23,7 +23,7 @@
 #include "ldb/include/ldb.h"
 #include "ldb/include/ldb_errors.h"
 #include "auth/auth.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "param/share.h"
 #include "param/param.h"
 
index 25d6f8c8f71128774bf9a3965f96907925b4c6e1..0b426145c6f6099616eaec4ff96ae80aafee60e2 100644 (file)
@@ -21,6 +21,7 @@
 */
 
 #include "rpc_server/lsa/lsa.h"
+#include "util/util_ldb.h"
 
 /*
   this type allows us to distinguish handle types
index 6ecda0ff820a2d00415356e9384bc14d93ae88c9..3959311b99b3234e0f1a814e790d1e13c17ada81 100644 (file)
@@ -30,7 +30,7 @@
 #include "libcli/security/security.h"
 #include "libcli/auth/libcli_auth.h"
 #include "param/secrets.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 #include "librpc/gen_ndr/ndr_dssetup.h"
 #include "param/param.h"
 
index 7bee070251f672119dec15320780f364e0f370ed..b8f0103901e7d869936771c1b71a054b3d43cd62 100644 (file)
@@ -28,7 +28,7 @@
 #include "auth/auth_sam.h"
 #include "dsdb/samdb/samdb.h"
 #include "rpc_server/samr/proto.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 #include "libcli/auth/libcli_auth.h"
 #include "auth/gensec/schannel_state.h"
 #include "libcli/security/security.h"
index 0ec979b81f3f5364de17bb8e23ba995d3703f5d3..e0d965da9e418a52b1cae605b495131119c478d3 100644 (file)
@@ -34,7 +34,7 @@
 #include "libcli/ldap/ldap.h"
 #include "libcli/security/security.h"
 #include "rpc_server/samr/proto.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 #include "param/param.h"
 
 /* these query macros make samr_Query[User|Group]Info a bit easier to read */
index 28816c03f8e4659922b85035cfe317498327c119..a38f9840b666e86cf57c70ef2e99a476f9ad4097 100644 (file)
@@ -32,7 +32,7 @@
 #include "auth/auth.h"
 #include "rpc_server/samr/proto.h"
 #include "libcli/auth/libcli_auth.h"
-#include "db_wrap.h"
+#include "util/util_ldb.h"
 
 /* 
   samr_ChangePasswordUser 
index 04162830b4dbcbb740205fa1f6e755b65d67b01e..b8c35d267edc27ca25404197b8e4049ae2cd8800 100644 (file)
@@ -25,7 +25,7 @@
 #include "lib/appweb/ejs/ejs.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "dsdb/samdb/samdb.h"
 #include "librpc/ndr/libndr.h"
 
index d4b13cc2ca50775268efeb0b40eaab6c9b2a3a36..38634b996c9f1f91edc3f17367958266349c7b37 100644 (file)
@@ -22,7 +22,6 @@
 #include "includes.h"
 #include "scripting/ejs/smbcalls.h"
 #include "lib/appweb/ejs/ejs.h"
-#include "db_wrap.h"
 #include "dsdb/samdb/samdb.h"
 #include "librpc/ndr/libndr.h"
 #include "lib/registry/registry.h"
index 30fd9877e63310e3e714c4d01bac37df16fa4167..9d9195bb9d7625a3672f5f69dbd45f32885beda8 100644 (file)
@@ -22,7 +22,7 @@
 #include "includes.h"
 #include "libcli/ldap/ldap_client.h"
 #include "lib/cmdline/popt_common.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
 #include "dsdb/samdb/samdb.h"
index 7b1614af5229cc3ec8ff56629b6c831d502adacd..aa473ff5cf707c2ec196bf0b6bed19b650b37d18 100644 (file)
@@ -22,7 +22,7 @@
 #include "includes.h"
 #include "libcli/ldap/ldap_client.h"
 #include "lib/cmdline/popt_common.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
 #include "dsdb/samdb/samdb.h"
index 65d4deaaa4a5f095d34335b178c7573fdf1c79ed..ef8e4d03c0932ec053d79bc7f5cb7b325db3c522 100644 (file)
@@ -35,7 +35,7 @@
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "system/time.h"
 #include "auth/auth.h"
-#include "lib/db_wrap.h"
+#include "lib/ldb_wrap.h"
 #include "lib/appweb/ejs/ejs.h"
 #include "lib/appweb/ejs/ejsInternal.h"
 #include "scripting/ejs/smbcalls.h"
index 34458123650a10b6160364a33c2eceb3a76117b7..8bef01c20ac52415de65a497aff5d36767c8ca88 100644 (file)
@@ -24,7 +24,8 @@
 #include "lib/tdb/include/tdb.h"
 #include "lib/ldb/include/ldb.h"
 #include "lib/ldb/include/ldb_errors.h"
-#include "lib/db_wrap.h"
+#include "lib/ldb_wrap.h"
+#include "lib/tdb_wrap.h"
 #include "torture/torture.h"
 #include "param/param.h"
 
index bffbd1108cd46fe74e957685cc0e4a802d340853..2547f8ce001c4111686c3e3f8ff043c349631909 100644 (file)
@@ -29,7 +29,7 @@
 #include "smbd/process_model.h"
 #include "smb_server/smb_server.h"
 #include "lib/socket/netif.h"
-#include "dlinklist.h"
+#include "util/dlinklist.h"
 #include "ntvfs/ntvfs.h"
 #include "param/param.h"
 
index be606b2a0cceee5c244d32e77bd150e114d294fe..834d9a70e8119d694a419951bf6b1e5c9caf7846 100644 (file)
@@ -30,7 +30,7 @@
 #include "ldb/include/ldb.h"
 #include "ldb/include/ldb_errors.h"
 #include "auth/auth.h"
-#include "db_wrap.h"
+#include "ldb_wrap.h"
 #include "param/param.h"
 
 static struct ldb_context *wins_config_db_connect(TALLOC_CTX *mem_ctx)