static slap_response sasl_ap_lookup;
+static struct berval sc_cleartext = BER_BVC("{CLEARTEXT}");
+
static int
sasl_ap_lookup( Operation *op, SlapReply *rs )
{
sl->list[i].name );
}
for ( bv = a->a_vals; bv->bv_val; bv++ ) {
+ /* ITS#3846 don't give hashed passwords to SASL */
+ if ( ad == slap_schema.si_ad_userPassword &&
+ bv->bv_val[0] == '{' ) {
+ rc = lutil_passwd_scheme( bv->bv_val );
+ if ( rc ) {
+ /* If it's not a recognized scheme, just assume it's
+ * a cleartext password that happened to include brackets.
+ *
+ * If it's a recognized scheme, skip this value, unless the
+ * scheme is {CLEARTEXT}. In that case, skip over the
+ * scheme name and use the remainder. If there is nothing
+ * past the scheme name, skip this value.
+ */
+#ifdef SLAPD_CLEARTEXT
+ if ( !strncasecmp( bv->bv_val, sc_cleartext.bv_val,
+ sc_cleartext.bv_len )) {
+ struct berval cbv;
+ cbv.bv_len = bv->bv_len - sc_cleartext.bv_len;
+ if ( cbv.bv_len ) {
+ cbv.bv_val = bv->bv_val + sc_cleartext.bv_len;
+ sl->sparams->utils->prop_set( sl->sparams->propctx,
+ sl->list[i].name, cbv.bv_val, cbv.bv_len );
+ }
+ }
+#endif
+ continue;
+ }
+ }
sl->sparams->utils->prop_set( sl->sparams->propctx,
sl->list[i].name, bv->bv_val, bv->bv_len );
}
for (i=0; pr[i].name; i++) {
mod = (Modifications *)ch_malloc( sizeof(Modifications) );
mod->sml_op = LDAP_MOD_REPLACE;
+ mod->sml_flags = 0;
ber_str2bv( pr[i].name, 0, 0, &mod->sml_type );
mod->sml_values = (struct berval *)ch_malloc( (pr[i].nvalues + 1) *
sizeof(struct berval));
{
Connection *conn = (Connection *)context;
struct propval auxvals[3];
- struct berval authcDN, authzDN=BER_BVNULL;
+ struct berval authcDN, authzDN = BER_BVNULL;
int rc;
/* Simple Binds don't support proxy authorization, ignore it */
return SASL_NOAUTHZ;
}
- conn->c_sasl_authz_dn = authzDN;
+ /* FIXME: we need yet another dup because slap_sasl_getdn()
+ * is using the bind operation slab */
+ if ( conn->c_sasl_bindop ) {
+ ber_dupbv( &conn->c_sasl_authz_dn, &authzDN );
+ slap_sl_free( authzDN.bv_val,
+ conn->c_sasl_bindop->o_tmpmemctx );
+
+ } else {
+ conn->c_sasl_authz_dn = authzDN;
+ }
+
ok:
if (conn->c_sasl_bindop) {
Statslog( LDAP_DEBUG_STATS,
const char **user,
const char **errstr)
{
- struct berval authcDN, authzDN;
+ struct berval authcDN, authzDN = BER_BVNULL;
int rc;
Connection *conn = context;
char *realm;
return SASL_NOAUTHZ;
}
- rc = slap_sasl_authorized(conn->c_sasl_bindop, &authcDN, &authzDN );
+ rc = slap_sasl_authorized( conn->c_sasl_bindop, &authcDN, &authzDN );
if( rc ) {
Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: "
"proxy authorization disallowed (%d)\n",
ch_free( authzDN.bv_val );
return SASL_NOAUTHZ;
}
- conn->c_sasl_authz_dn = authzDN;
+
+ /* FIXME: we need yet another dup because slap_sasl_getdn()
+ * is using the bind operation slab */
+ if ( conn->c_sasl_bindop ) {
+ ber_dupbv( &conn->c_sasl_authz_dn, &authzDN );
+ slap_sl_free( authzDN.bv_val,
+ conn->c_sasl_bindop->o_tmpmemctx );
+
+ } else {
+ conn->c_sasl_authz_dn = authzDN;
+ }
ok:
Debug( LDAP_DEBUG_TRACE, "SASL Authorize [conn=%ld]: "
(long) (conn ? conn->c_connid : -1),
authzDN.bv_val ? authzDN.bv_val : "", 0 );
- if (conn->c_sasl_bindop) {
+ if ( conn->c_sasl_bindop ) {
Statslog( LDAP_DEBUG_STATS,
"conn=%lu op=%lu BIND authcid=\"%s\" authzid=\"%s\"\n",
conn->c_connid, conn->c_sasl_bindop->o_opid,
int rc, is_dn = SET_NONE, do_norm = 1;
struct berval dn2, *mech;
- assert( conn );
- assert( id );
+ assert( conn != NULL );
+ assert( id != NULL );
- Debug( LDAP_DEBUG_ARGS, "slap_sasl_getdn: conn %d id=%s [len=%d]\n",
+ Debug( LDAP_DEBUG_ARGS, "slap_sasl_getdn: conn %lu id=%s [len=%lu]\n",
conn->c_connid,
BER_BVISNULL( id ) ? "NULL" : ( BER_BVISEMPTY( id ) ? "<empty>" : id->bv_val ),
- BER_BVISNULL( id ) ? 0 : ( BER_BVISEMPTY( id ) ? 0 : id->bv_len ) );
+ BER_BVISNULL( id ) ? 0 : ( BER_BVISEMPTY( id ) ? 0 :
+ (unsigned long) id->bv_len ) );
if ( !op ) {
op = conn->c_sasl_bindop;
}
+ assert( op != NULL );
BER_BVZERO( dn );
irdn++;
DN[ irdn ] = NULL;
- rc = ldap_dn2bv_x( DN, dn, LDAP_DN_FORMAT_LDAPV3, op->o_tmpmemctx );
+ rc = ldap_dn2bv_x( DN, dn, LDAP_DN_FORMAT_LDAPV3,
+ op->o_tmpmemctx );
if ( rc != LDAP_SUCCESS ) {
BER_BVZERO( dn );
return rc;
}
- Debug( LDAP_DEBUG_TRACE, "slap_sasl_getdn: u:id converted to %s\n", dn->bv_val,0,0 );
+ Debug( LDAP_DEBUG_TRACE,
+ "slap_sasl_getdn: u:id converted to %s\n",
+ dn->bv_val, 0, 0 );
} else {
if( !BER_BVISNULL( &dn2 ) ) {
slap_sl_free( dn->bv_val, op->o_tmpmemctx );
*dn = dn2;
- Debug( LDAP_DEBUG_TRACE, "getdn: dn:id converted to %s\n",
+ Debug( LDAP_DEBUG_TRACE,
+ "slap_sasl_getdn: dn:id converted to %s\n",
dn->bv_val, 0, 0 );
}