Commit 71457e7b authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Sync with HEAD

parent 749308b6
......@@ -123,9 +123,6 @@ Package=<4>
Project_Dep_Name testavl
End Project Dependency
Begin Project Dependency
Project_Dep_Name ud
End Project Dependency
Begin Project Dependency
Project_Dep_Name slapcat
End Project Dependency
Begin Project Dependency
......@@ -155,6 +152,9 @@ Package=<4>
Begin Project Dependency
Project_Dep_Name ftest
End Project Dependency
Begin Project Dependency
Project_Dep_Name ldapwhoami
End Project Dependency
}}}
###############################################################################
......@@ -354,6 +354,27 @@ Package=<4>
###############################################################################
Project: "ldapwhoami"=..\clients\tools\ldapwhoami.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
}}}
###############################################################################
Project: "libavl"=..\libraries\libavl\libavl.dsp - Package Owner=<4>
Package=<5>
......@@ -777,27 +798,6 @@ Package=<4>
###############################################################################
Project: "ud"=..\clients\ud\ud.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libldap
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblber
End Project Dependency
Begin Project Dependency
Project_Dep_Name liblutil
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
......
......@@ -31,7 +31,7 @@ OpenLDAP 2.x Projects
Large projects
--------------
Redesign slapd memory allocation fault handling
Perform a security audit (and fix any hole found)
Update to latest autoconf and friends
Implement localization
......@@ -41,16 +41,14 @@ Implement LDAP Transactions extension
Implement Proxy Authorization Control extension
Implement LDAP Cancel extension
Implement authPassword (RFC 3112)
Update to latest autoconf and friends
Populate matchingRuleUse attribute in the subschema
Small projects
--------------
Add dumpasn1 logging support
Add LDIFv1 control support
Populate matchingRuleUse attribute in the subschema
Implement -V version options
Add No-Op Control support to client tools (e.g. ldapsearch(1))
Add tests to test suite (ACI, moddn, manageDSAit, etc.)
Recode linked-list structs to use <ldap_queue.h> macros
Create ldapbind(1) to support bind operations
......
......@@ -313,11 +313,6 @@ ber_pvt_sb_do_write( Sockbuf_IO_Desc *sbiod, Sockbuf_Buf *buf_out )
buf_out->buf_end = buf_out->buf_ptr = 0;
}
if ( (ber_len_t)ret < to_go ) {
/* not enough data, so pretend no data was sent. */
return -1;
}
return ret;
}
......
......@@ -224,7 +224,7 @@ do_abandon(
}
if ( lr != NULL ) {
if ( sendabandon ) {
if ( sendabandon || lr->lr_status == LDAP_REQST_WRITING ) {
ldap_free_connection( ld, lr->lr_conn, 0, 1 );
}
if ( origid == msgid ) {
......
......@@ -331,8 +331,13 @@ sb_sasl_write( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
/* Are there anything left in the buffer? */
if ( p->buf_out.buf_ptr != p->buf_out.buf_end ) {
ret = ber_pvt_sb_do_write( sbiod, &p->buf_out );
if ( ret <= 0 )
if ( ret < 0 )
return ret;
/* Still have something left?? */
if ( p->buf_out.buf_ptr != p->buf_out.buf_end ) {
errno = EWOULDBLOCK;
return 0;
}
}
/* now encode the next packet. */
......@@ -1088,6 +1093,7 @@ ldap_int_sasl_set_option( LDAP *ld, int option, void *arg )
}
#ifdef LDAP_R_COMPILE
#define LDAP_DEBUG_R_SASL
void *ldap_pvt_sasl_mutex_new(void)
{
ldap_pvt_thread_mutex_t *mutex;
......@@ -1098,23 +1104,47 @@ void *ldap_pvt_sasl_mutex_new(void)
if ( ldap_pvt_thread_mutex_init( mutex ) == 0 ) {
return mutex;
}
#ifndef LDAP_DEBUG_R_SASL
assert( 0 );
#endif /* !LDAP_DEBUG_R_SASL */
return NULL;
}
int ldap_pvt_sasl_mutex_lock(void *mutex)
{
#ifdef LDAP_DEBUG_R_SASL
if ( mutex == NULL ) {
return SASL_OK;
}
#else /* !LDAP_DEBUG_R_SASL */
assert( mutex );
#endif /* !LDAP_DEBUG_R_SASL */
return ldap_pvt_thread_mutex_lock( (ldap_pvt_thread_mutex_t *)mutex )
? SASL_FAIL : SASL_OK;
}
int ldap_pvt_sasl_mutex_unlock(void *mutex)
{
#ifdef LDAP_DEBUG_R_SASL
if ( mutex == NULL ) {
return SASL_OK;
}
#else /* !LDAP_DEBUG_R_SASL */
assert( mutex );
#endif /* !LDAP_DEBUG_R_SASL */
return ldap_pvt_thread_mutex_unlock( (ldap_pvt_thread_mutex_t *)mutex )
? SASL_FAIL : SASL_OK;
}
void ldap_pvt_sasl_mutex_dispose(void *mutex)
{
#ifdef LDAP_DEBUG_R_SASL
if ( mutex == NULL ) {
return;
}
#else /* !LDAP_DEBUG_R_SASL */
assert( mutex );
#endif /* !LDAP_DEBUG_R_SASL */
(void) ldap_pvt_thread_mutex_destroy( (ldap_pvt_thread_mutex_t *)mutex );
LDAP_FREE( mutex );
}
......
......@@ -837,8 +837,7 @@ put_vrFilter( BerElement *ber, const char *str_in )
*/
#ifdef NEW_LOGGING
LDAP_LOG ( FILTER, ARGS, "ldap_pvt_put_vrFilter: \"%s\"\n",
str_in, 0, 0 );
LDAP_LOG ( FILTER, ARGS, "put_vrFilter: \"%s\"\n", str_in, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE, "put_vrFilter: \"%s\"\n", str_in, 0, 0 );
#endif
......@@ -933,9 +932,9 @@ put_vrFilter( BerElement *ber, const char *str_in )
case /*'('*/ ')':
#ifdef NEW_LOGGING
LDAP_LOG ( FILTER, DETAIL1, "ldap_pvt_put_filter: end\n", 0, 0, 0 );
LDAP_LOG ( FILTER, DETAIL1, "put_vrFilter: end\n", 0, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE, "put_filter: end\n",
Debug( LDAP_DEBUG_TRACE, "put_vrFilter: end\n",
0, 0, 0 );
#endif
if ( ber_printf( ber, /*"["*/ "]" ) == -1 ) {
......@@ -952,10 +951,10 @@ put_vrFilter( BerElement *ber, const char *str_in )
default: /* assume it's a simple type=value filter */
#ifdef NEW_LOGGING
LDAP_LOG ( FILTER, DETAIL1, "ldap_pvt_put_filter: default\n",
LDAP_LOG ( FILTER, DETAIL1, "put_vrFilter: default\n",
0, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE, "put_filter: default\n",
Debug( LDAP_DEBUG_TRACE, "put_vrFilter: default\n",
0, 0, 0 );
#endif
next = strchr( str, '\0' );
......
......@@ -467,6 +467,7 @@ LDAP_F (int) ldap_chase_referrals( LDAP *ld, LDAPRequest *lr,
LDAP_F (int) ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr,
char **refs, int sref, char **referralsp, int *hadrefp );
LDAP_F (int) ldap_append_referral( LDAP *ld, char **referralsp, char *s );
LDAP_F (int) ldap_int_flush_request( LDAP *ld, LDAPRequest *lr );
/*
* in result.c:
......
......@@ -137,6 +137,39 @@ ldap_send_initial_request(
}
int
ldap_int_flush_request(
LDAP *ld,
LDAPRequest *lr
)
{
LDAPConn *lc = lr->lr_conn;
if ( ber_flush( lc->lconn_sb, lr->lr_ber, 0 ) != 0 ) {
if ( errno == EWOULDBLOCK ) {
/* need to continue write later */
lr->lr_status = LDAP_REQST_WRITING;
ldap_mark_select_write( ld, lc->lconn_sb );
ld->ld_errno = LDAP_BUSY;
return -2;
} else {
ld->ld_errno = LDAP_SERVER_DOWN;
ldap_free_request( ld, lr );
ldap_free_connection( ld, lc, 0, 0 );
return( -1 );
}
} else {
if ( lr->lr_parent == NULL ) {
lr->lr_ber->ber_end = lr->lr_ber->ber_ptr;
lr->lr_ber->ber_ptr = lr->lr_ber->ber_buf;
}
lr->lr_status = LDAP_REQST_INPROGRESS;
/* sent -- waiting for a response */
ldap_mark_select_read( ld, lc->lconn_sb );
}
return 0;
}
int
ldap_send_server_request(
......@@ -189,6 +222,18 @@ ldap_send_server_request(
}
use_connection( ld, lc );
/* If we still have an incomplete write, try to finish it before
* dealing with the new request. If we don't finish here, return
* LDAP_BUSY and let the caller retry later. We only allow a single
* request to be in WRITING state.
*/
if ( ld->ld_requests &&
ld->ld_requests->lr_status == LDAP_REQST_WRITING &&
ldap_int_flush_request( ld, ld->ld_requests ) < 0 ) {
return -1;
}
if (( lr = (LDAPRequest *)LDAP_CALLOC( 1, sizeof( LDAPRequest ))) ==
NULL ) {
ld->ld_errno = LDAP_NO_MEMORY;
......@@ -225,30 +270,8 @@ ldap_send_server_request(
ld->ld_requests = lr;
lr->lr_prev = NULL;
if ( ber_flush( lc->lconn_sb, ber, 0 ) != 0 ) {
#ifdef notyet
if ( errno == EWOULDBLOCK ) {
/* need to continue write later */
lr->lr_status = LDAP_REQST_WRITING;
ldap_mark_select_write( ld, lc->lconn_sb );
} else {
#else /* notyet */
ld->ld_errno = LDAP_SERVER_DOWN;
ldap_free_request( ld, lr );
ldap_free_connection( ld, lc, 0, 0 );
return( -1 );
#endif /* notyet */
#ifdef notyet
}
#endif /* notyet */
} else {
if ( parentreq == NULL ) {
ber->ber_end = ber->ber_ptr;
ber->ber_ptr = ber->ber_buf;
}
/* sent -- waiting for a response */
ldap_mark_select_read( ld, lc->lconn_sb );
if ( ldap_int_flush_request( ld, lr ) == -1 ) {
return -1;
}
ld->ld_errno = LDAP_SUCCESS;
......
......@@ -334,6 +334,12 @@ wait4msg(
rc = -2; /* select interrupted: loop */
} else {
rc = -2;
if ( ld->ld_requests &&
ld->ld_requests->lr_status == LDAP_REQST_WRITING &&
ldap_is_write_ready( ld,
ld->ld_requests->lr_conn->lconn_sb ) ) {
ldap_int_flush_request( ld, ld->ld_requests );
}
for ( lc = ld->ld_conns; rc == -2 && lc != NULL;
lc = nextlc ) {
nextlc = lc->lconn_next;
......
......@@ -204,6 +204,10 @@ SOURCE=.\ntservice.c
# End Source File
# Begin Source File
SOURCE=.\passfile.c
# End Source File
# Begin Source File
SOURCE=.\passwd.c
# End Source File
# Begin Source File
......
......@@ -243,7 +243,9 @@ struct rewrite_session {
Avlnode *ls_vars;
#ifdef USE_REWRITE_LDAP_PVT_THREADS
ldap_pvt_thread_rdwr_t ls_vars_mutex;
ldap_pvt_thread_mutex_t ls_mutex;
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
int ls_count;
};
/*
......
......@@ -44,7 +44,7 @@ rewrite_cookie_cmp(
assert( s2 != NULL );
assert( s1->ls_cookie != NULL );
assert( s2->ls_cookie != NULL );
return ( ( s1->ls_cookie < s2->ls_cookie ) ? -1 :
( ( s1->ls_cookie > s2->ls_cookie ) ? 1 : 0 ) );
}
......@@ -68,6 +68,8 @@ rewrite_cookie_dup(
assert( s1->ls_cookie != NULL );
assert( s2->ls_cookie != NULL );
assert( s1->ls_cookie != s2->ls_cookie );
return ( ( s1->ls_cookie == s2->ls_cookie ) ? -1 : 0 );
}
......@@ -80,24 +82,44 @@ rewrite_session_init(
const void *cookie
)
{
struct rewrite_session *session;
int rc;
struct rewrite_session *session, tmp;
int rc;
assert( info != NULL );
assert( cookie != NULL );
#ifdef USE_REWRITE_LDAP_PVT_THREADS
ldap_pvt_thread_rdwr_wlock( &info->li_cookies_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
tmp.ls_cookie = ( void * )cookie;
session = ( struct rewrite_session * )avl_find( info->li_cookies,
( caddr_t )&tmp, rewrite_cookie_cmp );
if ( session ) {
session->ls_count++;
#ifdef USE_REWRITE_LDAP_PVT_THREADS
ldap_pvt_thread_rdwr_wunlock( &info->li_cookies_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
return session;
}
session = calloc( sizeof( struct rewrite_session ), 1 );
if ( session == NULL ) {
return NULL;
}
session->ls_cookie = ( void * )cookie;
session->ls_count = 1;
#ifdef USE_REWRITE_LDAP_PVT_THREADS
if ( ldap_pvt_thread_mutex_init( &session->ls_mutex ) ) {
free( session );
return NULL;
}
if ( ldap_pvt_thread_rdwr_init( &session->ls_vars_mutex ) ) {
ldap_pvt_thread_mutex_destroy( &session->ls_mutex );
free( session );
return NULL;
}
ldap_pvt_thread_rdwr_wlock( &info->li_cookies_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
rc = avl_insert( &info->li_cookies, ( caddr_t )session,
......@@ -109,6 +131,11 @@ rewrite_session_init(
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
if ( rc != 0 ) {
#ifdef USE_REWRITE_LDAP_PVT_THREADS
ldap_pvt_thread_rdwr_destroy( &session->ls_vars_mutex );
ldap_pvt_thread_mutex_destroy( &session->ls_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
free( session );
return NULL;
}
......@@ -137,11 +164,26 @@ rewrite_session_find(
session = ( struct rewrite_session * )avl_find( info->li_cookies,
( caddr_t )&tmp, rewrite_cookie_cmp );
#ifdef USE_REWRITE_LDAP_PVT_THREADS
if ( session ) {
ldap_pvt_thread_mutex_lock( &session->ls_mutex );
}
ldap_pvt_thread_rdwr_runlock( &info->li_cookies_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
return session;
}
/*
* Returns a session
*/
void
rewrite_session_return(
struct rewrite_info *info,
struct rewrite_session *session
)
{
assert( session );
ldap_pvt_thread_mutex_unlock( &session->ls_mutex );
}
/*
......@@ -184,6 +226,7 @@ rewrite_session_var_set(
#ifdef USE_REWRITE_LDAP_PVT_THREADS
ldap_pvt_thread_rdwr_wunlock( &session->ls_vars_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
rewrite_session_return( info, session );
return REWRITE_ERR;
}
}
......@@ -192,6 +235,8 @@ rewrite_session_var_set(
ldap_pvt_thread_rdwr_wunlock( &session->ls_vars_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
rewrite_session_return( info, session );
return REWRITE_SUCCESS;
}
......@@ -236,7 +281,9 @@ rewrite_session_var_get(
#ifdef USE_REWRITE_LDAP_PVT_THREADS
ldap_pvt_thread_rdwr_runlock( &session->ls_vars_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
rewrite_session_return( info, session );
return REWRITE_ERR;
} else {
value->bv_val = strdup( var->lv_value.bv_val );
......@@ -246,6 +293,8 @@ rewrite_session_var_get(
#ifdef USE_REWRITE_LDAP_PVT_THREADS
ldap_pvt_thread_rdwr_runlock( &session->ls_vars_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
rewrite_session_return( info, session );
return REWRITE_SUCCESS;
}
......@@ -269,12 +318,20 @@ rewrite_session_delete(
session = rewrite_session_find( info, cookie );
if ( session != NULL ) {
if ( --session->ls_count > 0 ) {
rewrite_session_return( info, session );
return REWRITE_SUCCESS;
}
#ifdef USE_REWRITE_LDAP_PVT_THREADS
ldap_pvt_thread_rdwr_wlock( &session->ls_vars_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
rewrite_var_delete( session->ls_vars );
#ifdef USE_REWRITE_LDAP_PVT_THREADS
ldap_pvt_thread_rdwr_wunlock( &session->ls_vars_mutex );
ldap_pvt_thread_rdwr_destroy( &session->ls_vars_mutex );
ldap_pvt_thread_mutex_destroy( &session->ls_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
}
......@@ -289,6 +346,8 @@ rewrite_session_delete(
* There is nothing to delete in the return value
*/
avl_delete( &info->li_cookies, ( caddr_t )&tmp, rewrite_cookie_cmp );
free( session );
#ifdef USE_REWRITE_LDAP_PVT_THREADS
ldap_pvt_thread_rdwr_wunlock( &info->li_cookies_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
......@@ -318,6 +377,10 @@ rewrite_session_destroy(
count = avl_free( info->li_cookies, NULL );
info->li_cookies = NULL;
fprintf( stderr, "count = %d; num_cookies = %d\n",
count, info->li_num_cookies );
assert( count == info->li_num_cookies );
info->li_num_cookies = 0;
......
......@@ -40,7 +40,6 @@ bdb_group(
int rc = 1;
Attribute *attr;
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
const char *group_oc_name = NULL;
const char *group_at_name = group_at->ad_cname.bv_val;
......
......@@ -20,27 +20,20 @@
*/
int
bdb_operational(
bdb_hasSubordinates(
BackendDB *be,
Connection *conn,
Operation *op,
Entry *e,
AttributeName *attrs,
int opattrs,
Attribute **a )
int *hasSubordinates )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
Attribute **aa = a;
int rc;
DB_TXN *ltid = NULL;
struct bdb_op_info opinfo;
struct bdb_op_info opinfo;
assert( e );
if ( !opattrs && !ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) {
return 0;
}
assert( hasSubordinates );
if( 0 ) {
retry: /* transaction retry */
......@@ -51,9 +44,9 @@ retry: /* transaction retry */
#endif
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, DETAIL1,
"=> bdb_operational: retrying...\n", 0, 0, 0 );
"=> bdb_hasSubordinates: retrying...\n", 0, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE, "==> bdb_operational: retrying...\n",
Debug( LDAP_DEBUG_TRACE, "==> bdb_hasSubordinates: retrying...\n",
0, 0, 0 );
#endif
rc = TXN_ABORT( ltid );
......@@ -71,11 +64,11 @@ retry: /* transaction retry */
if ( rc != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
"=> bdb_operational: txn_begin failed: %s (%d)\n",
"=> bdb_hasSubordinates: txn_begin failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"bdb_operational: txn_begin failed: %s (%d)\n",
"bdb_hasSubordinates: txn_begin failed: %s (%d)\n",
db_strerror( rc ), rc, 0 );
#endif
rc = LDAP_OTHER;
......@@ -95,21 +88,22 @@ retry: /* transaction retry */
goto retry;
case 0:
*hasSubordinates = LDAP_COMPARE_TRUE;
break;
case DB_NOTFOUND:
*aa = slap_operational_hasSubordinate( rc == 0 );
if ( *aa != NULL ) {
aa = &(*aa)->a_next;