diff options
author | Aaron Haslett <aaronhaslett@catalyst.net.nz> | 2019-05-20 16:19:51 +1200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2019-08-28 07:36:29 +0000 |
commit | e22c1fbd56fcc0e7603f643d45efc83a846d573c (patch) | |
tree | 644e3636a5e02554b8b4a59b1f632e71baa107ed | |
parent | 388cb30bd7d70301fe1fd9dbecd1a1921955dc5b (diff) | |
download | samba-e22c1fbd56fcc0e7603f643d45efc83a846d573c.tar.gz |
ldb: ldbdump key and pack format version comments
For testing we need to know the actual KV level key of records and each
record's pack format version. This patch makes ldbdump add comments with
that info. We will parse it out in python tests.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13978
Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed May 22 05:58:17 UTC 2019 on sn-devel-184
(cherry picked from commit a666a99e4dc594bc153cd26b24cddd547c1cc750)
-rw-r--r-- | lib/ldb/tools/ldbdump.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/ldb/tools/ldbdump.c b/lib/ldb/tools/ldbdump.c index 4697661a59d..f01403418f1 100644 --- a/lib/ldb/tools/ldbdump.c +++ b/lib/ldb/tools/ldbdump.c @@ -36,6 +36,26 @@ static struct ldb_context *ldb; bool show_index = false; bool validate_contents = false; +static void print_data(TDB_DATA d) +{ + unsigned char *p = (unsigned char *)d.dptr; + int len = d.dsize; + while (len--) { + if (isprint(*p) && !strchr("\"\\", *p)) { + fputc(*p, stdout); + } else { + printf("\\%02X", *p); + } + p++; + } +} + +static unsigned int pull_uint32(uint8_t *p) +{ + return p[0] | (p[1]<<8) | (p[2]<<16) | (p[3]<<24); +} + + static int traverse_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA _dbuf, void *state) { int ret, i, j; @@ -79,6 +99,10 @@ static int traverse_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA _dbuf, void *sta } } + printf("# key: "); + print_data(key); + printf("\n# pack format: %#010x\n", pull_uint32(_dbuf.dptr)); + if (!validate_contents || ldb_dn_is_special(msg->dn)) { ldb_ldif_write_file(ldb, stdout, &ldif); TALLOC_FREE(msg); |