entry_rdwr_init(e);
e->e_dn = dn;
- dn = dn_normalize( ch_strdup( dn ) );
- Debug( LDAP_DEBUG_ARGS, " do_add: dn (%s)\n", dn, 0, 0 );
+ e->e_ndn = dn_normalize( ch_strdup( dn ) );
+ dn = NULL;
+
+ Debug( LDAP_DEBUG_ARGS, " do_add: ndn (%s)\n", e->e_ndn, 0, 0 );
/* get the attrs */
e->e_attrs = NULL;
if ( ber_scanf( ber, "{a{V}}", &type, &vals ) == LBER_ERROR ) {
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
NULL, "decoding error" );
- free( dn );
entry_free( e );
return;
}
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
NULL );
free( type );
- free( dn );
entry_free( e );
return;
}
}
Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d ADD dn=\"%s\"\n",
- conn->c_connid, op->o_opid, dn, 0, 0 );
+ conn->c_connid, op->o_opid, e->e_ndn, 0, 0 );
/*
* We could be serving multiple database backends. Select the
* appropriate one, or send a referral to our "referral server"
* if we don't hold it.
*/
- be = select_backend( dn );
- free( dn );
+ be = select_backend( e->e_ndn );
if ( be == NULL ) {
entry_free( e );
send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
static int
cache_entrydn_cmp( Entry *e1, Entry *e2 )
{
- return( strcasecmp( e1->e_dn, e2->e_dn ) );
+ /* compare their normalized dn's */
+ return( strcasecmp( e1->e_ndn, e2->e_ndn ) );
}
static int
pthread_mutex_lock( &cache->c_mutex );
e.e_dn = dn;
+ e.e_ndn = dn_normalize( ch_strdup( dn ) );
if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
cache_entrydn_cmp )) != NULL )
{
+ free(e.e_ndn);
+
Debug(LDAP_DEBUG_TRACE, "====> cache_find_entry_dn2id: found dn: %s\n",
dn, 0, 0);
return( id );
}
+ free(e.e_ndn);
+
/* free cache mutex */
pthread_mutex_unlock( &cache->c_mutex );
sprintf( buf, "%s@%s", pw->pw_name, be->be_suffix[0] );
e->e_dn = ch_strdup( buf );
+ e->e_ndn = ch_strdup( buf );
val.bv_val = pw->pw_name;
val.bv_len = strlen( pw->pw_name );
Entry *
str2entry( char *s )
{
- int i;
+ int id = 0;
Entry *e;
Attribute **a;
char *type;
Debug( LDAP_DEBUG_TRACE, "=> str2entry\n",
s ? s : "NULL", 0, 0 );
- e = (Entry *) ch_calloc( 1, sizeof(Entry) );
-
/* check to see if there's an id included */
next = s;
if ( isdigit( *s ) ) {
- e->e_id = atoi( s );
+ id = atoi( s );
if ( (s = ldif_getline( &next )) == NULL ) {
Debug( LDAP_DEBUG_TRACE,
"<= str2entry NULL (missing newline after id)\n",
0, 0, 0 );
- free( e );
return( NULL );
}
}
/* initialize reader/writer lock */
+ e = (Entry *) ch_calloc( 1, sizeof(Entry) );
+
+ if( e == NULL ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<= str2entry NULL (entry allocation failed)\n",
+ 0, 0, 0 );
+ return( NULL );
+ }
+ e->e_id = id;
+
entry_rdwr_init(e);
/* dn + attributes */
maxvals = 0;
a = NULL;
}
+
if ( strcasecmp( type, "dn" ) == 0 ) {
if ( e->e_dn != NULL ) {
Debug( LDAP_DEBUG_ANY,
continue;
}
e->e_dn = ch_strdup( value );
+
+ if ( e->e_ndn != NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "str2entry: entry %lu already has a normalized dn \"%s\" for \"%s\" (first ignored)\n",
+ e->e_id, e->e_ndn, value );
+ free( e->e_ndn );
+ }
+ e->e_ndn = dn_normalize( ch_strdup( value ) );
continue;
}
return( NULL );
}
+ if ( e->e_ndn == NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "str2entry: entry %lu (\"%s\") has no normalized dn\n",
+ e->e_id, e->e_dn, 0 );
+ entry_free( e );
+ return( NULL );
+ }
+
Debug(LDAP_DEBUG_TRACE, "<= str2entry 0x%lx\n", (unsigned long)e, 0,0);
return( e );
if ( e->e_dn != NULL ) {
free( e->e_dn );
}
+ if ( e->e_ndn != NULL ) {
+ free( e->e_ndn );
+ }
for ( a = e->e_attrs; a != NULL; a = next ) {
next = a->a_next;
attr_free( a );
entry_rdwr_init(e);
e->e_attrs = NULL;
e->e_dn = ch_strdup( SLAPD_MONITOR_DN );
+ e->e_ndn = NULL;
val.bv_val = Versionstr;
if (( p = strchr( Versionstr, '\n' )) == NULL ) {
*/
typedef struct entry {
char *e_dn; /* DN of this entry */
+ char *e_ndn; /* normalized DN of this entry */
Attribute *e_attrs; /* list of attributes + values */
ID e_id; /* id of this entry - this should */