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

36 Commits

Author SHA1 Message Date
Volker Lendecke
a41af25ebd dbwrap: Remove "db_context->try_fetch_locked()" fn pointer
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
ca8c23bb42 dbwrap: Don't set rec->value in dbwrap_do_locked()
We pass that via the callback now

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22 23:57:46 +00:00
Volker Lendecke
1dc3c16824 dbwrap: Protect against invalid db_record->value
After dbwrap_record_storev()/delete(), dbwrap_record_get_value()
information is stale. Assert on the attempt to re-fetch data after it
became stale. This can't protect against someone copying the result
from dbwrap_record_get_value() somewhere else, but it's better than
nothing.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22 23:57:46 +00:00
Volker Lendecke
caef82b1fe dbwrap: Pass "value" to dbwrap_do_locked() callback
I want to reduce dbwrap_record_get_value(). It makes the caller believe it can
make a copy of the TDB_DATA returned and that the value remains constant. It's
not, as you can always do a dbwrap_record_store().

This patch removes one requirement for getting the value out of a
db_record via dbwrap_record_get_value(). You can still make a copy, but from an
API perspective to me it's more obvious that "value" as a parameter to the
callback has a limited lifetime.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22 23:57:46 +00:00
Volker Lendecke
a58633f64e dbwrap_tdb: Return correct error from db_tdb_storev()
Don't lose information to NT_STATUS_UNSUCCESSFUL

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22 23:57:46 +00:00
Volker Lendecke
bc2fc51abe dbwrap_tdb: Avoid includes.h
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-22 23:57:46 +00:00
Volker Lendecke
d6223677bf dbwrap_tdb: Avoid a use of talloc_stackframe()
For really large keys (that probably don't exist), use dump_data()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-11-06 20:36:34 +00:00
Volker Lendecke
58b5bfba11 lib: Micro-optimization for db_tdb_do_locked()
We don't need the tdb lock for the talloc_free(buf) anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
2019-08-19 23:14:38 +00:00
Volker Lendecke
b6b7c15758 dbwrap_tdb: Avoid double-call to talloc_get_type_abort
We've already retrieved "ctx" in the callers of db_tdb_fetch_locked_internal().

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-14 07:49:13 +02:00
Ralph Boehme
382620d42d dbwrap_tdb: use struct initializer
This ensures all struct members are implicitly initialized.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-12 22:25:19 +02:00
Ralph Boehme
9a9620bb42 dbwrap_tdb: move a function call out of an if condition
At least for me this improves readability somewhat. No change in
behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-09-12 22:25:19 +02:00
Timur I. Bakeyev
010cddae6c Convert affected by previous commit lines from DEBUG(10,..) to DBG_DEBUG().
Signed-off-by: Timur I. Bakeyev <timur@iXsystems.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed May 16 21:29:24 CEST 2018 on sn-devel-144
2018-05-16 21:29:24 +02:00
Timur I. Bakeyev
d3cbcbd5c0 Remove extra 0x prefix for the "%p" format specifiers, avoiding 0x0x0 strings in the output.
Signed-off-by: Timur I. Bakeyev <timur@iXsystems.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2018-05-16 18:06:23 +02:00
Volker Lendecke
e3a0f0c100 dbwrap_tdb: Implement do_locked
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2017-07-25 17:43:16 +02:00
Volker Lendecke
09915bf8e5 dbwrap: Convert backend store to storev
Convert all implementors of dbwrap_store to a storev-style call
by using the dbwrap_merge_dbufs call

For dbwrap_tdb, this matches tdb_storev.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2017-07-25 17:43:16 +02:00
Volker Lendecke
8aab4426a5 dbwrap_tdb: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Mon Nov 23 15:16:19 CET 2015 on sn-devel-104
2015-11-23 15:16:19 +01:00
Volker Lendecke
9964d60e3e dbwrap: Make dbwrap_db_id return size_t
This will make an on-stack db-id easier

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2015-09-22 04:51:16 +02:00
Volker Lendecke
71a407edad dbwrap: Remove talloc_reference()
We want to know (by crashing) when we free the database with records still
around. This would be a serious violation of our data structure hierarchies.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2015-09-22 04:51:16 +02:00
Volker Lendecke
225cba6e41 dbwrap: Remove unused dbwrap_hash_size()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2015-09-22 04:51:16 +02:00
Volker Lendecke
5d12eb8908 dbwrap: Remove loadparm_context from db_open_tdb
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2015-09-22 04:51:16 +02:00
Volker Lendecke
fe81b50d65 Remove ntdb protection from db_open_tdb
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-03-17 11:30:51 +01:00
Volker Lendecke
d6db35d7a5 tdb_wrap: Remove tdb_wrap_open_ again
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-31 22:52:14 +02:00
Volker Lendecke
acbc1ed703 dbwrap: Avoid passing lp_ctx to tdb_wrap_open in db_open_tdb
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-31 22:52:13 +02:00
Michael Adam
bbf0903d6b dbwrap: add a dbwrap_flags argument to db_open_tdb()
...for consistency and in preparation of future flags
that the tdb backend might be aware of.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-02-07 16:06:07 +01:00
Volker Lendecke
56055f788c Revert "dbwrap: dbwrap_fetch_locked_timeout()."
This reverts commit f6eb187fda.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Rusty Russell <rusty@rustcorp.com.au>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Jun  6 14:26:26 CEST 2013 on sn-devel-104
2013-06-06 14:26:26 +02:00
Volker Lendecke
e271db4fd8 dbwrap: Remove an unnecessary if-statement
TALLOC_FREE can live with a NULL pointer

Reviewed-by: Michael Adam <obnox@samba.org>
2012-11-29 18:27:38 +01:00
Volker Lendecke
c7af12dd30 dbwrap: No need to NULL out a talloc_zero'ed structure element
Reviewed-by: Michael Adam <obnox@samba.org>
2012-11-29 18:27:37 +01:00
Andrew Bartlett
f8e6bb46c0 dbwrap: use talloc_stackframe() in db_tdb_log_key()
We can not be sure that there is already a talloc_stackframe() in place
so we must create one.

Andrew Bartlett
2012-10-25 22:19:59 +11:00
Rusty Russell
945473aac0 dbwrap: dbwrap_hash_size().
Implemented for ntdb and tdb; falls back to 0 for others.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:17 +02:00
Rusty Russell
e92cb556fd dbwrap: dbwrap_name().
Useful for debug messages: particularly once we start switching between .tdb
and .ntdb files.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:17 +02:00
Rusty Russell
41f799d877 dbwrap: dbwrap_transaction_start_nonblock().
Implemented for ntdb and tdb; falls back to the blocking variant
for others.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:17 +02:00
Rusty Russell
f6eb187fda dbwrap: dbwrap_fetch_locked_timeout().
Implemented for ntdb and tdb; falls back to the non-timeout variant
for others.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:17 +02:00
Rusty Russell
431667b47c dbwrap: add dbwrap_check() function.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:17 +02:00
Rusty Russell
9d97bf3f47 dbwrap: dbwrap_local_open()
This simply opens a tdb: it will eventually switch depending on the
extension.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:17 +02:00
Rusty Russell
1acf548eb7 dbwrap: remove get_flags().
The flags returned were TDB-specific: this was only used for detecting
the endianness of obsolete databases (the conversion code was put in in
2003, with reference to Samba 2.3).

It's easier to remove it than to translate the NTDB flags to TDB flags,
and it's a really weird thing to ask for anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:17 +02:00
Michael Adam
e945511aae move the dbwrap library to the top level
Autobuild-User: Michael Adam <obnox@samba.org>
Autobuild-Date: Mon May 14 04:04:55 CEST 2012 on sn-devel-104
2012-05-14 04:04:55 +02:00