summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbindd_idmap.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-04-26 23:11:26 +0000
committerJeremy Allison <jra@samba.org>2002-04-26 23:11:26 +0000
commit9199721eba64b7808471f6f0811dfd20e85938ca (patch)
tree3758c3aeb39e4838655d17bfb20c542c96ee4f1f /source3/nsswitch/winbindd_idmap.c
parent19bacddd52f4099fcad39e666e6eba26d16b4863 (diff)
downloadsamba-9199721eba64b7808471f6f0811dfd20e85938ca.tar.gz
samba-9199721eba64b7808471f6f0811dfd20e85938ca.tar.bz2
samba-9199721eba64b7808471f6f0811dfd20e85938ca.zip
Attempt to fix big-endian upgrade problem (Herb, Jerry, please check).
Jeremy. (This used to be commit 54261460b35cc531e033a99596d5596e94bebe24)
Diffstat (limited to 'source3/nsswitch/winbindd_idmap.c')
-rw-r--r--source3/nsswitch/winbindd_idmap.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/source3/nsswitch/winbindd_idmap.c b/source3/nsswitch/winbindd_idmap.c
index 6528efea43..3649b8ff7a 100644
--- a/source3/nsswitch/winbindd_idmap.c
+++ b/source3/nsswitch/winbindd_idmap.c
@@ -363,6 +363,7 @@ fail:
static BOOL idmap_convert(const char *idmap_name)
{
+ BOOL bytereversed = False;
int32 vers = tdb_fetch_int32(idmap_tdb, "IDMAP_VERSION");
if (vers == IDMAP_VERSION)
@@ -374,15 +375,18 @@ static BOOL idmap_convert(const char *idmap_name)
return False;
#endif
- if ((vers == -1) || (IREV(vers) == IDMAP_VERSION)) {
+ bytereversed = (IREV(vers) == IDMAP_VERSION) ? True : False;
+
+ if ((vers == -1) || bytereversed) {
/* Arrggghh ! Bytereversed or missing - make order independent ! */
int32 wm;
wm = tdb_fetch_int32(idmap_tdb, HWM_USER);
- if (wm != -1)
+ if (wm != -1 && bytereversed) {
+ /* A record existed and it was from a big endian machine. */
wm = IREV(wm);
- else
+ } else if (wm == -1)
wm = server_state.uid_low;
if (tdb_store_int32(idmap_tdb, HWM_USER, wm) == -1) {
@@ -391,10 +395,12 @@ static BOOL idmap_convert(const char *idmap_name)
}
wm = tdb_fetch_int32(idmap_tdb, HWM_GROUP);
- if (wm != -1)
+ if (wm != -1 && bytereversed) {
+ /* A record existed and it was from a big endian machine. */
wm = IREV(wm);
- else
+ } else if (wm == -1)
wm = server_state.gid_low;
+
if (tdb_store_int32(idmap_tdb, HWM_GROUP, wm) == -1) {
DEBUG(0, ("idmap_convert: Unable to byteswap group hwm in idmap database\n"));
return False;
@@ -404,7 +410,7 @@ static BOOL idmap_convert(const char *idmap_name)
/* the old format stored as DOMAIN/rid - now we store the SID direct */
tdb_traverse(idmap_tdb, convert_fn, NULL);
- if (tdb_store_int32(idmap_tdb, "IDMAP_VERSION", IDMAP_VERSION) == -1) {
+ if (tdb_store_int32(idmap_tdb, "IDMAP_VERSION", IDMAP_VERSION) == -1) {
DEBUG(0, ("idmap_convert: Unable to byteswap group hwm in idmap database\n"));
return False;
}