1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00
Commit Graph

76078 Commits

Author SHA1 Message Date
Rusty Russell
b4a5c6dcb6 tdb2: don't cancel transactions on lock failures in tdb1 backend.
In TDB2, the user can override locking functions, so they may
deliberarely fail (eg. be non-blocking) expecting to retry.

For this reason, the TDB2 API requires the caller to cancel the
transaction if tdb_transaction_prepare_commit() fails.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 8458811a4126c22635b974718bfbf2876c893c37)
2011-09-14 07:40:13 +09:30
Rusty Russell
88ce92b92e tdb2: suppress tdb1 backend logging when locking returns EINTR or EAGAIN
The TDB1 code logs multiple times on errors; we must prevent that in
the limited case where locking fails.  With TDB2, this can happen due
to the lock function attribute, where the user supplies replacement
locking functions which are allowed to return with errno EAGAIN or
EINTR for various special-effects.  Flooding the logs for this is
unfriendly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit a391b2b900bc6d5c0467869a454bdb5c51b5a3be)
2011-09-14 07:39:13 +09:30
Rusty Russell
bdd46e4513 tdb2: make tdb1 use same low-level lock functions.
This means they will use the TDB_ATTRIBUTE_FLOCK functions, and get automatic
reopen support.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit fbad02b680b6cbc33ae305ae1cbcdead4eedc7b1)
2011-09-14 07:38:13 +09:30
Rusty Russell
c5b7c4aea8 tdb2: Make tdb1 use the tdb_file structure.
Because tdb2 allows multiple opens of the same TDB, we separate out
the file information from the struct tdb_context.  Do the same for
tdb1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 60210a73ec08a7b34ba637ad19e6749cf6dc1952)
2011-09-14 07:37:13 +09:30
Rusty Russell
5a3f207318 tdb2: add TDB_VERSION1 flag.
This will be set for old TDBs; we can start distinguishing paths based
on it now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 2b50be90a23893a06e0f1436a31d18b97ad0e11d)
2011-09-14 07:36:13 +09:30
Rusty Russell
9b98acbba3 tdb2: Make TDB1 code use TDB2's open flags.
This means getting rid of TDB_VOLATILE (perhaps we should use an
attribute for that?), TDB_INCOMPATIBLE_HASH (use the
tdb_attribute_hash for that) and TDB_CLEAR_IF_FIRST (use the
tdb_attribute_openhook for that).

We also get rid of TDB_DISALLOW_NESTING: that's the default for TDB2.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 22d0e0dc59fc9d7e0046fec6971ef478c2d604fd)
2011-09-14 07:35:13 +09:30
Rusty Russell
61b1bd1dca tdb2: approximate INCOMPATIBLE_HASH flag with tdb1_incompatible_hash()
Rather than leak TDB_INCOMPATIBLE_HASH through to the TDB2 API, we make
it that if they use the tdb1_incompatible_hash function as their hash,
then we treat it as if they had specified the TDB_INCOMPATIBLE_HASH
flag (ie. we mark the header so it's unusable by tdb < 1.2.6).

This precludes the possibility of using TDB_INCOMPATIBLE_HASH with a
custom hash function: that used to allow the user to ensure that old TDB
versions couldn't open the TDB file (and recent ones check the header to
ensure they're using the right hash).  But that's a small loss.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 3004f7e89a5978064b4fb29c1027e6d0d39e9418)
2011-09-14 07:34:13 +09:30
Rusty Russell
ebb3017cf0 tdb2: Make tdb1 share tdb_store flags, struct tdb_data and TDB_MAGIC_FOOD.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 8a47d50d72ea62e378dc92b150c92c1317c73fa3)
2011-09-14 07:33:13 +09:30
Rusty Russell
e613effeae tdb2: make TDB1 code use tdb2's TDB_ERROR and tdb_logerr()
To do this, we make sure that the first few fields of tdb1_context and
tdb_context are the same.

This sweep also fixes up a few paths where we weren't setting
tdb->ecode before our old logging function.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 919937354a331bb964564a11b5a5b80403ff8db9)
2011-09-14 07:32:13 +09:30
Rusty Russell
50484d4bed tdb2: make tdb1 headers include tdb2 headers.
They're about to start sharing TDB2's definitions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 1e3138a0ad0c184d2ca49ce7bc47173eb2fe67bd)
2011-09-14 07:31:13 +09:30
Rusty Russell
a14df0f361 tdb2: rearrange tdb_context layout so tdb1_context can match
By moving all the parts of struct tdb_context which logging and
locking use to the beginning of the structure, we can make
tdb1_context match, and thus pass that directly to the tdb_logerr()
function, and later the locking functions.

This is only necessary until we unify tdb1_context and tdb_context.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 0fd5be2955f8e6487c0f4ab711e2a6958bb8f412)
2011-09-14 07:30:13 +09:30
Rusty Russell
f6eee4216f tdb2: add tdb1 code to build.
The following patches integrate it together, but from here on we build
it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:29:13 +09:30
Rusty Russell
f49d86edfe tdb2: remove TDB1 TDB_NO_FSYNC environment variable hack.
The caller should do this: the SAMBA compatibility later does.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 75a6a6ad64156ef3b13493be2970ae3cb99ccf8b)
2011-09-14 07:28:13 +09:30
Rusty Russell
3b2c10f895 tdb2: get rid of TDB1 mark and nonblock functions.
We do this using hooks in tdb2.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 444fade529f68eb2b0aebbc8de442478c5c6f916)
2011-09-14 07:27:13 +09:30
Rusty Russell
0b81b07110 tdb2: remove _PUBLIC_ in tdb1 functions.
They'll all be accessed via the tdb2 API.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 39f55294799c6443c0ad7bef09f1c113cf89d295)
2011-09-14 07:26:13 +09:30
Rusty Russell
e9fe56cdf3 tdb2: Remove unused tdb1 functions.
We're going to use TDB2's API, so some TDB1 APIs are obviously unnecessary.  
We also get rid of USE_RIGHT_MERGES and TRACE code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit b929638e3cfe629285af3ecd0813e03eaeaa1133)
2011-09-14 07:25:13 +09:30
Rusty Russell
9660546a18 tdb2: test: import tdb1's tests.
The main change is to s/tdb/tdb1_/ everywhere.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit fab544c24c1ad6523f95893abcaec4e6cce6c2b4)
2011-09-14 07:24:13 +09:30
Rusty Russell
bfcd0ebd98 tdb2: include tdb1 source in tests.
Since we've renamed everything in tdb1, they won't clash.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 5d6194b434f3664d1025df12ef06c6a25f693bc8)
2011-09-14 07:23:13 +09:30
Rusty Russell
a81bb8d7d1 tdb2: import TDB1 code.
We import the entire codebase, putting a "tdb1_" prefix on the files
and changing the "tdb_" prefix to "tdb1_" everywhere.

The next patches will gradually merge it with the TDB2 code where
necessary.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 19e6c1a250ade1e7204ada17163294855585e825)
2011-09-14 07:22:13 +09:30
Rusty Russell
59527bcc7b tdb2: make tests include a single mega-header to simplify future patches
This lets us add the new files to a single place.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 476567430be6962625bf399192e20938985232c7)
2011-09-14 07:21:13 +09:30
Rusty Russell
b67acb7e2a tdb2: tdb_foreach()
Create an iterator over every open tdb (not internal TDBs).  This is
useful for re-establishing the tdb1-style active lock for
CLEAR_IF_FIRST.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 1a0c636bc38213bd0322db47529f78f2dc22ffdd)
2011-09-14 07:20:13 +09:30
Rusty Russell
1664702d2f tdb2: keep link of every non-internal tdb.
Instead of a per-file linked list, use a per-tdb list.  This is needed
for tdb_foreach().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 2414f261918b4fb8a549dd385dba32118e37bf85)
2011-09-14 07:19:13 +09:30
Rusty Russell
617c1fcfa4 tdb2: save openhook, allow tdb_get_attribute() on it.
This makes it easy to call it again after a fork(), such as for
re-establishing the CLEAR_IF_FIRST files locks.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 937d0babe99dcd315040a9e48430140e63e4a7df)
2011-09-14 07:18:13 +09:30
Rusty Russell
73e4f35e3d tdb_compat: make tdb2s temporarily read-only for tdb_traverse_read()
It doesn't make a difference unless the tdb2 opens a TDB1 on disk, in
which case tdb1_traverse() takes a write lock on the entire file.  By
setting the tdb to read-only first, we simulate the old behaviour.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:17:13 +09:30
Rusty Russell
bdc5499205 tdb2: add TDB_RDONLY flag, allow setting/unsetting it.
You can only unset it if the TDB was originally opened O_RDWR.

Also, cleaned up error handling in tdb_allrecord_lock() so we only get
one log message on a r/o database.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit b87e14495d5b07e1b247218a72329f10ecb3da7f)
2011-09-14 07:16:13 +09:30
Rusty Russell
37c704be0a tdb2: return TDB_ERR_RDONLY if trying to start a transaction on a R/O tdb.
This is more accurate than returning TDB_ERR_EINVAL.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 91436a25574597dbd1fd2de5bcd5826a234100d6)
2011-09-14 07:15:13 +09:30
Rusty Russell
2cf3f7c074 tdb2: save open_flags instead of mmap_flags.
It's more consistent with what tdb1 does, and slightly more encapsulated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 6b7c3c840eafbec211b9f58751c5ff754302a68e)
2011-09-14 07:14:13 +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
Rusty Russell
ab61a57e01 tdb2: Hand error code to logging function.
Since we've deprecated tdb_error() function (and it didn't work right
from inside the logging function anyway, since we didn't set
tdb->ecode yet) we need to hand it to the log function.

(Imported from CCAN commit 6e3d9e8a66bf8b45150500f176452ee8e9ee9927)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:12:13 +09:30
Rusty Russell
fb37849abd tdb2: move transaction lock
Make it the same offset as TDB1.  This isn't strictly necessary, but
it would allow for total unification later, since TDB1 and TDB2's
transaction code is otherwise completely compatible.

(Imported from CCAN commit de432e8f857ce23bccde7c6ffa3e7e21456df18b)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:11:13 +09:30
Rusty Russell
e69c90e5d5 tdb2: enforce TDB_CONVERT
If the caller actually specifies TDB_CONVERT, fail if the TDB does not
need conversion.  It's unusual for the user to specify TDB_CONVERT
(it's auto-detected) but better to be strict.

(Imported from CCAN commit 3e3ee8b0c1e77340ab9e8678c2d23646d8cdb627)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:10:13 +09:30
Rusty Russell
34c2d1658a tdb2: cleanup oob handling.
The tdb_oob() function can fail due to errors, as well as because the length
asked for is greater than the size of the file.  Clean that up:

(1) If probe is true, only fail if there's an error, not if the length is
    too great.
(2) Exit tdb_open() if it tdb_oob() probe fails; this helps cut down
    test time for failtest.
(3) Don't set probe to true in tdb_direct() fail; a minor issue, but it means
    we log failure.

(Imported from CCAN commit 77658070a3e4f712b94d659b2e399031ce3394c8)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:09:13 +09:30
Rusty Russell
1bba793fd6 tdb2: fix tdb_lock offset.
It can be 64 bits, for huge databases.

(Imported from CCAN commit 736c033322079baf754261d82b6a83de53b2bb4e)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:08:13 +09:30
Rusty Russell
9b9aa556de tdb2: fix internal tdb_write_convert() error handling in tdb_open()
As noted, failtest was taking a long time, because a failure injected here
was not detected.

(Imported from CCAN commit 51f592dfcda4d58d6b9d8134b6e1aff791dc40f2)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:07:13 +09:30
Rusty Russell
e8eebe0fbc tdb2: Fix to always use 64-bit offset definition
We use off_t in the tdb2 interface (for tdb_attribute_flock); we need
to make sure that all callers agree on the size.

This also causes a problem in the tests: it's not enough to include
config.h first, we need the _FILE_OFFSET_BITS define from private.h.
Otherwise, we can disagree about the definitions of F_SETLK, F_SETLKW
and off_t, causing strange problems.

(Imported from CCAN commit baa17ee2d5e01a32030f19e566007417d72b4b6e)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:06:13 +09:30
Rusty Russell
abb437c0ab ccan: configure check for HAVE_BUILTIN_CHOOSE_EXPR
We weren't testing for this, and without it, typesafe_cb just casts
its function argument.  This is why I didn't get a warning when one of
my patches amended a function incorrectly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14 07:05:13 +09:30
Stefan Metzmacher
a26fe036fe s3:smb2cli: split cli->smb2.gss_blob from cli->secblob
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Tue Sep 13 23:34:13 CEST 2011 on sn-devel-104
2011-09-13 23:34:13 +02:00
Stefan Metzmacher
15179852ea s3:net_time: make use of cli_state_server_time_zone() and cli_state_server_time()
metze
2011-09-13 21:53:08 +02:00
Stefan Metzmacher
7ba2bc35a3 s3:libsmb: make use of cli_state_server_time_zone()
metze
2011-09-13 21:53:07 +02:00
Stefan Metzmacher
d62f1e1e19 s3:libsmb: add cli_state_server_time()
metze
2011-09-13 21:53:07 +02:00
Stefan Metzmacher
4154b374d6 s3:libsmb: add cli_state_server_time_zone()
metze
2011-09-13 20:50:16 +02:00
Stefan Metzmacher
43976bdece s3:libsmb: make use of cli_state_server_session_key()
metze
2011-09-13 20:49:27 +02:00
Stefan Metzmacher
7ec961d987 s3:libsmb: add cli_state_server_session_key()
metze
2011-09-13 20:49:27 +02:00
Stefan Metzmacher
fa5475ea9e s3:libsmb: make use of cli_state_security_mode()
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Tue Sep 13 19:45:01 CEST 2011 on sn-devel-104
2011-09-13 19:45:01 +02:00
Stefan Metzmacher
faab79e28e s3:winbindd_cm: make use of cli_state_security_mode()
metze
2011-09-13 18:12:23 +02:00
Stefan Metzmacher
9a855dd5d9 s3:auth_server: make use of cli_state_security_mode()
metze
2011-09-13 18:12:23 +02:00
Stefan Metzmacher
fbd5cb5835 s3:libsmb: add cli_state_security_mode()
metze
2011-09-13 18:12:23 +02:00
Stefan Metzmacher
7c405fd92c s3:libsmb: make use of cli_state_max_requests() in cli_push_send()
metze
2011-09-13 18:12:23 +02:00
Stefan Metzmacher
c5072534bc s3:libsmb: make use of cli_state_max_requests() in cli_pull_send()
metze
2011-09-13 18:12:23 +02:00
Stefan Metzmacher
dafeef47b4 s3:libsmb: add cli_state_max_requests()
metze
2011-09-13 18:12:23 +02:00