[SCM] Samba Shared Repository - branch v3-6-test updated
Günther Deschner
gd at samba.org
Mon May 16 10:16:45 MDT 2011
The branch, v3-6-test has been updated
via 138da8f s3: only include tdb headers where needed.
via a7f3984 lib/util Move source3 tdb_wrap_open() into the common code.
from f407006 s3-includes: remove ipv6 related prototype which is already defined in ../lib/util/util_net.h.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test
- Log -----------------------------------------------------------------
commit 138da8f4b1eb4715b7fb259986b9c1e8ffae469e
Author: Günther Deschner <gd at samba.org>
Date: Thu May 5 11:25:29 2011 +0200
s3: only include tdb headers where needed.
Guenther
(cherry picked from commit d8cfca3a9bd2b6b6c562fd202377d95a98eb5472)
commit a7f39847ebf29b821aab2570a2f2bd841a28e836
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed May 4 10:28:15 2011 +1000
lib/util Move source3 tdb_wrap_open() into the common code.
This #if _SAMBA_BUILD == 3 is very unfortunate, as it means that in
the top level build, these options are not available for these
databases. However, having two different tdb_wrap lists is a worse
fate, so this will do for now.
Andrew Bartlett
(cherry picked from commit 14750139639b3531e57a3ca3f9e481d6e458dc06)
-----------------------------------------------------------------------
Summary of changes:
lib/util/tdb_wrap.c | 194 +++++++++++++++++++++++++
{source4/lib => lib/util}/tdb_wrap.h | 3 -
lib/util/util_tdb.h | 1 -
lib/util/wscript_build | 10 ++
libcli/auth/schannel_state_tdb.c | 4 +-
source3/Makefile.in | 1 +
source3/groupdb/mapping.c | 1 +
source3/groupdb/mapping_tdb.c | 1 +
source3/include/ctdbd_conn.h | 2 +
source3/include/dbwrap.h | 2 +
source3/include/includes.h | 3 +-
source3/include/printing.h | 7 +-
source3/include/util_tdb.h | 8 -
source3/intl/lang_tdb.c | 1 +
source3/lib/ctdbd_conn.c | 1 +
source3/lib/dbwrap.c | 1 +
source3/lib/dbwrap_ctdb.c | 2 +
source3/lib/dbwrap_tdb.c | 1 +
source3/lib/dbwrap_util.c | 1 +
source3/lib/eventlog/eventlog.c | 1 +
source3/lib/eventlog/eventlog.h | 2 +
source3/lib/g_lock.c | 1 +
source3/lib/gencache.c | 1 +
source3/lib/messages_ctdbd.c | 1 +
source3/lib/messages_local.c | 1 +
source3/lib/server_mutex.c | 2 +
source3/lib/serverid.c | 2 +
source3/lib/sessionid_tdb.c | 1 +
source3/lib/sharesec.c | 1 +
source3/lib/talloc_dict.c | 1 +
source3/lib/tdb_validate.c | 1 +
source3/lib/util.c | 1 +
source3/lib/util_tdb.c | 161 +--------------------
source3/libnet/libnet_dssync_passdb.c | 1 +
source3/libsmb/samlogon_cache.c | 1 +
source3/libsmb/smb_share_modes.c | 1 +
source3/locking/locking.c | 1 +
source3/locking/posix.c | 1 +
source3/modules/nfs4_acls.c | 1 +
source3/modules/vfs_acl_tdb.c | 1 +
source3/modules/vfs_xattr_tdb.c | 1 +
source3/nmbd/nmbd_winsserver.c | 1 +
source3/param/loadparm.c | 1 +
source3/passdb/login_cache.c | 1 +
source3/passdb/machine_account_secrets.c | 1 +
source3/passdb/passdb.c | 1 +
source3/passdb/pdb_tdb.c | 1 +
source3/passdb/secrets.c | 1 +
source3/printing/notify.c | 1 +
source3/printing/nt_printing_migrate.c | 1 +
source3/printing/nt_printing_tdb.c | 1 +
source3/printing/printer_list.c | 1 +
source3/printing/printing.c | 1 +
source3/printing/printing_db.c | 3 +-
source3/printing/tests/vlp.c | 1 +
source3/registry/reg_backend_db.c | 1 +
source3/registry/reg_objects.c | 1 +
source3/registry/reg_perfcount.c | 1 +
source3/rpc_server/eventlog/srv_eventlog_nt.c | 1 +
source3/rpc_server/spoolss/srv_spoolss_nt.c | 1 +
source3/smbd/files.c | 1 +
source3/smbd/globals.c | 1 +
source3/smbd/globals.h | 3 +-
source3/smbd/mangle_hash.c | 1 +
source3/smbd/notify_internal.c | 2 +
source3/smbd/proto.h | 3 +-
source3/smbd/statcache.c | 3 +-
source3/torture/mangle_test.c | 1 +
source3/torture/torture.c | 1 +
source3/utils/net_idmap.c | 1 +
source3/utils/net_idmap_check.c | 1 +
source3/utils/net_printing.c | 1 +
source3/utils/smbcontrol.c | 1 +
source3/winbindd/idmap_autorid.c | 1 +
source3/winbindd/idmap_tdb.c | 1 +
source3/winbindd/idmap_tdb2.c | 1 +
source3/winbindd/winbindd_cache.c | 1 +
source3/wscript_build | 2 +-
source4/cluster/local.c | 2 +-
source4/lib/messaging/messaging.c | 2 +-
source4/lib/tdb_wrap.c | 117 ---------------
source4/lib/wscript_build | 9 -
source4/ntvfs/common/brlock_tdb.c | 2 +-
source4/ntvfs/common/notify.c | 2 +-
source4/ntvfs/common/opendb_tdb.c | 2 +-
source4/ntvfs/posix/python/pyxattr_tdb.c | 2 +-
source4/ntvfs/posix/vfs_posix.c | 2 +-
source4/ntvfs/posix/xattr_tdb.c | 2 +-
source4/param/secrets.c | 2 +-
source4/torture/local/dbspeed.c | 2 +-
90 files changed, 303 insertions(+), 319 deletions(-)
create mode 100644 lib/util/tdb_wrap.c
rename {source4/lib => lib/util}/tdb_wrap.h (96%)
delete mode 100644 source4/lib/tdb_wrap.c
Changeset truncated at 500 lines:
diff --git a/lib/util/tdb_wrap.c b/lib/util/tdb_wrap.c
new file mode 100644
index 0000000..c9562c6
--- /dev/null
+++ b/lib/util/tdb_wrap.c
@@ -0,0 +1,194 @@
+/*
+ Unix SMB/CIFS implementation.
+ TDB wrap functions
+
+ Copyright (C) Andrew Tridgell 2004
+ Copyright (C) Jelmer Vernooij <jelmer at 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 <tdb.h>
+#include "lib/util/dlinklist.h"
+#include "lib/util/tdb_wrap.h"
+#include <tdb.h>
+
+/*
+ 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 debuglevel = 0;
+ int ret;
+
+ switch (level) {
+ case TDB_DEBUG_FATAL:
+ debuglevel = 0;
+ break;
+ case TDB_DEBUG_ERROR:
+ debuglevel = 1;
+ break;
+ case TDB_DEBUG_WARNING:
+ debuglevel = 2;
+ break;
+ case TDB_DEBUG_TRACE:
+ debuglevel = 5;
+ break;
+ default:
+ debuglevel = 0;
+ }
+
+ va_start(ap, format);
+ ret = vasprintf(&ptr, format, ap);
+ va_end(ap);
+
+ if (ret != -1) {
+ const char *name = tdb_name(tdb);
+ DEBUG(debuglevel, ("tdb(%s): %s", name ? name : "unnamed", ptr));
+ free(ptr);
+ }
+}
+
+struct tdb_wrap_private {
+ struct tdb_context *tdb;
+ const char *name;
+ struct tdb_wrap_private *next, *prev;
+};
+
+static struct tdb_wrap_private *tdb_list;
+
+/* destroy the last connection to a tdb */
+static int tdb_wrap_private_destructor(struct tdb_wrap_private *w)
+{
+ tdb_close(w->tdb);
+ DLIST_REMOVE(tdb_list, w);
+ return 0;
+}
+
+static struct tdb_wrap_private *tdb_wrap_private_open(TALLOC_CTX *mem_ctx,
+ const char *name,
+ int hash_size,
+ int tdb_flags,
+ int open_flags,
+ mode_t mode)
+{
+ struct tdb_wrap_private *result;
+ struct tdb_logging_context log_ctx;
+
+ result = talloc(mem_ctx, struct tdb_wrap_private);
+ if (result == NULL) {
+ return NULL;
+ }
+ result->name = talloc_strdup(result, name);
+ if (result->name == NULL) {
+ goto fail;
+ }
+
+ log_ctx.log_fn = tdb_wrap_log;
+
+#if _SAMBA_BUILD_ == 3
+ /* This #if _SAMBA_BUILD == 3 is very unfortunate, as it means
+ * that in the top level build, these options are not
+ * available for these databases. However, having two
+ * different tdb_wrap lists is a worse fate, so this will do
+ * for now */
+
+ if (!lp_use_mmap()) {
+ tdb_flags |= TDB_NOMMAP;
+ }
+
+ if ((hash_size == 0) && (name != NULL)) {
+ const char *base;
+ base = strrchr_m(name, '/');
+
+ if (base != NULL) {
+ base += 1;
+ } else {
+ base = name;
+ }
+ hash_size = lp_parm_int(-1, "tdb_hashsize", base, 0);
+ }
+#endif
+
+ result->tdb = tdb_open_ex(name, hash_size, tdb_flags,
+ open_flags, mode, &log_ctx, NULL);
+ if (result->tdb == NULL) {
+ goto fail;
+ }
+ talloc_set_destructor(result, tdb_wrap_private_destructor);
+ DLIST_ADD(tdb_list, result);
+ return result;
+
+fail:
+ TALLOC_FREE(result);
+ return NULL;
+}
+
+/*
+ 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 *result;
+ struct tdb_wrap_private *w;
+
+ result = talloc(mem_ctx, struct tdb_wrap);
+ if (result == NULL) {
+ return NULL;
+ }
+
+ for (w=tdb_list;w;w=w->next) {
+ if (strcmp(name, w->name) == 0) {
+ break;
+ }
+ }
+
+ if (w == NULL) {
+ w = tdb_wrap_private_open(result, name, hash_size, tdb_flags,
+ open_flags, mode);
+ } else {
+ /*
+ * Correctly use talloc_reference: The tdb will be
+ * closed when "w" is being freed. The caller never
+ * sees "w", so an incorrect use of talloc_free(w)
+ * instead of calling talloc_unlink is not possible.
+ * To avoid having to refcount ourselves, "w" will
+ * have multiple parents that hang off all the
+ * tdb_wrap's being returned from here. Those parents
+ * can be freed without problem.
+ */
+ if (talloc_reference(result, w) == NULL) {
+ goto fail;
+ }
+ }
+ if (w == NULL) {
+ goto fail;
+ }
+ result->tdb = w->tdb;
+ return result;
+fail:
+ TALLOC_FREE(result);
+ return NULL;
+}
+
diff --git a/source4/lib/tdb_wrap.h b/lib/util/tdb_wrap.h
similarity index 96%
rename from source4/lib/tdb_wrap.h
rename to lib/util/tdb_wrap.h
index 94035c1..1be2bb0 100644
--- a/source4/lib/tdb_wrap.h
+++ b/lib/util/tdb_wrap.h
@@ -33,9 +33,6 @@
struct tdb_wrap {
struct tdb_context *tdb;
-
- const char *name;
- struct tdb_wrap *next, *prev;
};
struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
diff --git a/lib/util/util_tdb.h b/lib/util/util_tdb.h
index d2f6648..c11a347 100644
--- a/lib/util/util_tdb.h
+++ b/lib/util/util_tdb.h
@@ -1,7 +1,6 @@
#ifndef _____LIB_UTIL_UTIL_TDB_H__
#define _____LIB_UTIL_UTIL_TDB_H__
-
/***************************************************************
Make a TDB_DATA and keep the const warning in one place
****************************************************************/
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index a5985c6..b68791f 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -91,3 +91,13 @@ bld.SAMBA_SUBSYSTEM('UTIL_PW',
local_include=False,
public_deps='talloc'
)
+
+
+bld.SAMBA_LIBRARY('tdb-wrap',
+ source='tdb_wrap.c',
+ deps='tdb talloc samba-util',
+ public_headers='tdb_wrap.h',
+ private_library=True,
+ local_include=False
+ )
+
diff --git a/libcli/auth/schannel_state_tdb.c b/libcli/auth/schannel_state_tdb.c
index c332bae..ca35a11 100644
--- a/libcli/auth/schannel_state_tdb.c
+++ b/libcli/auth/schannel_state_tdb.c
@@ -27,9 +27,7 @@
#include "../lib/util/util_tdb.h"
#include "../libcli/auth/schannel.h"
#include "../librpc/gen_ndr/ndr_schannel.h"
-#if _SAMBA_BUILD_ == 4
-#include "tdb_wrap.h"
-#endif
+#include "lib/util/tdb_wrap.h"
#define SECRETS_SCHANNEL_STATE "SECRETS/SCHANNEL"
diff --git a/source3/Makefile.in b/source3/Makefile.in
index aa92d46..561f215 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -269,6 +269,7 @@ EXTRA_ALL_TARGETS = @EXTRA_ALL_TARGETS@
######################################################################
TDB_LIB_OBJ = lib/util_tdb.o ../lib/util/util_tdb.o \
+ ../lib/util/tdb_wrap.o \
lib/dbwrap.o lib/dbwrap_tdb.o \
lib/dbwrap_ctdb.o \
lib/g_lock.o \
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 3646e04..c760dec 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -26,6 +26,7 @@
#include "groupdb/mapping.h"
#include "../libcli/security/security.h"
#include "lib/winbind_util.h"
+#include <tdb.h>
static const struct mapping_backend *backend;
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c
index 548d3a3..a5fa1b7 100644
--- a/source3/groupdb/mapping_tdb.c
+++ b/source3/groupdb/mapping_tdb.c
@@ -25,6 +25,7 @@
#include "passdb.h"
#include "groupdb/mapping.h"
#include "dbwrap.h"
+#include "util_tdb.h"
#include "../libcli/security/security.h"
static struct db_context *db; /* used for driver files */
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index ef291fb..36b6542 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -20,6 +20,8 @@
#ifndef _CTDBD_CONN_H
#define _CTDBD_CONN_H
+#include <tdb.h>
+
struct ctdbd_connection;
struct messaging_context;
struct messaging_rec;
diff --git a/source3/include/dbwrap.h b/source3/include/dbwrap.h
index ef35b00..d657ee7 100644
--- a/source3/include/dbwrap.h
+++ b/source3/include/dbwrap.h
@@ -20,6 +20,8 @@
#ifndef __DBWRAP_H__
#define __DBWRAP_H__
+#include <tdb.h>
+
struct db_record {
TDB_DATA key, value;
NTSTATUS (*store)(struct db_record *rec, TDB_DATA data, int flag);
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 060f6fa..432e475 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -510,8 +510,6 @@ typedef char fstring[FSTRING_LEN];
#include "../lib/util/attr.h"
#include "../lib/util/tsort.h"
#include "../lib/util/dlinklist.h"
-#include <tdb.h>
-#include "util_tdb.h"
#include <talloc.h>
@@ -522,6 +520,7 @@ typedef char fstring[FSTRING_LEN];
#include "../lib/util/debug.h"
#include "../lib/util/debug_s3.h"
+#include "../libcli/util/ntstatus.h"
#include "libads/ads_status.h"
#include "../libcli/util/error.h"
#include "../lib/util/charset/charset.h"
diff --git a/source3/include/printing.h b/source3/include/printing.h
index 084c699..bba7d53 100644
--- a/source3/include/printing.h
+++ b/source3/include/printing.h
@@ -158,9 +158,12 @@ extern struct printif iprint_printif;
/* There can be this many printing tdb's open, plus any locked ones. */
#define MAX_PRINT_DBS_OPEN 1
+struct TDB_DATA;
+struct tdb_context;
+
struct tdb_print_db {
struct tdb_print_db *next, *prev;
- TDB_CONTEXT *tdb;
+ struct tdb_context *tdb;
int ref_count;
fstring printer_name;
};
@@ -249,7 +252,7 @@ uint32_t print_parse_jobid(const char *fname);
struct tdb_print_db *get_print_db_byname(const char *printername);
void release_print_db( struct tdb_print_db *pdb);
void close_all_print_db(void);
-TDB_DATA get_printer_notify_pid_list(TDB_CONTEXT *tdb, const char *printer_name, bool cleanlist);
+struct TDB_DATA get_printer_notify_pid_list(struct tdb_context *tdb, const char *printer_name, bool cleanlist);
void print_queue_receive(struct messaging_context *msg,
void *private_data,
diff --git a/source3/include/util_tdb.h b/source3/include/util_tdb.h
index 3bdb697..a6144ba 100644
--- a/source3/include/util_tdb.h
+++ b/source3/include/util_tdb.h
@@ -26,10 +26,6 @@
#include "../libcli/util/ntstatus.h" /* for map_nt_error_from_tdb() */
#include "../../lib/util/util_tdb.h"
-struct tdb_wrap {
- struct tdb_context *tdb;
-};
-
int tdb_chainlock_with_timeout( struct tdb_context *tdb, TDB_DATA key,
unsigned int timeout);
int tdb_lock_bystring_with_timeout(struct tdb_context *tdb, const char *keyval,
@@ -51,10 +47,6 @@ bool tdb_pack_append(TALLOC_CTX *mem_ctx, uint8 **buf, size_t *len,
struct tdb_context *tdb_open_log(const char *name, int hash_size,
int tdb_flags, int open_flags, mode_t mode);
-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);
-
NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err);
int tdb_data_cmp(TDB_DATA t1, TDB_DATA t2);
diff --git a/source3/intl/lang_tdb.c b/source3/intl/lang_tdb.c
index 8fcb9f2..d6a196e 100644
--- a/source3/intl/lang_tdb.c
+++ b/source3/intl/lang_tdb.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "system/filesys.h"
#include "intl/lang_tdb.h"
+#include "util_tdb.h"
static TDB_CONTEXT *tdb;
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 21bd96d..b928ed9 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -19,6 +19,7 @@
*/
#include "includes.h"
+#include "util_tdb.h"
#ifdef CLUSTER_SUPPORT
diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c
index 4e7346c..9b3197f 100644
--- a/source3/lib/dbwrap.c
+++ b/source3/lib/dbwrap.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "dbwrap.h"
+#include "util_tdb.h"
#ifdef CLUSTER_SUPPORT
#include "ctdb_private.h"
#endif
diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c
index f9a7dd6..298f4c1 100644
--- a/source3/lib/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap_ctdb.c
@@ -20,6 +20,8 @@
#include "includes.h"
#include "system/filesys.h"
+#include "lib/util/tdb_wrap.h"
+#include "util_tdb.h"
#ifdef CLUSTER_SUPPORT
#include "ctdb.h"
#include "ctdb_private.h"
diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c
index 4cdc193..98fd255 100644
--- a/source3/lib/dbwrap_tdb.c
+++ b/source3/lib/dbwrap_tdb.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "dbwrap.h"
+#include "lib/util/tdb_wrap.h"
struct db_tdb_ctx {
struct tdb_wrap *wtdb;
diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c
index 35f8a14..365f0a0 100644
--- a/source3/lib/dbwrap_util.c
+++ b/source3/lib/dbwrap_util.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "dbwrap.h"
+#include "util_tdb.h"
int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr)
{
diff --git a/source3/lib/eventlog/eventlog.c b/source3/lib/eventlog/eventlog.c
index b3aa05c..5c57ac0 100644
--- a/source3/lib/eventlog/eventlog.c
+++ b/source3/lib/eventlog/eventlog.c
@@ -24,6 +24,7 @@
#include "system/filesys.h"
#include "lib/eventlog/eventlog.h"
#include "../libcli/security/security.h"
+#include "util_tdb.h"
/* maintain a list of open eventlog tdbs with reference counts */
diff --git a/source3/lib/eventlog/eventlog.h b/source3/lib/eventlog/eventlog.h
index 29c25c3..b485bfe 100644
--- a/source3/lib/eventlog/eventlog.h
+++ b/source3/lib/eventlog/eventlog.h
@@ -17,6 +17,8 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <tdb.h>
+
/* Defines for TDB keys */
#define EVT_OLDEST_ENTRY "INFO/oldest_entry"
#define EVT_NEXT_RECORD "INFO/next_record"
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 184da9b..c3d863f 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
--
Samba Shared Repository
More information about the samba-cvs
mailing list