summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/uuid.c
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2007-09-24 22:54:55 +0000
committerRich Megginson <rmeggins@redhat.com>2007-09-24 22:54:55 +0000
commit6db4b30d1d7b3962764380bee9b8c563209407ff (patch)
treec10baa80f08e20a47c8af0cbab5d237b695412f9 /ldap/servers/slapd/uuid.c
parent71867898256b2cd8b8c66dca2a12debf4d8879ee (diff)
downloadds-6db4b30d1d7b3962764380bee9b8c563209407ff.tar.gz
ds-6db4b30d1d7b3962764380bee9b8c563209407ff.tar.xz
ds-6db4b30d1d7b3962764380bee9b8c563209407ff.zip
Resolves: bug 262021
Bug Description: Migration script does not migrate nsDS5ReplicaCredentials correctly. Reviewed by: nkinder (Thanks!) Fix Description: 7.1 and earlier chaining and replication credentials were stored incorrectly on little endian machines (x86 and itanium). They were "accidentally" stored correctly on big endian machines (sparc, pa-risc) because val == ntohl(val) on those platforms. When migrating from a little endian machine, we need to decode the password using the broken algorithm and re-encode it using the good method. We determine if the password is encode incorrectly by the following method: we use migratecred to decode and encode using the old path. If the values are equal, this means the password was already encoded correctly and we don't need to fix it. Otherwise, we set the flag that tells migratecred to fix it. In order to decode the broken password correctly on big endian machines, we have to swap the byte order to convert the values to little endian. Platforms tested: RHEL5 x86_64, RHEL5 i386, Solaris 9 Flag Day: no Doc impact: no QA impact: should be covered by regular nightly and manual testing New Tests integrated into TET: none
Diffstat (limited to 'ldap/servers/slapd/uuid.c')
-rw-r--r--ldap/servers/slapd/uuid.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/ldap/servers/slapd/uuid.c b/ldap/servers/slapd/uuid.c
index 626b0330..3089de09 100644
--- a/ldap/servers/slapd/uuid.c
+++ b/ldap/servers/slapd/uuid.c
@@ -847,10 +847,16 @@ static void format_uuid_v1(guid_t * uuid, uuid_time_t timestamp, unsigned16 cloc
memcpy(&uuid->node, &_state.genstate.node, sizeof (uuid->node));
}
+/* when converting broken values, we may need to swap the bytes */
+#define BSWAP16(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+#define BSWAP32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+
/* format_uuid_v3 -- make a UUID from a (pseudo)random 128 bit number
*/
static void format_uuid_v3(guid_t * uuid, unsigned char hash[16])
{
+ char *use_broken_uuid = getenv("USE_BROKEN_UUID");
/* Construct a version 3 uuid with the (pseudo-)random number
* plus a few constants. */
@@ -858,11 +864,18 @@ static void format_uuid_v3(guid_t * uuid, unsigned char hash[16])
/* when migrating, we skip the ntohl in order to read in old,
incorrectly formatted uuids */
- if (!getenv("USE_BROKEN_UUID")) {
+ if (!use_broken_uuid || (*use_broken_uuid == '0')) {
/* convert UUID to local byte order */
uuid->time_low = PR_ntohl(uuid->time_low);
uuid->time_mid = PR_ntohs(uuid->time_mid);
uuid->time_hi_and_version = PR_ntohs(uuid->time_hi_and_version);
+ } else {
+#if defined(IS_BIG_ENDIAN)
+ /* convert UUID to b0rken byte order */
+ uuid->time_low = BSWAP32(uuid->time_low);
+ uuid->time_mid = BSWAP16(uuid->time_mid);
+ uuid->time_hi_and_version = BSWAP16(uuid->time_hi_and_version);
+#endif
}
/* put in the variant and version bits */