]> git.sur5r.net Git - openldap/blobdiff - clients/tools/common.c
ITS#6282
[openldap] / clients / tools / common.c
index c39b9c1a2154c2fbebf1adf93bd5065317e5d6b9..8cbb480eb3561aba19715ed6907007bdd233689e 100644 (file)
@@ -271,7 +271,6 @@ void
 tool_common_usage( void )
 {
        static const char *const descriptions[] = {
-N_("  -c         continuous operation mode (do not stop on errors)\n"),
 N_("  -d level   set LDAP debugging level to `level'\n"),
 N_("  -D binddn  bind DN\n"),
 N_("  -e [!]<ext>[=<extparam>] general extensions (! indicates criticality)\n")
@@ -302,18 +301,15 @@ N_("             [!]sessiontracking\n")
 N_("             abandon, cancel, ignore (SIGINT sends abandon/cancel,\n"
    "             or ignores response; if critical, doesn't wait for SIGINT.\n"
    "             not really controls)\n")
-N_("  -f file    read operations from `file'\n"),
 N_("  -h host    LDAP server\n"),
 N_("  -H URI     LDAP Uniform Resource Identifier(s)\n"),
 N_("  -I         use SASL Interactive mode\n"),
-N_("  -M         enable Manage DSA IT control (-MM to make critical)\n"),
 N_("  -n         show what would be done but don't actually do it\n"),
 N_("  -N         do not use reverse DNS to canonicalize SASL host name\n"),
 N_("  -O props   SASL security properties\n"),
 N_("  -o <opt>[=<optparam] general options\n"),
 N_("             nettimeout=<timeout> (in seconds, or \"none\" or \"max\")\n"),
 N_("  -p port    port on LDAP server\n"),
-N_("  -P version protocol version (default: 3)\n"),
 N_("  -Q         use SASL Quiet mode\n"),
 N_("  -R realm   SASL realm\n"),
 N_("  -U authcid SASL authentication identity\n"),
@@ -1291,7 +1287,10 @@ dnssrv_free:;
                if ( use_tls ) {
                        rc = ldap_start_tls_s( ld, NULL, NULL );
                        if ( rc != LDAP_SUCCESS ) {
-                               tool_perror( "ldap_start_tls", rc, NULL, NULL, NULL, NULL );
+                               char *msg=NULL;
+                               ldap_get_option( ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, (void*)&msg);
+                               tool_perror( "ldap_start_tls", rc, NULL, NULL, msg, NULL );
+                               ldap_memfree(msg);
                                if ( use_tls > 1 ) {
                                        exit( EXIT_FAILURE );
                                }
@@ -1388,8 +1387,11 @@ tool_bind( LDAP *ld )
 
                lutil_sasl_freedefs( defaults );
                if( rc != LDAP_SUCCESS ) {
+                       char *msg=NULL;
+                       ldap_get_option( ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, (void*)&msg);
                        tool_perror( "ldap_sasl_interactive_bind_s",
-                               rc, NULL, NULL, NULL, NULL );
+                               rc, NULL, NULL, msg, NULL );
+                       ldap_memfree(msg);
                        exit( rc );
                }
 #else
@@ -1418,11 +1420,17 @@ tool_bind( LDAP *ld )
                        }
                }
 
-               if ( ldap_result( ld, msgid, LDAP_MSG_ALL, NULL, &result ) == -1 ) {
+               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 );
                }
 
+               if ( rc == 0 ) {
+                       tool_perror( "ldap_result", LDAP_TIMEOUT, NULL, NULL, NULL, NULL );
+                       exit( LDAP_LOCAL_ERROR );
+               }
+
                rc = ldap_parse_result( ld, result, &err, &matched, &info, &refs,
                        &ctrls, 1 );
                if ( rc != LDAP_SUCCESS ) {
@@ -2016,22 +2024,15 @@ print_deref( LDAP *ld, LDAPControl *ctrl )
                        if ( dv->vals != NULL ) {
                                int j;
                                for ( j = 0; dv->vals[ j ].bv_val != NULL; j++ ) {
-                                       int k;
-
-                                       for ( k = 0; k < dv->vals[ j ].bv_len; k++ ) {
-                                               if ( !isprint( dv->vals[ j ].bv_val[k] ) ) {
-                                                       k = -1;
-                                                       break;
-                                               }
-                                       }
+                                       int k = ldif_is_not_printable( dv->vals[ j ].bv_val, dv->vals[ j ].bv_len );
 
                                        *ptr++ = '<';
                                        ptr = lutil_strcopy( ptr, dv->type );
-                                       if ( k == -1 ) {
+                                       if ( k ) {
                                                *ptr++ = ':';
                                        }
                                        *ptr++ = '=';
-                                       if ( k == -1 ) {
+                                       if ( k ) {
                                                k = lutil_b64_ntop(
                                                        (unsigned char *) dv->vals[ j ].bv_val,
                                                        dv->vals[ j ].bv_len,