Commit b2809cb3 authored by Howard Chu's avatar Howard Chu
Browse files

Fix dnParent to return "" for root

parent affa8f5a
......@@ -93,11 +93,11 @@ retry: rc = txn_abort( ltid );
* If the parent does not exist, only allow the "root" user to
* add the entry.
*/
pdn.bv_val = dn_parent( be, e->e_nname.bv_val );
if (pdn.bv_val == NULL)
pdn.bv_len = 0;
pdn.bv_val = dn_parent( be, e->e_ndn );
if (pdn.bv_val && *pdn.bv_val)
pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_ndn);
else
pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_nname.bv_val);
pdn.bv_len = 0;
if( pdn.bv_len != 0 ) {
Entry *matched = NULL;
......
......@@ -160,7 +160,7 @@ retry: /* transaction retry */
}
p_ndn.bv_val = dn_parent( be, e->e_ndn );
if (p_ndn.bv_val)
if (p_ndn.bv_val && *p_ndn.bv_val)
p_ndn.bv_len = e->e_nname.bv_len - (p_ndn.bv_val - e->e_ndn);
else
p_ndn.bv_len = 0;
......@@ -207,7 +207,7 @@ retry: /* transaction retry */
p_ndn.bv_val, 0, 0 );
p_dn.bv_val = dn_parent( be, e->e_dn );
if (p_dn.bv_val)
if (p_dn.bv_val && *p_dn.bv_val)
p_dn.bv_len = e->e_name.bv_len - (p_dn.bv_val - e->e_dn);
else
p_dn.bv_len = 0;
......
......@@ -146,7 +146,7 @@ ID bdb_tool_entry_put(
/* add dn2id indices */
pdn.bv_val = dn_parent( be, e->e_ndn );
if (pdn.bv_val)
if (pdn.bv_val && *pdn.bv_val)
pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_ndn);
else
pdn.bv_len = 0;
......@@ -242,7 +242,7 @@ int bdb_tool_entry_reindex(
/* add dn2id indices */
pdn.bv_val = dn_parent( be, e->e_ndn );
if (pdn.bv_val)
if (pdn.bv_val && *pdn.bv_val)
pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_ndn);
else
pdn.bv_len = 0;
......
......@@ -232,6 +232,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
slap_syntax_transform_func *transf = NULL;
MatchingRule *mr;
struct berval bv = { 0, NULL };
int do_sort = 0;
assert( ava );
......@@ -244,6 +245,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
}
ava->la_private = ( void * )ad;
do_sort = 1;
}
/*
......@@ -285,7 +287,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
ava->la_value = bv;
}
AVA_Sort( rdn, iAVA );
if( do_sort ) AVA_Sort( rdn, iAVA );
}
}
......@@ -649,6 +651,12 @@ dnParent(
return rc;
}
/* Parent is root */
if (*p == '\0') {
*pdn = "";
return LDAP_SUCCESS;
}
assert( DN_SEPARATOR( p[ 0 ] ) );
p++;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment