1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-14 19:24:43 +03:00

55 Commits

Author SHA1 Message Date
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 d9bd894c2ec4faf87e8ff96e27c7e2b8175f9387)
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 cdde2e4eaca51d51f036ad99d55df7bfd6535b03)
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 1c51bec5318bad085c09931aa7e8f72f41d103fe)
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 abf02a5a142c55d9e0053d319c867e4fcc3e6c30)
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 d4be4e30cd8c3bdc303da30e42280f892a45a8c9)
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 b42cf3fc69414270be9d0f430f2e95a72894f00e)
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 ad37b7b0aee265a3e4d8b7552610f4b9a105434d)
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 ec367f307dff7948722b9ac97beb960efd91991f)
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 7722a7d2c63f84b8105aa775b39f0ceedd4ed513)
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 ef8da1698371c95495add53df81a978df709c88d)
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 f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f)
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 9b25355dd66519afd548fecbf2da7608b024a35b)
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 dc0b08e6590caa4974fd4d9f34f39f261d1f1dee)
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 cb3583b39212688a627a29bbddb2e98497714d42)
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 3eee1fe28057e2e3da2e9d1506f57f3e35fd37b7)
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 e9bd7a63a8d462b1fc3bab99ff843e25bffd156b)
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 f81f2bf480a955213be8461636ee6f81643f17b8)
2007-10-10 12:28:52 -05:00
Michael Adam
6a16ad09cb r23975: Enhance some debug output.
(This used to be commit 909172839a512b60db075fb1a7488345a2e48eb0)
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 efabd7fe03733d1fcb02d0d270c18ede7836f3a9)
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 1c36ccd86d85b02f27ec66d37bdf7f04ad760901)
2007-10-10 12:28:49 -05:00
Michael Adam
f932dccd5d r23938: Add a debug message.
(This used to be commit 6bd2c48921dd8dbf2885a8135ba01a1324e020c8)
2007-10-10 12:28:47 -05:00
Michael Adam
dc278f2d8f r23932: Fill extended status with information in case the validation traverse
functions did not do so but returned an error. (This is the case when
error occurred deeper than at the level of the content checking done by
the per entry validate_fn.)

Michael
(This used to be commit e56be59947a29d0a5692f3f3bc6c089dd8b4b5d9)
2007-10-10 12:28:46 -05:00
Michael Adam
7291251efb r23930: Introduce tdb_validate_and_backup:
This is a wrapper around tdb_validate, that does backup handling:

* if the given tdb is valid, a backup is created (name.bak)
* if the tdb is invalid, if a valid bakup is found (validated
  with the same validation function) under the name "name.bak"
  the orignal tdb is moved to name.corrupt and the backup
  is restored.

For the backup handling, a variant of the backup_tdb function
from lib/tdb/tools/tdbbackup.c is included in lib/util_tdb.c.
The copy function for the traverse action eliminates the need
to maintain a global success state by using a struct wrapping
the target tdb and a success flag as the private data.

Michael
(This used to be commit ca63a99b6188c0976603dc2852e478cc7a6b2f8b)
2007-10-10 12:28:46 -05:00
Michael Adam
f0072e5476 r23828: Add entry and exit debug statments to tdb_validate
at a lower debug level.

Michael
(This used to be commit b636f8cdad72a9a9bc1d302d8d681dca2da6105a)
2007-10-10 12:28:31 -05:00
Michael Adam
d775ad4aba r23822: Clean some debugging output (as well in content and
amount as in source code formatting...)

Michael
(This used to be commit 9794b94ebf79686da2e1b3ae343953581e3459a1)
2007-10-10 12:28:30 -05:00
Michael Adam
0543963797 r23819: It is currently unnecessary to pass the extended validation status
from the validating child process down to the parent though the
pipe. All the parent evaluates is the overall success, so the exit
status should do.

Michael
(This used to be commit 9415ea0fde2ff0c801d043ce77b778fceedb6592)
2007-10-10 12:28:30 -05:00
Michael Adam
344f7aa381 r23814: Fix a couple of comments and debug messages.
(This used to be commit ef40ef67649c8793921619c128e2923e20aa68da)
2007-10-10 12:28:29 -05:00
Andrew Tridgell
5e54558c6d r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
(This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07)
2007-10-10 12:28:22 -05:00
Jeremy Allison
d824b98f80 r23779: Change from v2 or later to v3 or later.
Jeremy.
(This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3)
2007-10-10 12:28:20 -05:00
Michael Adam
5e4962d9e7 r23769: Move removal of the tdb from the generic tdb_validate function
to the caller (winbindd_validate_cache in this case).
Next, there will be a backup handling for the tdb files.

Michael
(This used to be commit 821bc84109625c9d85edee38fa26d16f9f0a0fe2)
2007-10-10 12:23:55 -05:00
Michael Adam
052ddc9cd0 r23751: Call tdb_close even when validation was not successful.
Michael
(This used to be commit b68856d9902f41079224ba11c7d0ab811b082201)
2007-10-10 12:23:52 -05:00
Michael Adam
839d4647a9 r23639: Eliminate trailing whitespaces in the new tdb_validate functions...
Michael
(This used to be commit d4accdbb5285216d532f57f545a846734a2fe774)
2007-10-10 12:23:39 -05:00
Michael Adam
7c48598e86 r23610: Move some winbindd_cache specific flags and actions
back to winbindd_cache.c. The generic mechanism
should open the cache tdb readonly and with default
flags.

Michael
(This used to be commit 062d8c61294a1e9f8588fa8af31954dd286c7bde)
2007-10-10 12:23:36 -05:00
Michael Adam
133472ac66 r23600: First step in abstracting the winbindd cache validation
code into a generic tdb validation code.
In lib/util_tdb.c for a start.

Michael
(This used to be commit 527edfa0cbcb233218ebabc395666d1d7228ee37)
2007-10-10 12:23:35 -05:00
James Peach
b1ce226af8 r23510: Tidy calls to smb_panic by removing trailing newlines. Print the
failed expression in SMB_ASSERT.
(This used to be commit 171dc060e2a576d724eed1ca65636bdafffd7713)
2007-10-10 12:23:23 -05:00
Volker Lendecke
cc2b76b644 r23362: Respect "use mmap" in tdb_wrap_open(). Tridge, you might want to merge
this in your tree.
(This used to be commit c0f40eb5846f617d9c421136b0e1ea593c8d8458)
2007-10-10 12:23:10 -05:00
Volker Lendecke
7e27c984c4 r23170: Add map_nt_error_from_tdb()
(This used to be commit 02beae81c8ecef7cfe300a29852d74813c9409bf)
2007-10-10 12:22:51 -05:00
Stefan Metzmacher
bc2b6436d0 r22009: change TDB_DATA from char * to unsigned char *
and fix all compiler warnings in the users

metze
(This used to be commit 3a28443079c141a6ce8182c65b56ca210e34f37f)
2007-10-10 12:19:00 -05:00
Stefan Metzmacher
7bdd7ecafa r22007: make string_tdb_data(NULL) possible...
metze
(This used to be commit d03094708378bde088bf6e90efe54deb83d3952e)
2007-10-10 12:19:00 -05:00
Stefan Metzmacher
2aee3c2689 r21972: - add string_term_tdb_data() it creates a null-terminates tdb key from a string
(the current string_tdb_data() creates a non-terminates tdb key from a string!)
- pass TDB_DATA instead of const char *, size_t len to some functions

metze
(This used to be commit 815ef8acdc7f89d30f3fd1812b12bd0e2dc62473)
2007-10-10 12:18:54 -05:00