/* $OpenLDAP$ */
-/*
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
* 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
+ * <http://www.OpenLDAP.org/license.html>.
*/
/*
#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;
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 }
};
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
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 );
}
#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" );
#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;
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;
} 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;
}
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;
int
load_extop(
struct berval *ext_oid,
+ slap_mask_t ext_flags,
SLAP_EXTOP_MAIN_FN *ext_main )
{
struct extop_list *ext;
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;
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);
}
{
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;