[Fedora-directory-commits] ldapserver/ldap/servers/slapd uuid.c, 1.8, 1.9

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Mon Sep 24 22:54:59 UTC 2007


Author: rmeggins

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1102/ldapserver/ldap/servers/slapd

Modified Files:
	uuid.c 
Log Message:
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 



Index: uuid.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/uuid.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- uuid.c	20 Sep 2007 20:27:35 -0000	1.8
+++ uuid.c	24 Sep 2007 22:54:55 -0000	1.9
@@ -847,10 +847,16 @@
     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 @@
 
 	/* 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 */




More information about the Fedora-directory-commits mailing list