version 1.88.2.13, 2004/04/13 22:35:20
|
version 1.88.2.22, 2005/01/20 17:01:09
|
Line 1
|
Line 1
|
/* $OpenLDAP: pkg/ldap/servers/slapd/saslauthz.c,v 1.88.2.12 2004/04/12 18:20:12 kurt Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/saslauthz.c,v 1.88.2.21 2004/12/03 07:21:05 ando Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 1998-2004 The OpenLDAP Foundation. |
* Copyright 1998-2005 The OpenLDAP Foundation. |
* Portions Copyright 2000 Mark Adamson, Carnegie Mellon. |
* Portions Copyright 2000 Mark Adamson, Carnegie Mellon. |
* All rights reserved. |
* All rights reserved. |
* |
* |
Line 211 static int slap_parseURI( Operation *op,
|
Line 211 static int slap_parseURI( Operation *op,
|
bv.bv_val++; |
bv.bv_val++; |
|
|
if ( !strncasecmp( bv.bv_val, "exact:", sizeof( "exact:" ) - 1 ) ) { |
if ( !strncasecmp( bv.bv_val, "exact:", sizeof( "exact:" ) - 1 ) ) { |
bv.bv_val += sizeof( "exact" ) - 1; |
bv.bv_val += sizeof( "exact:" ) - 1; |
*scope = LDAP_X_SCOPE_EXACT; |
*scope = LDAP_X_SCOPE_EXACT; |
|
|
} else if ( !strncasecmp( bv.bv_val, "regex:", sizeof( "regex:" ) - 1 ) ) { |
} else if ( !strncasecmp( bv.bv_val, "regex:", sizeof( "regex:" ) - 1 ) ) { |
bv.bv_val += sizeof( "regex" ) - 1; |
bv.bv_val += sizeof( "regex:" ) - 1; |
*scope = LDAP_X_SCOPE_REGEX; |
*scope = LDAP_X_SCOPE_REGEX; |
|
|
} else if ( !strncasecmp( bv.bv_val, "children:", sizeof( "chldren:" ) - 1 ) ) { |
} else if ( !strncasecmp( bv.bv_val, "children:", sizeof( "chldren:" ) - 1 ) ) { |
bv.bv_val += sizeof( "children" ) - 1; |
bv.bv_val += sizeof( "children:" ) - 1; |
*scope = LDAP_X_SCOPE_CHILDREN; |
*scope = LDAP_X_SCOPE_CHILDREN; |
|
|
} else if ( !strncasecmp( bv.bv_val, "subtree:", sizeof( "subtree:" ) - 1 ) ) { |
} else if ( !strncasecmp( bv.bv_val, "subtree:", sizeof( "subtree:" ) - 1 ) ) { |
bv.bv_val += sizeof( "subtree" ) - 1; |
bv.bv_val += sizeof( "subtree:" ) - 1; |
*scope = LDAP_X_SCOPE_SUBTREE; |
*scope = LDAP_X_SCOPE_SUBTREE; |
|
|
} else if ( !strncasecmp( bv.bv_val, "onelevel:", sizeof( "onelevel:" ) - 1 ) ) { |
} else if ( !strncasecmp( bv.bv_val, "onelevel:", sizeof( "onelevel:" ) - 1 ) ) { |
bv.bv_val += sizeof( "onelevel" ) - 1; |
bv.bv_val += sizeof( "onelevel:" ) - 1; |
*scope = LDAP_X_SCOPE_ONELEVEL; |
*scope = LDAP_X_SCOPE_ONELEVEL; |
|
|
} else { |
} else { |
return LDAP_PROTOCOL_ERROR; |
return LDAP_PROTOCOL_ERROR; |
} |
} |
|
} else { |
|
if ( bv.bv_val[ 0 ] != ':' ) { |
|
return LDAP_PROTOCOL_ERROR; |
|
} |
|
*scope = LDAP_X_SCOPE_EXACT; |
|
bv.bv_val++; |
} |
} |
|
|
if ( bv.bv_val[ 0 ] != ':' ) { |
|
return LDAP_PROTOCOL_ERROR; |
|
} |
|
bv.bv_val++; |
|
|
|
bv.bv_val += strspn( bv.bv_val, " " ); |
bv.bv_val += strspn( bv.bv_val, " " ); |
/* jump here in case no type specification was present |
/* jump here in case no type specification was present |
* and uir was not an URI... HEADS-UP: assuming EXACT */ |
* and uir was not an URI... HEADS-UP: assuming EXACT */ |
Line 311 is_dn: bv.bv_len = uri->bv_len - (bv.bv
|
Line 312 is_dn: bv.bv_len = uri->bv_len - (bv.bv
|
} |
} |
|
|
rc = ldap_url_parse( uri->bv_val, &ludp ); |
rc = ldap_url_parse( uri->bv_val, &ludp ); |
if ( rc == LDAP_URL_ERR_BADSCHEME ) { |
switch ( rc ) { |
|
case LDAP_URL_SUCCESS: |
|
#if 0 /* leave this for later releases */ |
|
if ( strcasecmp( ludp->lud_scheme, "ldap" ) != 0 ) { |
|
/* |
|
* must be ldap:/// |
|
*/ |
|
return LDAP_PROTOCOL_ERROR; |
|
} |
|
#endif |
|
break; |
|
|
|
case LDAP_URL_ERR_BADSCHEME: |
/* last chance: assume it's a(n exact) DN ... */ |
/* last chance: assume it's a(n exact) DN ... */ |
bv.bv_val = uri->bv_val; |
bv.bv_val = uri->bv_val; |
*scope = LDAP_X_SCOPE_EXACT; |
*scope = LDAP_X_SCOPE_EXACT; |
goto is_dn; |
goto is_dn; |
} |
|
|
|
if ( rc != LDAP_URL_SUCCESS ) { |
default: |
return LDAP_PROTOCOL_ERROR; |
return LDAP_PROTOCOL_ERROR; |
} |
} |
|
|
if (( ludp->lud_host && *ludp->lud_host ) |
if ( ( ludp->lud_host && *ludp->lud_host ) |
|| ludp->lud_attrs || ludp->lud_exts ) |
|| ludp->lud_attrs || ludp->lud_exts ) |
{ |
{ |
/* host part must be empty */ |
/* host part must be empty */ |
Line 632 int slap_sasl_match( Operation *opx, str
|
Line 644 int slap_sasl_match( Operation *opx, str
|
&op.ors_filterstr ); |
&op.ors_filterstr ); |
if( rc != LDAP_SUCCESS ) goto CONCLUDED; |
if( rc != LDAP_SUCCESS ) goto CONCLUDED; |
|
|
/* Massive shortcut: search scope == base */ |
|
switch ( op.oq_search.rs_scope ) { |
switch ( op.oq_search.rs_scope ) { |
case LDAP_SCOPE_BASE: |
|
case LDAP_X_SCOPE_EXACT: |
case LDAP_X_SCOPE_EXACT: |
exact_match: |
exact_match: |
if ( dn_match( &op.o_req_ndn, assertDN ) ) { |
if ( dn_match( &op.o_req_ndn, assertDN ) ) { |
Line 750 exact_match:
|
Line 760 exact_match:
|
#endif |
#endif |
op.o_conn = opx->o_conn; |
op.o_conn = opx->o_conn; |
op.o_connid = opx->o_connid; |
op.o_connid = opx->o_connid; |
op.o_req_dn = op.o_req_ndn; |
/* use req_ndn as req_dn instead of non-pretty base of uri */ |
|
if( !BER_BVISNULL( &op.o_req_dn ) ) ch_free( op.o_req_dn.bv_val ); |
|
ber_dupbv_x( &op.o_req_dn, &op.o_req_ndn, op.o_tmpmemctx ); |
op.oq_search.rs_slimit = 1; |
op.oq_search.rs_slimit = 1; |
op.oq_search.rs_tlimit = -1; |
op.oq_search.rs_tlimit = SLAP_NO_LIMIT; |
|
op.o_sync_slog_size = -1; |
|
|
op.o_bd->be_search( &op, &rs ); |
op.o_bd->be_search( &op, &rs ); |
|
|
Line 763 exact_match:
|
Line 776 exact_match:
|
} |
} |
|
|
CONCLUDED: |
CONCLUDED: |
if( op.o_req_dn.bv_len ) ch_free( op.o_req_dn.bv_val ); |
if( !BER_BVISNULL( &op.o_req_dn ) ) sl_free( op.o_req_dn.bv_val, opx->o_tmpmemctx ); |
if( op.o_req_ndn.bv_len ) sl_free( op.o_req_ndn.bv_val, opx->o_tmpmemctx ); |
if( !BER_BVISNULL( &op.o_req_ndn ) ) sl_free( op.o_req_ndn.bv_val, opx->o_tmpmemctx ); |
if( op.oq_search.rs_filter ) filter_free_x( opx, op.oq_search.rs_filter ); |
if( op.oq_search.rs_filter ) filter_free_x( opx, op.oq_search.rs_filter ); |
if( op.ors_filterstr.bv_len ) ch_free( op.ors_filterstr.bv_val ); |
if( op.ors_filterstr.bv_val ) ch_free( op.ors_filterstr.bv_val ); |
|
|
#ifdef NEW_LOGGING |
#ifdef NEW_LOGGING |
LDAP_LOG( TRANSPORT, ENTRY, |
LDAP_LOG( TRANSPORT, ENTRY, |
Line 808 slap_sasl_check_authz( Operation *op,
|
Line 821 slap_sasl_check_authz( Operation *op,
|
assertDN->bv_val, ad->ad_cname.bv_val, searchDN->bv_val); |
assertDN->bv_val, ad->ad_cname.bv_val, searchDN->bv_val); |
#endif |
#endif |
|
|
rc = backend_attribute( op, NULL, |
rc = backend_attribute( op, NULL, searchDN, ad, &vals, ACL_AUTH ); |
searchDN, ad, &vals ); |
|
if( rc != LDAP_SUCCESS ) goto COMPLETE; |
if( rc != LDAP_SUCCESS ) goto COMPLETE; |
|
|
/* Check if the *assertDN matches any **vals */ |
/* Check if the *assertDN matches any **vals */ |
Line 884 void slap_sasl2dn( Operation *opx,
|
Line 896 void slap_sasl2dn( Operation *opx,
|
/* Must do an internal search */ |
/* Must do an internal search */ |
op.o_bd = select_backend( &op.o_req_ndn, 0, 1 ); |
op.o_bd = select_backend( &op.o_req_ndn, 0, 1 ); |
|
|
/* Massive shortcut: search scope == base */ |
|
switch ( op.oq_search.rs_scope ) { |
switch ( op.oq_search.rs_scope ) { |
case LDAP_SCOPE_BASE: |
|
case LDAP_X_SCOPE_EXACT: |
case LDAP_X_SCOPE_EXACT: |
*sasldn = op.o_req_ndn; |
*sasldn = op.o_req_ndn; |
op.o_req_ndn.bv_len = 0; |
op.o_req_ndn.bv_len = 0; |
Line 900 void slap_sasl2dn( Operation *opx,
|
Line 910 void slap_sasl2dn( Operation *opx,
|
/* correctly parsed, but illegal */ |
/* correctly parsed, but illegal */ |
goto FINISHED; |
goto FINISHED; |
|
|
|
case LDAP_SCOPE_BASE: |
case LDAP_SCOPE_ONELEVEL: |
case LDAP_SCOPE_ONELEVEL: |
case LDAP_SCOPE_SUBTREE: |
case LDAP_SCOPE_SUBTREE: |
#ifdef LDAP_SCOPE_SUBORDINATE |
#ifdef LDAP_SCOPE_SUBORDINATE |
Line 923 void slap_sasl2dn( Operation *opx,
|
Line 934 void slap_sasl2dn( Operation *opx,
|
op.o_req_ndn.bv_val, op.oq_search.rs_scope, 0 ); |
op.o_req_ndn.bv_val, op.oq_search.rs_scope, 0 ); |
#endif |
#endif |
|
|
if(( op.o_bd == NULL ) || ( op.o_bd->be_search == NULL)) { |
if ( ( op.o_bd == NULL ) || ( op.o_bd->be_search == NULL) ) { |
|
goto FINISHED; |
|
} |
|
|
|
/* Must run an internal search. */ |
|
if ( op.ors_filter == NULL ) { |
|
rc = LDAP_FILTER_ERROR; |
goto FINISHED; |
goto FINISHED; |
} |
} |
|
|
Line 944 void slap_sasl2dn( Operation *opx,
|
Line 961 void slap_sasl2dn( Operation *opx,
|
#endif |
#endif |
op.oq_search.rs_deref = LDAP_DEREF_NEVER; |
op.oq_search.rs_deref = LDAP_DEREF_NEVER; |
op.oq_search.rs_slimit = 1; |
op.oq_search.rs_slimit = 1; |
op.oq_search.rs_tlimit = -1; |
op.oq_search.rs_tlimit = SLAP_NO_LIMIT; |
op.oq_search.rs_attrsonly = 1; |
op.oq_search.rs_attrsonly = 1; |
op.o_req_dn = op.o_req_ndn; |
/* use req_ndn as req_dn instead of non-pretty base of uri */ |
|
if( !BER_BVISNULL( &op.o_req_dn ) ) ch_free( op.o_req_dn.bv_val ); |
|
ber_dupbv_x( &op.o_req_dn, &op.o_req_ndn, op.o_tmpmemctx ); |
|
|
op.o_bd->be_search( &op, &rs ); |
op.o_bd->be_search( &op, &rs ); |
|
|
Line 954 FINISHED:
|
Line 973 FINISHED:
|
if( sasldn->bv_len ) { |
if( sasldn->bv_len ) { |
opx->o_conn->c_authz_backend = op.o_bd; |
opx->o_conn->c_authz_backend = op.o_bd; |
} |
} |
if( op.o_req_dn.bv_len ) ch_free( op.o_req_dn.bv_val ); |
if( !BER_BVISNULL( &op.o_req_dn ) ) sl_free( op.o_req_dn.bv_val, opx->o_tmpmemctx ); |
if( op.o_req_ndn.bv_len ) sl_free( op.o_req_ndn.bv_val, opx->o_tmpmemctx ); |
if( !BER_BVISNULL( &op.o_req_ndn ) ) sl_free( op.o_req_ndn.bv_val, opx->o_tmpmemctx ); |
if( op.oq_search.rs_filter ) filter_free_x( opx, op.oq_search.rs_filter ); |
if( op.oq_search.rs_filter ) filter_free_x( opx, op.oq_search.rs_filter ); |
if( op.ors_filterstr.bv_len ) ch_free( op.ors_filterstr.bv_val ); |
if( op.ors_filterstr.bv_len ) ch_free( op.ors_filterstr.bv_val ); |
|
|