diff options
author | Gary Lockyer <gary@catalyst.net.nz> | 2018-02-21 15:20:17 +1300 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2018-03-03 05:20:35 +0100 |
commit | 0bfbcdb69155315415867cee34d5293b1ee125fa (patch) | |
tree | 472dbcc34220bafe7ec5f5c838238de9083e43b1 /lib | |
parent | ffb836f3feb25861ab3fadc42b0fc2603468015c (diff) | |
download | samba-0bfbcdb69155315415867cee34d5293b1ee125fa.tar.gz |
ldb_tdb: Add support for an option to restrict the key length
Allow the setting of the maximum key length, this allows the testing of
index key truncation code. Index key truncation is required to allow
the samba indexing scheme to be used with backends that enforce a
maximum key length.
This will allow emulation of a length-limited key DB for testing.
This is a testing-only feature, as the index format changes
based on this value.
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/ldb_tdb/ldb_tdb.c | 13 | ||||
-rw-r--r-- | lib/ldb/ldb_tdb/ldb_tdb.h | 7 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index 16e4b8ea26e..dcb877312a9 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -1952,6 +1952,19 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, } *_module = module; + + /* + * Set the maximum key length + */ + { + const char *len_str = + ldb_options_find(ldb, options, + "max_key_len_for_self_test"); + if (len_str != NULL) { + unsigned len = strtoul(len_str, NULL, 0); + ltdb->max_key_length = len; + } + } return LDB_SUCCESS; } diff --git a/lib/ldb/ldb_tdb/ldb_tdb.h b/lib/ldb/ldb_tdb/ldb_tdb.h index 7e182495928..421ae4d95d6 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/lib/ldb/ldb_tdb/ldb_tdb.h @@ -38,6 +38,13 @@ struct ltdb_private { bool read_only; const struct ldb_schema_syntax *GUID_index_syntax; + + /* + * Maximum index key length. If non zero keys longer than this length + * will be truncated for non unique indexes. Keys for unique indexes + * greater than this length will be rejected. + */ + unsigned max_key_length; }; struct ltdb_context { |