Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14694/servers/slapd/back-ldbm
Modified Files:
back-ldbm.h import-threads.c index.c ldbm_add.c ldbm_delete.c
ldbm_modrdn.c
Log Message:
Resolves: #199923
Summary: subtree search fails to find items under a db containing special characters
(Comment#16)
Description: When dn contains rdn which includes '\\', it was escaped twice to
generate a key for entrydn and caused mismatch in forming ancestorid index. It ends up
the subtree search fail.
Index: back-ldbm.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/back-ldbm.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- back-ldbm.h 12 Aug 2005 05:49:55 -0000 1.6
+++ back-ldbm.h 6 Nov 2006 20:51:31 -0000 1.7
@@ -638,6 +638,7 @@
#define BE_INDEX_TOMBSTONE 8 /* Index entry as a tombstone */
#define BE_INDEX_DONT_ENCRYPT 16 /* Disable any encryption if this flag is set */
#define BE_INDEX_EQUALITY 32 /* (w/DEL) remove the equality index */
+#define BE_INDEX_NORMALIZED SLAPI_ATTR_FLAG_NORMALIZED /* value already normalized */
/* Name of attribute type used for binder-based look through limit */
#define LDBM_LOOKTHROUGHLIMIT_AT "nsLookThroughLimit"
Index: import-threads.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import-threads.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- import-threads.c 6 Dec 2005 18:28:14 -0000 1.9
+++ import-threads.c 6 Nov 2006 20:51:32 -0000 1.10
@@ -933,7 +933,7 @@
/* insert into the entrydn index */
bv.bv_val = (void*)backentry_get_ndn(fi->entry); /* jcm - Had to cast away const
*/
- bv.bv_len = strlen(backentry_get_ndn(fi->entry));
+ bv.bv_len = strlen(bv.bv_val);
/* We need to check here whether the DN is already present in
* the entrydn index. If it is then the input ldif
@@ -960,7 +960,7 @@
if ((ret = index_addordel_string(be, "entrydn",
bv.bv_val,
fi->entry->ep_id,
- BE_INDEX_ADD, NULL)) != 0) {
+ BE_INDEX_ADD|BE_INDEX_NORMALIZED, NULL)) != 0) {
import_log_notice(job, "Error writing entrydn index "
"(error %d: %s)",
ret, dblayer_strerror(ret));
Index: index.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/index.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- index.c 15 Aug 2005 20:59:27 -0000 1.8
+++ index.c 6 Nov 2006 20:51:32 -0000 1.9
@@ -381,10 +381,10 @@
/* if we are adding a tombstone entry (see ldbm_add.c) */
if ((flags & BE_INDEX_TOMBSTONE) && (flags & BE_INDEX_ADD))
{
- Slapi_DN parent;
- Slapi_DN *sdn = slapi_entry_get_sdn(e->ep_entry);
- slapi_sdn_init(&parent);
- slapi_sdn_get_parent(sdn, &parent);
+ Slapi_DN parent;
+ Slapi_DN *sdn = slapi_entry_get_sdn(e->ep_entry);
+ slapi_sdn_init(&parent);
+ slapi_sdn_get_parent(sdn, &parent);
/*
* Just index the "nstombstone" attribute value from the objectclass
* attribute, and the nsuniqueid attribute value, and the entrydn value of the
deleted entry.
@@ -404,7 +404,7 @@
ldbm_nasty(errmsg, 1020, result);
return( result );
}
- slapi_sdn_done(&parent);
+ slapi_sdn_done(&parent);
}
else
{
@@ -414,8 +414,11 @@
rc = slapi_entry_next_attr( e->ep_entry, attr, &attr ) ) {
slapi_attr_get_type( attr, &type );
svals = attr_get_present_values(attr);
- result = index_addordel_values_sv( be, type, svals, NULL, e->ep_id,
- flags, txn );
+ if ( 0 == strcmp( type, "entrydn" )) {
+ slapi_values_set_flags(svals, SLAPI_ATTR_FLAG_NORMALIZED);
+ }
+ result = index_addordel_values_sv( be, type, svals, NULL,
+ e->ep_id, flags, txn );
if ( result != 0 ) {
ldbm_nasty(errmsg, 1030, result);
return( result );
@@ -423,13 +426,13 @@
}
/* update ancestorid index . . . */
- /* . . . only if we are not deleting a tombstone entry - tombstone entries are not in
the ancestor id index - see bug 603279 */
- if (!((flags & BE_INDEX_TOMBSTONE) && (flags & BE_INDEX_DEL))) {
- result = ldbm_ancestorid_index_entry(be, e, flags, txn);
- if ( result != 0 ) {
- return( result );
- }
- }
+ /* . . . only if we are not deleting a tombstone entry - tombstone entries are
not in the ancestor id index - see bug 603279 */
+ if (!((flags & BE_INDEX_TOMBSTONE) && (flags & BE_INDEX_DEL))) {
+ result = ldbm_ancestorid_index_entry(be, e, flags, txn);
+ if ( result != 0 ) {
+ return( result );
+ }
+ }
}
LDAPDebug( LDAP_DEBUG_TRACE, "<= index_%s_entry%s %d\n",
@@ -1643,6 +1646,8 @@
sv.bv.bv_val= (void*)s;
svp[0] = &sv;
svp[1] = NULL;
+ if (flags & BE_INDEX_NORMALIZED)
+ slapi_value_set_flags(&sv, BE_INDEX_NORMALIZED);
return index_addordel_values_ext_sv(be,type,svp,NULL,id,flags,txn,NULL,NULL);
}
Index: ldbm_add.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_add.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ldbm_add.c 19 Apr 2005 22:07:38 -0000 1.4
+++ ldbm_add.c 6 Nov 2006 20:51:32 -0000 1.5
@@ -195,7 +195,7 @@
slapi_isbitset_int(rc,SLAPI_RTN_BIT_FETCH_PARENT_ENTRY))
{
done_with_pblock_entry(pb,SLAPI_ADD_PARENT_ENTRY); /* Could be through this multiple
times */
- addr.dn = (char*)slapi_sdn_get_ndn (&parentsdn);
+ addr.dn = (char*)slapi_sdn_get_dn (&parentsdn); /* get_copy_of_entry assumes the
DN is not normalized */
addr.uniqueid = operation->o_params.p.p_add.parentuniqueid;
ldap_result_code= get_copy_of_entry(pb, &addr, &txn, SLAPI_ADD_PARENT_ENTRY,
!is_replicated_operation);
/* need to set parentsdn or parentuniqueid if either is not set? */
@@ -234,7 +234,7 @@
*/
if(have_parent_address(&parentsdn,
operation->o_params.p.p_add.parentuniqueid))
{
- addr.dn = (char*)slapi_sdn_get_ndn (&parentsdn);
+ addr.dn = (char*)slapi_sdn_get_dn (&parentsdn);
addr.uniqueid = operation->o_params.p.p_add.parentuniqueid;
parententry = find_entry2modify_only(pb,be,&addr,&txn);
if (parententry && parententry->ep_entry) {
@@ -898,7 +898,7 @@
bvp[1] = NULL;
bv.bv_val = (void*)backentry_get_ndn(ep);
bv.bv_len = strlen( bv.bv_val );
- entry_replace_values( ep->ep_entry, "entrydn", bvp );
+ entry_replace_values_with_flags( ep->ep_entry, "entrydn", bvp,
SLAPI_ATTR_FLAG_NORMALIZED );
}
/*
Index: ldbm_delete.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_delete.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ldbm_delete.c 12 Aug 2005 22:52:29 -0000 1.5
+++ ldbm_delete.c 6 Nov 2006 20:51:32 -0000 1.6
@@ -250,7 +250,7 @@
struct backentry *parent = NULL;
entry_address parent_addr;
- parent_addr.dn = (char*)slapi_sdn_get_ndn (&parentsdn);
+ parent_addr.dn = (char*)slapi_sdn_get_dn (&parentsdn);
parent_addr.uniqueid = NULL;
parent = find_entry2modify_only(pb,be,&parent_addr,&txn);
if (NULL != parent) {
Index: ldbm_modrdn.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ldbm_modrdn.c 19 Apr 2005 22:07:38 -0000 1.4
+++ ldbm_modrdn.c 6 Nov 2006 20:51:32 -0000 1.5
@@ -271,7 +271,7 @@
}
/* Fetch and lock the parent of the entry that is moving */
- oldparent_addr.dn = (char*)slapi_sdn_get_ndn (&dn_parentdn);
+ oldparent_addr.dn = (char*)slapi_sdn_get_dn (&dn_parentdn);
oldparent_addr.uniqueid = NULL;
parententry = find_entry2modify_only( pb, be, &oldparent_addr, NULL );
modify_init(&parent_modify_context,parententry);
@@ -360,10 +360,17 @@
if(!(slapi_dn_isbesuffix(pb,slapi_sdn_get_ndn(&dn_olddn)) && isroot))
{
/* Here means that we didn't find the parent */
- ldap_result_matcheddn = slapi_ch_strdup((char *)
slapi_entry_get_dn(parententry->ep_entry));
+ if (parententry && parententry->ep_entry)
+ {
+ ldap_result_matcheddn = slapi_ch_strdup((char *)
slapi_entry_get_dn(parententry->ep_entry));
+ }
+ else
+ {
+ ldap_result_matcheddn = "NULL";
+ }
ldap_result_code= LDAP_NO_SUCH_OBJECT;
LDAPDebug( LDAP_DEBUG_TRACE, "Parent does not exist matched %s, parentdn =
%s\n",
- ldap_result_matcheddn == NULL ? "NULL" : ldap_result_matcheddn,
slapi_sdn_get_ndn(&dn_parentdn), 0 );
+ ldap_result_matcheddn, slapi_sdn_get_ndn(&dn_parentdn), 0 );
goto error_return;
}
}
@@ -818,7 +825,8 @@
moddn_unlock_and_return_entries(be,&e,&existingentry);
slapi_ch_free((void**)&child_entries);
slapi_ch_free((void**)&child_entry_copies);
- slapi_ch_free((void**)&ldap_result_matcheddn);
+ if (ldap_result_matcheddn && 0 != strcmp(ldap_result_matcheddn,
"NULL"))
+ slapi_ch_free((void**)&ldap_result_matcheddn);
idl_free(children);
slapi_sdn_done(&dn_olddn);
slapi_sdn_done(&dn_newdn);