]> git.sur5r.net Git - openldap/blobdiff - tests/progs/slapd-bind.c
ITS#6003, #5916 fix ldap_back_entry_get_rw, no deref here
[openldap] / tests / progs / slapd-bind.c
index 4f1b1f2d5c7f4180f0355ab845b242498889fa09..1b597f27f04b1063528a535992e2ee259bb15943 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2007 The OpenLDAP Foundation.
+ * Copyright 1999-2009 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -249,13 +249,17 @@ main( int argc, char **argv )
        uri = tester_uri( uri, host, port );
 
        for ( i = 0; i < outerloops; i++ ) {
+               int rc;
+
                if ( base != NULL ) {
-                       do_base( uri, dn, &pass, base, filter, pwattr, loops,
+                       rc = do_base( uri, dn, &pass, base, filter, pwattr, loops,
                                force, chaserefs, noinit, delay, -1, NULL );
                } else {
-                       do_bind( uri, dn, &pass, loops,
+                       rc = do_bind( uri, dn, &pass, loops,
                                force, chaserefs, noinit, NULL, -1, NULL );
                }
+               if ( rc == LDAP_SERVER_DOWN )
+                       break;
        }
 
        exit( EXIT_SUCCESS );
@@ -339,12 +343,12 @@ do_bind( char *uri, char *dn, struct berval *pass, int maxloop,
 
                rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, pass, NULL, NULL, NULL );
                if ( rc ) {
-                       unsigned first = tester_ignore_err( rc );
+                       int first = tester_ignore_err( rc );
 
                        /* if ignore.. */
                        if ( first ) {
                                /* only log if first occurrence */
-                               if ( force < 2 || first == 1 ) {
+                               if ( ( force < 2 && first > 0 ) || abs(first) == 1 ) {
                                        tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
                                }
                                rc = LDAP_SUCCESS;
@@ -394,7 +398,7 @@ do_bind( char *uri, char *dn, struct berval *pass, int maxloop,
        }
 
        if ( maxloop > 1 ) {
-               fprintf( stderr, " PID=%ld - Bind done (%d).\n", (long) pid, rc );
+               fprintf( stderr, "  PID=%ld - Bind done (%d).\n", (long) pid, rc );
        }
 
        if ( ldp && noinit ) {
@@ -570,7 +574,7 @@ novals:;
        end = GetTickCount();
        end -= beg;
 
-       fprintf( stderr, " PID=%ld - Bind done %d in %d.%03d seconds.\n",
+       fprintf( stderr, "  PID=%ld - Bind done %d in %d.%03d seconds.\n",
                (long) pid, i, end / 1000, end % 1000 );
 #else
        gettimeofday( &end, NULL );
@@ -581,7 +585,7 @@ novals:;
        }
        end.tv_sec -= beg.tv_sec;
 
-       fprintf( stderr, " PID=%ld - Bind done %d in %ld.%06ld seconds.\n",
+       fprintf( stderr, "  PID=%ld - Bind done %d in %ld.%06ld seconds.\n",
                (long) pid, i, (long) end.tv_sec, (long) end.tv_usec );
 #endif