]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/tls.c
Rework counter code in fallback.
[openldap] / libraries / libldap / tls.c
index 1ac30e5496f50e9f5101d413b292ee54ced98a65..53c4e3b0804090d6387be7feaa05873f3a9bc527 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -378,21 +379,19 @@ ldap_pvt_tls_config( struct ldapoptions *lo, int option, const char *arg )
                      ( strcasecmp( arg, "true" ) == 0 ) );
                return ldap_pvt_tls_set_option( NULL, option, (void *) &i );
        case LDAP_OPT_X_TLS:
+               i = -1;
                if ( strcasecmp( arg, "never" ) == 0 )
-                       return ldap_pvt_tls_set_option( lo, option,
-                               LDAP_OPT_X_TLS_NEVER );
+                       i = LDAP_OPT_X_TLS_NEVER ;
                if ( strcasecmp( arg, "demand" ) == 0 )
-                       return ldap_pvt_tls_set_option( lo, option,
-                               LDAP_OPT_X_TLS_DEMAND );
+                       i = LDAP_OPT_X_TLS_DEMAND ;
                if ( strcasecmp( arg, "allow" ) == 0 )
-                       return ldap_pvt_tls_set_option( lo, option,
-                               LDAP_OPT_X_TLS_ALLOW );
+                       i = LDAP_OPT_X_TLS_ALLOW ;
                if ( strcasecmp( arg, "try" ) == 0 )
-                       return ldap_pvt_tls_set_option( lo, option,
-                               LDAP_OPT_X_TLS_TRY );
+                       i = LDAP_OPT_X_TLS_TRY ;
                if ( strcasecmp( arg, "hard" ) == 0 )
-                       return ldap_pvt_tls_set_option( lo, option,
-                               LDAP_OPT_X_TLS_HARD );
+                       i = LDAP_OPT_X_TLS_HARD ;
+               if (i >= 0)
+                       return ldap_pvt_tls_set_option( lo, option, &i );
                return -1;
        default:
                return -1;
@@ -414,19 +413,19 @@ ldap_pvt_tls_get_option( struct ldapoptions *lo, int option, void *arg )
                break;
        case LDAP_OPT_X_TLS_CACERTFILE:
                *(char **)arg = tls_opt_cacertfile ?
-                       strdup( tls_opt_cacertfile ) : NULL;
+                       LDAP_STRDUP( tls_opt_cacertfile ) : NULL;
                break;
        case LDAP_OPT_X_TLS_CACERTDIR:
                *(char **)arg = tls_opt_cacertdir ?
-                       strdup( tls_opt_cacertdir ) : NULL;
+                       LDAP_STRDUP( tls_opt_cacertdir ) : NULL;
                break;
        case LDAP_OPT_X_TLS_CERTFILE:
                *(char **)arg = tls_opt_certfile ?
-                       strdup( tls_opt_certfile ) : NULL;
+                       LDAP_STRDUP( tls_opt_certfile ) : NULL;
                break;
        case LDAP_OPT_X_TLS_KEYFILE:
                *(char **)arg = tls_opt_keyfile ?
-                       strdup( tls_opt_keyfile ) : NULL;
+                       LDAP_STRDUP( tls_opt_keyfile ) : NULL;
                break;
        case LDAP_OPT_X_TLS_REQUIRE_CERT:
                *(int *)arg = tls_opt_require_cert;
@@ -466,26 +465,26 @@ ldap_pvt_tls_set_option( struct ldapoptions *lo, int option, void *arg )
        switch( option ) {
        case LDAP_OPT_X_TLS_CACERTFILE:
                if ( tls_opt_cacertfile ) free( tls_opt_cacertfile );
-               tls_opt_cacertfile = arg ? strdup( (char *) arg ) : NULL;
+               tls_opt_cacertfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
                break;
        case LDAP_OPT_X_TLS_CACERTDIR:
                if ( tls_opt_cacertdir ) free( tls_opt_cacertdir );
-               tls_opt_cacertdir = arg ? strdup( (char *) arg ) : NULL;
+               tls_opt_cacertdir = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
                break;
        case LDAP_OPT_X_TLS_CERTFILE:
                if ( tls_opt_certfile ) free( tls_opt_certfile );
-               tls_opt_certfile = arg ? strdup( (char *) arg ) : NULL;
+               tls_opt_certfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
                break;
        case LDAP_OPT_X_TLS_KEYFILE:
                if ( tls_opt_keyfile ) free( tls_opt_keyfile );
-               tls_opt_keyfile = arg ? strdup( (char *) arg ) : NULL;
+               tls_opt_keyfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
                break;
        case LDAP_OPT_X_TLS_REQUIRE_CERT:
                tls_opt_require_cert = * (int *) arg;
                break;
        case LDAP_OPT_X_TLS_CIPHER_SUITE:
                if ( tls_opt_ciphersuite ) free( tls_opt_ciphersuite );
-               tls_opt_ciphersuite = arg ? strdup( (char *) arg ) : NULL;
+               tls_opt_ciphersuite = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
                break;
        default:
                return -1;