]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/extended.c
fix ITS#3753
[openldap] / servers / slapd / extended.c
index 3bd004c482cfb349f4c016fd51787db9b9c198fa..6d3237cae4b796b0de47efe423bc699a51dae28a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 
 #define UNSUPPORTED_EXOP "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;
@@ -77,7 +72,7 @@ static struct {
 } builtin_extops[] = {
        { &slap_EXOP_CANCEL, SLAP_EXOP_HIDE, cancel_extop },
        { &slap_EXOP_WHOAMI, 0, whoami_extop },
-       { &slap_EXOP_MODIFY_PASSWD, 0, passwd_extop },
+       { &slap_EXOP_MODIFY_PASSWD, SLAP_EXOP_WRITES, passwd_extop },
 #ifdef HAVE_TLS
        { &slap_EXOP_START_TLS, 0, starttls_extop },
 #endif
@@ -174,7 +169,7 @@ do_extended(
        } 
 
        /* check for controls inappropriate for all extended operations */
-       if( get_manageDSAit( op ) == SLAP_CRITICAL_CONTROL ) {
+       if( get_manageDSAit( op ) == SLAP_CONTROL_CRITICAL ) {
                send_ldap_error( op, rs,
                        LDAP_UNAVAILABLE_CRITICAL_EXTENSION,
                        "manageDSAit control inappropriate" );
@@ -188,6 +183,7 @@ do_extended(
 
        op->o_bd = frontendDB;
        rs->sr_err = frontendDB->be_extended( op, rs );
+
 done:
        return rs->sr_err;
 }
@@ -225,6 +221,8 @@ fe_extended( Operation *op, SlapReply *rs )
                goto done;
        }
 
+       op->ore_flags = ext->flags;
+
        Debug( LDAP_DEBUG_ARGS, "do_extended: oid=%s\n",
                op->ore_reqoid.bv_val, 0 ,0 );
 
@@ -295,9 +293,9 @@ done2:;
 
                if( rs->sr_err != SLAPD_ABANDON ) {
                        if ( rs->sr_err == LDAP_REFERRAL && rs->sr_ref == NULL ) {
-                               rs->sr_ref = referral_rewrite( SLAPD_GLOBAL(default_referral),
+                               rs->sr_ref = referral_rewrite( default_referral,
                                        NULL, NULL, LDAP_SCOPE_DEFAULT );
-                               if ( !rs->sr_ref ) rs->sr_ref = SLAPD_GLOBAL(default_referral);
+                               if ( !rs->sr_ref ) rs->sr_ref = default_referral;
                                if ( !rs->sr_ref ) {
                                        rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
                                        rs->sr_text = "referral missing";
@@ -306,7 +304,7 @@ done2:;
 
                        send_ldap_extended( op, rs );
 
-                       if ( rs->sr_ref != SLAPD_GLOBAL(default_referral) ) {
+                       if ( rs->sr_ref != default_referral ) {
                                ber_bvarray_free( rs->sr_ref );
                                rs->sr_ref = NULL;
                        }
@@ -416,10 +414,10 @@ whoami_extop (
 
        bv = (struct berval *) ch_malloc( sizeof(struct berval) );
        if( op->o_dn.bv_len ) {
-               bv->bv_len = op->o_dn.bv_len + sizeof("dn:")-1;
+               bv->bv_len = op->o_dn.bv_len + STRLENOF( "dn:" );
                bv->bv_val = ch_malloc( bv->bv_len + 1 );
-               AC_MEMCPY( bv->bv_val, "dn:", sizeof("dn:")-1 );
-               AC_MEMCPY( &bv->bv_val[sizeof("dn:")-1], op->o_dn.bv_val,
+               AC_MEMCPY( bv->bv_val, "dn:", STRLENOF( "dn:" ) );
+               AC_MEMCPY( &bv->bv_val[STRLENOF( "dn:" )], op->o_dn.bv_val,
                        op->o_dn.bv_len );
                bv->bv_val[bv->bv_len] = '\0';