]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/sasl.c
cleanup
[openldap] / libraries / liblutil / sasl.c
index 743758f815e86efe6d7f4244771ebd6bc90fa7a1..a1308a8018deb8cd52e6a1a89ad02a14b7f6e8fa 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 2000-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
 #include <ac/string.h>
 #include <ac/unistd.h>
 
+#ifdef HAVE_SASL_SASL_H
+#include <sasl/sasl.h>
+#else
 #include <sasl.h>
+#endif
 
 #include <ldap.h>
 #include "lutil_ldap.h"
@@ -101,7 +105,9 @@ static int interaction(
 
        if( dflt && !*dflt ) dflt = NULL;
 
-       if( flags != LDAP_SASL_INTERACTIVE && dflt ) {
+       if( flags != LDAP_SASL_INTERACTIVE &&
+               ( dflt || interact->id == SASL_CB_USER ) )
+       {
                goto use_default;
        }
 
@@ -120,7 +126,7 @@ static int interaction(
                fprintf( stderr, "Default: %s\n", dflt );
        }
 
-       sprintf( input, "%s: ",
+       snprintf( input, sizeof input, "%s: ",
                interact->prompt ? interact->prompt : "Interact" );
 
        if( noecho ) {
@@ -153,7 +159,7 @@ static int interaction(
 
        if( interact->len > 0 ) {
                /* duplicate */
-               char *p = interact->result;
+               char *p = (char *)interact->result;
                interact->result = strdup( p );
 
                /* zap */
@@ -161,7 +167,7 @@ static int interaction(
 
        } else {
 use_default:
-               /* must be empty */
+               /* input must be empty */
                interact->result = strdup( (dflt && *dflt) ? dflt : "" );
                interact->len = interact->result
                        ? strlen( interact->result ) : 0;
@@ -184,7 +190,7 @@ int lutil_sasl_interact(
 {
        sasl_interact_t *interact = in;
 
-       if( flags != LDAP_SASL_QUIET ) {
+       if( flags == LDAP_SASL_INTERACTIVE ) {
                fputs( "SASL Interaction\n", stderr );
        }