extop_list_t *supp_ext_list = NULL;
+/* this list of built-in extops is for extops that are not part
+ * of backends or in external modules. essentially, this is
+ * just a way to get built-in extops onto the extop list without
+ * having a separate init routine for each built-in extop.
+ */
+struct {
+ char *oid;
+ SLAP_EXTOP_MAIN_FN ext_main;
+} builtin_extops[] = {
+#ifdef HAVE_TLS
+ { LDAP_EXOP_START_TLS, starttls_extop },
+#endif
+ { LDAP_EXOP_X_MODIFY_PASSWD, passwd_extop },
+ { NULL, NULL }
+ };
+
+
static extop_list_t *find_extop( extop_list_t *list, char *oid );
static int extop_callback(
)
{
int rc = LDAP_SUCCESS;
- char* oid;
+ char* reqoid;
struct berval *reqdata;
ber_tag_t tag;
ber_len_t len;
extop_list_t *ext;
char *text;
+ struct berval **refs;
+ char *rspoid;
struct berval *rspdata;
+ LDAPControl **rspctrls;
Debug( LDAP_DEBUG_TRACE, "do_extended\n", 0, 0, 0 );
- oid = NULL;
+ reqoid = NULL;
reqdata = NULL;
if( op->o_protocol < LDAP_VERSION3 ) {
goto done;
}
- if ( ber_scanf( op->o_ber, "{a" /*}*/, &oid ) == LBER_ERROR ) {
+ if ( ber_scanf( op->o_ber, "{a" /*}*/, &reqoid ) == LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 );
send_ldap_disconnect( conn, op,
LDAP_PROTOCOL_ERROR, "decoding error" );
goto done;
}
- if( !(ext = find_extop(supp_ext_list, oid)) ) {
+ if( !(ext = find_extop(supp_ext_list, reqoid)) ) {
Debug( LDAP_DEBUG_ANY, "do_extended: unsupported operation \"%s\"\n",
- oid, 0 ,0 );
+ reqoid, 0 ,0 );
send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
NULL, "unsupported extended operation", NULL, NULL );
goto done;
return rc;
}
- Debug( LDAP_DEBUG_ARGS, "do_extended: oid=%s\n", oid, 0 ,0 );
+ Debug( LDAP_DEBUG_ARGS, "do_extended: oid=%s\n", reqoid, 0 ,0 );
+ rspoid = NULL;
rspdata = NULL;
+ rspctrls = NULL;
text = NULL;
+ refs = NULL;
rc = (ext->ext_main)( extop_callback, conn, op,
- oid, reqdata, &rspdata, &text );
+ reqoid, reqdata,
+ &rspoid, &rspdata, &rspctrls, &text, &refs );
if( rc != SLAPD_ABANDON ) {
- send_ldap_extended( conn, op, rc, NULL, text,
- oid, rspdata );
+ if (rc == LDAP_REFERRAL) {
+ refs = default_referral;
+ }
+
+ send_ldap_extended( conn, op, rc, NULL, text, refs,
+ rspoid, rspdata, rspctrls );
+ }
+
+ if ( rspoid != NULL ) {
+ free( rspoid );
}
if ( rspdata != NULL )
if ( reqdata != NULL ) {
ber_bvfree( reqdata );
}
- if ( oid != NULL ) {
- free( oid );
+ if ( reqoid != NULL ) {
+ free( reqoid );
}
return rc;
return(0);
}
+int
+extops_init (void)
+{
+ int i;
+
+ for (i = 0; builtin_extops[i].oid != NULL; i++) {
+ load_extop(builtin_extops[i].oid, builtin_extops[i].ext_main);
+ }
+ return(0);
+}
+
+int
+extops_kill (void)
+{
+ extop_list_t *ext;
+
+ /* we allocated the memory, so we have to free it, too. */
+ while ((ext = supp_ext_list) != NULL) {
+ supp_ext_list = ext->next;
+ if (ext->oid != NULL)
+ ch_free(ext->oid);
+ ch_free(ext);
+ }
+ return(0);
+}
static extop_list_t *
find_extop( extop_list_t *list, char *oid )