backsql_bind( Operation *op, SlapReply *rs )
{
SQLHDBC dbh = SQL_NULL_HDBC;
- AttributeDescription *password = slap_schema.si_ad_userPassword;
- Entry *e, user_entry;
+ Entry *e = NULL,
+ user_entry = { 0 };
Attribute *a;
backsql_srch_info bsi;
AttributeName anlist[2];
return 1;
}
- anlist[0].an_name = password->ad_cname;
- anlist[0].an_desc = password;
+ anlist[0].an_name = slap_schema.si_ad_userPassword->ad_cname;
+ anlist[0].an_desc = slap_schema.si_ad_userPassword;
anlist[1].an_name.bv_val = NULL;
rc = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE,
}
e = &user_entry;
- a = attr_find( e->e_attrs, password );
+ a = attr_find( e->e_attrs, slap_schema.si_ad_userPassword );
if ( a == NULL ) {
rs->sr_err = LDAP_INVALID_CREDENTIALS;
goto error_return;
(void)backsql_free_entryID( &bsi.bsi_base_id, 0 );
}
+ if ( e ) {
+ entry_clean( e );
+ }
+
if ( rs->sr_err ) {
send_ldap_result( op, rs );
return 1;
}
Debug(LDAP_DEBUG_TRACE,"<==backsql_bind()\n",0,0,0);
+
return 0;
}
}
Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
"use_subtree_shortcut=%s\n",
- BACKSQL_USE_SUBTREE_SHORTCUT( bi ) ? "yes" : "no", 0, 0 );
+ BACKSQL_USE_SUBTREE_SHORTCUT( bi ) ? "yes" : "no",
+ 0, 0 );
} else {
return SLAP_CONF_UNKNOWN;
fp = fopen( fname, "r" );
if ( fp == NULL ) {
Debug( LDAP_DEBUG_ANY,
- "could not open back-sql baseObject attr file \"%s\" - absolute path?\n",
+ "could not open back-sql baseObject "
+ "attr file \"%s\" - absolute path?\n",
fname, 0, 0 );
perror( fname );
return LDAP_OTHER;
Attribute *a;
if( e == NULL ) {
- fprintf( stderr, "back-sql baseObject: could not parse entry (line=%d)\n",
- lineno );
+ fprintf( stderr, "back-sql baseObject: "
+ "could not parse entry (line=%d)\n",
+ lineno );
rc = LDAP_OTHER;
break;
}
/* make sure the DN is the database's suffix */
if ( !be_issuffix( be, &e->e_nname ) ) {
fprintf( stderr,
- "back-sql: invalid baseObject - dn=\"%s\" (line=%d)\n",
- e->e_dn, lineno );
+ "back-sql: invalid baseObject - "
+ "dn=\"%s\" (line=%d)\n",
+ e->e_name.bv_val, lineno );
entry_free( e );
rc = EXIT_FAILURE;
break;
* entry, and add each attribute type and description to baseObject
*/
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
- if ( attr_merge( bi->sql_baseObject, a->a_desc, a->a_vals,
- ( a->a_nvals == a->a_vals ) ? NULL : a->a_nvals ) )
+ if ( attr_merge( bi->sql_baseObject, a->a_desc,
+ a->a_vals,
+ ( a->a_nvals == a->a_vals ) ?
+ NULL : a->a_nvals ) )
{
rc = LDAP_OTHER;
break;
fclose( fp );
- Debug( LDAP_DEBUG_CONFIG, "back-sql baseObject file \"%s\" read.\n", fname, 0, 0 );
+ Debug( LDAP_DEBUG_CONFIG, "back-sql baseObject file \"%s\" read.\n",
+ fname, 0, 0 );
return rc;
}
"dn: %s\n"
"objectClass: extensibleObject\n"
"description: builtin baseObject for back-sql\n"
- "description: all entries mapped in the \"ldap_entries\" table\n"
- "description: must have \"" BACKSQL_BASEOBJECT_IDSTR "\" "
- "in the \"parent\" column",
+ "description: all entries mapped "
+ "in the \"ldap_entries\" table\n"
+ "description: must have "
+ "\"" BACKSQL_BASEOBJECT_IDSTR "\" "
+ "in the \"parent\" column",
be->be_suffix[0].bv_val );
bi->sql_baseObject = str2entry( buf );
return 0;
}
- rc = ldap_bv2rdn( &be->be_suffix[ 0 ], &rdn, (char **) &p, LDAP_DN_FORMAT_LDAP );
+ rc = ldap_bv2rdn( &be->be_suffix[ 0 ], &rdn, (char **)&p,
+ LDAP_DN_FORMAT_LDAP );
if ( rc != LDAP_SUCCESS ) {
snprintf( buf, sizeof(buf),
- "unable to extract RDN from baseObject DN \"%s\" (%d: %s)",
- be->be_suffix[ 0 ].bv_val, rc, ldap_err2string( rc ) );
+ "unable to extract RDN "
+ "from baseObject DN \"%s\" (%d: %s)",
+ be->be_suffix[ 0 ].bv_val,
+ rc, ldap_err2string( rc ) );
Debug( LDAP_DEBUG_TRACE,
"<==backsql_db_config (%s line %d): %s\n",
fname, lineno, buf );
if ( rc != LDAP_SUCCESS ) {
snprintf( buf, sizeof(buf),
- "prettying of attribute #%d from baseObject "
+ "prettying of attribute #%d "
+ "from baseObject "
"DN \"%s\" failed: %d: %s",
iAVA, be->be_suffix[ 0 ].bv_val,
rc, ldap_err2string( rc ) );
Debug( LDAP_DEBUG_TRACE,
- "<==backsql_db_config (%s line %d): %s\n",
+ "<==backsql_db_config (%s line %d): "
+ "%s\n",
fname, lineno, buf );
return 1;
}
backsql_info *bi = (backsql_info *)bsi->bsi_op->o_bd->be_private;
int i;
int rc;
- AttributeDescription *ad_oc = slap_schema.si_ad_objectClass;
Debug( LDAP_DEBUG_TRACE, "==>backsql_id2entry()\n", 0, 0, 0 );
goto done;
}
- ber_dupbv_x( &bsi->bsi_e->e_name, &eid->eid_dn, bsi->bsi_op->o_tmpmemctx );
- ber_dupbv_x( &bsi->bsi_e->e_nname, &eid->eid_ndn, bsi->bsi_op->o_tmpmemctx );
+ ber_dupbv( &bsi->bsi_e->e_name, &eid->eid_dn );
+ ber_dupbv( &bsi->bsi_e->e_nname, &eid->eid_ndn );
bsi->bsi_e->e_attrs = NULL;
bsi->bsi_e->e_private = NULL;
bsi->bsi_e->e_id = eid->eid_id;
#endif /* ! BACKSQL_ARBITRARY_KEY */
- rc = attr_merge_normalize_one( bsi->bsi_e, ad_oc,
- &bsi->bsi_oc->bom_oc->soc_cname,
- bsi->bsi_op->o_tmpmemctx );
+ rc = attr_merge_normalize_one( bsi->bsi_e,
+ slap_schema.si_ad_objectClass,
+ &bsi->bsi_oc->bom_oc->soc_cname,
+ bsi->bsi_op->o_tmpmemctx );
if ( rc != LDAP_SUCCESS ) {
entry_clean( bsi->bsi_e );
return rc;
snprintf( uuidbuf, sizeof( uuidbuf ),
"%08x-%04x-%04x-0000-000000000000",
( id->eid_oc_id & 0xFFFFFFFF ),
- ( ( id->eid_keyval & 0xFFFF0000 ) >> 16 ),
+ ( ( id->eid_keyval & 0xFFFF0000 ) >> 020 /* 16 */ ),
( id->eid_keyval & 0xFFFF ) );
#endif /* ! BACKSQL_ARBITRARY_KEY */
{
fprintf( stderr, "==> backsql_entryUUID_decode()\n" );
- *oc_id = ( entryUUID->bv_val[0] << 3 )
- + ( entryUUID->bv_val[1] << 2 )
- + ( entryUUID->bv_val[2] << 1 )
+ *oc_id = ( entryUUID->bv_val[0] << 030 /* 24 */ )
+ + ( entryUUID->bv_val[1] << 020 /* 16 */ )
+ + ( entryUUID->bv_val[2] << 010 /* 8 */ )
+ entryUUID->bv_val[3];
#ifdef BACKSQL_ARBITRARY_KEY
+ /* FIXME */
#else /* ! BACKSQL_ARBITRARY_KEY */
- *keyval = ( entryUUID->bv_val[4] << 3 )
- + ( entryUUID->bv_val[5] << 2 )
- + ( entryUUID->bv_val[6] << 1 )
+ *keyval = ( entryUUID->bv_val[4] << 030 /* 24 */ )
+ + ( entryUUID->bv_val[5] << 020 /* 16 */ )
+ + ( entryUUID->bv_val[6] << 010 /* 8 */ )
+ entryUUID->bv_val[7];
#endif /* ! BACKSQL_ARBITRARY_KEY */