1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

75 Commits

Author SHA1 Message Date
Gregor Beck
037f57e12f util_tdb: add function tdb_data_string()
Signed-off-by: Gregor Beck <gbeck@sernet.de>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-04-18 13:15:11 +02:00
David Disseldorp
e4505fc27b tdb: return unpack error on strdup failure
Signed-off-by: Lars Müller <lars@samba.org>

Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Fri Aug 31 21:05:21 CEST 2012 on sn-devel-104
2012-08-31 21:05:21 +02:00
Rusty Russell
fc9b298761 util_tdb: move timeout chainlock variants from source3/lib/util/util_tdb.c
We're about to use them for dbwrap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:17 +02:00
Rusty Russell
6244f668a3 TDB2: make SAMBA use tdb1 again for the moment.
Otherwise the following surgery will break the SAMBA build and testsuite.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-19 05:38:05 +02:00
Andrew Bartlett
cc86f8e985 lib/util: Move map_nt_error_from_tdb to the top level
This will help with making dbwrap available as a top level library.

Andrew Bartlett
2012-04-18 12:04:59 +10:00
Rusty Russell
26ce47ecc0 util_tdb: return -1/0 from lock_with_timeout functions.
Keeps the tdb2 API change (which returns error codes, rather than -1)
localized.  The function returns -1 down the other path, so make it
consistent.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 08:13:28 +09:30
Rusty Russell
376511ed4d tdb_compat: adapt to tdb2 API change.
Add the ecode arg to all the log functions, and log it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:13:13 +09:30
Michael Adam
0aa85ec43a s3:lib: fix a comment in tdb_unpack() 2011-08-15 17:15:15 +02:00
Gregor Beck
8a36e72140 s3: avoid reading past the end of buffer in tdb_unpack 'f' if zero termination is missing
Signed-off-by: Michael Adam <obnox@samba.org>
2011-08-15 17:15:14 +02:00
Gregor Beck
39f9c854ae s3: avoid reading past the end of buffer in tdb_unpack 'P' if zero termination is missing
Signed-off-by: Michael Adam <obnox@samba.org>
2011-08-15 17:15:14 +02:00
Rusty Russell
cd96271036 source3/lib/util_tdb.c: operation timeout support for TDB2.
TDB2 doesn't have (the racy) signal pointer; the new method is to
override the locking callbacks and do the timeout internally.

The technique here is to invalidate the struct flock when the timeout
occurs, so it works even if it happens before we enter the fcntl() call.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20 11:18:35 +02:00
Rusty Russell
d925b327f4 tdb_compat: Higher level API fixes.
My previous patches fixed up all direct TDB callers, but there are a
few utility functions and the db_context functions which are still
using the old -1 / 0 return codes.

It's clearer to fix up all the callers of these too, so everywhere is
consistent: non-zero means an error.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20 11:18:35 +02:00
Rusty Russell
ca1936fbb2 tdb_compat: use tdb_open_compat.
This is a helper for the common case of opening a tdb with a logging
function, but it doesn't do all the work, since TDB1 and TDB2's log
functions are different types.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20 11:18:35 +02:00
Rusty Russell
4823262439 tdb2: #ifdef out TDB_ERR_NOLOCK and TDB_ERR_LOCK_TIMEOUT.
These don't exist in tdb2.  The former is used in one weird place in
tdb1, and the latter not at all.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20 11:18:35 +02:00
Rusty Russell
868d77bc5b tdb_chainlock: check returns for 0, not -1.
TDB2 returns a negative error number on failure.  This is compatible
if we always check for != 0 instead of == -1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20 11:18:35 +02:00
Rusty Russell
d6251996fa tdb_transaction_cancel: ignore return value.
TDB2 returns void here.  tdb_transaction_cancel will *always* return
with the transaction cancelled, but it will complain via the log
function if a transaction wasn't in progress.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20 11:18:35 +02:00
Andrew Bartlett
73b377432c s3-talloc Change TALLOC_REALLOC_ARRAY() to talloc_realloc()
Using the standard macro makes it easier to move code into common, as
TALLOC_REALLOC_ARRAY isn't standard talloc.

Andrew Bartlett
2011-06-09 12:40:08 +02:00
Günther Deschner
d8cfca3a9b s3: only include tdb headers where needed.
Guenther
2011-05-06 10:48:10 +02:00
Andrew Bartlett
1475013963 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
2011-05-06 07:51:24 +02:00
Günther Deschner
0e771263ee s3-includes: only include system/filesys.h when needed.
Guenther
2011-03-30 01:13:07 +02:00
Volker Lendecke
2111fe5255 s3: Use a switch to implement map_nt_error_from_tdb
First, this immediately gave me the warning that TDB_ERR_NESTING was not
covered and second, this saved 48 bytes in the .o :-)
2010-03-14 17:42:49 +01:00
Volker Lendecke
cfc44d2441 s3: Make tdb_wrap_open more robust
This hides the use of talloc_reference from the caller, making it impossible to
wrongly call talloc_free() on the result.
2010-03-13 20:20:37 +01:00
Andreas Schneider
c6c21f489d s3-lib: Remove obsolete signal type cast. 2010-02-23 12:23:43 +01:00
Volker Lendecke
8300b255a5 Fix some nonempty blank lines 2009-08-07 13:02:15 +02:00
Volker Lendecke
ed87594e5f Add tdb_data_cmp 2009-07-15 10:55:20 +02:00
Michael Adam
59859b547c s3: separate tdb validation code out into its own source file
So this gets now linked only into its single user: winbindd
(needed by winbindd_cache.c)

Michael
2009-01-28 09:43:57 +01:00
Volker Lendecke
fe9dd8710d Remove unused tdb_search_keys() 2009-01-19 00:05:56 +01:00
Günther Deschner
64d8eb0cee s3-util: for convenience, provide format comments in tdb_unpack().
Guenther
2009-01-16 00:28:45 +01:00
Jeremy Allison
c07ea13d30 Fix race condition in alarm lock processing noticed by Richard Sharpe <realrichardsharpe@gmail.com>.
"It seems to me that if the lock is already held by another process when we
enter this code, there is a race between the timeout and the granting. If
the lock is subsequently granted, the process releasing the lock will signal
the wait variable (or whatever) and our process will be scheduled. However,
if the timeout occurs before we are scheduled, the timeout will be delivered
first.

We will have the lock but will forget we have the lock, and never release
it."
Jeremy.
2009-01-08 10:36:10 -08:00
Jelmer Vernooij
7d371c684d Sync util_tdb implementations. 2008-10-12 16:53:17 +02:00
Michael Adam
8be49cdd3e util_tdb: fix a segfault caused by a fatal typo.
In tdb_wrap_log(), in on occurrence of "debug_level = 0"
instead of "debuglevel = 0" caused me segfaults when
accessing DEBUGLEVEL (which is defined as "*debug_level"...)

Michael
(This used to be commit d9bd894c2e)
2008-04-12 01:36:10 +02:00
Michael Adam
f1c844c168 util_tdb: remove trivial and unused tdb_wipe().
It has been replaced by tdb_wipe_all().

Michael
(This used to be commit cdde2e4eac)
2008-03-26 11:15:03 +01:00
Michael Adam
6efe4873dc util_tdb: make the _byblob fetch/store functions public again.
Users of these are currently being written...

Michael
(This used to be commit 1c51bec531)
2008-03-26 10:50:35 +01:00
Michael Adam
6fa39aa87d util_tdb: add my (C) for the tdb validation code
Michael
(This used to be commit abf02a5a14)
2008-03-25 15:55:34 +01:00
Michael Adam
aaa5971315 util_tdb: add a wrapper tdb_wipe() for traverse with tdb_traverse_delete_fn().
Replace all callers of traverse with this tdb_traverse_delete_fn() and
don't export tdb_traverse_delete_fn() anymore.

Michael
(This used to be commit d4be4e30cd)
2008-03-25 15:55:34 +01:00
Michael Adam
90ce5f189f util_tdb: make the _byblob functions static - not currently used elsewhere.
Michael
(This used to be commit b42cf3fc69)
2008-03-25 15:55:34 +01:00
Volker Lendecke
3176392878 Fix some warnings
warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result
(This used to be commit ad37b7b0ae)
2008-02-25 16:09:26 +01:00
Tim Potter
54db183987 Adding missing calls to va_end().
Just a small commit to get a handle on this git thingy.  This patch
fixes some missing calls to va_end() to match various calls to va_start()
and VA_COPY().

Tim.
(This used to be commit ec367f307d)
2008-01-27 09:33:42 +01:00
Jeremy Allison
bcf033b38e Change tdb_unpack "P" to return a malloc'ed string rather
than expect a pstring space to put data into.
Fix the (few) callers.
Jeremy.
(This used to be commit 7722a7d2c6)
2007-12-03 14:54:06 -08:00
Jeremy Allison
d8f3c9d078 Fix bug where tdb lock call interrupted with
an alarm sig would not terminate and could lead
to runaway smbd processes.
Thanks to Dave Daugherty @ Centrify for pointing
this out to us.
Jeremy.
(This used to be commit ef8da16983)
2007-11-06 21:47:57 -08:00
Jeremy Allison
30191d1a57 RIP BOOL. Convert BOOL -> bool. I found a few interesting
bugs in various places whilst doing this (places that assumed
BOOL == int). I also need to fix the Samba4 pidl generation
(next checkin).
Jeremy.
(This used to be commit f35a266b3c)
2007-10-18 17:40:25 -07:00
Michael Adam
60abd094fa r24877: Don't panic in tdb validation code when the fork or waitpid fails.
Return error instead.

Michael
(This used to be commit 9b25355dd6)
2007-10-10 12:30:28 -05:00
Michael Adam
57ac659fb6 r24848: Make tdb_validate() take an open tdb handle instead of a file name.
A new wrapper tdb_validate_open() takes a filename an opens and closes
the tdb before and after calling tdb_validate() respectively.

winbindd_validata_cache_nobackup() now dynamically calls one of
the above functions depending on whether the cache tdb has already
been opened or not.

Michael
(This used to be commit dc0b08e659)
2007-10-10 12:30:27 -05:00
Michael Adam
f02f8563a2 r24847: Change standard failure return code of tdb_validate from "-1" to "1".
(This is more safely used with casts from int to uint8, e.g.)

Michael
(This used to be commit cb3583b392)
2007-10-10 12:30:27 -05:00
Volker Lendecke
42c1eca265 r24267: Fix the build farm
I had only tested with "net getlocalsid". posix_locking_init() calls this
with a NULL name...
(This used to be commit 3eee1fe280)
2007-10-10 12:29:22 -05:00
Volker Lendecke
8c154674c6 r24265: Add the tdb_hashsize:<tdbname> parameter
This makes it possible to set the default hashsize for any tdb. I would
like to remove the "open files database hash size" in favor of this one.

I'll check that removal in with the next commit, please complain/revert
if it's not ok.

Volker
(This used to be commit e9bd7a63a8)
2007-10-10 12:29:21 -05:00
Michael Adam
7712e7eeb6 r23981: Make tdb_validate_and_backup try harder to end up with a valid tdb:
If restoring a backup fails due to lack of space, remove the
corrupt tdb previously moved away to "name.corrupt", and retry.
If restoring still fails, move the backup in place instead of
copying it.

Michael
(This used to be commit f81f2bf480)
2007-10-10 12:28:52 -05:00
Michael Adam
6a16ad09cb r23975: Enhance some debug output.
(This used to be commit 909172839a)
2007-10-10 12:28:51 -05:00
Michael Adam
b8a4863ca4 r23957: Use tdb_open_log instead of tdb_open.
Michael
(This used to be commit efabd7fe03)
2007-10-10 12:28:49 -05:00
Michael Adam
21a847473d r23952: Streamline and improve the logic of tdb_validate_and backup:
- call tdb_validate on the given tdb.
- if validation is successful, create a backup
  return 0 (success) even if the backup fails.
- if validation fails:
  - move tdb to name.corrupt (don't exit if this fails)
  - look for a valid backup
  - if a valid backup is found, restore it, else return -1 (failure)
    if restoring succeeds, return 0 (success), else -1 (failure)

Summing up:

If 0 is returned, there is a valid tdb at the given location:
either the original one ore one restrored from a backup.

If -1 is returned, there is no valid tdb at the given location:
Either there is no file at all, or the original file is still
in place (if moving it away failed).

Michael
(This used to be commit 1c36ccd86d)
2007-10-10 12:28:49 -05:00