mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
ITS#6548,#7092 Unbind,cleanup before client exit.
Gets rid of "(connection lost)" in slapd statslog "closed" message.
This commit is contained in:
parent
26d881a93c
commit
ef76d419ec
11 changed files with 93 additions and 105 deletions
|
|
@ -252,6 +252,10 @@ tool_init( tool_type_t type )
|
|||
void
|
||||
tool_destroy( void )
|
||||
{
|
||||
static int destroyed;
|
||||
if ( destroyed++ )
|
||||
return;
|
||||
|
||||
#ifdef HAVE_CYRUS_SASL
|
||||
sasl_done();
|
||||
#endif
|
||||
|
|
@ -1401,7 +1405,7 @@ dnssrv_free:;
|
|||
{
|
||||
fprintf( stderr, "Could not set LDAP_OPT_REFERRALS %s\n",
|
||||
referrals ? "on" : "off" );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
#ifdef HAVE_CYRUS_SASL
|
||||
|
|
@ -1411,7 +1415,7 @@ dnssrv_free:;
|
|||
{
|
||||
fprintf( stderr, "Could not set LDAP_OPT_X_SASL_NOCANON %s\n",
|
||||
nocanon ? "on" : "off" );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
#endif
|
||||
if( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &protocol )
|
||||
|
|
@ -1419,7 +1423,7 @@ dnssrv_free:;
|
|||
{
|
||||
fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n",
|
||||
protocol );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( use_tls ) {
|
||||
|
|
@ -1430,7 +1434,7 @@ dnssrv_free:;
|
|||
tool_perror( "ldap_start_tls", rc, NULL, NULL, msg, NULL );
|
||||
ldap_memfree(msg);
|
||||
if ( use_tls > 1 ) {
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1441,7 +1445,7 @@ dnssrv_free:;
|
|||
{
|
||||
fprintf( stderr, "Could not set LDAP_OPT_NETWORK_TIMEOUT %ld\n",
|
||||
(long)nettimeout.tv_sec );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1500,7 +1504,7 @@ tool_bind( LDAP *ld )
|
|||
LDAPControl c;
|
||||
|
||||
if ( BER_BVISNULL( &stValue) && st_value( ld, &stValue ) ) {
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c.ldctl_oid = LDAP_CONTROL_X_SESSION_TRACKING;
|
||||
|
|
@ -1524,7 +1528,7 @@ tool_bind( LDAP *ld )
|
|||
|
||||
if ( pw_file ) {
|
||||
if ( lutil_get_filed_password( pw_file, &passwd ) ) {
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -1549,7 +1553,7 @@ tool_bind( LDAP *ld )
|
|||
fprintf( stderr,
|
||||
"Could not set LDAP_OPT_X_SASL_SECPROPS: %s\n",
|
||||
sasl_secprops );
|
||||
exit( LDAP_LOCAL_ERROR );
|
||||
tool_exit( ld, LDAP_LOCAL_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1576,7 +1580,7 @@ tool_bind( LDAP *ld )
|
|||
tool_perror( "ldap_sasl_interactive_bind",
|
||||
err, NULL, NULL, info, NULL );
|
||||
ldap_memfree( info );
|
||||
exit( err );
|
||||
tool_exit( ld, err );
|
||||
}
|
||||
} while ( rc == LDAP_SASL_BIND_IN_PROGRESS );
|
||||
|
||||
|
|
@ -1587,11 +1591,11 @@ tool_bind( LDAP *ld )
|
|||
tool_perror( "ldap_sasl_interactive_bind",
|
||||
rc, NULL, NULL, info, NULL );
|
||||
ldap_memfree( info );
|
||||
exit( rc );
|
||||
tool_exit( ld, rc );
|
||||
}
|
||||
#else
|
||||
fprintf( stderr, "%s: not compiled with SASL support\n", prog );
|
||||
exit( LDAP_NOT_SUPPORTED );
|
||||
tool_exit( ld, LDAP_NOT_SUPPORTED );
|
||||
#endif
|
||||
} else {
|
||||
/* simple bind */
|
||||
|
|
@ -1600,18 +1604,18 @@ tool_bind( LDAP *ld )
|
|||
if ( msgid == -1 ) {
|
||||
tool_perror( "ldap_sasl_bind(SIMPLE)", rc,
|
||||
NULL, NULL, NULL, NULL );
|
||||
exit( rc );
|
||||
tool_exit( ld, rc );
|
||||
}
|
||||
|
||||
rc = ldap_result( ld, msgid, LDAP_MSG_ALL, NULL, &result );
|
||||
if ( rc == -1 ) {
|
||||
tool_perror( "ldap_result", -1, NULL, NULL, NULL, NULL );
|
||||
exit( LDAP_LOCAL_ERROR );
|
||||
tool_exit( ld, LDAP_LOCAL_ERROR );
|
||||
}
|
||||
|
||||
if ( rc == 0 ) {
|
||||
tool_perror( "ldap_result", LDAP_TIMEOUT, NULL, NULL, NULL, NULL );
|
||||
exit( LDAP_LOCAL_ERROR );
|
||||
tool_exit( ld, LDAP_LOCAL_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1619,7 +1623,7 @@ tool_bind( LDAP *ld )
|
|||
&ctrls, 1 );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
tool_perror( "ldap_bind parse result", rc, NULL, matched, info, refs );
|
||||
exit( LDAP_LOCAL_ERROR );
|
||||
tool_exit( ld, LDAP_LOCAL_ERROR );
|
||||
}
|
||||
|
||||
#ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
|
||||
|
|
@ -1682,7 +1686,7 @@ tool_bind( LDAP *ld )
|
|||
if( info ) ber_memfree( info );
|
||||
if( refs ) ber_memvfree( (void **)refs );
|
||||
|
||||
if ( err != LDAP_SUCCESS ) exit( err );
|
||||
if ( err != LDAP_SUCCESS ) tool_exit( ld, err );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1698,6 +1702,16 @@ tool_unbind( LDAP *ld )
|
|||
(void) ldap_unbind_ext( ld, NULL, NULL );
|
||||
}
|
||||
|
||||
void
|
||||
tool_exit( LDAP *ld, int status )
|
||||
{
|
||||
if ( ld != NULL ) {
|
||||
tool_unbind( ld );
|
||||
}
|
||||
tool_destroy();
|
||||
exit( status );
|
||||
}
|
||||
|
||||
|
||||
/* Set server controls. Add controls extra_c[0..count-1], if set. */
|
||||
void
|
||||
|
|
@ -1734,7 +1748,7 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
|
|||
ctrls = (LDAPControl**) malloc(sizeof(c) + (count + unknown_ctrls_num + 1)*sizeof(LDAPControl*));
|
||||
if ( ctrls == NULL ) {
|
||||
fprintf( stderr, "No memory\n" );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( assertctl ) {
|
||||
|
|
@ -1774,11 +1788,11 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
|
|||
ber_init2( ber, NULL, LBER_USE_DER );
|
||||
|
||||
if ( ber_printf( ber, "s", proxydn ) == -1 ) {
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ber_flatten2( ber, &c[i].ldctl_value, 0 ) == -1 ) {
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ;
|
||||
|
|
@ -1835,13 +1849,13 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
|
|||
|
||||
if( ber_printf( ber, "{v}", attrs ) == -1 ) {
|
||||
fprintf( stderr, "preread attrs encode failed.\n" );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
err = ber_flatten2( ber, &c[i].ldctl_value, 0 );
|
||||
if( err < 0 ) {
|
||||
fprintf( stderr, "preread flatten failed (%d)\n", err );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_PRE_READ;
|
||||
|
|
@ -1865,13 +1879,13 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
|
|||
|
||||
if( ber_printf( ber, "{v}", attrs ) == -1 ) {
|
||||
fprintf( stderr, "postread attrs encode failed.\n" );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
err = ber_flatten2( ber, &c[i].ldctl_value, 0 );
|
||||
if( err < 0 ) {
|
||||
fprintf( stderr, "postread flatten failed (%d)\n", err );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_POST_READ;
|
||||
|
|
@ -1894,7 +1908,7 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
|
|||
if ( err == -1 ) {
|
||||
ber_free( ber, 1 );
|
||||
fprintf( stderr, _("Chaining behavior control encoding error!\n") );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( chainingContinuation > -1 ) {
|
||||
|
|
@ -1902,7 +1916,7 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
|
|||
if ( err == -1 ) {
|
||||
ber_free( ber, 1 );
|
||||
fprintf( stderr, _("Chaining behavior control encoding error!\n") );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1910,11 +1924,11 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
|
|||
if ( err == -1 ) {
|
||||
ber_free( ber, 1 );
|
||||
fprintf( stderr, _("Chaining behavior control encoding error!\n") );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ber_flatten2( ber, &c[i].ldctl_value, 0 ) == -1 ) {
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -1931,7 +1945,7 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
|
|||
#ifdef LDAP_CONTROL_X_SESSION_TRACKING
|
||||
if ( sessionTracking ) {
|
||||
if ( BER_BVISNULL( &stValue ) && st_value( ld, &stValue ) ) {
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_X_SESSION_TRACKING;
|
||||
|
|
@ -1963,7 +1977,7 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
|
|||
|
||||
free( ctrls );
|
||||
if ( crit ) {
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2497,4 +2511,3 @@ tool_is_oid( const char *s )
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ LDAP *tool_conn_setup LDAP_P(( int dont, void (*private_setup)( LDAP * ) ));
|
|||
void tool_bind LDAP_P(( LDAP * ));
|
||||
void tool_unbind LDAP_P(( LDAP * ));
|
||||
void tool_destroy LDAP_P(( void ));
|
||||
void tool_exit LDAP_P(( LDAP *ld, int status )) LDAP_GCCATTR((noreturn));
|
||||
void tool_server_controls LDAP_P(( LDAP *, LDAPControl *, int ));
|
||||
int tool_check_abandon LDAP_P(( LDAP *ld, int msgid ));
|
||||
void tool_perror LDAP_P((
|
||||
|
|
|
|||
|
|
@ -260,9 +260,7 @@ main( int argc, char **argv )
|
|||
|
||||
free( bvalue.bv_val );
|
||||
|
||||
tool_unbind( ld );
|
||||
tool_destroy();
|
||||
return rc;
|
||||
tool_exit( ld, rc );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -218,9 +218,7 @@ main( int argc, char **argv )
|
|||
fclose( fp );
|
||||
}
|
||||
|
||||
tool_unbind( ld );
|
||||
tool_destroy();
|
||||
return retval;
|
||||
tool_exit( ld, retval );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ main( int argc, char *argv[] )
|
|||
struct timeval tv;
|
||||
|
||||
if ( tool_check_abandon( ld, id ) ) {
|
||||
return LDAP_CANCELLED;
|
||||
tool_exit( ld, LDAP_CANCELLED );
|
||||
}
|
||||
|
||||
tv.tv_sec = 0;
|
||||
|
|
@ -351,8 +351,5 @@ skip:
|
|||
/* disconnect from server */
|
||||
if ( res )
|
||||
ldap_msgfree( res );
|
||||
tool_unbind( ld );
|
||||
tool_destroy();
|
||||
|
||||
return code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
tool_exit( ld, code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -363,12 +363,6 @@ main( int argc, char **argv )
|
|||
}
|
||||
#endif
|
||||
|
||||
if ( !dont && ld != NULL ) {
|
||||
tool_unbind( ld );
|
||||
}
|
||||
|
||||
tool_destroy();
|
||||
|
||||
fail:;
|
||||
if ( rejfp != NULL ) {
|
||||
fclose( rejfp );
|
||||
|
|
@ -378,7 +372,7 @@ fail:;
|
|||
ldif_close( ldiffp );
|
||||
}
|
||||
|
||||
return( retval );
|
||||
tool_exit( ld, retval );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ main(int argc, char **argv)
|
|||
{
|
||||
char *entrydn = NULL, *rdn = NULL, buf[ 4096 ];
|
||||
FILE *fp = NULL;
|
||||
LDAP *ld;
|
||||
LDAP *ld = NULL;
|
||||
int rc, retval, havedn;
|
||||
|
||||
tool_init( TOOL_MODRDN );
|
||||
|
|
@ -227,13 +227,11 @@ main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
tool_unbind( ld );
|
||||
tool_destroy();
|
||||
fail:
|
||||
if ( fp && fp != stdin ) fclose( fp );
|
||||
if ( entrydn ) free( entrydn );
|
||||
if ( rdn ) free( rdn );
|
||||
return( retval );
|
||||
tool_exit( ld, retval );
|
||||
}
|
||||
|
||||
static int domodrdn(
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ main( int argc, char *argv[] )
|
|||
struct timeval tv;
|
||||
|
||||
if ( tool_check_abandon( ld, id ) ) {
|
||||
return LDAP_CANCELLED;
|
||||
tool_exit( ld, LDAP_CANCELLED );
|
||||
}
|
||||
|
||||
tv.tv_sec = 0;
|
||||
|
|
@ -322,7 +322,7 @@ main( int argc, char *argv[] )
|
|||
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
|
||||
if ( rc < 0 ) {
|
||||
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
|
||||
return rc;
|
||||
tool_exit( ld, rc );
|
||||
}
|
||||
|
||||
if ( rc != 0 ) {
|
||||
|
|
@ -409,8 +409,5 @@ main( int argc, char *argv[] )
|
|||
|
||||
done:
|
||||
/* disconnect from server */
|
||||
if ( ld )
|
||||
tool_unbind( ld );
|
||||
tool_destroy();
|
||||
return rc;
|
||||
tool_exit( ld, rc );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -777,7 +777,7 @@ private_conn_setup( LDAP *ld )
|
|||
!= LDAP_OPT_SUCCESS )
|
||||
{
|
||||
fprintf( stderr, _("Could not set LDAP_OPT_DEREF %d\n"), deref );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -908,7 +908,7 @@ getNextPage:
|
|||
if ( !fp && infile ) {
|
||||
if (( fp = fopen( infile, "r" )) == NULL ) {
|
||||
perror( infile );
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
save_nctrls = nctrls;
|
||||
|
|
@ -932,7 +932,7 @@ getNextPage:
|
|||
#ifdef LDAP_CONTROL_DONTUSECOPY
|
||||
if ( dontUseCopy ) {
|
||||
if ( ctrl_add() ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_DONTUSECOPY;
|
||||
|
|
@ -945,7 +945,7 @@ getNextPage:
|
|||
|
||||
if ( domainScope ) {
|
||||
if ( ctrl_add() ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_X_DOMAIN_SCOPE;
|
||||
|
|
@ -957,22 +957,22 @@ getNextPage:
|
|||
|
||||
if ( subentries ) {
|
||||
if ( ctrl_add() ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if (( seber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
err = ber_printf( seber, "b", abs(subentries) == 1 ? 0 : 1 );
|
||||
if ( err == -1 ) {
|
||||
ber_free( seber, 1 );
|
||||
fprintf( stderr, _("Subentries control encoding error!\n") );
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ber_flatten2( seber, &c[i].ldctl_value, 0 ) == -1 ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_SUBENTRIES;
|
||||
|
|
@ -982,11 +982,11 @@ getNextPage:
|
|||
|
||||
if ( ldapsync ) {
|
||||
if ( ctrl_add() ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if (( syncber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( sync_cookie.bv_len == 0 ) {
|
||||
|
|
@ -999,11 +999,11 @@ getNextPage:
|
|||
if ( err == -1 ) {
|
||||
ber_free( syncber, 1 );
|
||||
fprintf( stderr, _("ldap sync control encoding error!\n") );
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ber_flatten( syncber, &syncbvalp ) == -1 ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_SYNC;
|
||||
|
|
@ -1014,21 +1014,21 @@ getNextPage:
|
|||
|
||||
if ( valuesReturnFilter ) {
|
||||
if ( ctrl_add() ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if (( vrber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ( err = ldap_put_vrFilter( vrber, vrFilter ) ) == -1 ) {
|
||||
ber_free( vrber, 1 );
|
||||
fprintf( stderr, _("Bad ValuesReturnFilter: %s\n"), vrFilter );
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ber_flatten2( vrber, &c[i].ldctl_value, 0 ) == -1 ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_VALUESRETURNFILTER;
|
||||
|
|
@ -1038,13 +1038,13 @@ getNextPage:
|
|||
|
||||
if ( pagedResults ) {
|
||||
if ( ctrl_add() ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ldap_create_page_control_value( ld,
|
||||
pageSize, &pr_cookie, &c[i].ldctl_value ) )
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( pr_cookie.bv_val != NULL ) {
|
||||
|
|
@ -1060,13 +1060,13 @@ getNextPage:
|
|||
|
||||
if ( sss ) {
|
||||
if ( ctrl_add() ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ldap_create_sort_control_value( ld,
|
||||
sss_keys, &c[i].ldctl_value ) )
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_SORTREQUEST;
|
||||
|
|
@ -1076,13 +1076,13 @@ getNextPage:
|
|||
|
||||
if ( vlv ) {
|
||||
if ( ctrl_add() ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ldap_create_vlv_control_value( ld,
|
||||
&vlvInfo, &c[i].ldctl_value ) )
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[i].ldctl_oid = LDAP_CONTROL_VLVREQUEST;
|
||||
|
|
@ -1097,7 +1097,7 @@ getNextPage:
|
|||
assert( ds != NULL );
|
||||
|
||||
if ( ldap_create_deref_control_value( ld, ds, &derefval ) != LDAP_SUCCESS ) {
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
for ( i = 0; ds[ i ].derefAttr != NULL; i++ ) {
|
||||
|
|
@ -1109,7 +1109,7 @@ getNextPage:
|
|||
}
|
||||
|
||||
if ( ctrl_add() ) {
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
c[ i ].ldctl_iscritical = derefcrit > 1;
|
||||
|
|
@ -1285,7 +1285,7 @@ getNextPage:
|
|||
if ( num != 1 ) {
|
||||
fprintf( stderr,
|
||||
_("Invalid value for PagedResultsControl, %s.\n"), buf);
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
|
||||
}
|
||||
pageSize = (ber_int_t)tmpSize;
|
||||
|
|
@ -1316,7 +1316,7 @@ getNextPage:
|
|||
if ( buf[0] ) {
|
||||
i = parse_vlv( strdup( buf ));
|
||||
if ( i )
|
||||
return EXIT_FAILURE;
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
} else {
|
||||
vlvInfo.ldvlv_attrvalue = NULL;
|
||||
vlvInfo.ldvlv_count = vlvCount;
|
||||
|
|
@ -1330,8 +1330,6 @@ getNextPage:
|
|||
goto getNextPage;
|
||||
}
|
||||
|
||||
tool_unbind( ld );
|
||||
tool_destroy();
|
||||
if ( base != NULL ) {
|
||||
ber_memfree( base );
|
||||
}
|
||||
|
|
@ -1358,7 +1356,7 @@ getNextPage:
|
|||
c = NULL;
|
||||
}
|
||||
|
||||
return( rc );
|
||||
tool_exit( ld, rc );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1623,7 +1621,7 @@ print_entry(
|
|||
if( rc != LDAP_SUCCESS ) {
|
||||
fprintf(stderr, _("print_entry: %d\n"), rc );
|
||||
tool_perror( "ldap_get_entry_controls", rc, NULL, NULL, NULL, NULL );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if( ctrls ) {
|
||||
|
|
@ -1721,7 +1719,7 @@ static void print_reference(
|
|||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
tool_perror( "ldap_parse_reference", rc, NULL, NULL, NULL, NULL );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if( refs ) {
|
||||
|
|
@ -1756,7 +1754,7 @@ static void print_extended(
|
|||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
tool_perror( "ldap_parse_extended_result", rc, NULL, NULL, NULL, NULL );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ldif < 2 ) {
|
||||
|
|
@ -1794,7 +1792,7 @@ static void print_partial(
|
|||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
tool_perror( "ldap_parse_intermediate", rc, NULL, NULL, NULL, NULL );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( ldif < 2 ) {
|
||||
|
|
@ -1844,7 +1842,7 @@ static int print_result(
|
|||
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
tool_perror( "ldap_parse_result", rc, NULL, NULL, NULL, NULL );
|
||||
exit( EXIT_FAILURE );
|
||||
tool_exit( ld, EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ main( int argc, char *argv[] )
|
|||
ldap_get_option(ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, (void*) &text);
|
||||
tool_perror( "ldap_verify_credentials_interactive", rc, NULL, NULL, text, NULL);
|
||||
ldap_memfree(text);
|
||||
exit(rc);
|
||||
tool_exit(ld, rc);
|
||||
}
|
||||
} while (rc == LDAP_SASL_BIND_IN_PROGRESS);
|
||||
|
||||
|
|
@ -415,7 +415,7 @@ main( int argc, char *argv[] )
|
|||
struct timeval tv;
|
||||
|
||||
if ( tool_check_abandon( ld, id ) ) {
|
||||
return LDAP_CANCELLED;
|
||||
tool_exit( ld, LDAP_CANCELLED );
|
||||
}
|
||||
|
||||
tv.tv_sec = 0;
|
||||
|
|
@ -424,7 +424,7 @@ main( int argc, char *argv[] )
|
|||
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
|
||||
if ( rc < 0 ) {
|
||||
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
|
||||
return rc;
|
||||
tool_exit( ld, rc );
|
||||
}
|
||||
|
||||
if ( rc != 0 ) {
|
||||
|
|
@ -504,8 +504,5 @@ skip:
|
|||
free( cred.bv_val );
|
||||
|
||||
/* disconnect from server */
|
||||
tool_unbind( ld );
|
||||
tool_destroy();
|
||||
|
||||
return code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
tool_exit( ld, code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ main( int argc, char *argv[] )
|
|||
struct timeval tv;
|
||||
|
||||
if ( tool_check_abandon( ld, id ) ) {
|
||||
return LDAP_CANCELLED;
|
||||
tool_exit( ld, LDAP_CANCELLED );
|
||||
}
|
||||
|
||||
tv.tv_sec = 0;
|
||||
|
|
@ -160,7 +160,7 @@ main( int argc, char *argv[] )
|
|||
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
|
||||
if ( rc < 0 ) {
|
||||
tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
|
||||
return rc;
|
||||
tool_exit( ld, rc );
|
||||
}
|
||||
|
||||
if ( rc != 0 ) {
|
||||
|
|
@ -231,8 +231,5 @@ skip:
|
|||
ber_bvfree( authzid );
|
||||
|
||||
/* disconnect from server */
|
||||
tool_unbind( ld );
|
||||
tool_destroy();
|
||||
|
||||
return code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
tool_exit( ld, code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue