From b2379d6100b03504d4c2daf29e09f0ab1047df7d Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Fri, 15 Jun 2018 09:45:08 -0400 Subject: [PATCH] Ticket 49782 - workaround fix winsync uid case Description; This sets all the entryes attributes and dn to lowercase consistency. But the original bug can not be reproduced so for now this should not be committed to the source. This patch is just to preserver the work in case it is needed later. --- ldap/servers/plugins/presence/presence.c | 19 +++---------------- .../plugins/replication/windows_connection.c | 5 ++++- .../replication/windows_protocol_util.c | 2 ++ ldap/servers/slapd/slapi-plugin.h | 2 ++ ldap/servers/slapd/util.c | 12 ++++++++++++ 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ldap/servers/plugins/presence/presence.c b/ldap/servers/plugins/presence/presence.c index a60513180..7ef439dd8 100644 --- a/ldap/servers/plugins/presence/presence.c +++ b/ldap/servers/plugins/presence/presence.c @@ -164,7 +164,6 @@ static int setTypes(PLHashEntry *he, PRIntn i, void *arg); static void deleteMapTables(void); static PRIntn destroyHashEntry(PLHashEntry *he, PRIntn index, void *arg); static void logGraphicAttributeValue(Slapi_Attr *attr, const char *attrname); -static void toLowerCase(char *str); /** * utility function @@ -563,7 +562,7 @@ parseConfigEntry(Slapi_Entry *e) map = (_Vmap *)slapi_ch_calloc(1, sizeof(_Vmap)); map->imID = key; map->syntax = PRESENCE_STRING; - toLowerCase(value); + slapi_str_tolower(value); PL_HashTableAdd(_IdVattrMapTable, value, map); } slapi_log_err(SLAPI_LOG_PLUGIN, PRESENCE_PLUGIN_SUBSYSTEM, "parseConfigEntry - nsIMStatusText [%s] \n", value); @@ -574,7 +573,7 @@ parseConfigEntry(Slapi_Entry *e) map = (_Vmap *)slapi_ch_calloc(1, sizeof(_Vmap)); map->imID = key; map->syntax = PRESENCE_BINARY; - toLowerCase(value); + slapi_str_tolower(value); PL_HashTableAdd(_IdVattrMapTable, value, map); } @@ -679,7 +678,7 @@ imIDExists(Slapi_Entry *e, char *type, char **value, _Vmap **map, _ConfigEntry * * which just does a lookup and doesn't modifies the * hashtable */ - toLowerCase(type); + slapi_str_tolower(type); tMap = PL_HashTableLookupConst(_IdVattrMapTable, type); if (!tMap) { /** @@ -1093,18 +1092,6 @@ destroyHashEntry(PLHashEntry *he, PRIntn index, void *arg) return HT_ENUMERATE_REMOVE; } -static void -toLowerCase(char *str) -{ - if (str) { - char *lstr = str; - for (; (*lstr != '\0'); ++lstr) { - *lstr = tolower(*lstr); - } - } -} - - /** * utility function to print the array */ diff --git a/ldap/servers/plugins/replication/windows_connection.c b/ldap/servers/plugins/replication/windows_connection.c index 8efa23b7d..6c1a8c7b5 100644 --- a/ldap/servers/plugins/replication/windows_connection.c +++ b/ldap/servers/plugins/replication/windows_connection.c @@ -473,6 +473,7 @@ windows_LDAPMessage2Entry(Slapi_Entry *e, Repl_Connection *conn, LDAPMessage *ms int exattridx = 0; char **deletedattrs = NULL; char **dap; + char *dn = NULL; windows_private_set_raw_entry(conn->agmt, NULL); /* clear it first */ @@ -494,7 +495,9 @@ windows_LDAPMessage2Entry(Slapi_Entry *e, Repl_Connection *conn, LDAPMessage *ms slapi_entry_free(e); return NULL; } - slapi_entry_set_sdn(rawentry, slapi_entry_get_sdn(e)); + dn = slapi_ch_strdup(slapi_entry_get_dn(e)); + slapi_str_tolower(dn); + slapi_entry_set_dn(rawentry, dn); for (a = ldap_first_attribute(ld, msg, &ber); a != NULL; a = ldap_next_attribute(ld, msg, ber)) { struct berval **aVal = ldap_get_values_len(ld, msg, a); diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c index f350b6d34..0bbefd6d1 100644 --- a/ldap/servers/plugins/replication/windows_protocol_util.c +++ b/ldap/servers/plugins/replication/windows_protocol_util.c @@ -3494,6 +3494,7 @@ extract_username_from_entry(Slapi_Entry *e) { char *uid = NULL; uid = slapi_entry_attr_get_charptr(e, "samAccountName"); + slapi_str_tolower(uid); return uid; } @@ -5762,3 +5763,4 @@ windows_dirsync_inc_run(Private_Repl_Protocol *prp) error: slapi_log_err(SLAPI_LOG_TRACE, windows_repl_plugin_name, "<= windows_dirsync_inc_run\n"); } + diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index e862382fa..26bbc48fd 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -8285,6 +8285,8 @@ int32_t slapi_atomic_decr_32(int32_t *ptr, int memorder); */ uint64_t slapi_atomic_decr_64(uint64_t *ptr, int memorder); +/* util.c */ +void slapi_str_tolower(char *str); #ifdef __cplusplus } diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c index 1be215bfa..8fcb2c3d1 100644 --- a/ldap/servers/slapd/util.c +++ b/ldap/servers/slapd/util.c @@ -1589,3 +1589,15 @@ slapi_create_errormsg( va_end(ap); } } + + +void +slapi_str_tolower(char *str) +{ + if (str) { + char *lstr = str; + for (; (*lstr != '\0'); ++lstr) { + *lstr = tolower(*lstr); + } + } +} -- 2.17.1