Lines Matching defs:lc

69 ldap_back_conn_print( ldapconn_t *lc )
75 ldap_back_conn2str( &lc->lc_base, buf, sizeof( buf ) );
77 if ( lc->lc_lcflags & flagsmap[i].f ) {
86 fprintf( stderr, "lc=%p %s flags=0x%08x (%s)\n",
87 (void *)lc, buf, lc->lc_lcflags, fbuf );
110 ldapconn_t *lc;
114 LDAP_TAILQ_FOREACH( lc, &li->li_conn_priv[ c ].lic_priv, lc_q )
117 ldap_back_conn_print( lc );
138 ldap_back_freeconn( ldapinfo_t *li, ldapconn_t *lc, int dolock );
149 ldap_back_proxy_authz_bind( ldapconn_t *lc, Operation *op, SlapReply *rs,
153 ldap_back_prepare_conn( ldapconn_t *lc, Operation *op, SlapReply *rs,
163 ldap_back_schedule_conn_expiry( ldapinfo_t *li, ldapconn_t *lc );
166 ldap_back_conn_delete( ldapinfo_t *li, ldapconn_t *lc )
168 if ( LDAP_BACK_PCONN_ISPRIV( lc ) ) {
169 if ( LDAP_BACK_CONN_CACHED( lc ) ) {
170 assert( lc->lc_q.tqe_prev != NULL );
171 assert( li->li_conn_priv[ LDAP_BACK_CONN2PRIV( lc ) ].lic_num > 0 );
172 li->li_conn_priv[ LDAP_BACK_CONN2PRIV( lc ) ].lic_num--;
173 LDAP_TAILQ_REMOVE( &li->li_conn_priv[ LDAP_BACK_CONN2PRIV( lc ) ].lic_priv, lc, lc_q );
174 LDAP_TAILQ_ENTRY_INIT( lc, lc_q );
175 LDAP_BACK_CONN_CACHED_CLEAR( lc );
178 assert( LDAP_BACK_CONN_TAINTED( lc ) );
179 assert( lc->lc_q.tqe_prev == NULL );
185 if ( LDAP_BACK_CONN_CACHED( lc ) ) {
186 assert( !LDAP_BACK_CONN_TAINTED( lc ) );
187 tmplc = ldap_tavl_delete( &li->li_conninfo.lai_tree, (caddr_t)lc,
189 assert( tmplc == lc );
190 LDAP_BACK_CONN_CACHED_CLEAR( lc );
193 assert( LDAP_BACK_CONN_TAINTED( lc ) || tmplc == lc );
196 return lc;
203 ldapconn_t *lc;
222 lc = ldap_back_getconn( op, rs, LDAP_BACK_BIND_SERR, NULL, NULL );
223 if ( !lc ) {
229 if ( !BER_BVISNULL( &lc->lc_bound_ndn ) ) {
230 ch_free( lc->lc_bound_ndn.bv_val );
231 BER_BVZERO( &lc->lc_bound_ndn );
233 if ( !BER_BVISNULL( &lc->lc_cred ) ) {
234 memset( lc->lc_cred.bv_val, 0, lc->lc_cred.bv_len );
235 ch_free( lc->lc_cred.bv_val );
236 BER_BVZERO( &lc->lc_cred );
238 LDAP_BACK_CONN_ISBOUND_CLEAR( lc );
247 rc = ldap_back_controls_add( op, rs, lc, &ctrls );
252 ldap_back_release_conn( li, lc );
258 rs->sr_err = ldap_sasl_bind( lc->lc_ld, op->o_req_dn.bv_val,
263 rc = ldap_back_op_result( lc, op, rs, msgid,
268 if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_BIND_SERR ) ) {
271 if ( !lc )
292 ldap_back_release_conn( li, lc );
298 LDAP_BACK_CONN_ISBOUND_SET( lc );
299 ber_dupbv( &lc->lc_bound_ndn, &op->o_req_ndn );
301 if ( !BER_BVISNULL( &lc->lc_cred ) ) {
302 memset( lc->lc_cred.bv_val, 0,
303 lc->lc_cred.bv_len );
307 ber_bvreplace( &lc->lc_cred, &op->orb_cred );
308 ldap_set_rebind_proc( lc->lc_ld, li->li_rebind_f, lc );
311 lc->lc_cred.bv_len = 0;
316 if ( !LDAP_BACK_CONN_ISBOUND( lc )
317 || ( !dn_match( &op->o_req_ndn, &lc->lc_local_ndn )
318 && !LDAP_BACK_PCONN_ISPRIV( lc ) ) )
326 if ( lc->lc_refcnt > 1 ) {
336 assert( lc->lc_refcnt == 1 );
337 ldap_back_conn_delete( li, lc );
341 while ( ( tmplc = ldap_tavl_delete( &li->li_conninfo.lai_tree, (caddr_t)lc, ldap_back_conn_cmp ) ) != NULL )
343 assert( !LDAP_BACK_PCONN_ISPRIV( lc ) );
346 lc->lc_conn->c_connid, lc->lc_refcnt );
364 if ( LDAP_BACK_CONN_ISBOUND( lc ) ) {
365 ber_bvreplace( &lc->lc_local_ndn, &op->o_req_ndn );
367 LDAP_BACK_PCONN_ROOTDN_SET( lc, op );
369 lerr = ldap_tavl_insert( &li->li_conninfo.lai_tree, (caddr_t)lc,
380 LDAP_BACK_CONN_CACHED_SET( lc );
387 ldap_back_conn_free( lc );
388 lc = NULL;
392 if ( lc != NULL ) {
393 ldap_back_release_conn( li, lc );
429 * the local DN and the lc pointer; used by avl stuff for insert, lookup
495 ldap_back_freeconn( ldapinfo_t *li, ldapconn_t *lc, int dolock )
505 (void)ldap_back_conn_delete( li, lc );
507 if ( lc->lc_refcnt == 0 ) {
508 ldap_back_conn_free( (void *)lc );
658 ldap_back_prepare_conn( ldapconn_t *lc, Operation *op, SlapReply *rs, ldap_back_send_t sendok )
717 if ( LDAP_BACK_CONN_ISPRIV( lc ) ) {
725 } else if ( LDAP_BACK_CONN_ISIDASSERT( lc ) ) {
759 lc->lc_ld = ld;
760 lc->lc_refcnt = 1;
763 LDAP_BACK_CONN_ISTLS_SET( lc );
765 LDAP_BACK_CONN_ISTLS_CLEAR( lc );
768 lc->lc_time = lctime;
784 lc->lc_create_time = op->o_time;
800 ldapconn_t *lc = NULL,
908 LDAP_TAILQ_FOREACH( lc,
912 if ( !LDAP_BACK_CONN_BINDING( lc ) && lc->lc_refcnt == 0 ) {
917 if ( lc != NULL ) {
918 if ( lc != LDAP_TAILQ_LAST( &li->li_conn_priv[ LDAP_BACK_CONN2PRIV( lc ) ].lic_priv,
921 LDAP_TAILQ_REMOVE( &li->li_conn_priv[ LDAP_BACK_CONN2PRIV( lc ) ].lic_priv,
922 lc, lc_q );
923 LDAP_TAILQ_ENTRY_INIT( lc, lc_q );
924 LDAP_TAILQ_INSERT_TAIL( &li->li_conn_priv[ LDAP_BACK_CONN2PRIV( lc ) ].lic_priv,
925 lc, lc_q );
931 lc = LDAP_TAILQ_FIRST( &li->li_conn_priv[ LDAP_BACK_CONN2PRIV( &lc_curr ) ].lic_priv );
937 lc = (ldapconn_t *)ldap_tavl_find( li->li_conninfo.lai_tree,
941 if ( lc != NULL ) {
943 if ( LDAP_BACK_CONN_BINDING( lc ) ) {
950 lc = NULL;
953 if ( lc != NULL ) {
957 LDAP_BACK_CONN_BINDING_SET( lc );
960 refcnt = ++lc->lc_refcnt;
967 if ( lc == NULL ) {
968 lc = (ldapconn_t *)ch_calloc( 1, sizeof( ldapconn_t ) );
969 lc->lc_flags = li->li_flags;
970 lc->lc_lcflags = lc_curr.lc_lcflags;
971 lc->lc_ldapinfo = li;
972 if ( ldap_back_prepare_conn( lc, op, rs, sendok ) != LDAP_SUCCESS ) {
973 ch_free( lc );
978 LDAP_BACK_CONN_BINDING_SET( lc );
981 lc->lc_conn = lc_curr.lc_conn;
982 ber_dupbv( &lc->lc_local_ndn, &lc_curr.lc_local_ndn );
999 ber_dupbv( &lc->lc_bound_ndn, &li->li_idassert_authcDN );
1000 ber_dupbv( &lc->lc_cred, &li->li_idassert_passwd );
1003 ber_dupbv( &lc->lc_bound_ndn, &li->li_acl_authcDN );
1004 ber_dupbv( &lc->lc_cred, &li->li_acl_passwd );
1006 LDAP_BACK_CONN_ISPRIV_SET( lc );
1010 ber_dupbv( &lc->lc_bound_ndn, &li->li_idassert_authcDN );
1011 ber_dupbv( &lc->lc_cred, &li->li_idassert_passwd );
1013 LDAP_BACK_CONN_ISIDASSERT_SET( lc );
1016 BER_BVZERO( &lc->lc_cred );
1017 BER_BVZERO( &lc->lc_bound_ndn );
1021 ber_dupbv( &lc->lc_bound_ndn, &op->o_ndn );
1030 if ( LDAP_BACK_PCONN_ISTLS( lc )
1031 && !ldap_tls_inplace( lc->lc_ld ) )
1048 ldap_back_conn_free( lc );
1049 lc = tmplc;
1062 LDAP_BACK_CONN_ISBOUND_CLEAR( lc );
1063 lc->lc_connid = li->li_conn_nextid++;
1065 assert( lc->lc_refcnt == 1 );
1071 if ( LDAP_BACK_PCONN_ISPRIV( lc ) ) {
1072 if ( li->li_conn_priv[ LDAP_BACK_CONN2PRIV( lc ) ].lic_num < li->li_conn_priv_max ) {
1073 LDAP_TAILQ_INSERT_TAIL( &li->li_conn_priv[ LDAP_BACK_CONN2PRIV( lc ) ].lic_priv, lc, lc_q );
1074 li->li_conn_priv[ LDAP_BACK_CONN2PRIV( lc ) ].lic_num++;
1075 LDAP_BACK_CONN_CACHED_SET( lc );
1078 LDAP_BACK_CONN_TAINTED_SET( lc );
1083 rs->sr_err = ldap_tavl_insert( &li->li_conninfo.lai_tree, (caddr_t)lc,
1085 LDAP_BACK_CONN_CACHED_SET( lc );
1095 "=>ldap_back_getconn: %s: lc=%p inserted refcnt=%u rc=%d\n",
1096 op->o_log_prefix, (void *)lc, refcnt,
1099 if ( !LDAP_BACK_PCONN_ISPRIV( lc ) ) {
1106 LDAP_BACK_CONN_CACHED_CLEAR( lc );
1109 ldap_back_conn_free( lc );
1110 lc = NULL;
1115 LDAP_BACK_CONN_TAINTED_SET( lc );
1119 LDAP_BACK_CONN_CACHED_CLEAR( lc );
1120 ldap_back_conn_free( lc );
1129 ldap_back_schedule_conn_expiry( li, lc );
1134 if ( ( li->li_idle_timeout != 0 && op->o_time > lc->lc_time + li->li_idle_timeout )
1135 || ( li->li_conn_ttl != 0 && op->o_time > lc->lc_create_time + li->li_conn_ttl ) )
1147 (void)ldap_back_conn_delete( li, lc );
1148 LDAP_BACK_CONN_TAINTED_SET( lc );
1159 (void *)lc, refcnt, expiring ? " expiring" : "" );
1166 return lc;
1176 ldapconn_t *lc = *lcp;
1181 assert( lc->lc_refcnt > 0 );
1182 LDAP_BACK_CONN_BINDING_CLEAR( lc );
1183 lc->lc_refcnt--;
1184 if ( LDAP_BACK_CONN_TAINTED( lc ) ) {
1185 ldap_back_freeconn( li, lc, 0 );
1293 ldapconn_t *lc;
1311 lc = ldap_back_getconn( op, rs, sendok, &binddn, &bindcred );
1312 if ( lc == NULL ) {
1315 *lcp = lc;
1318 lc = *lcp;
1321 assert( lc != NULL );
1330 rc = isbound = LDAP_BACK_CONN_ISBOUND( lc );
1338 if ( LDAP_BACK_CONN_BINDING( lc ) ) {
1348 LDAP_BACK_CONN_BINDING_SET( lc );
1385 if ( LDAP_BACK_CONN_ISIDASSERT( lc ) ) {
1395 LDAP_BACK_CONN_ISBOUND_CLEAR( lc );
1402 rc = ldap_back_proxy_authz_bind( lc, op, rs, sendok, &binddn, &bindcred );
1407 if ( LDAP_BACK_CONN_ISPRIV( lc )) {
1418 rc = ldap_set_option( lc->lc_ld,
1429 defaults = lutil_sasl_defaults( lc->lc_ld,
1437 LDAP_BACK_CONN_ISBOUND_CLEAR( lc );
1444 rs->sr_err = ldap_sasl_interactive_bind_s( lc->lc_ld,
1458 LDAP_BACK_CONN_ISBOUND_SET( lc );
1465 LDAP_BACK_CONN_TAINTED_SET( lc );
1470 LDAP_BACK_CONN_ISBOUND_CLEAR( lc );
1488 if ( BER_BVISNULL( &lc->lc_cred ) ) {
1490 if ( !BER_BVISNULL( &lc->lc_bound_ndn ) && !BER_BVISEMPTY( &lc->lc_bound_ndn ) ) {
1492 op->o_log_prefix, lc->lc_bound_ndn.bv_val );
1496 tmp_dn = lc->lc_bound_ndn.bv_val;
1498 rs->sr_err = ldap_sasl_bind( lc->lc_ld,
1500 LDAP_SASL_SIMPLE, &lc->lc_cred,
1513 assert( lc->lc_refcnt > 0 );
1514 if ( lc->lc_refcnt == 1 ) {
1515 ldap_unbind_ext( lc->lc_ld, NULL, NULL );
1516 lc->lc_ld = NULL;
1518 /* lc here must be the regular lc, reset and ready for init */
1519 rs->sr_err = ldap_back_prepare_conn( lc, op, rs, sendok );
1522 lc->lc_refcnt = 0;
1538 assert( lc->lc_refcnt == 1 );
1539 lc->lc_refcnt = 0;
1540 ldap_back_freeconn( li, lc, dolock );
1568 rc = ldap_back_op_result( lc, op, rs, msgid,
1571 LDAP_BACK_CONN_ISBOUND_SET( lc );
1575 LDAP_BACK_CONN_BINDING_CLEAR( lc );
1576 rc = LDAP_BACK_CONN_ISBOUND( lc );
1581 ldap_set_rebind_proc( lc->lc_ld, li->li_rebind_f, lc );
1616 ldapconn_t *lc = (ldapconn_t *)params;
1620 assert( lc != NULL );
1623 int is_tls = LDAP_BACK_CONN_ISTLS( lc ),
1627 rc = ldap_back_start_tls( ld, 0, &is_tls, url, lc->lc_flags,
1628 lc->lc_ldapinfo->li_timeout[ SLAP_OP_BIND ], &text );
1640 BER_BVISNULL( &lc->lc_cred ) ? "" : lc->lc_bound_ndn.bv_val,
1641 LDAP_SASL_SIMPLE, &lc->lc_cred, NULL, NULL, NULL );
1687 ldapconn_t *lc,
1697 return ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL );
1701 return ldap_pvt_discard( lc->lc_ld, msgid );
1706 return ldap_cancel_s( lc->lc_ld, msgid, NULL, NULL );
1716 ldapconn_t *lc,
1785 rc = ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, &tv, &res );
1790 ldap_unbind_ext( lc->lc_ld, NULL, NULL );
1791 lc->lc_ld = NULL;
1801 (void)ldap_back_conn_delete( li, lc );
1802 LDAP_BACK_CONN_TAINTED_SET( lc );
1810 (void)ldap_back_cancel( lc, op, rs, msgid, sendok );
1823 ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER,
1835 lc->lc_time = op->o_time;
1838 rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err,
2015 /* lc here must be the regular lc, reset and ready for init */
2210 ldapconn_t *lc,
2278 rs->sr_err = ldap_set_option( lc->lc_ld,
2287 LDAP_BACK_CONN_ISBOUND_CLEAR( lc );
2292 defaults = lutil_sasl_defaults( lc->lc_ld,
2300 LDAP_BACK_CONN_ISBOUND_CLEAR( lc );
2321 rs->sr_err = ldap_sasl_interactive_bind( lc->lc_ld, binddn->bv_val,
2331 if ( ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, NULL, &result ) == -1 || !result ) {
2332 ldap_get_option( lc->lc_ld, LDAP_OPT_RESULT_CODE, (void*)&rs->sr_err );
2333 ldap_get_option( lc->lc_ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, (void*)&rs->sr_text );
2349 rc = ldap_parse_result( lc->lc_ld, result, NULL, NULL, NULL, NULL,
2365 ber_bvreplace( &lc->lc_bound_ndn, &bv );
2374 rc = ldap_whoami_s( lc->lc_ld, &val, NULL, NULL );
2384 ber_bvreplace( &lc->lc_bound_ndn, &bv );
2391 BER_BVISNULL( &lc->lc_bound_ndn ) )
2396 ber_bvreplace( &lc->lc_bound_ndn, &bv );
2399 LDAP_BACK_CONN_ISBOUND_SET( lc );
2406 LDAP_BACK_CONN_TAINTED_SET( lc );
2411 LDAP_BACK_CONN_ISBOUND_CLEAR( lc );
2443 rs->sr_err = ldap_sasl_bind( lc->lc_ld,
2446 rc = ldap_back_op_result( lc, op, rs, msgid,
2456 LDAP_BACK_CONN_ISBOUND_CLEAR( lc );
2468 LDAP_BACK_CONN_ISBOUND_SET( lc );
2470 ber_bvreplace( &lc->lc_bound_ndn, binddn );
2473 if ( !BER_BVISNULL( &lc->lc_cred ) ) {
2474 memset( lc->lc_cred.bv_val, 0,
2475 lc->lc_cred.bv_len );
2480 ber_bvreplace( &lc->lc_cred, bindcred );
2481 ldap_set_rebind_proc( lc->lc_ld, li->li_rebind_f, lc );
2485 lc->lc_cred.bv_len = 0;
2490 return LDAP_BACK_CONN_ISBOUND( lc );
2798 ldapconn_t *lc,
2830 switch ( ldap_back_proxy_authz_ctrl( op, rs, &lc->lc_bound_ndn,
2978 ldap_back_conn2str( const ldapconn_base_t *lc, char *buf, ber_len_t buflen )
2987 len = ldap_back_connid2str( lc, ptr, (ber_len_t)(end - ptr) );
2991 if ( !BER_BVISNULL( &lc->lcb_local_ndn ) ) {
2992 if ( ptr + sizeof(" DN=\"\"") + lc->lcb_local_ndn.bv_len > end ) return -1;
2994 ptr = lutil_strncopy( ptr, lc->lcb_local_ndn.bv_val, lc->lcb_local_ndn.bv_len );
2998 if ( lc->lcb_create_time != 0 ) {
2999 len = snprintf( tbuf, sizeof(tbuf), "%ld", lc->lcb_create_time );
3005 if ( lc->lcb_time != 0 ) {
3006 len = snprintf( tbuf, sizeof(tbuf), "%ld", lc->lcb_time );
3012 len = snprintf( tbuf, sizeof(tbuf), "%u", lc->lcb_refcnt );
3021 ldap_back_connid2str( const ldapconn_base_t *lc, char *buf, ber_len_t buflen )
3035 if ( LDAP_BACK_PCONN_ISPRIV( (const ldapconn_t *)lc ) ) {
3039 cid = (long)lc->lcb_conn;
3052 len = snprintf( buf, buflen, "%lu", lc->lcb_conn->c_connid );
3070 ldap_back_conn_expire_time( ldapinfo_t *li, ldapconn_t *lc) {
3072 return ( lc->lc_create_time + li->li_conn_ttl ) < ( lc->lc_time + li->li_idle_timeout ) ?
3073 ( lc->lc_create_time + li->li_conn_ttl ) : ( lc->lc_time + li->li_idle_timeout );
3075 return lc->lc_create_time + li->li_conn_ttl;
3077 return lc->lc_time + li->li_idle_timeout;
3097 ldapconn_t *lc = LDAP_TAILQ_FIRST( &li->li_conn_priv[ c ].lic_priv );
3099 while ( lc ) {
3100 ldapconn_t *next = LDAP_TAILQ_NEXT( lc, lc_q );
3101 time_t conn_expires = ldap_back_conn_expire_time( li, lc );
3104 if ( lc->lc_refcnt == 0 ) {
3106 "ldap_back_conn_prune: closing expired connection lc=%p\n",
3107 lc );
3108 ldap_back_freeconn( li, lc, 0 );
3111 "ldap_back_conn_prune: tainting expired connection lc=%p\n",
3112 lc );
3113 LDAP_BACK_CONN_TAINTED_SET( lc );
3120 lc = next;
3127 ldapconn_t *lc = (ldapconn_t *)edge->avl_data;
3128 time_t conn_expires = ldap_back_conn_expire_time( li, lc );
3131 if ( lc->lc_refcnt == 0 ) {
3133 "ldap_back_conn_prune: closing expired connection lc=%p\n",
3134 lc );
3135 ldap_back_freeconn( li, lc, 0 );
3138 "ldap_back_conn_prune: tainting expired connection lc=%p\n",
3139 lc );
3140 LDAP_BACK_CONN_TAINTED_SET( lc );
3182 ldap_back_schedule_conn_expiry( ldapinfo_t *li, ldapconn_t *lc ) {
3198 ldap_back_conn_expire_time( li, lc ) - slap_get_time(),