]> git.sur5r.net Git - openldap/commitdiff
Sync with HEAD
authorKurt Zeilenga <kurt@openldap.org>
Fri, 19 Aug 2005 20:09:03 +0000 (20:09 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 19 Aug 2005 20:09:03 +0000 (20:09 +0000)
ready for 2.3.6?

28 files changed:
CHANGES
doc/drafts/draft-zeilenga-ldap-noop-xx.txt [new file with mode: 0644]
libraries/libldap/dntest.c
libraries/libldap/schema.c
servers/slapd/aci.c
servers/slapd/acl.c
servers/slapd/aclparse.c
servers/slapd/ad.c
servers/slapd/back-ldap/search.c
servers/slapd/back-meta/search.c
servers/slapd/backend.c
servers/slapd/modify.c
servers/slapd/overlays/ppolicy.c
servers/slapd/proto-slap.h
servers/slapd/schema_prep.c
servers/slapd/slap.h
servers/slapd/slapcommon.c
servers/slapd/slapi/slapi_overlay.c
tests/data/retcode.conf
tests/data/subtree-rename.out [new file with mode: 0644]
tests/progs/slapd-addel.c
tests/progs/slapd-modify.c
tests/progs/slapd-modrdn.c
tests/progs/slapd-read.c
tests/progs/slapd-search.c
tests/progs/slapd-tester.c
tests/scripts/defines.sh
tests/scripts/test040-subtree-rename [new file with mode: 0755]

diff --git a/CHANGES b/CHANGES
index bc66c47a2a28cf25678d39c6c558555f6316d509..715b234a6278eb38e0ac0ad8804f861c0ceabc50 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,29 +1,34 @@
 OpenLDAP 2.3 Change Log
 
 OpenLDAP 2.3.6 Engineering
+       3951
        Fixed slapd dnRelativeMatch return (ITS#3931)
-       Added slapd ACI syntax validater (ITS#3877)
-       Added slapd posixgroup ACL module to contrib
        Fixed slapd-bdb/hdb release entry in paged resposne
-       Added slapd-meta overlapping targets enhancement (ITS#3711)
        Fixed slapd-meta resources release issue (ITS#3943)
-       Updated slapo-syncprov CSN filter checks
        Fixed slapd-ldap/meta matched return (ITS#3942,ITS#3944)
        Fixed slapo-ppolicy reset lockouts issue (ITS#3946)
        Fixed nis.schema posixGroup object class kind (ITS#3941)
        Revert librewrite regex mutex change (ITS#3932)
+       Updated slapd manage capability
+       Updated slapo-syncprov CSN filter checks
        Updated libldap url list parsing
+       Added slapd SASL rootpw support (ITS#3845)
+       Added slapd Stats logging for additional cases
+       Added slapd ACI syntax validater (ITS#3877)
+       Added slapd posixgroup ACL module to contrib
        Added slapi SLAPI_X_ADD_STRUCTURAL_CLASS extension
-       Add slapd SASL rootpw support (ITS#3845)
-       Add slapd Stats logging for additional cases
+       Added slapd-ldap subtree renaming proxing
+       Added slapd-meta overlapping targets enhancement (ITS#3711)
        Removed lint
        Documentation
                Added slapcat(8) -a usage example (ITS#3930)
                Updated slapo-unique(5) for clarity (ITS#3936)
                Updated slapo-syncprov(5) sessionlog description (ITS#3935)
+               Updated doc/drafts
        Build Environment
                Updated test prog bind retry code
                Fixed test015-xsearch regression (ITS#3506)
+               Added test040-subtree-rename
 
 OpenLDAP 2.3.5 Release
        Fixed slapd integerBitOr/AndMatch logic (ITS#3782)
diff --git a/doc/drafts/draft-zeilenga-ldap-noop-xx.txt b/doc/drafts/draft-zeilenga-ldap-noop-xx.txt
new file mode 100644 (file)
index 0000000..9c65f9b
--- /dev/null
@@ -0,0 +1,340 @@
+
+
+
+
+
+INTERNET-DRAFT                                      Kurt D. Zeilenga
+Intended Category: Standard Track                OpenLDAP Foundation
+Expires in six months                               10 February 2005
+
+
+
+                          The LDAP No-Op Control
+                    <draft-zeilenga-ldap-noop-06.txt>
+
+
+Status of this Memo
+
+  This document is intended to be, after appropriate review and
+  revision, submitted to the IESG for consideration as a Standard Track
+  document.  Distribution of this memo is unlimited.  Technical
+  discussion of this document will take place on the IETF LDAP
+  Extensions mailing list <ldapext@ietf.org>.  Please send editorial
+  comments directly to the author <Kurt@OpenLDAP.org>.
+
+  By submitting this Internet-Draft, I accept the provisions of Section
+  4 of RFC 3667.  By submitting this Internet-Draft, I certify that any
+  applicable patent or other IPR claims of which I am aware have been
+  disclosed, or will be disclosed, and any of which I become aware will
+  be disclosed, in accordance with RFC 3668.
+
+  Internet-Drafts are working documents of the Internet Engineering Task
+  Force (IETF), its areas, and its working groups. Note that other
+  groups may also distribute working documents as Internet-Drafts.
+
+  Internet-Drafts are draft documents valid for a maximum of six months
+  and may be updated, replaced, or obsoleted by other documents at any
+  time. It is inappropriate to use Internet-Drafts as reference material
+  or to cite them other than as "work in progress."
+
+  The list of current Internet-Drafts can be accessed at
+  http://www.ietf.org/1id-abstracts.html
+
+  The list of Internet-Draft Shadow Directories can be accessed at
+  http://www.ietf.org/shadow.html
+
+
+  Copyright (C) The Internet Society (2005).  All Rights Reserved.
+
+  Please see the Full Copyright section near the end of this document
+  for more information.
+
+
+
+
+
+
+Zeilenga                   LDAP No-Op Control                   [Page 1]
+\f
+INTERNET-DRAFT         draft-zeilenga-ldap-noop-06      10 February 2005
+
+
+Abstract
+
+  This document defines the Lightweight Directory Access Protocol (LDAP)
+  No-Op control which can be used to disable the normal effect of an
+  operation.  The control can be used to discover how a server might
+  react to a particular update request without updating the directory.
+
+
+1.  Overview
+
+  It is often desirable to be able to determine if a directory operation
+  [Protocol] would successful complete or not without having the normal
+  effect of the operation take place.  For example, an administrative
+  client might want to verify that new user could update their entry
+  (and not other entries) without the directory actually being updated.
+  The mechanism could be used to build more sophisticated security
+  auditing tools.
+
+  This document defines the Lightweight Directory Access Protocol (LDAP)
+  [Roadmap] No-Op control extension.  The presence of the No-Op control
+  in an operation request message disables its normal effect upon the
+  directory which operation would otherwise have.  Instead of updating
+  the directory and return the normal indication of success, the server
+  does not update the directory and indicates so by returning the
+  noOperation resultCode (introduced below).
+
+  For example, when the No-Op control is present in a LDAP modify
+  operation [Protocol], the server is do all processing necessary to
+  perform the operation without actually updating the directory.  If it
+  detects an error during this processing, it returns a non-success
+  (other than noOperation) resultCode as it normally would.  Otherwise,
+  it returns the noOperation.  In either case, the directory is left
+  unchanged.
+
+  This No-Op control is not intended to be to an "effective access"
+  mechanism [RFC2820, U12].
+
+
+1.1.  Terminology
+
+  The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
+  "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
+  document are to be interpreted as described in BCP 14 [RFC2119].
+
+  DN stands for Distinguished Name.
+  DSA stands for Directory System Agent.
+  DSE stands for DSA-specific entry.
+
+
+
+
+Zeilenga                   LDAP No-Op Control                   [Page 2]
+\f
+INTERNET-DRAFT         draft-zeilenga-ldap-noop-06      10 February 2005
+
+
+2.  No-Op Control
+
+  The No-Op control is an LDAP Control [Protocol] whose controlType is
+  IANA-ASSIGNED-OID and controlValue is absent.  Clients MUST provide a
+  criticality value of TRUE to prevent unintended modification of the
+  directory.
+
+  The control is appropriate for request messages of LDAP Add, Delete,
+  Modify and ModifyDN operations [Protocol].  The control is also
+  appropriate for requests of extended operations which update the
+  directory (or other data stores), such as Password Modify Extended
+  Operation [RFC3062].  There is no corresponding response control.
+
+  When the control is attached to an LDAP request, the server does all
+  normal processing possible for the operation without modification of
+  the directory.  That is, when the control is attached to an LDAP
+  request, the directory SHALL NOT be updated and the response SHALL NOT
+  have a resultCode of success (0).
+
+  A result code other than noOperation (IANA-ASSIGNED-CODE) means that
+  the server is unable or unwilling to complete the processing for the
+  reason indicated by the result code.  A result code of noOperation
+  (IANA-ASSIGNED-CODE) indicates that the server discovered no reason
+  why the operation would fail if submitted without the No-Op control.
+
+  Servers SHOULD indicate their support for this control by providing
+  IANA-ASSIGNED-OID as a value of the 'supportedControl' attribute type
+  [Models] in their root DSE entry.  A server MAY choose to advertise
+  this extension only when the client is authorized to use this
+  operation.
+
+
+3.  Security Considerations
+
+  The No-Op control mechanism allows directory administrators and users
+  to verify that access control and other administrative policy controls
+  are properly configured.  The mechanism may also lead to the
+  development (and deployment) of more effective security auditing
+  tools.
+
+  Implementors of this LDAP extension should be familiar with security
+  considerations applicable to the LDAP operations [Protocol] extended
+  by this control, as well as general LDAP security considerations
+  [Roadmap].
+
+
+4.  IANA Considerations
+
+
+
+
+Zeilenga                   LDAP No-Op Control                   [Page 3]
+\f
+INTERNET-DRAFT         draft-zeilenga-ldap-noop-06      10 February 2005
+
+
+4.1.  Object Identifier
+
+  It is requested that IANA assign an LDAP Object Identifier [BCP64bis]
+  to identify the LDAP No-Op Control defined in this document.
+
+      Subject: Request for LDAP Object Identifier Registration
+      Person & email address to contact for further information:
+          Kurt Zeilenga <kurt@OpenLDAP.org>
+      Specification: RFC XXXX
+      Author/Change Controller: IESG
+      Comments:
+          Identifies the LDAP No-Op Control
+
+
+4.2  LDAP Protocol Mechanism
+
+  Registration of this protocol mechanism is requested [RFC3383].
+
+  Subject: Request for LDAP Protocol Mechanism Registration
+  Object Identifier: IANA-ASSIGNED-OID
+  Description: No-Op Control
+  Person & email address to contact for further information:
+      Kurt Zeilenga <kurt@openldap.org>
+  Usage: Control
+  Specification: RFC XXXX
+  Author/Change Controller: IESG
+  Comments: none
+
+
+4.3  LDAP Result Code
+
+  Assignment of an LDAP Result Code called 'noOperation' is requested.
+
+      Subject: LDAP Result Code Registration
+      Person & email address to contact for further information:
+          Kurt Zeilenga <kurt@OpenLDAP.org>
+      Result Code Name: noOperation
+      Specification: RFC XXXX
+      Author/Change Controller: IESG
+      Comments:  none
+
+
+5.  Author's Address
+
+  Kurt D. Zeilenga
+  OpenLDAP Foundation
+
+  Email: Kurt@OpenLDAP.org
+
+
+
+Zeilenga                   LDAP No-Op Control                   [Page 4]
+\f
+INTERNET-DRAFT         draft-zeilenga-ldap-noop-06      10 February 2005
+
+
+6. References
+
+  [[Note to the RFC Editor: please replace the citation tags used in
+  referencing Internet-Drafts with tags of the form RFCnnnn where
+  possible.]]
+
+
+6.1. Normative References
+
+  [RFC2119]     Bradner, S., "Key words for use in RFCs to Indicate
+                Requirement Levels", BCP 14 (also RFC 2119), March 1997.
+
+  [Protocol]    Sermersheim, J. (editor), "LDAP: The Protocol",
+                draft-ietf-ldapbis-protocol-xx.txt, a work in progress.
+
+  [Roadmap]     Zeilenga, K. (editor), "LDAP: Technical Specification
+                Road Map", draft-ietf-ldapbis-roadmap-xx.txt, a work in
+                progress.
+
+  [Models]      Zeilenga, K. (editor), "LDAP: Directory Information
+                Models", draft-ietf-ldapbis-models-xx.txt, a work in
+                progress.
+
+
+6.2. Informative References
+
+  [X.500]       International Telecommunication Union -
+                Telecommunication Standardization Sector, "The Directory
+                -- Overview of concepts, models and services,"
+                X.500(1993) (also ISO/IEC 9594-1:1994).
+
+  [RFC2820]     Stokes, E., et. al., "Access Control Requirements for
+                LDAP", RFC 2820, May 2000.
+
+  [RFC3062]     Zeilenga, K., "LDAP Password Modify Extended Operation",
+                RFC 3062, February 2000.
+
+  [BCP64bis]    Zeilenga, K., "IANA Considerations for LDAP",
+                draft-ietf-ldapbis-bcp64-xx.txt, a work in progress.
+
+
+
+Intellectual Property Rights
+
+  The IETF takes no position regarding the validity or scope of any
+  Intellectual Property Rights or other rights that might be claimed to
+  pertain to the implementation or use of the technology described in
+  this document or the extent to which any license under such rights
+
+
+
+Zeilenga                   LDAP No-Op Control                   [Page 5]
+\f
+INTERNET-DRAFT         draft-zeilenga-ldap-noop-06      10 February 2005
+
+
+  might or might not be available; nor does it represent that it has
+  made any independent effort to identify any such rights.  Information
+  on the procedures with respect to rights in RFC documents can be found
+  in BCP 78 and BCP 79.
+
+  Copies of IPR disclosures made to the IETF Secretariat and any
+  assurances of licenses to be made available, or the result of an
+  attempt made to obtain a general license or permission for the use of
+  such proprietary rights by implementers or users of this specification
+  can be obtained from the IETF on-line IPR repository at
+  http://www.ietf.org/ipr.
+
+  The IETF invites any interested party to bring to its attention any
+  copyrights, patents or patent applications, or other proprietary
+  rights that may cover technology that may be required to implement
+  this standard.  Please address the information to the IETF at
+  ietf-ipr@ietf.org.
+
+
+
+Full Copyright
+
+  Copyright (C) The Internet Society (2005).  This document is subject
+  to the rights, licenses and restrictions contained in BCP 78, and
+  except as set forth therein, the authors retain all their rights.
+
+  This document and the information contained herein are provided on an
+  "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
+  OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
+  ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
+  INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
+  INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
+  WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Zeilenga                   LDAP No-Op Control                   [Page 6]
+\f
+
+
index 9e0abe37ee48c44b8da5074f292034b8a1c8e738..e99a0570c61926216117be556f33a4c58160e76c 100644 (file)
@@ -171,31 +171,32 @@ main( int argc, char *argv[] )
                case LDAP_DN_FORMAT_LDAPV3:
                case LDAP_DN_FORMAT_LDAPV2:
                        n = ldap_dn2domain( strin, &tmp );
-                       if( n ) {
+                       if ( n ) {
                                fprintf( stdout, "\nldap_dn2domain(\"%s\") FAILED\n", strin );
                        } else {
                                fprintf( stdout, "\nldap_dn2domain(\"%s\")\n"
-                                       "\t= \"%s\"\n", strin, tmp );
+                                       "\t= \"%s\"\n", strin, tmp ? tmp : "" );
                        }
                        ldap_memfree( tmp );
 
                        tmp = ldap_dn2ufn( strin );
                        fprintf( stdout, "\nldap_dn2ufn(\"%s\")\n"
-                                       "\t= \"%s\"\n", strin, tmp );
+                                       "\t= \"%s\"\n", strin, tmp ? tmp : "" );
                        ldap_memfree( tmp );
 
                        tmp = ldap_dn2dcedn( strin );
                        fprintf( stdout, "\nldap_dn2dcedn(\"%s\")\n"
-                                       "\t= \"%s\"\n", strin, tmp );
+                                       "\t= \"%s\"\n", strin, tmp ? tmp : "" );
                        tmp2 = ldap_dcedn2dn( tmp );
                        fprintf( stdout, "\nldap_dcedn2dn(\"%s\")\n"
-                                       "\t= \"%s\"\n", tmp, tmp2 );
+                                       "\t= \"%s\"\n",
+                                       tmp ? tmp : "", tmp2 ? tmp2 : "" );
                        ldap_memfree( tmp );
                        ldap_memfree( tmp2 );
 
                        tmp = ldap_dn2ad_canonical( strin );
                        fprintf( stdout, "\nldap_dn2ad_canonical(\"%s\")\n"
-                                       "\t= \"%s\"\n", strin, tmp );
+                                       "\t= \"%s\"\n", strin, tmp ? tmp : "" );
                        ldap_memfree( tmp );
 
                        fprintf( stdout, "\nldap_explode_dn(\"%s\"):\n", str );
index 07a315a9572ba08e22f4e628dbac2bf789b6787a..bff6c5bdbe11db353cbb016bc8a49f0a14ea314a 100644 (file)
@@ -959,21 +959,23 @@ ldap_attributetype2bv(  LDAPAttributeType * at, struct berval *bv )
  * interpretation of the specs).
  */
 
-#define TK_NOENDQUOTE  -2
-#define TK_OUTOFMEM    -1
-#define TK_EOS         0
-#define TK_UNEXPCHAR   1
-#define TK_BAREWORD    2
-#define TK_QDSTRING    3
-#define TK_LEFTPAREN   4
-#define TK_RIGHTPAREN  5
-#define TK_DOLLAR      6
-#define TK_QDESCR      TK_QDSTRING
-
-static int
+typedef enum tk_t {
+       TK_NOENDQUOTE   = -2,
+       TK_OUTOFMEM     = -1,
+       TK_EOS          = 0,
+       TK_UNEXPCHAR    = 1,
+       TK_BAREWORD     = 2,
+       TK_QDSTRING     = 3,
+       TK_LEFTPAREN    = 4,
+       TK_RIGHTPAREN   = 5,
+       TK_DOLLAR       = 6,
+       TK_QDESCR       = TK_QDSTRING
+} tk_t;
+
+static tk_t
 get_token( const char ** sp, char ** token_val )
 {
-       int kind;
+       tk_t kind;
        const char * p;
        const char * q;
        char * res;
@@ -1145,7 +1147,7 @@ parse_qdescrs(const char **sp, int *code)
 {
        char ** res;
        char ** res1;
-       int kind;
+       tk_t kind;
        char * sval;
        int size;
        int pos;
@@ -1212,7 +1214,7 @@ static char *
 parse_woid(const char **sp, int *code)
 {
        char * sval;
-       int kind;
+       tk_t kind;
 
        parse_whsp(sp);
        kind = get_token(sp, &sval);
@@ -1227,10 +1229,13 @@ parse_woid(const char **sp, int *code)
 
 /* Parse a noidlen */
 static char *
-parse_noidlen(const char **sp, int *code, int *len, int allow_quoted)
+parse_noidlen(const char **sp, int *code, int *len, int flags)
 {
        char * sval;
+       const char *savepos;
        int quoted = 0;
+       int allow_quoted = ( flags & LDAP_SCHEMA_ALLOW_QUOTED );
+       int allow_oidmacro = ( flags & LDAP_SCHEMA_ALLOW_OID_MACRO );
 
        *len = 0;
        /* Netscape puts the SYNTAX value in quotes (incorrectly) */
@@ -1238,9 +1243,22 @@ parse_noidlen(const char **sp, int *code, int *len, int allow_quoted)
                quoted = 1;
                (*sp)++;
        }
+       savepos = *sp;
        sval = ldap_int_parse_numericoid(sp, code, 0);
        if ( !sval ) {
-               return NULL;
+               if ( allow_oidmacro
+                       && *sp == savepos
+                       && *code == LDAP_SCHERR_NODIGIT )
+               {
+                       if ( get_token(sp, &sval) != TK_BAREWORD ) {
+                               if ( sval != NULL ) {
+                                       LDAP_FREE(sval);
+                               }
+                               return NULL;
+                       }
+               } else {
+                       return NULL;
+               }
        }
        if ( **sp == '{' /*}*/ ) {
                (*sp)++;
@@ -1279,7 +1297,7 @@ parse_oids(const char **sp, int *code, const int allow_quoted)
 {
        char ** res;
        char ** res1;
-       int kind;
+       tk_t kind;
        char * sval;
        int size;
        int pos;
@@ -1441,7 +1459,7 @@ ldap_str2syntax( LDAP_CONST char * s,
        LDAP_CONST char ** errp,
        LDAP_CONST unsigned flags )
 {
-       int kind;
+       tk_t kind;
        const char * ss = s;
        char * sval;
        int seen_name = 0;
@@ -1583,7 +1601,7 @@ ldap_str2matchingrule( LDAP_CONST char * s,
        LDAP_CONST char ** errp,
        LDAP_CONST unsigned flags )
 {
-       int kind;
+       tk_t kind;
        const char * ss = s;
        char * sval;
        int seen_name = 0;
@@ -1782,7 +1800,7 @@ ldap_str2matchingruleuse( LDAP_CONST char * s,
        LDAP_CONST char ** errp,
        LDAP_CONST unsigned flags )
 {
-       int kind;
+       tk_t kind;
        const char * ss = s;
        char * sval;
        int seen_name = 0;
@@ -1984,7 +2002,7 @@ ldap_str2attributetype( LDAP_CONST char * s,
        LDAP_CONST char ** errp,
        LDAP_CONST unsigned flags )
 {
-       int kind;
+       tk_t kind;
        const char * ss = s;
        char * sval;
        int seen_name = 0;
@@ -2362,7 +2380,7 @@ ldap_str2objectclass( LDAP_CONST char * s,
        LDAP_CONST char ** errp,
        LDAP_CONST unsigned flags )
 {
-       int kind;
+       tk_t kind;
        const char * ss = s;
        char * sval;
        int seen_name = 0;
@@ -2437,6 +2455,7 @@ ldap_str2objectclass( LDAP_CONST char * s,
                                }
                        }
                        LDAP_FREE(sval);
+                       *code = 0;
                } else {
                        *errp = ss;
                        ldap_objectclass_free(oc);
@@ -2525,6 +2544,7 @@ ldap_str2objectclass( LDAP_CONST char * s,
                                        ldap_objectclass_free(oc);
                                        return NULL;
                                }
+                               *code = 0;
                        } else if ( !strcasecmp(sval,"ABSTRACT") ) {
                                LDAP_FREE(sval);
                                if ( seen_kind ) {
@@ -2573,6 +2593,7 @@ ldap_str2objectclass( LDAP_CONST char * s,
                                        ldap_objectclass_free(oc);
                                        return NULL;
                                }
+                               *code = 0;
                                parse_whsp(&ss);
                        } else if ( !strcasecmp(sval,"MAY") ) {
                                LDAP_FREE(sval);
@@ -2589,10 +2610,12 @@ ldap_str2objectclass( LDAP_CONST char * s,
                                        ldap_objectclass_free(oc);
                                        return NULL;
                                }
+                               *code = 0;
                                parse_whsp(&ss);
                        } else if ( sval[0] == 'X' && sval[1] == '-' ) {
                                /* Should be parse_qdstrings */
                                ext_vals = parse_qdescrs(&ss, code);
+                               *code = 0;
                                if ( !ext_vals ) {
                                        *errp = ss;
                                        ldap_objectclass_free(oc);
@@ -2644,7 +2667,7 @@ ldap_str2contentrule( LDAP_CONST char * s,
        LDAP_CONST char ** errp,
        LDAP_CONST unsigned flags )
 {
-       int kind;
+       tk_t kind;
        const char * ss = s;
        char * sval;
        int seen_name = 0;
@@ -2898,7 +2921,8 @@ ldap_str2structurerule( LDAP_CONST char * s,
        LDAP_CONST char ** errp,
        LDAP_CONST unsigned flags )
 {
-       int kind, ret;
+       tk_t kind;
+       int ret;
        const char * ss = s;
        char * sval;
        int seen_name = 0;
@@ -3081,7 +3105,7 @@ ldap_str2nameform( LDAP_CONST char * s,
        LDAP_CONST char ** errp,
        LDAP_CONST unsigned flags )
 {
-       int kind;
+       tk_t kind;
        const char * ss = s;
        char * sval;
        int seen_name = 0;
index 3d587cd9e661bb7d69ae376b534fb657fbcb8c86..bfceacf03d90409f47d6a9949eb7fc83dc81e9cf 100644 (file)
@@ -348,8 +348,7 @@ aci_mask(
         * both match "subtree" */
        switch ( asserted_scope ) {
        case SLAP_ACI_SCOPE_ENTRY:
-               /* TODO: use ber_bvcmp */
-               if ( ber_bvstrcasecmp( &scope, &aci_bv[ ACI_BV_ENTRY ] ) != 0
+               if ( ber_bvcmp( &scope, &aci_bv[ ACI_BV_ENTRY ] ) != 0
                                && ber_bvstrcasecmp( &scope, &aci_bv[ ACI_BV_SUBTREE ] ) != 0 )
                {
                        return 0;
@@ -357,22 +356,21 @@ aci_mask(
                break;
 
        case SLAP_ACI_SCOPE_CHILDREN:
-               /* TODO: use ber_bvcmp */
-               if ( ber_bvstrcasecmp( &scope, &aci_bv[ ACI_BV_CHILDREN ] ) != 0
+               if ( ber_bvcmp( &scope, &aci_bv[ ACI_BV_CHILDREN ] ) != 0
                                && ber_bvstrcasecmp( &scope, &aci_bv[ ACI_BV_SUBTREE ] ) != 0 )
                {
                        return 0;
                }
                break;
 
-       default:
-               /* TODO: add assertion */
+       case SLAP_ACI_SCOPE_SUBTREE:
+               /* TODO: add assertion? */
                return 0;
        }
 
        /* get the list of permissions clauses, bail if empty */
        if ( acl_get_part( aci, 2, '#', &perms ) <= 0 ) {
-               /* TODO: add assertion */
+               assert( 0 );
                return 0;
        }
 
@@ -383,13 +381,12 @@ aci_mask(
 
        /* see if we have a DN match */
        if ( acl_get_part( aci, 3, '#', &type ) < 0 ) {
-               /* TODO: add assertion */
+               assert( 0 );
                return 0;
        }
 
        /* see if we have a public (i.e. anonymous) access */
-       /* TODO: use ber_bvcmp */
-       if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_PUBLIC ], &type ) == 0 ) {
+       if ( ber_bvcmp( &aci_bv[ ACI_BV_PUBLIC ], &type ) == 0 ) {
                return 1;
        }
        
@@ -399,8 +396,7 @@ aci_mask(
        }
 
        /* see if we have a users access */
-       /* TODO: use ber_bvcmp */
-       if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_USERS ], &type ) == 0 ) {
+       if ( ber_bvcmp( &aci_bv[ ACI_BV_USERS ], &type ) == 0 ) {
                return 1;
        }
        
@@ -417,95 +413,32 @@ aci_mask(
        sdn.bv_val = type.bv_val + type.bv_len + STRLENOF( "#" );
        sdn.bv_len = aci->bv_len - ( sdn.bv_val - aci->bv_val );
 
-       /* TODO: use ber_bvcmp */
-       if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_ACCESS_ID ], &type ) == 0 ) {
-               struct berval ndn;
-               
-               /* TODO: don't normalize */
-               rc = dnNormalize( 0, NULL, NULL, &sdn, &ndn, op->o_tmpmemctx );
-               if ( rc != LDAP_SUCCESS ) {
-                       return 0;
-               }
-
-               if ( dn_match( &op->o_ndn, &ndn ) ) {
-                       rc = 1;
-               }
-               slap_sl_free( ndn.bv_val, op->o_tmpmemctx );
-
-               return rc;
-
-       /* TODO: use ber_bvcmp */
-       } else if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_SUBTREE ], &type ) == 0 ) {
-               struct berval ndn;
-               
-               /* TODO: don't normalize */
-               rc = dnNormalize( 0, NULL, NULL, &sdn, &ndn, op->o_tmpmemctx );
-               if ( rc != LDAP_SUCCESS ) {
-                       return 0;
-               }
-
-               if ( dnIsSuffix( &op->o_ndn, &ndn ) ) {
-                       rc = 1;
-               }
-               slap_sl_free( ndn.bv_val, op->o_tmpmemctx );
-
-               return rc;
-
-       /* TODO: use ber_bvcmp */
-       } else if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_ONELEVEL ], &type ) == 0 ) {
-               struct berval ndn, pndn;
-               
-               /* TODO: don't normalize */
-               rc = dnNormalize( 0, NULL, NULL, &sdn, &ndn, op->o_tmpmemctx );
-               if ( rc != LDAP_SUCCESS ) {
-                       return 0;
-               }
-
-               dnParent( &ndn, &pndn );
-
-               if ( dn_match( &op->o_ndn, &pndn ) ) {
-                       rc = 1;
-               }
-               slap_sl_free( ndn.bv_val, op->o_tmpmemctx );
+       if ( ber_bvcmp( &aci_bv[ ACI_BV_ACCESS_ID ], &type ) == 0 ) {
+               return dn_match( &op->o_ndn, &sdn );
 
-               return rc;
+       } else if ( ber_bvcmp( &aci_bv[ ACI_BV_SUBTREE ], &type ) == 0 ) {
+               return dnIsSuffix( &op->o_ndn, &sdn );
 
-       /* TODO: use ber_bvcmp */
-       } else if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_CHILDREN ], &type ) == 0 ) {
-               struct berval ndn;
+       } else if ( ber_bvcmp( &aci_bv[ ACI_BV_ONELEVEL ], &type ) == 0 ) {
+               struct berval pdn;
                
-               /* TODO: don't normalize */
-               rc = dnNormalize( 0, NULL, NULL, &sdn, &ndn, op->o_tmpmemctx );
-               if ( rc != LDAP_SUCCESS ) {
-                       return 0;
-               }
+               dnParent( &sdn, &pdn );
 
-               if ( !dn_match( &op->o_ndn, &ndn )
-                               && dnIsSuffix( &op->o_ndn, &ndn ) )
-               {
-                       rc = 1;
-               }
-               slap_sl_free( ndn.bv_val, op->o_tmpmemctx );
+               return dn_match( &op->o_ndn, &pdn );
 
-               return rc;
+       } else if ( ber_bvcmp( &aci_bv[ ACI_BV_CHILDREN ], &type ) == 0 ) {
+               return ( !dn_match( &op->o_ndn, &sdn ) && dnIsSuffix( &op->o_ndn, &sdn ) );
 
-       /* TODO: use ber_bvcmp */
-       } else if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_SELF ], &type ) == 0 ) {
-               if ( dn_match( &op->o_ndn, &e->e_nname ) ) {
-                       return 1;
-               }
+       } else if ( ber_bvcmp( &aci_bv[ ACI_BV_SELF ], &type ) == 0 ) {
+               return dn_match( &op->o_ndn, &e->e_nname );
 
-       /* TODO: use ber_bvcmp */
-       } else if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_DNATTR ], &type ) == 0 ) {
+       } else if ( ber_bvcmp( &aci_bv[ ACI_BV_DNATTR ], &type ) == 0 ) {
                Attribute               *at;
                AttributeDescription    *ad = NULL;
                const char              *text;
 
                rc = slap_bv2ad( &sdn, &ad, &text );
-               if ( rc != LDAP_SUCCESS ) {
-                       /* TODO: add assertion */
-                       return 0;
-               }
+               assert( rc == LDAP_SUCCESS );
 
                rc = 0;
                for ( at = attrs_find( e->e_attrs, ad );
@@ -525,30 +458,26 @@ aci_mask(
 
                return rc;
 
-       /* TODO: use ber_bvcmp */
-       } else if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_GROUP ], &type ) == 0 ) {
+       } else if ( ber_bvcmp( &aci_bv[ ACI_BV_GROUP ], &type ) == 0 ) {
                if ( aci_group_member( &sdn, &aci_bv[ ACI_BV_GROUP_CLASS ],
                                &aci_bv[ ACI_BV_GROUP_ATTR ], op, e, nmatch, matches ) )
                {
                        return 1;
                }
 
-       /* TODO: use ber_bvcmp */
-       } else if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_ROLE ], &type ) == 0 ) {
+       } else if ( ber_bvcmp( &aci_bv[ ACI_BV_ROLE ], &type ) == 0 ) {
                if ( aci_group_member( &sdn, &aci_bv[ ACI_BV_ROLE_CLASS ],
                                &aci_bv[ ACI_BV_ROLE_ATTR ], op, e, nmatch, matches ) )
                {
                        return 1;
                }
 
-       /* TODO: use ber_bvcmp */
-       } else if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_SET ], &type ) == 0 ) {
+       } else if ( ber_bvcmp( &aci_bv[ ACI_BV_SET ], &type ) == 0 ) {
                if ( acl_match_set( &sdn, op, e, 0 ) ) {
                        return 1;
                }
 
-       /* TODO: use ber_bvcmp */
-       } else if ( ber_bvstrcasecmp( &aci_bv[ ACI_BV_SET_REF ], &type ) == 0 ) {
+       } else if ( ber_bvcmp( &aci_bv[ ACI_BV_SET_REF ], &type ) == 0 ) {
                if ( acl_match_set( &sdn, op, e, 1 ) ) {
                        return 1;
                }
@@ -1079,6 +1008,7 @@ OpenLDAPaciNormalizeRights(
 static const struct berval *OpenLDAPaciscopes[] = {
        &aci_bv[ ACI_BV_ENTRY ],
        &aci_bv[ ACI_BV_CHILDREN ],
+       &aci_bv[ ACI_BV_SUBTREE ],
 
        NULL
 };
index d6bc21d3118c8f69c9902ac5317b946499accf58..a96104f84fa925b21f9123283e91db5566cdd107 100644 (file)
@@ -192,8 +192,12 @@ slap_access_allowed(
         * no-user-modification operational attributes are ignored
         * by ACL_WRITE checking as any found here are not provided
         * by the user
+        *
+        * NOTE: but they are not ignored for ACL_MANAGE, because
+        * if we get here it means a non-root user is trying to 
+        * manage data, so we need to check its privileges.
         */
-       if ( access_level >= ACL_WRITE && is_at_no_user_mod( desc->ad_type )
+       if ( access_level == ACL_WRITE && is_at_no_user_mod( desc->ad_type )
                && desc != slap_schema.si_ad_entry
                && desc != slap_schema.si_ad_children )
        {
@@ -384,10 +388,17 @@ access_allowed_mask(
 
        assert( attr != NULL );
 
-       if ( op && op->o_is_auth_check &&
-               ( access_level == ACL_SEARCH || access_level == ACL_READ ) )
-       {
-               access = ACL_AUTH;
+       if ( op ) {
+               if ( op->o_is_auth_check &&
+                       ( access_level == ACL_SEARCH || access_level == ACL_READ ) )
+               {
+                       access = ACL_AUTH;
+
+               } else if ( get_manageDIT( op ) && access_level == ACL_WRITE &&
+                       desc == slap_schema.si_ad_entry )
+               {
+                       access = ACL_MANAGE;
+               }
        }
 
        if ( state ) {
@@ -528,10 +539,17 @@ access_allowed_mask(
 
        assert( attr != NULL );
 
-       if ( op && op->o_is_auth_check &&
-               ( access_level == ACL_SEARCH || access_level == ACL_READ ) )
-       {
-               access = ACL_AUTH;
+       if ( op ) {
+               if ( op->o_is_auth_check &&
+                       ( access_level == ACL_SEARCH || access_level == ACL_READ ) )
+               {
+                       access = ACL_AUTH;
+
+               } else if ( get_manageDIT( op ) && access_level == ACL_WRITE &&
+                       desc == slap_schema.si_ad_entry )
+               {
+                       access = ACL_MANAGE;
+               }
        }
 
        if ( state ) {
@@ -595,8 +613,12 @@ access_allowed_mask(
         * no-user-modification operational attributes are ignored
         * by ACL_WRITE checking as any found here are not provided
         * by the user
+        *
+        * NOTE: but they are not ignored for ACL_MANAGE, because
+        * if we get here it means a non-root user is trying to 
+        * manage data, so we need to check its privileges.
         */
-       if ( access_level >= ACL_WRITE && is_at_no_user_mod( desc->ad_type )
+       if ( access_level == ACL_WRITE && is_at_no_user_mod( desc->ad_type )
                && desc != slap_schema.si_ad_entry
                && desc != slap_schema.si_ad_children )
        {
@@ -2237,8 +2259,7 @@ int
 acl_check_modlist(
        Operation       *op,
        Entry   *e,
-       Modifications   *mlist
-)
+       Modifications   *mlist )
 {
        struct berval *bv;
        AccessControlState state = ACL_STATE_INIT;
@@ -2291,7 +2312,7 @@ acl_check_modlist(
                 * by the user
                 */
                if ( is_at_no_user_mod( mlist->sml_desc->ad_type )
-                               && !mlist->sml_managing )
+                               && ! ( mlist->sml_flags & SLAP_MOD_MANAGING ) )
                {
                        Debug( LDAP_DEBUG_ACL, "acl: no-user-mod %s:"
                                " modify access granted\n",
@@ -2307,7 +2328,9 @@ acl_check_modlist(
                         * This prevents abuse from selfwriters.
                         */
                        if ( ! access_allowed( op, e,
-                               mlist->sml_desc, NULL, ACL_WDEL, &state ) )
+                               mlist->sml_desc, NULL,
+                               ( mlist->sml_flags & SLAP_MOD_MANAGING ) ? ACL_MANAGE : ACL_WDEL,
+                               &state ) )
                        {
                                ret = 0;
                                goto done;
@@ -2325,7 +2348,9 @@ acl_check_modlist(
                                bv->bv_val != NULL; bv++ )
                        {
                                if ( ! access_allowed( op, e,
-                                       mlist->sml_desc, bv, ACL_WADD, &state ) )
+                                       mlist->sml_desc, bv,
+                                       ( mlist->sml_flags & SLAP_MOD_MANAGING ) ? ACL_MANAGE : ACL_WADD,
+                                       &state ) )
                                {
                                        ret = 0;
                                        goto done;
@@ -2336,7 +2361,9 @@ acl_check_modlist(
                case LDAP_MOD_DELETE:
                        if ( mlist->sml_values == NULL ) {
                                if ( ! access_allowed( op, e,
-                                       mlist->sml_desc, NULL, ACL_WDEL, NULL ) )
+                                       mlist->sml_desc, NULL,
+                                       ( mlist->sml_flags & SLAP_MOD_MANAGING ) ? ACL_MANAGE : ACL_WDEL,
+                                       NULL ) )
                                {
                                        ret = 0;
                                        goto done;
@@ -2348,7 +2375,9 @@ acl_check_modlist(
                                bv->bv_val != NULL; bv++ )
                        {
                                if ( ! access_allowed( op, e,
-                                       mlist->sml_desc, bv, ACL_WDEL, &state ) )
+                                       mlist->sml_desc, bv,
+                                       ( mlist->sml_flags & SLAP_MOD_MANAGING ) ? ACL_MANAGE : ACL_WDEL,
+                                       &state ) )
                                {
                                        ret = 0;
                                        goto done;
index bc372d7e4bb18bcc7819b6327b5a72b13d80bbd9..bca6db91c2db94ede075ce1c2f829d9b68af1446 100644 (file)
@@ -2119,7 +2119,7 @@ acl_usage( void )
                        "\t[peername[.<peernamestyle>]=<peer>] [sockname[.<style>]=<name>]\n"
                        "\t[domain[.<domainstyle>]=<domain>] [sockurl[.<style>]=<url>]\n"
 #ifdef SLAPD_ACI_ENABLED
-                       "\t[aci=[<attrname>]]\n"
+                       "\t[aci[=<attrname>]]\n"
 #endif
 #ifdef SLAP_DYNACL
                        "\t[dynacl/<name>[.<dynstyle>][=<pattern>]]\n"
index 5258dc3fc3d2902b4c8a4c9f92ee6532a20eaaed..38bda68141f8f6e4ec0ee1ee4a4158ebf6945500 100644 (file)
@@ -557,6 +557,20 @@ int ad_inlist(
                        continue;
                }
 
+               if ( ber_bvccmp( &attrs->an_name, '*' ) ) {
+                       if ( !is_at_operational( desc->ad_type ) ) {
+                               return 1;
+                       }
+                       continue;
+               }
+
+               if ( ber_bvccmp( &attrs->an_name, '+' ) ) {
+                       if ( is_at_operational( desc->ad_type ) ) {
+                               return 1;
+                       }
+                       continue;
+               }
+
                /*
                 * EXTENSION: see if requested description is @objectClass
                 * if so, return attributes which the class requires/allows
index ff9425bb5734c76d2c153f5d05906416ef094398..e06cb8bb42ee53754c94810438faf775554d4bd2 100644 (file)
@@ -545,7 +545,9 @@ ldap_build_entry(
                }
 
                /* no subschemaSubentry */
-               if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry ) {
+               if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry
+                       || attr->a_desc == slap_schema.si_ad_entryDN )
+               {
 
                        /* 
                         * We eat target's subschemaSubentry because
@@ -553,6 +555,10 @@ ldap_build_entry(
                         * to resolve to the appropriate backend;
                         * later, the local subschemaSubentry is
                         * added.
+                        *
+                        * We also eat entryDN because the frontend
+                        * will reattach it without checking if already
+                        * present...
                         */
                        ( void )ber_scanf( &ber, "x" /* [W] */ );
 
index 8437cea8e8232331a24000f921bc3c96898e32b5..ce7d3d9a6fa3bf81fda7a2916a594f07096b11e6 100644 (file)
@@ -320,8 +320,20 @@ meta_back_search( Operation *op, SlapReply *rs )
 #endif
 
        if ( initial_candidates == 0 ) {
+               /* NOTE: here we are not sending any matchedDN;
+                * this is intended, because if the back-meta
+                * is serving this search request, but no valid
+                * candidate could be looked up, it means that
+                * there is a hole in the mapping of the targets
+                * and thus no knowledge of any remote superior
+                * is available */
+               Debug( LDAP_DEBUG_ANY, "%s meta_back_search: "
+                       "base=\"%s\" scope=%d: "
+                       "no candidate could be selected\n",
+                       op->o_log_prefix, op->o_req_dn.bv_val,
+                       op->ors_scope );
+
                send_ldap_error( op, rs, LDAP_NO_SUCH_OBJECT, NULL );
-               /* FIXME: find a way to look up the best match */
 
                rc = LDAP_NO_SUCH_OBJECT;
                goto finish;
@@ -924,7 +936,9 @@ meta_send_entry(
                }
 
                /* no subschemaSubentry */
-               if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry ) {
+               if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry
+                       || attr->a_desc == slap_schema.si_ad_entryDN )
+               {
 
                        /* 
                         * We eat target's subschemaSubentry because
@@ -932,6 +946,10 @@ meta_send_entry(
                         * to resolve to the appropriate backend;
                         * later, the local subschemaSubentry is
                         * added.
+                        *
+                        * We also eat entryDN because the frontend
+                        * will reattach it without checking if already
+                        * present...
                         */
                        ( void )ber_scanf( &ber, "x" /* [W] */ );
 
index 63a3d00a98c7e4b0fa1b4741f849087794c82446..18feb7df24433419ff42dbc35ad5838084db8fbd 100644 (file)
@@ -835,11 +835,14 @@ backend_check_controls(
                }
        }
 
+       /* temporarily removed */
+#if 0
        /* check should be generalized */
        if( get_manageDIT(op) && !be_isroot(op)) {
                rs->sr_text = "requires manager authorization";
                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
        }
+#endif
 
 done:;
        return rs->sr_err;
@@ -1663,7 +1666,7 @@ fe_aux_operational(
                /* Let the overlays have a chance at this */
                be_orig = op->o_bd;
                op->o_bd = select_backend( &op->o_req_ndn, 0, 0 );
-               if ( op->o_bd != frontendDB &&
+               if ( !be_match( op->o_bd, frontendDB ) &&
                        ( SLAP_OPATTRS( rs->sr_attr_flags ) || rs->sr_attrs ) &&
                        op->o_bd != NULL && op->o_bd->be_operational != NULL )
                {
index 9dd1061f7f0f6b045864317c5937d48f2b6fbbed..ba5477b7f8f4845d6065d2822633212f59038c21 100644 (file)
@@ -140,7 +140,7 @@ do_modify(
                                        goto cleanup;
                                }
 
-                               if( mod->sml_values[1].bv_val ) {
+                               if ( !BER_BVISNULL( &mod->sml_values[ 1 ] ) ) {
                                        Debug( LDAP_DEBUG_ANY, "do_modify: modify/increment "
                                                "operation (%ld) requires single value\n",
                                                (long) mop, 0, 0 );
@@ -251,10 +251,10 @@ fe_op_modify( Operation *op, SlapReply *rs )
                if ( tmp->sml_values == NULL ) {
                        Debug( LDAP_DEBUG_ARGS, "%s\n",
                           "\t\tno values", NULL, NULL );
-               } else if ( tmp->sml_values[0].bv_val == NULL ) {
+               } else if ( BER_BVISNULL( &tmp->sml_values[ 0 ] ) ) {
                        Debug( LDAP_DEBUG_ARGS, "%s\n",
                           "\t\tzero values", NULL, NULL );
-               } else if ( tmp->sml_values[1].bv_val == NULL ) {
+               } else if ( BER_BVISNULL( &tmp->sml_values[ 1 ] ) ) {
                        Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
                           "\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
                } else {
@@ -501,7 +501,7 @@ slap_mods_no_user_mod_check(
 
                if ( get_manageDIT( op ) ) {
                        if ( ml->sml_desc->ad_type->sat_flags & SLAP_AT_MANAGEABLE ) {
-                               ml->sml_managing = 1;
+                               ml->sml_flags |= SLAP_MOD_MANAGING;
                                continue;
                        }
 
@@ -885,20 +885,18 @@ int slap_mods_opattrs(
                        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mod->sml_op = mop;
                        mod->sml_flags = SLAP_MOD_INTERNAL;
-                       mod->sml_type.bv_val = NULL;
+                       BER_BVZERO( &mod->sml_type );
                        mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
                        mod->sml_values =
                                (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                        ber_dupbv( &mod->sml_values[0], &tmpval );
-                       mod->sml_values[1].bv_len = 0;
-                       mod->sml_values[1].bv_val = NULL;
-                       assert( mod->sml_values[0].bv_val != NULL );
+                       BER_BVZERO( &mod->sml_values[1] );
+                       assert( !BER_BVISNULL( &mod->sml_values[0] ) );
                        mod->sml_nvalues =
                                (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                        ber_dupbv( &mod->sml_nvalues[0], &tmpval );
-                       mod->sml_nvalues[1].bv_len = 0;
-                       mod->sml_nvalues[1].bv_val = NULL;
-                       assert( mod->sml_nvalues[0].bv_val != NULL );
+                       BER_BVZERO( &mod->sml_nvalues[1] );
+                       assert( !BER_BVISNULL( &mod->sml_nvalues[0] ) );
                        *modtail = mod;
                        modtail = &mod->sml_next;
                }
@@ -922,14 +920,13 @@ int slap_mods_opattrs(
                                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                                mod->sml_op = mop;
                                mod->sml_flags = SLAP_MOD_INTERNAL;
-                               mod->sml_type.bv_val = NULL;
+                               BER_BVZERO( &mod->sml_type );
                                mod->sml_desc = slap_schema.si_ad_entryUUID;
                                mod->sml_values =
                                        (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                                ber_dupbv( &mod->sml_values[0], &tmpval );
-                               mod->sml_values[1].bv_len = 0;
-                               mod->sml_values[1].bv_val = NULL;
-                               assert( mod->sml_values[0].bv_val != NULL );
+                               BER_BVZERO( &mod->sml_values[1] );
+                               assert( !BER_BVISNULL( &mod->sml_values[0] ) );
                                mod->sml_nvalues =
                                        (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                                (*mod->sml_desc->ad_type->sat_equality->smr_normalize)(
@@ -937,8 +934,7 @@ int slap_mods_opattrs(
                                                mod->sml_desc->ad_type->sat_syntax,
                                                mod->sml_desc->ad_type->sat_equality,
                                                mod->sml_values, mod->sml_nvalues, NULL );
-                               mod->sml_nvalues[1].bv_len = 0;
-                               mod->sml_nvalues[1].bv_val = NULL;
+                               BER_BVZERO( &mod->sml_nvalues[1] );
                                *modtail = mod;
                                modtail = &mod->sml_next;
                        }
@@ -956,20 +952,18 @@ int slap_mods_opattrs(
                                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                                mod->sml_op = mop;
                                mod->sml_flags = SLAP_MOD_INTERNAL;
-                               mod->sml_type.bv_val = NULL;
+                               BER_BVZERO( &mod->sml_type );
                                mod->sml_desc = slap_schema.si_ad_creatorsName;
                                mod->sml_values =
                                        (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                                ber_dupbv( &mod->sml_values[0], &name );
-                               mod->sml_values[1].bv_len = 0;
-                               mod->sml_values[1].bv_val = NULL;
-                               assert( mod->sml_values[0].bv_val != NULL );
+                               BER_BVZERO( &mod->sml_values[1] );
+                               assert( !BER_BVISNULL( &mod->sml_values[0] ) );
                                mod->sml_nvalues =
                                        (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                                ber_dupbv( &mod->sml_nvalues[0], &nname );
-                               mod->sml_nvalues[1].bv_len = 0;
-                               mod->sml_nvalues[1].bv_val = NULL;
-                               assert( mod->sml_nvalues[0].bv_val != NULL );
+                               BER_BVZERO( &mod->sml_nvalues[1] );
+                               assert( !BER_BVISNULL( &mod->sml_nvalues[0] ) );
                                *modtail = mod;
                                modtail = &mod->sml_next;
                        }
@@ -987,14 +981,13 @@ int slap_mods_opattrs(
                                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                                mod->sml_op = mop;
                                mod->sml_flags = SLAP_MOD_INTERNAL;
-                               mod->sml_type.bv_val = NULL;
+                               BER_BVZERO( &mod->sml_type );
                                mod->sml_desc = slap_schema.si_ad_createTimestamp;
                                mod->sml_values =
                                        (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                                ber_dupbv( &mod->sml_values[0], &timestamp );
-                               mod->sml_values[1].bv_len = 0;
-                               mod->sml_values[1].bv_val = NULL;
-                               assert( mod->sml_values[0].bv_val != NULL );
+                               BER_BVZERO( &mod->sml_values[1] );
+                               assert( !BER_BVISNULL( &mod->sml_values[0] ) );
                                mod->sml_nvalues = NULL;
                                *modtail = mod;
                                modtail = &mod->sml_next;
@@ -1006,13 +999,12 @@ int slap_mods_opattrs(
                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                mod->sml_op = mop;
                mod->sml_flags = SLAP_MOD_INTERNAL;
-               mod->sml_type.bv_val = NULL;
+               BER_BVZERO( &mod->sml_type );
                mod->sml_desc = slap_schema.si_ad_entryCSN;
                mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                ber_dupbv( &mod->sml_values[0], &csn );
-               mod->sml_values[1].bv_len = 0;
-               mod->sml_values[1].bv_val = NULL;
-               assert( mod->sml_values[0].bv_val != NULL );
+               BER_BVZERO( &mod->sml_values[1] );
+               assert( !BER_BVISNULL( &mod->sml_values[0] ) );
                mod->sml_nvalues = NULL;
                *modtail = mod;
                modtail = &mod->sml_next;
@@ -1030,19 +1022,17 @@ int slap_mods_opattrs(
                        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mod->sml_op = mop;
                        mod->sml_flags = SLAP_MOD_INTERNAL;
-                       mod->sml_type.bv_val = NULL;
+                       BER_BVZERO( &mod->sml_type );
                        mod->sml_desc = slap_schema.si_ad_modifiersName;
                        mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                        ber_dupbv( &mod->sml_values[0], &name );
-                       mod->sml_values[1].bv_len = 0;
-                       mod->sml_values[1].bv_val = NULL;
-                       assert( mod->sml_values[0].bv_val != NULL );
+                       BER_BVZERO( &mod->sml_values[1] );
+                       assert( !BER_BVISNULL( &mod->sml_values[0] ) );
                        mod->sml_nvalues =
                                (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                        ber_dupbv( &mod->sml_nvalues[0], &nname );
-                       mod->sml_nvalues[1].bv_len = 0;
-                       mod->sml_nvalues[1].bv_val = NULL;
-                       assert( mod->sml_nvalues[0].bv_val != NULL );
+                       BER_BVZERO( &mod->sml_nvalues[1] );
+                       assert( !BER_BVISNULL( &mod->sml_nvalues[0] ) );
                        *modtail = mod;
                        modtail = &mod->sml_next;
                }
@@ -1060,13 +1050,12 @@ int slap_mods_opattrs(
                        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mod->sml_op = mop;
                        mod->sml_flags = SLAP_MOD_INTERNAL;
-                       mod->sml_type.bv_val = NULL;
+                       BER_BVZERO( &mod->sml_type );
                        mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
                        mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                        ber_dupbv( &mod->sml_values[0], &timestamp );
-                       mod->sml_values[1].bv_len = 0;
-                       mod->sml_values[1].bv_val = NULL;
-                       assert( mod->sml_values[0].bv_val != NULL );
+                       BER_BVZERO( &mod->sml_values[1] );
+                       assert( !BER_BVISNULL( &mod->sml_values[0] ) );
                        mod->sml_nvalues = NULL;
                        *modtail = mod;
                        modtail = &mod->sml_next;
index 503a9c63fa108dc643f8ae35c52b21cd67a33c19..6d0757c2dfc64d59af8b0b1ac99156f80553fe59 100644 (file)
@@ -944,6 +944,9 @@ ppolicy_bind( Operation *op, SlapReply *rs )
 {
        slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
 
+       /* Reset lockout status on all Bind requests */
+       pwcons[op->o_conn->c_conn_idx].restricted = 0;
+
        /* Root bypasses policy */
        if ( !be_isroot_dn( op->o_bd, &op->o_req_ndn )) {
                Entry *e;
index 08b9668d32271a7dbd7dbcd7b08cc5211f368caf..996cc7fdc925761a5b2b2a07f944cd7e04d1366e 100644 (file)
@@ -296,6 +296,10 @@ LDAP_SLAPD_F (void) ava_free LDAP_P((
 /*
  * backend.c
  */
+
+#define be_match( be1, be2 )   ( (be1) == (be2) || \
+                                 ( (be1) && (be2) && (be1)->be_nsuffix == (be2)->be_nsuffix ) )
+
 LDAP_SLAPD_F (int) backend_init LDAP_P((void));
 LDAP_SLAPD_F (int) backend_add LDAP_P((BackendInfo *aBackendInfo));
 LDAP_SLAPD_F (int) backend_num LDAP_P((Backend *be));
index ac81a92017eff971819befd16e0f8bac21a3ed8c..03bca79b8b43f8fbef6b087187e8a1457c63340e 100644 (file)
@@ -1028,9 +1028,9 @@ static struct slap_schema_ad_map {
 };
 
 static AttributeType slap_at_undefined = {
-       { "1.1.1", NULL, NULL, 1, NULL,
+       { "1.1.1", NULL, "Catchall for undefined attribute types", 1, NULL,
                NULL, NULL, NULL, NULL,
-               0, 0, 0, 1, 3, NULL }, /* LDAPAttributeType */
+               0, 0, 0, 1, LDAP_SCHEMA_DSA_OPERATION, NULL }, /* LDAPAttributeType */
        BER_BVC("UNDEFINED"), /* cname */
        NULL, /* sup */
        NULL, /* subtypes */
index 5fed372fd32afbd93d6c84847110b76be269b6e4..a212f44bd1e481b7c9b8546f2c510258811f0a07 100644 (file)
@@ -1158,6 +1158,7 @@ typedef struct slap_mod {
  * running as non-root user, for user modifiable attributes.
  */
 #define        SLAP_MOD_INTERNAL       0x01
+#define        SLAP_MOD_MANAGING       0x02
 
        AttributeDescription *sm_desc;
        struct berval sm_type;
@@ -1173,7 +1174,6 @@ typedef struct slap_mod_list {
 #define        sml_type        sml_mod.sm_type
 #define sml_values     sml_mod.sm_values
 #define sml_nvalues    sml_mod.sm_nvalues
-       char sml_managing;
        struct slap_mod_list *sml_next;
 } Modifications;
 
index 5c273c605d6d4dc1f5b13eeae25194c785b15deb..c6418c9142dab31c8ea1fe5238c7eb1c3843158d 100644 (file)
@@ -424,6 +424,13 @@ slap_tool_init(
                exit( EXIT_FAILURE );
        }
 
+#ifdef SLAP_DYNACL
+       if ( acl_init() ) {
+               fprintf( stderr, "%s: acl_init failed!\n", progname );
+               exit( EXIT_FAILURE );
+       }
+#endif /* SLAP_DYNACL */
+
        rc = read_config( conffile, confdir );
 
        if ( rc != 0 ) {
index 9670898f4e26d386d651db74bde66aaabf036b2f..48c6d9bc14d0fe325edb5911acdeeaaf2308d0cc 100644 (file)
@@ -190,7 +190,7 @@ slapi_over_call_plugins( Slapi_PBlock *pb, int type )
        PBLOCK_ASSERT_OP( pb, 0 );
        op = pb->pb_op;
 
-       if ( op->o_bd != frontendDB ) {
+       if ( !be_match( op->o_bd, frontendDB ) ) {
                rc = slapi_int_call_plugins( frontendDB, type, pb );
        }
        if ( rc >= 0 ) {
index 7a433db11eb265d7d1bc38334641ddee7edbcb8d..1b9b3e1f7a5a23ca83ab08a94183bc39ba627cd6 100644 (file)
@@ -31,7 +31,7 @@ retcode-item  "cn=strongAuthRequired"                 0x08
 retcode-item   "cn=strongerAuthRequired"               0x08    text="same as strongAuthRequired"
 #retcode-item  "cn=partialResults"                     0x09 "LDAPv2+ (not LDAPv3)"
 
-retcode-item   "cn=referral"                           0x0a    text="LDAPv3"
+retcode-item   "cn=referral"                           0x0a    text="LDAPv3"   ref="ldap://:9010"
 retcode-item   "cn=adminLimitExceeded"                 0x0b    text="LDAPv3"
 retcode-item   "cn=unavailableCriticalExtension"       0x0c    text="LDAPv3"
 retcode-item   "cn=confidentialityRequired"            0x0d    text="LDAPv3"
diff --git a/tests/data/subtree-rename.out b/tests/data/subtree-rename.out
new file mode 100644 (file)
index 0000000..e5f753a
--- /dev/null
@@ -0,0 +1,97 @@
+# Searching all database (after add)...
+dn: ou=Another parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Another parent
+
+dn: ou=Child,ou=Parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Child
+
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example, Inc.
+dc: example
+
+dn: ou=Grandchild,ou=Child,ou=Parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Grandchild
+
+dn: ou=Parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Parent
+
+# Searching all database (after PASS1)...
+dn: ou=Another parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Another parent
+
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example, Inc.
+dc: example
+
+dn: ou=Grandchild,ou=Renamed child,ou=Parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Grandchild
+
+dn: ou=Parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Parent
+
+dn: ou=Renamed child,ou=Parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Child
+ou: Renamed child
+
+# Searching all database (after PASS2)...
+dn: ou=Another parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Another parent
+
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example, Inc.
+dc: example
+
+dn: ou=Grandchild,ou=Renamed child,ou=Renamed parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Grandchild
+
+dn: ou=Renamed child,ou=Renamed parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Child
+ou: Renamed child
+
+dn: ou=Renamed parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Parent
+ou: Renamed parent
+
+# Searching all database (after PASS3)...
+dn: ou=Another parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Another parent
+
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example, Inc.
+dc: example
+
+dn: ou=Grandchild,ou=Renamed child,ou=Another parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Grandchild
+
+dn: ou=Renamed child,ou=Another parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Child
+ou: Renamed child
+
+dn: ou=Renamed parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Parent
+ou: Renamed parent
+
index 6b8caacc0633293494a111f4bcaf02a67e9baba7..082a7aa3d530e4ab770ca9d34304971ba74aeef4 100644 (file)
@@ -41,12 +41,20 @@ get_add_entry( char *filename, LDAPMod ***mods );
 
 static void
 do_addel( char *uri, char *host, int port, char *manager, char *passwd,
-       char *dn, LDAPMod **attrs, int maxloop, int maxretries );
+       char *dn, LDAPMod **attrs, int maxloop, int maxretries, int delay );
 
 static void
 usage( char *name )
 {
-       fprintf( stderr, "usage: %s [-h <host>] -p port -D <managerDN> -w <passwd> -f <addfile> [-l <loops>]\n",
+        fprintf( stderr,
+               "usage: %s "
+               "-H <uri> | ([-h <host>] -p <port>) "
+               "-D <manager> "
+               "-w <passwd> "
+               "-f <addfile> "
+               "[-l <loops>] "
+               "[-r <maxretries>] "
+               "[-t <delay>]\n",
                        name );
        exit( EXIT_FAILURE );
 }
@@ -64,9 +72,10 @@ main( int argc, char **argv )
        char            *entry = NULL;
        int             loops = LOOPS;
        int             retries = RETRIES;
+       int             delay = 0;
        LDAPMod         **attrs = NULL;
 
-       while ( (i = getopt( argc, argv, "H:h:p:D:w:f:l:r:" )) != EOF ) {
+       while ( (i = getopt( argc, argv, "H:h:p:D:w:f:l:r:t:" )) != EOF ) {
                switch( i ) {
                case 'H':               /* the server's URI */
                        uri = strdup( optarg );
@@ -96,10 +105,14 @@ main( int argc, char **argv )
                        loops = atoi( optarg );
                        break;
 
-               case 'r':
+               case 'r':               /* number of retries */
                        retries = atoi( optarg );
                        break;
 
+               case 't':               /* delay in seconds */
+                       delay = atoi( optarg );
+                       break;
+
                default:
                        usage( argv[0] );
                        break;
@@ -128,7 +141,7 @@ main( int argc, char **argv )
        }
 
        do_addel( uri, host, port, manager, passwd, entry, attrs,
-                       loops, retries );
+                       loops, retries, delay );
 
        exit( EXIT_SUCCESS );
 }
@@ -258,7 +271,8 @@ do_addel(
        char *entry,
        LDAPMod **attrs,
        int maxloop,
-       int maxretries
+       int maxretries,
+       int delay
 )
 {
        LDAP    *ld = NULL;
@@ -294,9 +308,11 @@ retry:;
                switch ( rc ) {
                case LDAP_BUSY:
                case LDAP_UNAVAILABLE:
-                       if ( do_retry == 1 ) {
-                               do_retry = 0;
-                               sleep( 1 );
+                       if ( do_retry > 0 ) {
+                               do_retry--;
+                               if ( delay != 0 ) {
+                                   sleep( delay );
+                               }
                                goto retry;
                        }
                /* fallthru */
index b639df553908dd065281e8020b2e37334780b25a..c0484dbc5cfa7d6611ff3971a5bbfe17a176b435 100644 (file)
 static void
 do_modify( char *uri, char *host, int port, char *manager, char *passwd,
                char *entry, char *attr, char *value, int maxloop,
-               int maxretries );
+               int maxretries, int delay );
 
 
 static void
 usage( char *name )
 {
-       fprintf( stderr, "usage: %s [-h <host>] -p port -D <managerDN> -w <passwd> -e <entry> [-l <loops>]\n",
+        fprintf( stderr,
+               "usage: %s "
+               "-H <uri> | ([-h <host>] -p <port>) "
+               "-D <manager> "
+               "-w <passwd> "
+               "-e <entry> "
+               "[-l <loops>] "
+               "[-r <maxretries>] "
+               "[-t <delay>]\n",
                        name );
        exit( EXIT_FAILURE );
 }
@@ -60,8 +68,9 @@ main( int argc, char **argv )
        char            *value = NULL;
        int             loops = LOOPS;
        int             retries = RETRIES;
+       int             delay = 0;
 
-       while ( (i = getopt( argc, argv, "H:h:p:D:w:e:a:l:r:" )) != EOF ) {
+       while ( (i = getopt( argc, argv, "H:h:p:D:w:e:a:l:r:t:" )) != EOF ) {
                switch( i ) {
                case 'H':               /* the server uri */
                        uri = strdup( optarg );
@@ -95,10 +104,14 @@ main( int argc, char **argv )
                        loops = atoi( optarg );
                        break;
 
-               case 'r':
+               case 'r':               /* number of retries */
                        retries = atoi( optarg );
                        break;
 
+               case 't':               /* delay in seconds */
+                       delay = atoi( optarg );
+                       break;
+
                default:
                        usage( argv[0] );
                        break;
@@ -131,7 +144,7 @@ main( int argc, char **argv )
                value++;
 
        do_modify( uri, host, port, manager, passwd, entry, ava, value,
-                       loops, retries );
+                       loops, retries, delay );
        exit( EXIT_SUCCESS );
 }
 
@@ -139,7 +152,7 @@ main( int argc, char **argv )
 static void
 do_modify( char *uri, char *host, int port, char *manager,
        char *passwd, char *entry, char* attr, char* value,
-       int maxloop, int maxretries )
+       int maxloop, int maxretries, int delay )
 {
        LDAP    *ld = NULL;
        int     i = 0, do_retry = maxretries;
@@ -188,9 +201,11 @@ retry:;
                switch ( rc ) {
                case LDAP_BUSY:
                case LDAP_UNAVAILABLE:
-                       if ( do_retry == 1 ) {
-                               do_retry = 0;
-                               sleep( 1 );
+                       if ( do_retry > 0 ) {
+                               do_retry--;
+                               if ( delay > 0 ) {
+                                   sleep( delay );
+                               }
                                goto retry;
                        }
                /* fallthru */
index 2e95ddfa038e126f7ee1319f9d897d02f069da08..06b513044269dbbc68033bde43a79533149ab6bf 100644 (file)
 
 static void
 do_modrdn( char *uri, char *host, int port, char *manager, char *passwd,
-               char *entry, int maxloop, int maxretries );
+               char *entry, int maxloop, int maxretries, int delay );
 
 static void
 usage( char *name )
 {
-       fprintf( stderr, "usage: %s [-h <host>] -p port -D <managerDN> -w <passwd> -e <entry> [-l <loops>]\n",
+        fprintf( stderr,
+               "usage: %s "
+               "-H <uri> | ([-h <host>] -p <port>) "
+               "-D <manager> "
+               "-w <passwd> "
+               "-e <entry> "
+               "[-l <loops>] "
+               "[-r <maxretries>] "
+               "[-t <delay>]\n",
                        name );
        exit( EXIT_FAILURE );
 }
@@ -60,8 +68,9 @@ main( int argc, char **argv )
        char            *entry = NULL;
        int             loops = LOOPS;
        int             retries = RETRIES;
+       int             delay = 0;
 
-       while ( (i = getopt( argc, argv, "H:h:p:D:w:e:l:r:" )) != EOF ) {
+       while ( (i = getopt( argc, argv, "H:h:p:D:w:e:l:r:t:" )) != EOF ) {
                switch( i ) {
                case 'H':               /* the server uri */
                        uri = strdup( optarg );
@@ -95,6 +104,10 @@ main( int argc, char **argv )
                        retries = atoi( optarg );
                        break;
 
+               case 't':               /* delay in seconds */
+                       delay = atoi( optarg );
+                       break;
+
                default:
                        usage( argv[0] );
                        break;
@@ -112,14 +125,14 @@ main( int argc, char **argv )
 
        }
 
-       do_modrdn( uri, host, port, manager, passwd, entry, loops, retries );
+       do_modrdn( uri, host, port, manager, passwd, entry, loops, retries, delay );
        exit( EXIT_SUCCESS );
 }
 
 
 static void
 do_modrdn( char *uri, char *host, int port, char *manager,
-       char *passwd, char *entry, int maxloop, int maxretries )
+       char *passwd, char *entry, int maxloop, int maxretries, int delay )
 {
        LDAP    *ld = NULL;
        int     i = 0, do_retry = maxretries;
@@ -180,9 +193,11 @@ retry:;
                switch ( rc ) {
                case LDAP_BUSY:
                case LDAP_UNAVAILABLE:
-                       if ( do_retry == 1 ) {
-                               do_retry = 0;
-                               sleep( 1 );
+                       if ( do_retry > 0 ) {
+                               do_retry--;
+                               if ( delay > 0) {
+                                   sleep( delay );
+                               }
                                goto retry;
                        }
                /* fallthru */
index e2c07686794808b4508b2580f3c2349e9e03d1e4..c5cb56ce33bd87d9ece5e3acdaa198eeb4a141f2 100644 (file)
 
 static void
 do_read( char *uri, char *host, int port, char *entry, int maxloop,
-               int maxretries );
+               int maxretries, int delay );
 
 static void
 usage( char *name )
 {
-       fprintf( stderr, "usage: %s [-h <host>] -p port -e <entry> [-l <loops>]\n",
+        fprintf( stderr,
+               "usage: %s "
+               "-H <uri> | ([-h <host>] -p <port>) "
+               "-e <entry> "
+               "[-l <loops>] "
+               "[-r <maxretries>] "
+               "[-t <delay>]\n",
                        name );
        exit( EXIT_FAILURE );
 }
@@ -58,8 +64,9 @@ main( int argc, char **argv )
        char            *entry = NULL;
        int             loops = LOOPS;
        int             retries = RETRIES;
+       int             delay = 0;
 
-       while ( (i = getopt( argc, argv, "H:h:p:e:l:r:" )) != EOF ) {
+       while ( (i = getopt( argc, argv, "H:h:p:e:l:r:t:" )) != EOF ) {
                switch( i ) {
                case 'H':               /* the server uri */
                        uri = strdup( optarg );
@@ -85,6 +92,10 @@ main( int argc, char **argv )
                        retries = atoi( optarg );
                        break;
 
+               case 't':               /* delay in seconds */
+                       delay = atoi( optarg );
+                       break;
+
                default:
                        usage( argv[0] );
                        break;
@@ -100,14 +111,14 @@ main( int argc, char **argv )
                exit( EXIT_FAILURE );
        }
 
-       do_read( uri, host, port, entry, ( 20 * loops ), retries );
+       do_read( uri, host, port, entry, ( 20 * loops ), retries, delay );
        exit( EXIT_SUCCESS );
 }
 
 
 static void
 do_read( char *uri, char *host, int port, char *entry, int maxloop,
-               int maxretries )
+               int maxretries, int delay )
 {
        LDAP    *ld = NULL;
        int     i = 0, do_retry = maxretries;
@@ -143,9 +154,11 @@ retry:;
                switch ( rc ) {
                case LDAP_BUSY:
                case LDAP_UNAVAILABLE:
-                       if ( do_retry == 1 ) {
-                               do_retry = 0;
-                               sleep( 1 );
+                       if ( do_retry > 0 ) {
+                               do_retry--;
+                               if ( delay > 0 ) {
+                                   sleep( delay );
+                               }
                                goto retry;
                        }
                /* fallthru */
index 71588310565c47fd78f7d627fbb05aba0a1022de..9d9afe1e4fd39b144c1484fd72eca9066edbc585 100644 (file)
 
 static void
 do_search( char *uri, char *host, int port, char *manager, char *passwd,
-               char *sbase, char *filter, int maxloop, int maxretries );
+               char *sbase, char *filter, int maxloop, int maxretries, int delay );
 
 static void
 usage( char *name )
 {
-       fprintf( stderr, "usage: %s [-h <host>] -p port -b <searchbase> -f <searchfiter> [-l <loops>]\n",
+        fprintf( stderr,
+               "usage: %s "
+               "-H <uri> | ([-h <host>] -p <port>) "
+               "-D <manager> "
+               "-w <passwd> "
+               "-b <searchbase> "
+               "-f <searchfilter> "
+               "[-l <loops>] "
+               "[-r <maxretries>] "
+               "[-t <delay>]\n",
                        name );
        exit( EXIT_FAILURE );
 }
@@ -61,8 +70,9 @@ main( int argc, char **argv )
        char            *filter  = NULL;
        int             loops = LOOPS;
        int             retries = RETRIES;
+       int             delay = 0;
 
-       while ( (i = getopt( argc, argv, "b:D:f:H:h:l:p:w:r:" )) != EOF ) {
+       while ( (i = getopt( argc, argv, "b:D:f:H:h:l:p:w:r:t:" )) != EOF ) {
                switch( i ) {
                case 'H':               /* the server uri */
                        uri = strdup( optarg );
@@ -100,6 +110,10 @@ main( int argc, char **argv )
                        retries = atoi( optarg );
                        break;
 
+               case 't':               /* delay in seconds */
+                       delay = atoi( optarg );
+                       break;
+
                default:
                        usage( argv[0] );
                        break;
@@ -118,14 +132,14 @@ main( int argc, char **argv )
        }
 
        do_search( uri, host, port, manager, passwd, sbase, filter,
-                       ( 10 * loops ), retries );
+                       ( 10 * loops ), retries, delay );
        exit( EXIT_SUCCESS );
 }
 
 
 static void
 do_search( char *uri, char *host, int port, char *manager, char *passwd,
-               char *sbase, char *filter, int maxloop, int maxretries )
+               char *sbase, char *filter, int maxloop, int maxretries, int delay )
 {
        LDAP    *ld = NULL;
        int     i = 0, do_retry = maxretries;
@@ -163,7 +177,9 @@ retry:;
                case LDAP_UNAVAILABLE:
                        if ( do_retry > 0 ) {
                                do_retry--;
-                               sleep( 1 );
+                               if ( delay != 0 ) {
+                                   sleep( delay );
+                               }
                                goto retry;
                        }
                /* fallthru */
@@ -196,5 +212,3 @@ retry:;
 
        ldap_unbind( ld );
 }
-
-
index 4121b4d17454a45d3be0998025618622eda084f1..c8d4d57f25cd0efc1568c1f0fa523d5f15f4f268 100644 (file)
@@ -80,7 +80,8 @@ usage( char *name )
                "[-j <maxchild>] "
                "[-l <loops>] "
                "-P <progdir> "
-               "[-r <maxretries>]\n",
+               "[-r <maxretries>]"
+               "[-t <delay>]\n",
                name );
        exit( EXIT_FAILURE );
 }
@@ -98,6 +99,7 @@ main( int argc, char **argv )
        char            *progdir = NULL;
        char            *loops = LOOPS;
        char            *retries = RETRIES;
+       char            *delay = "0";
        DIR                     *datadir;
        struct dirent   *file;
        char            *sfile = NULL;
@@ -132,7 +134,7 @@ main( int argc, char **argv )
        char            *moddn[MAXREQS];
        int             modnum = 0;
 
-       while ( (i = getopt( argc, argv, "D:d:H:h:j:l:P:p:r:w:" )) != EOF ) {
+       while ( (i = getopt( argc, argv, "D:d:H:h:j:l:P:p:r:t:w:" )) != EOF ) {
                switch( i ) {
                case 'D':               /* slapd manager */
                        manager = ArgDup( optarg );
@@ -166,10 +168,14 @@ main( int argc, char **argv )
                        port = strdup( optarg );
                        break;
 
-               case 'r':
+               case 'r':               /* the number of retries in case of error */
                        retries = strdup( optarg );
                        break;
 
+               case 't':               /* the delay in seconds between each retry */
+                       delay = strdup( optarg );
+                       break;
+
                case 'w':               /* the managers passwd */
                        passwd = ArgDup( optarg );
                        break;
@@ -264,6 +270,8 @@ main( int argc, char **argv )
        sargs[sanum++] = loops;
        sargs[sanum++] = "-r";
        sargs[sanum++] = retries;
+       sargs[sanum++] = "-t";
+       sargs[sanum++] = delay;
        sargs[sanum++] = "-b";
        sargs[sanum++] = NULL;          /* will hold the search base */
        sargs[sanum++] = "-f";
@@ -291,6 +299,8 @@ main( int argc, char **argv )
        rargs[ranum++] = loops;
        rargs[ranum++] = "-r";
        rargs[ranum++] = retries;
+       rargs[ranum++] = "-t";
+       rargs[ranum++] = delay;
        rargs[ranum++] = "-e";
        rargs[ranum++] = NULL;          /* will hold the read entry */
        rargs[ranum++] = NULL;
@@ -320,6 +330,8 @@ main( int argc, char **argv )
        margs[manum++] = loops;
        margs[manum++] = "-r";
        margs[manum++] = retries;
+       margs[manum++] = "-t";
+       margs[manum++] = delay;
        margs[manum++] = "-e";
        margs[manum++] = NULL;          /* will hold the modrdn entry */
        margs[manum++] = NULL;
@@ -349,6 +361,8 @@ main( int argc, char **argv )
        modargs[modanum++] = loops;
        modargs[modanum++] = "-r";
        modargs[modanum++] = retries;
+       modargs[modanum++] = "-t";
+       modargs[modanum++] = delay;
        modargs[modanum++] = "-e";
        modargs[modanum++] = NULL;              /* will hold the modify entry */
        modargs[modanum++] = "-a";;
@@ -380,6 +394,8 @@ main( int argc, char **argv )
        aargs[aanum++] = loops;
        aargs[aanum++] = "-r";
        aargs[aanum++] = retries;
+       aargs[aanum++] = "-t";
+       aargs[aanum++] = delay;
        aargs[aanum++] = "-f";
        aargs[aanum++] = NULL;          /* will hold the add data file */
        aargs[aanum++] = NULL;
index 1741c291cce98918a2e377fc0b235248c65ef97c..426c41d9354a0db8db9c76e2e1e7c993db5dce83 100755 (executable)
@@ -273,6 +273,7 @@ TRANSLUCENTOUT=$DATADIR/translucent.search.out
 METAOUT=$DATADIR/meta.out
 METACONCURRENCYOUT=$DATADIR/metaconcurrency.out
 MANAGEOUT=$DATADIR/manage.out
+SUBTREERENAMEOUT=$DATADIR/subtree-rename.out
 
 # Just in case we linked the binaries dynamically
 LD_LIBRARY_PATH=`pwd`/../libraries:${LD_LIBRARY_PATH} export LD_LIBRARY_PATH
diff --git a/tests/scripts/test040-subtree-rename b/tests/scripts/test040-subtree-rename
new file mode 100755 (executable)
index 0000000..f212a5c
--- /dev/null
@@ -0,0 +1,207 @@
+#! /bin/sh
+# $OpenLDAP$ */
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
+##
+## Copyright 1998-2005 The OpenLDAP Foundation.
+## All rights reserved.
+##
+## 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>.
+
+echo "running defines.sh"
+. $SRCDIR/scripts/defines.sh
+
+case $BACKEND in
+hdb)
+       ;;
+*)
+       echo "subtree rename not supported by back-$BACKEND"
+       exit 0
+esac
+
+mkdir -p $TESTDIR $DBDIR1
+
+echo "Starting slapd on TCP/IP port $PORT1..."
+. $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
+$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
+PID=$!
+if test $WAIT != 0 ; then
+    echo PID $PID
+    read foo
+fi
+KILLPIDS="$PID"
+
+echo "Testing slapd searching..."
+for i in 0 1 2 3 4 5; do
+       $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
+               '(objectclass=*)' > /dev/null 2>&1
+       RC=$?
+       if test $RC = 0 ; then
+               break
+       fi
+       echo "Waiting 5 seconds for slapd to start..."
+       sleep 5
+done
+
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+cat /dev/null > $TESTOUT
+cat /dev/null > $SEARCHOUT
+
+# Add
+echo "Populating the database..."
+echo "# Populating the database..." >> $TESTOUT
+$LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
+       >> $TESTOUT 2>&1 << EOMODS0
+dn: dc=example,dc=com
+objectClass: organization
+objectClass: dcObject
+o: Example, Inc.
+dc: example
+
+dn: ou=Parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Parent
+
+dn: ou=Another parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Another parent
+
+dn: ou=Child,ou=Parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Child
+
+dn: ou=Grandchild,ou=Child,ou=Parent,dc=example,dc=com
+objectClass: organizationalUnit
+ou: Grandchild
+EOMODS0
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapadd failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+echo "Searching all database..."
+echo "# Searching all database (after add)..." >> $SEARCHOUT
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+       '(objectClass=*)' >> $SEARCHOUT 2>&1
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+# Rename (PASS1)
+echo "Renaming (PASS1)..."
+echo "# Renaming (PASS1)..." >> $TESTOUT
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
+       >> $TESTOUT 2>&1 << EOMODS1
+dn: ou=Child,ou=Parent,dc=example,dc=com
+changetype: modrdn
+newrdn: ou=Renamed child
+deleteoldrdn: 0
+EOMODS1
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapadd failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+echo "Searching all database..."
+echo "# Searching all database (after PASS1)..." >> $SEARCHOUT
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+       '(objectClass=*)' >> $SEARCHOUT 2>&1
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+# Rename (PASS2)
+echo "Renaming (PASS2)..."
+echo "# Renaming (PASS2)..." >> $TESTOUT
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
+       >> $TESTOUT 2>&1 << EOMODS2
+dn: ou=Parent,dc=example,dc=com
+changetype: modrdn
+newrdn: ou=Renamed parent
+deleteoldrdn: 0
+EOMODS2
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapadd failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+echo "Searching all database..."
+echo "# Searching all database (after PASS2)..." >> $SEARCHOUT
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+       '(objectClass=*)' >> $SEARCHOUT 2>&1
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+# Rename (PASS3)
+echo "Renaming (PASS3)..."
+echo "# Renaming (PASS3)..." >> $TESTOUT
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
+       >> $TESTOUT 2>&1 << EOMODS3
+dn: ou=Renamed child,ou=Renamed parent,dc=example,dc=com
+changetype: modrdn
+newrdn: ou=Renamed child
+deleteoldrdn: 0
+newsuperior: ou=Another parent,dc=example,dc=com
+EOMODS3
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapadd failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+echo "Searching all database..."
+echo "# Searching all database (after PASS3)..." >> $SEARCHOUT
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+       '(objectClass=*)' >> $SEARCHOUT 2>&1
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+test $KILLSERVERS != no && kill -HUP $KILLPIDS
+
+LDIF=$SUBTREERENAMEOUT
+
+echo "Filtering ldapsearch results..."
+. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
+echo "Filtering original ldif used to create database..."
+. $LDIFFILTER < $LDIF > $LDIFFLT
+echo "Comparing filter output..."
+$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
+
+if test $? != 0 ; then
+       echo "Comparison failed"
+       exit 1
+fi
+
+echo ">>>>> Test succeeded"
+exit 0