X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fextended.c;h=7c2efda7bf4736ec09840d6eac9dfd1dca775c70;hb=12d5c6bba210de4a03363567be1c19a37f8e806b;hp=1a8ffe14c0c44ce2e9a36e3cdfabd8e9c0cdca43;hpb=e8c58b4e7f21caa6c0b6006e3528cbad9b8aed45;p=openldap diff --git a/servers/slapd/extended.c b/servers/slapd/extended.c index 1a8ffe14c0..7c2efda7bf 100644 --- a/servers/slapd/extended.c +++ b/servers/slapd/extended.c @@ -1,12 +1,16 @@ /* $OpenLDAP$ */ -/* +/* This work is part of OpenLDAP Software . + * * Copyright 1999-2003 The OpenLDAP Foundation. * All rights reserved. * - * Redistribution and use in source and binary forms are permitted only - * as authorized by the OpenLDAP Public License. A copy of this - * license is available at http://www.OpenLDAP.org/license.html or - * in file LICENSE in the top-level directory of the distribution. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . */ /* @@ -41,9 +45,16 @@ #define UNSUPPORTED_EXTENDEDOP "unsupported extended operation" +#ifdef LDAP_DEVEL +#define SLAP_EXOP_HIDE 0x0000 +#else +#define SLAP_EXOP_HIDE 0x8000 +#endif + static struct extop_list { struct extop_list *next; struct berval oid; + slap_mask_t flags; SLAP_EXTOP_MAIN_FN *ext_main; } *supp_ext_list = NULL; @@ -63,17 +74,18 @@ const struct berval slap_EXOP_START_TLS = BER_BVC(LDAP_EXOP_START_TLS); static struct { const struct berval *oid; + slap_mask_t flags; SLAP_EXTOP_MAIN_FN *ext_main; } builtin_extops[] = { #ifdef LDAP_EXOP_X_CANCEL - { &slap_EXOP_CANCEL, cancel_extop }, + { &slap_EXOP_CANCEL, SLAP_EXOP_HIDE, cancel_extop }, #endif - { &slap_EXOP_WHOAMI, whoami_extop }, - { &slap_EXOP_MODIFY_PASSWD, passwd_extop }, + { &slap_EXOP_WHOAMI, 0, whoami_extop }, + { &slap_EXOP_MODIFY_PASSWD, 0, passwd_extop }, #ifdef HAVE_TLS - { &slap_EXOP_START_TLS, starttls_extop }, + { &slap_EXOP_START_TLS, 0, starttls_extop }, #endif - { NULL, NULL } + { NULL, 0, NULL } }; @@ -94,7 +106,31 @@ get_supported_extop (int index) if (ext == NULL) return NULL; - return &ext->oid ; + return &ext->oid; +} + + +int exop_root_dse_info( Entry *e ) +{ + AttributeDescription *ad_supportedExtension + = slap_schema.si_ad_supportedExtension; + struct berval vals[2]; + struct extop_list *ext; + + vals[1].bv_val = NULL; + vals[1].bv_len = 0; + + for (ext = supp_ext_list; ext != NULL; ext = ext->next) { + if( ext->flags & SLAP_EXOP_HIDE ) continue; + + vals[0] = ext->oid; + + if( attr_merge( e, ad_supportedExtension, vals, NULL ) ) { + return LDAP_OTHER; + } + } + + return LDAP_SUCCESS; } int @@ -135,7 +171,7 @@ do_extended( goto done; } - if ( ber_scanf( op->o_ber, "{m" /*}*/, &op->oq_extended.rs_reqoid ) == LBER_ERROR ) { + if ( ber_scanf( op->o_ber, "{m" /*}*/, &op->ore_reqoid ) == LBER_ERROR ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, ERR, "do_extended: conn %d ber_scanf failed\n", op->o_connid, 0, 0 ); @@ -148,19 +184,19 @@ do_extended( } #ifdef LDAP_SLAPI - getPluginFunc( &op->oq_extended.rs_reqoid, &funcAddr ); /* NS-SLAPI extended operation */ - if( !funcAddr && !(ext = find_extop(supp_ext_list, &op->oq_extended.rs_reqoid ))) + getPluginFunc( &op->ore_reqoid, &funcAddr ); /* NS-SLAPI extended operation */ + if( !funcAddr && !(ext = find_extop(supp_ext_list, &op->ore_reqoid ))) #else - if( !(ext = find_extop(supp_ext_list, &op->oq_extended.rs_reqoid ))) + if( !(ext = find_extop(supp_ext_list, &op->ore_reqoid ))) #endif { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, ERR, "do_extended: conn %d unsupported operation \"%s\"\n", - op->o_connid, op->oq_extended.rs_reqoid.bv_val, 0 ); + op->o_connid, op->ore_reqoid.bv_val, 0 ); #else Debug( LDAP_DEBUG_ANY, "do_extended: unsupported operation \"%s\"\n", - op->oq_extended.rs_reqoid.bv_val, 0 ,0 ); + op->ore_reqoid.bv_val, 0 ,0 ); #endif send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR, "unsupported extended operation" ); @@ -204,43 +240,15 @@ do_extended( #ifdef NEW_LOGGING LDAP_LOG( OPERATION, DETAIL1, - "do_extended: conn %d oid=%s\n.", op->o_connid, op->oq_extended.rs_reqoid.bv_val, 0 ); + "do_extended: conn %d oid=%s\n.", op->o_connid, op->ore_reqoid.bv_val, 0 ); #else - Debug( LDAP_DEBUG_ARGS, "do_extended: oid=%s\n", op->oq_extended.rs_reqoid.bv_val, 0 ,0 ); + Debug( LDAP_DEBUG_ARGS, "do_extended: oid=%s\n", op->ore_reqoid.bv_val, 0 ,0 ); #endif #if defined(LDAP_SLAPI) - if (ext != NULL) { /* OpenLDAP extended operation */ -#endif /* defined(LDAP_SLAPI) */ - - if (reqdata.bv_val) op->oq_extended.rs_reqdata = &reqdata; - rs->sr_err = (ext->ext_main)( op, rs ); - - if( rs->sr_err != SLAPD_ABANDON ) { - if ( rs->sr_err == LDAP_REFERRAL && rs->sr_ref == NULL ) { - rs->sr_ref = referral_rewrite( default_referral, - NULL, NULL, LDAP_SCOPE_DEFAULT ); - } - - send_ldap_extended( op, rs ); - - ber_bvarray_free( rs->sr_ref ); - } - - if ( rs->sr_rspoid != NULL ) { - free( (char *)rs->sr_rspoid ); - } - - if ( rs->sr_rspdata != NULL ) { - ber_bvfree( rs->sr_rspdata ); - } - -#if defined( LDAP_SLAPI ) - goto done; /* end of OpenLDAP extended operation */ - - } else { /* start of Netscape extended operation */ + if ( funcAddr != NULL ) { rs->sr_err = slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_OID, - (void *)op->oq_extended.rs_reqoid.bv_val); + (void *)op->ore_reqoid.bv_val); if ( rs->sr_err != LDAP_SUCCESS ) { rs->sr_err = LDAP_OTHER; goto done; @@ -253,13 +261,7 @@ do_extended( goto done; } - rs->sr_err = slapi_x_connection_set_pb( pb, op->o_conn ); - if ( rs->sr_err != LDAP_SUCCESS ) { - rs->sr_err = LDAP_OTHER; - goto done; - } - - rs->sr_err = slapi_x_operation_set_pb( pb, op ); + rs->sr_err = slapi_x_pblock_set_operation( pb, op ); if ( rs->sr_err != LDAP_SUCCESS ) { rs->sr_err = LDAP_OTHER; goto done; @@ -275,13 +277,13 @@ do_extended( } else { rs->sr_err = slapi_pblock_get( pb, SLAPI_EXT_OP_RET_OID, - &rs->sr_resoid); + &rs->sr_rspoid); if ( rs->sr_err != LDAP_SUCCESS ) { goto done2; } rs->sr_err = slapi_pblock_get( pb, SLAPI_EXT_OP_RET_VALUE, - &rs->sr_resdata); + &rs->sr_rspdata); if ( rs->sr_err != LDAP_SUCCESS ) { goto done2; } @@ -296,16 +298,39 @@ done2:; send_ldap_result( op, rs ); } - if ( op->oq_extended.rs_resoid != NULL ) { - free( op->oq_extended.rs_resoid ); + if ( rs->sr_rspoid != NULL ) { + ch_free( (char *)rs->sr_rspoid ); } - if ( op->oq_extended.rs_resdata != NULL ) { - ber_bvfree( op->oq_extended.rs_resdata ); + if ( rs->sr_rspdata != NULL ) { + ber_bvfree( rs->sr_rspdata ); } - - } /* end of Netscape extended operation */ + } else { /* start of OpenLDAP extended operation */ #endif /* defined( LDAP_SLAPI ) */ + if (reqdata.bv_val) op->ore_reqdata = &reqdata; + rs->sr_err = (ext->ext_main)( op, rs ); + + if( rs->sr_err != SLAPD_ABANDON ) { + if ( rs->sr_err == LDAP_REFERRAL && rs->sr_ref == NULL ) { + rs->sr_ref = referral_rewrite( default_referral, + NULL, NULL, LDAP_SCOPE_DEFAULT ); + } + + send_ldap_extended( op, rs ); + + ber_bvarray_free( rs->sr_ref ); + } + + if ( rs->sr_rspoid != NULL ) { + free( (char *)rs->sr_rspoid ); + } + + if ( rs->sr_rspdata != NULL ) { + ber_bvfree( rs->sr_rspdata ); + } +#ifdef LDAP_SLAPI + } /* end of OpenLDAP extended operation */ +#endif /* LDAP_SLAPI */ done: return rs->sr_err; @@ -314,6 +339,7 @@ done: int load_extop( struct berval *ext_oid, + slap_mask_t ext_flags, SLAP_EXTOP_MAIN_FN *ext_main ) { struct extop_list *ext; @@ -326,6 +352,8 @@ load_extop( if (ext == NULL) return(-1); + ext->flags = ext_flags; + ext->oid.bv_val = (char *)(ext + 1); AC_MEMCPY( ext->oid.bv_val, ext_oid->bv_val, ext_oid->bv_len ); ext->oid.bv_len = ext_oid->bv_len; @@ -345,7 +373,9 @@ extops_init (void) int i; for (i = 0; builtin_extops[i].oid != NULL; i++) { - load_extop((struct berval *)builtin_extops[i].oid, builtin_extops[i].ext_main); + load_extop((struct berval *)builtin_extops[i].oid, + builtin_extops[i].flags, + builtin_extops[i].ext_main); } return(0); } @@ -383,7 +413,7 @@ whoami_extop ( { struct berval *bv; - if ( op->oq_extended.rs_reqdata != NULL ) { + if ( op->ore_reqdata != NULL ) { /* no request data should be provided */ rs->sr_text = "no request data expected"; return LDAP_PROTOCOL_ERROR;