X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Foptions.c;h=a45cccecf77d5c6c7e9c1dca2e9fe608d717ab4b;hb=49d73e12a720cfe052a335d82e67994ff261d21c;hp=62af0ec4f96bf17a9a2e7fb87fbefe071a9df064;hpb=83e2f3854300453c1cba7d1f9022cd396d41d7d8;p=openldap diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c index 62af0ec4f9..a45cccecf7 100644 --- a/libraries/libldap/options.c +++ b/libraries/libldap/options.c @@ -1,6 +1,6 @@ /* $OpenLDAP$ */ /* - * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ @@ -16,6 +16,8 @@ #include "ldap-int.h" +#define LDAP_OPT_REBIND_PROC 0x4e814d + static const LDAPAPIFeatureInfo features[] = { #ifdef LDAP_API_FEATURE_X_OPENLDAP { /* OpenLDAP Extensions API Feature */ @@ -61,13 +63,6 @@ static const LDAPAPIFeatureInfo features[] = { LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE }, #endif -#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS - { /* DNS */ - LDAP_FEATURE_INFO_VERSION, - "X_OPENLDAP_V2_DNS", - LDAP_API_FEATURE_X_OPENLDAP_V2_DNS - }, -#endif #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS { /* V2 Referrals */ LDAP_FEATURE_INFO_VERSION, @@ -84,16 +79,19 @@ ldap_get_option( int option, void *outvalue) { - const struct ldapoptions *lo; + struct ldapoptions *lo; - if( ldap_int_global_options.ldo_valid != LDAP_INITIALIZED ) { - ldap_int_initialize(); + /* Get pointer to global option structure */ + lo = LDAP_INT_GLOBAL_OPT(); + if (NULL == lo) { + return LDAP_NO_MEMORY; } - if(ld == NULL) { - lo = &ldap_int_global_options; + if( lo->ldo_valid != LDAP_INITIALIZED ) { + ldap_int_initialize(lo, NULL); + } - } else { + if(ld != NULL) { assert( LDAP_VALID( ld ) ); if( !LDAP_VALID( ld ) ) { @@ -149,12 +147,12 @@ ldap_get_option( } break; case LDAP_OPT_DESC: - if(ld == NULL) { + if( ld == NULL || ld->ld_sb == NULL ) { /* bad param */ break; } - * (ber_socket_t *) outvalue = ber_pvt_sb_get_desc( &(ld->ld_sb) ); + ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, outvalue ); return LDAP_OPT_SUCCESS; case LDAP_OPT_TIMEOUT: @@ -193,16 +191,8 @@ ldap_get_option( * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_RESTART); return LDAP_OPT_SUCCESS; - case LDAP_OPT_DNS: /* LDAPv2 */ - * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_DNS); - return LDAP_OPT_SUCCESS; - case LDAP_OPT_PROTOCOL_VERSION: - if ((ld != NULL) && ld->ld_version) { - * (int *) outvalue = ld->ld_version; - } else { - * (int *) outvalue = lo->ldo_version; - } + * (int *) outvalue = lo->ldo_version; return LDAP_OPT_SUCCESS; case LDAP_OPT_SERVER_CONTROLS: @@ -293,6 +283,10 @@ ldap_get_option( #ifdef HAVE_TLS if ( ldap_pvt_tls_get_option((struct ldapoptions *)lo, option, outvalue ) == 0 ) return LDAP_OPT_SUCCESS; +#endif +#ifdef HAVE_CYRUS_SASL + if ( ldap_pvt_sasl_get_option(ld, option, outvalue ) == 0 ) + return LDAP_OPT_SUCCESS; #endif /* bad param */ break; @@ -308,15 +302,27 @@ ldap_set_option( LDAP_CONST void *invalue) { struct ldapoptions *lo; + int *dbglvl = NULL; - if( ldap_int_global_options.ldo_valid != LDAP_INITIALIZED ) { - ldap_int_initialize(); + /* Get pointer to global option structure */ + lo = LDAP_INT_GLOBAL_OPT(); + if (lo == NULL) { + return LDAP_NO_MEMORY; } - if(ld == NULL) { - lo = &ldap_int_global_options; + /* + * The architecture to turn on debugging has a chicken and egg + * problem. Thus, we introduce a fix here. + */ - } else { + if (option == LDAP_OPT_DEBUG_LEVEL) + dbglvl = (int *) invalue; + + if( lo->ldo_valid != LDAP_INITIALIZED ) { + ldap_int_initialize(lo, dbglvl); + } + + if(ld != NULL) { assert( LDAP_VALID( ld ) ); if( !LDAP_VALID( ld ) ) { @@ -411,6 +417,11 @@ ldap_set_option( return LDAP_OPT_ERROR; } } return LDAP_OPT_SUCCESS; + + /* Only accessed from inside this function by ldap_set_rebind_proc() */ + case LDAP_OPT_REBIND_PROC: { + lo->ldo_rebindproc = (LDAP_REBIND_PROC *)invalue; + } return LDAP_OPT_SUCCESS; } if(invalue == NULL) { @@ -444,7 +455,7 @@ ldap_set_option( /* not supported */ break; } - ld->ld_version = vers; + lo->ldo_version = vers; } return LDAP_OPT_SUCCESS; @@ -568,10 +579,20 @@ ldap_set_option( default: #ifdef HAVE_TLS if ( ldap_pvt_tls_set_option( lo, option, (void *)invalue ) == 0 ) - return LDAP_OPT_SUCCESS; + return LDAP_OPT_SUCCESS; +#endif +#ifdef HAVE_CYRUS_SASL + if ( ldap_pvt_sasl_set_option( ld, option, (void *)invalue ) == 0 ) + return LDAP_OPT_SUCCESS; #endif /* bad param */ break; } return LDAP_OPT_ERROR; } + +int +ldap_set_rebind_proc( LDAP *ld, LDAP_REBIND_PROC *rebind_proc) +{ + return( ldap_set_option( ld, LDAP_OPT_REBIND_PROC, (void *)rebind_proc)); +}