mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-09 22:04:12 -05:00
More struct berval fixes
This commit is contained in:
parent
0e5e2a95fd
commit
ef31250591
6 changed files with 45 additions and 25 deletions
|
|
@ -21,7 +21,7 @@ bdb_add(
|
|||
Entry *e )
|
||||
{
|
||||
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
||||
char *pdn = NULL;
|
||||
struct berval pdn;
|
||||
Entry *p = NULL;
|
||||
int rc;
|
||||
const char *text;
|
||||
|
|
@ -93,17 +93,17 @@ retry: rc = txn_abort( ltid );
|
|||
* If the parent does not exist, only allow the "root" user to
|
||||
* add the entry.
|
||||
*/
|
||||
pdn = dn_parent( be, e->e_nname.bv_val );
|
||||
pdn.bv_val = dn_parent( be, e->e_nname.bv_val );
|
||||
if (pdn.bv_val == NULL)
|
||||
pdn.bv_len = 0;
|
||||
else
|
||||
pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_nname.bv_val);
|
||||
|
||||
if( pdn != NULL && *pdn != '\0' ) {
|
||||
if( pdn.bv_len != 0 ) {
|
||||
Entry *matched = NULL;
|
||||
struct berval pbv;
|
||||
|
||||
pbv.bv_val = pdn;
|
||||
pbv.bv_len = e->e_nname.bv_len - (pdn - e->e_nname.bv_val);
|
||||
|
||||
/* get parent */
|
||||
rc = bdb_dn2entry( be, ltid, &pbv, &p, &matched, 0 );
|
||||
rc = bdb_dn2entry( be, ltid, &pdn, &p, &matched, 0 );
|
||||
|
||||
switch( rc ) {
|
||||
case 0:
|
||||
|
|
@ -214,7 +214,7 @@ retry: rc = txn_abort( ltid );
|
|||
|
||||
} else {
|
||||
Debug( LDAP_DEBUG_TRACE, "bdb_add: %s denied\n",
|
||||
pdn == NULL ? "suffix" : "entry at root",
|
||||
pdn.bv_len == 0 ? "suffix" : "entry at root",
|
||||
0, 0 );
|
||||
rc = LDAP_INSUFFICIENT_ACCESS;
|
||||
goto return_results;
|
||||
|
|
@ -223,7 +223,7 @@ retry: rc = txn_abort( ltid );
|
|||
}
|
||||
|
||||
/* dn2id index */
|
||||
rc = bdb_dn2id_add( be, ltid, pdn, e );
|
||||
rc = bdb_dn2id_add( be, ltid, &pdn, e );
|
||||
if ( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "bdb_add: dn2id_add failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ int
|
|||
bdb_dn2id_add(
|
||||
BackendDB *be,
|
||||
DB_TXN *txn,
|
||||
char *pdn,
|
||||
struct berval *pbv,
|
||||
Entry *e )
|
||||
{
|
||||
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
||||
DB *db = bdb->bi_dn2id->bdi_db;
|
||||
int rc;
|
||||
DBT key, data;
|
||||
char *buf, *ptr;
|
||||
char *buf, *ptr, *pdn;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_add( \"%s\", 0x%08lx )\n",
|
||||
e->e_ndn, (long) e->e_id, 0 );
|
||||
|
|
@ -636,7 +636,7 @@ int
|
|||
bdb_dn2id_add(
|
||||
BackendDB *be,
|
||||
DB_TXN *txn,
|
||||
char *pdn,
|
||||
struct berval *pdn,
|
||||
Entry *e )
|
||||
{
|
||||
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
||||
|
|
|
|||
|
|
@ -163,7 +163,10 @@ retry: /* transaction retry */
|
|||
}
|
||||
|
||||
p_ndn.bv_val = dn_parent( be, e->e_ndn );
|
||||
p_ndn.bv_len = e->e_nname.bv_len - (p_ndn.bv_val - e->e_ndn);
|
||||
if (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;
|
||||
np_ndn = &p_ndn;
|
||||
if ( p_ndn.bv_len != 0 ) {
|
||||
/* Make sure parent entry exist and we can write its
|
||||
|
|
@ -207,7 +210,10 @@ retry: /* transaction retry */
|
|||
p_ndn.bv_val, 0, 0 );
|
||||
|
||||
p_dn.bv_val = dn_parent( be, e->e_dn );
|
||||
p_dn.bv_len = e->e_name.bv_len - (p_dn.bv_val - e->e_dn);
|
||||
if (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;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_modrdn: parent dn=%s\n",
|
||||
|
|
@ -572,7 +578,7 @@ retry: /* transaction retry */
|
|||
e->e_nname = *new_ndn;
|
||||
|
||||
/* add new one */
|
||||
rc = bdb_dn2id_add( be, ltid, np_ndn->bv_val, e );
|
||||
rc = bdb_dn2id_add( be, ltid, np_ndn, e );
|
||||
if ( rc != 0 ) {
|
||||
switch( rc ) {
|
||||
case DB_LOCK_DEADLOCK:
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ int bdb_dn2id_matched(
|
|||
int bdb_dn2id_add(
|
||||
BackendDB *be,
|
||||
DB_TXN *tid,
|
||||
char *pdn,
|
||||
struct berval *pdn,
|
||||
Entry *e );
|
||||
|
||||
int bdb_dn2id_delete(
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ ID bdb_tool_entry_put(
|
|||
int rc;
|
||||
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
|
||||
DB_TXN *tid = NULL;
|
||||
char *pdn;
|
||||
struct berval pdn;
|
||||
|
||||
assert( be != NULL );
|
||||
assert( slapMode & SLAP_TOOL_MODE );
|
||||
|
|
@ -145,8 +145,12 @@ ID bdb_tool_entry_put(
|
|||
}
|
||||
|
||||
/* add dn2id indices */
|
||||
pdn = dn_parent( be, e->e_ndn );
|
||||
rc = bdb_dn2id_add( be, tid, pdn, e );
|
||||
pdn.bv_val = dn_parent( be, e->e_ndn );
|
||||
if (pdn.bv_val)
|
||||
pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_ndn);
|
||||
else
|
||||
pdn.bv_len = 0;
|
||||
rc = bdb_dn2id_add( be, tid, &pdn, e );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: dn2id_add failed: %s (%d)\n",
|
||||
|
|
@ -202,7 +206,7 @@ int bdb_tool_entry_reindex(
|
|||
int rc;
|
||||
Entry *e;
|
||||
DB_TXN *tid = NULL;
|
||||
char *pdn;
|
||||
struct berval pdn;
|
||||
|
||||
Debug( LDAP_DEBUG_ARGS, "=> bdb_tool_entry_reindex( %ld )\n",
|
||||
(long) id, 0, 0 );
|
||||
|
|
@ -237,8 +241,12 @@ int bdb_tool_entry_reindex(
|
|||
(long) id, e->e_dn, 0 );
|
||||
|
||||
/* add dn2id indices */
|
||||
pdn = dn_parent( be, e->e_ndn );
|
||||
rc = bdb_dn2id_add( be, tid, pdn, e );
|
||||
pdn.bv_val = dn_parent( be, e->e_ndn );
|
||||
if (pdn.bv_val)
|
||||
pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_ndn);
|
||||
else
|
||||
pdn.bv_len = 0;
|
||||
rc = bdb_dn2id_add( be, tid, &pdn, e );
|
||||
if( rc != 0 && rc != DB_KEYEXIST ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: dn2id_add failed: %s (%d)\n",
|
||||
|
|
|
|||
|
|
@ -153,7 +153,10 @@ ldbm_back_modrdn(
|
|||
}
|
||||
|
||||
p_ndn.bv_val = dn_parent( be, e->e_ndn );
|
||||
p_ndn.bv_len = e->e_nname.bv_len - (p_ndn.bv_val - e->e_ndn);
|
||||
if ( 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;
|
||||
|
||||
if ( p_ndn.bv_len != 0 ) {
|
||||
/* Make sure parent entry exist and we can write its
|
||||
|
|
@ -203,7 +206,10 @@ ldbm_back_modrdn(
|
|||
#endif
|
||||
|
||||
p_dn.bv_val = dn_parent( be, e->e_dn );
|
||||
p_dn.bv_len = e->e_name.bv_len - (p_dn.bv_val - e->e_dn);
|
||||
if ( 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;
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue