summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-06-20 18:40:32 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-06-20 11:18:35 +0200
commit42506c4a3e2da46d8df013e2bc17398b3193b381 (patch)
treee746c41386a9d6b22839e1b9672b87a8f7261741 /source3
parent61867eaa8458431c452352df021169c100fa9188 (diff)
downloadsamba-42506c4a3e2da46d8df013e2bc17398b3193b381.tar.gz
samba-42506c4a3e2da46d8df013e2bc17398b3193b381.tar.bz2
samba-42506c4a3e2da46d8df013e2bc17398b3193b381.zip
source3/winbindd/idmap_tdb.c: tdb2 support for wrong endian.
TDB has no idea of endian itself, but it knows whether the TDB is the same endian as the current machine, so we should use that rather than implementing TDB_BIGENDIAN in tdb2. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/idmap_tdb.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c
index 57a5e1c6ba..d99d2f0e4e 100644
--- a/source3/winbindd/idmap_tdb.c
+++ b/source3/winbindd/idmap_tdb.c
@@ -146,9 +146,23 @@ static bool idmap_tdb_upgrade(struct idmap_domain *dom, struct db_context *db)
bool bigendianheader;
struct convert_fn_state s;
- DEBUG(0, ("Upgrading winbindd_idmap.tdb from an old version\n"));
-
+#if BUILD_TDB2
+ /* If we are bigendian, tdb is bigendian if NOT converted. */
+ union {
+ uint16 large;
+ unsigned char small[2];
+ } u;
+ u.large = 0x0102;
+ if (u.small[0] == 0x01)
+ bigendianheader = !(db->get_flags(db) & TDB_CONVERT);
+ else {
+ assert(u.small[0] == 0x02);
+ bigendianheader = (db->get_flags(db) & TDB_CONVERT);
+ }
+#else
bigendianheader = (db->get_flags(db) & TDB_BIGENDIAN) ? True : False;
+#endif
+ DEBUG(0, ("Upgrading winbindd_idmap.tdb from an old version\n"));
vers = dbwrap_fetch_int32(db, "IDMAP_VERSION");