]> git.sur5r.net Git - openldap/commitdiff
(Partial) Sync with HEAD
authorKurt Zeilenga <kurt@openldap.org>
Mon, 29 Dec 2003 19:10:37 +0000 (19:10 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 29 Dec 2003 19:10:37 +0000 (19:10 +0000)
60 files changed:
doc/man/man5/slapd-bdb.5
doc/man/man5/slapd-meta.5
doc/man/man5/slapd.access.5
doc/man/man8/slapadd.8
doc/man/man8/slapcat.8
doc/man/man8/slapd.8
include/ldap_defaults.h
include/rewrite.h
include/slapi-plugin.h
libraries/libldap/os-ip.c
libraries/librewrite/config.c
libraries/librewrite/context.c
libraries/librewrite/info.c
libraries/librewrite/rewrite-int.h
libraries/librewrite/rewrite.c
libraries/librewrite/rule.c
libraries/librewrite/session.c
libraries/librewrite/subst.c
libraries/librewrite/var.c
servers/slapd/Makefile.in
servers/slapd/acl.c
servers/slapd/aclparse.c
servers/slapd/add.c
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/backend.c
servers/slapd/backglue.c
servers/slapd/backover.c
servers/slapd/bind.c
servers/slapd/compare.c
servers/slapd/config.c
servers/slapd/connection.c
servers/slapd/controls.c
servers/slapd/delete.c
servers/slapd/extended.c
servers/slapd/init.c
servers/slapd/main.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/operation.c
servers/slapd/overlays/pcache.c
servers/slapd/passwd.c
servers/slapd/proto-slap.h
servers/slapd/result.c
servers/slapd/root_dse.c
servers/slapd/sasl.c
servers/slapd/search.c
servers/slapd/slapd.conf
servers/slapd/slapi/plugin.c
servers/slapd/slapi/printmsg.c
servers/slapd/slapi/proto-slapi.h
servers/slapd/slapi/slapi.h
servers/slapd/slapi/slapi_ext.c
servers/slapd/slapi/slapi_ops.c
servers/slapd/slapi/slapi_utils.c
servers/slapd/tools/mimic.c
servers/slurpd/reject.c
tests/progs/slapd-addel.c

index d24bd0cff463cd45d45795b205635087ee24d789..4342574c7f2516dba04aa6c25ce7743baf16bf8d 100644 (file)
@@ -133,12 +133,19 @@ region that will house the environment.
 .TP
 .B sessionlog <sid> <limit>
 Specify a session log store for the syncrepl replication provider
-site which contains information on the entries that have been scoped
-out of the content of the replication session identified by {{EX:<sid>}}.
-The number of entries in the session log store is limited
-by {{EX:<limit>}}. Excessive entries are removed from the store
-in the FIFO order. Both {{EX:<sid>}} and {{EX:<limit>}} are
-non-negative integers. {{EX:<sid>}} has no more than three digits.
+server. The session log store contains information on the entries that
+have been scoped out of the provider replication content identified by
+.B <sid>.
+The number of entries in the session log store is limited by
+.B <limit>.
+Excessive entries are removed from the store in the FIFO order.
+Both
+.B <sid>
+and
+.B <limit>
+are non-negative integers.
+.B <sid>
+has no more than three decimal digits.
 Refer to the "OpenLDAP Administrator's Guide" for detailed information
 on setting up a replicated slapd directory service using the syncrepl
 replication engine and the session log store.
index cef94103b0a9f7199ff0390c62ce006e1142a241..d4bfeb74f947ce78ca4ab71d8ac0f9265892d95f 100644 (file)
@@ -332,8 +332,8 @@ server will possibly enforce additional restrictions to "foo".
 A string is rewritten according to a set of rules, called a `rewrite
 context'.
 The rules are based on Regular Expressions (POSIX regex) with
-substring matching; extensions are planned to allow basic variable
-substitution and map resolution of substrings.
+substring matching; basic variable substitution and map resolution 
+of substrings is allowed by specific mechanisms detailed in the following.
 The behavior of pattern matching/substitution can be altered by a set
 of flags.
 .LP
@@ -341,14 +341,17 @@ The underlying concept is to build a lightweight rewrite module
 for the slapd server (initially dedicated to the LDAP backend).
 .SH Passes
 An incoming string is matched agains a set of rules.
-Rules are made of a match pattern, a substitution pattern and a set of
-actions.
+Rules are made of a regex match pattern, a substitution pattern
+and a set of actions, described by a set of flags.
 In case of match a string rewriting is performed according to the
 substitution pattern that allows to refer to substrings matched in the
 incoming string.
 The actions, if any, are finally performed.
 The substitution pattern allows map resolution of substrings.
 A map is a generic object that maps a substitution pattern to a value.
+The flags are divided in "Pattern matching Flags" and "Action Flags";
+the former alter the regex match pattern behaviorm while the latter
+alter the action that is taken after substitution.
 .SH "Pattern Matching Flags"
 .TP
 .B `C'
@@ -356,31 +359,58 @@ honors case in matching (default is case insensitive)
 .TP
 .B `R'
 use POSIX Basic Regular Expressions (default is Extended)
+.TP
+.B `M{n}'
+allow no more than
+.B n
+recursive passes for a specific rule; does not alter the max total count
+of passes, so it can only enforce a stricter limit for a specific rule.
 .SH "Action Flags"
 .TP
 .B `:'
 apply the rule once only (default is recursive)
 .TP
 .B `@'
-stop applying rules in case of match.
+stop applying rules in case of match; the current rule is still applied 
+recursively; combine with `:' to apply the current rule only once 
+and then stop.
 .TP
 .B `#'
 stop current operation if the rule matches, and issue an `unwilling to
 perform' error.
 .TP
 .B `G{n}'
-jump n rules back and forth (watch for loops!).
+jump
+.B n
+rules back and forth (watch for loops!).
 Note that `G{1}' is implicit in every rule.
 .TP
 .B `I'
 ignores errors in rule; this means, in case of error, e.g. issued by a
 map, the error is treated as a missed match.
 The `unwilling to perform' is not overridden.
-.LP
-The ordering of the flags is significant.
+.TP
+.B `U{n}'
+uses
+.B
+n
+as return code if the rule matches; the flag does not alter the recursive
+behavior of the rule, so, to have it performed only once, it must be used 
+in combination with `:', e.g.
+.B `:U{16}'
+returns the value `16' after exactly one execution of the rule, if the
+pattern matches.
+As a consequence, its behavior is equivalent to `@', with the return
+code set to
+.BR n ;
+or, in other words, `@' is equivalent to `U{0}'.
+By convention, the freely available codes are above 16 included;
+the others are reserved.
+.LP
+The ordering of the flags can be significant.
 For instance: `IG{2}' means ignore errors and jump two lines ahead
 both in case of match and in case of error, while `G{2}I' means ignore
-errors, but jump thwo lines ahead only in case of match.
+errors, but jump two lines ahead only in case of match.
 .LP
 More flags (mainly Action Flags) will be added as needed.
 .SH "Pattern matching:"
@@ -527,8 +557,8 @@ A context may aliase another one.
 In this case the alias context contains no rule, and any reference to
 it will result in accessing the aliased one.
 .TP
-.B rewriteRule "<regex pattern>" "<substitution pattern>" "[ <flags> ]"
-Determines how a tring can be rewritten if a pattern is matched.
+.B rewriteRule "<regex match pattern>" "<substitution pattern>" "[ <flags> ]"
+Determines how a string can be rewritten if a pattern is matched.
 Examples are reported below.
 .SH "Additional configuration syntax:"
 .TP
@@ -541,9 +571,16 @@ The map is referenced inside the substitution pattern of a rule.
 Sets a value with global scope, that can be dereferenced by the
 command `%{$paramName}'.
 .TP
-.B rewriteMaxPasses <number of passes>
+.B rewriteMaxPasses <number of passes> [<number of passes per rule>]
 Sets the maximum number of total rewriting passes that can be
 performed in a single rewrite operation (to avoid loops).
+A safe default is set to 100; note that reaching this limit is still
+treated as a success; recursive invocation of rules is simply 
+interrupted.
+The count applies to the rewriting operation as a whole, not 
+to any single rule; an optional per-rule limit can be set.
+This limit is overridden by setting specific per-rule limits
+with the `M{n}' flag.
 .SH "Configuration examples:"
 .nf
 # set to `off' to disable rewriting
@@ -616,7 +653,7 @@ rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
 # regular DNs, because the definition of a bindDn
 # rewrite context overrides the default definition.
 rewriteContext bindDn
-rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" "@I"
+rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
 
 # This is a rather sophisticated example. It massages a
 # search filter in case who performs the search has
@@ -645,7 +682,7 @@ rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
   "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
   ":I"
 rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
-  "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" "@I"
+  "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
 rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
 
 # This example shows how to strip unwanted DN-valued
@@ -655,7 +692,7 @@ rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
 # The second rule matches everything else and causes
 # the value to be rejected.
 rewriteContext searchResult
-rewriteRule ".*,ou=People,dc=example,dc=com" "%0" "@"
+rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
 rewriteRule ".*" "" "#"
 .fi
 .SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
@@ -666,16 +703,16 @@ E.g.:
 .LP
 .nf
   rewriteRule '^cn=root,.*' '%0'                     'G{3}'
-  rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' '@'
-  rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' '@'
-  rewriteRule '.*'          'ldap://ldap3.my.org/%0' '@'
+  rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
+  rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
+  rewriteRule '.*'          'ldap://ldap3.my.org/%0' ':@'
 .fi
 .LP
 (Rule 1 is simply there to illustrate the `G{n}' action; it could have
 been written:
 .LP
 .nf
-  rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' '@'
+  rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
 .fi
 .LP
 with the advantage of saving one rewrite pass ...)
index 9b49572d22015319750a9081d1e1f4173ae93d58..3d0ba4c2e62c57d274700e389fc2122b2bd99ffd 100644 (file)
@@ -91,11 +91,15 @@ or
 .B exact 
 (an alias of 
 .BR base )
-indicates the entry whose DN is equal to the pattern.
+indicates the entry whose DN is equal to the pattern;
 .B one
+(synonym of
+.BR onelevel )
 indicates all the entries immediately below the
 .BR pattern ,
-.B subtree
+.B sub
+(synonym of
+.BR subtree )
 indicates all entries in the subtree at the pattern,
 .B children
 indicates all the entries below (subordinate to) the pattern.
@@ -370,7 +374,7 @@ Its component are defined as
 .LP
 .nf
        <level> ::= none|auth|compare|search|read|write
-       <priv> ::= {=|+|-}{w|r|s|c|x}+
+       <priv> ::= {=|+|-}{w|r|s|c|x|0}+
 .fi
 .LP
 The modifier
@@ -434,7 +438,9 @@ for search,
 for compare, and
 .B x
 for authentication.
-More than one privilege can be added in one statement.
+More than one of the above privileges can be added in one statement.
+.B 0
+indicates no privileges and is used only by itself (e.g., +0).
 .LP
 The optional field
 .B <control>
index 6bc17bac58531fe85d46ccf5be8fa121bea9e8eb..a71696faaa17e1ddc8c5e65fb87439992df174c0 100644 (file)
@@ -9,9 +9,13 @@ slapadd \- Add entries to a SLAPD database
 .B [\-v]
 .B [\-c]
 .B [\-u]
+.B [\-p]
+.B [\-r]
+.B [\-w]
 .B [\-d level]
 .B [\-b suffix]
 .B [\-n dbnum]
+.B [\-i rid1,rid2,...]
 .B [\-f slapd.conf]
 .B [\-l ldif-file]
 .B 
@@ -47,6 +51,26 @@ enable continue (ignore errors) mode.
 .B \-u
 enable dry-run (don't write to backend) mode.
 .TP
+.BI \-p
+If the LDIF input represents a syncrepl consumer replica,
+promote it to the syncrepl provider's content after adding
+the entries.
+.TP
+.BI    \-r
+If the LDIF input represents a syncrepl provider replica,
+demote it to the syncrepl consumer replica after adding
+the entries.
+.TP
+.BI \-w
+When used with either 
+.B \-p
+or
+.B \-r,
+rebuild the new syncrepl
+information from the contents of the added entries.
+The syncrepl information contained in the LDIF input
+file is ignored.
+.TP
 .BI \-d " level"
 enable debugging messages as defined by the specified
 .IR level .
@@ -66,6 +90,11 @@ cannot be used in conjunction with the
 .B \-b
 option.
 .TP
+.BI \-i " rid1,rid2,..."
+Specify the replication ids for one or more syncrepl consumer
+replicas contained in the LDIF input. If omitted, 0 is used
+as the replication id.
+.TP
 .BI \-f " slapd.conf"
 specify an alternative
 .BR slapd.conf (5)
index e53faf497cc4022c2d6759ef7aebe8d6b61743b1..ae9e5619633bd2bf39a598fc2f0aad0a7a41224c 100644 (file)
@@ -8,6 +8,8 @@ slapcat \- SLAPD database to LDIF utility
 .B SBINDIR/slapcat
 .B [\-v]
 .B [\-c]
+.B [\-k]
+.B [\-m]
 .B [\-d level]
 .B [\-b suffix]
 .B [\-n dbnum]
@@ -36,13 +38,23 @@ without first being reordered.
 .SH OPTIONS
 .TP
 .B \-v
-enable verbose mode.
+Enable verbose mode.
 .TP
 .B \-c
-enable continue (ignore errors) mode.
+Enable continue (ignore errors) mode.
+.TP
+.B \-k
+Include
+.B syncConsumerSubentry
+of the syncrepl consumer in the generated LDIF output.
+.TP
+.B \-m
+Include
+.B syncProviderSubentry
+of the syncrepl provider in the generated LDIF output.
 .TP
 .BI \-d " level"
-enable debugging messages as defined by the specified
+Enable debugging messages as defined by the specified
 .IR level .
 .TP
 .BI \-b " suffix" 
@@ -69,7 +81,7 @@ or
 option is given.
 .TP
 .BI \-f " slapd.conf"
-specify an alternative
+Specify an alternative
 .BR slapd.conf (5)
 file.
 .TP
index 38cfc4b977cd858d345d42e58bd1a834a0e320da..2d5d8585b0bd76fe18775a9d4b2798a415154ece 100644 (file)
@@ -13,6 +13,7 @@ slapd \- Stand-alone LDAP Daemon
 .B [\-n service\-name] [\-s syslog\-level] [\-l syslog\-local\-user]
 .B [\-r directory]
 .B [\-u user] [\-g group] [\-t]
+.B [\-c cookie]
 .B 
 .SH DESCRIPTION
 .LP
@@ -172,7 +173,7 @@ will read the configuration file (the default if none is given with the
 or database.
 .TP
 .BI \-c " cookie"
-This option provides a cookie for a syncrepl replication consumer.
+This option provides a cookie for the syncrepl replication consumer.
 The cookie is a comma separated list of name=value pairs.
 Currently supported syncrepl cookie fields are
 .B csn,
@@ -180,20 +181,18 @@ Currently supported syncrepl cookie fields are
 and
 .B rid.
 .B csn
-is the commit sequence number of the master content at the provider site
-and represents the state of the content to which the replica content
-was synchronized most recently.
+is the commit sequence number received by a previous synchronization
+and represents the state of the consumer replica content which the
+syncrepl engine will synchronize to the current provider content.
 .B sid
-is the identity of the session which this replication thread belongs to.
-The replication provider site may maintain a session history store
-for each replication session to reduce synchronization traffic.
+is the identity of the per-scope session log with which the 
+provider server can process this syncrepl request to reduce
+synchronization traffic.
 .B rid
-identifies a replication thread within a replication consumer site
-and is used to find the replication thread specification of 
+identifies a replication thread within the consumer server
+and is used to find the syncrepl specification in 
 .BR slapd.conf (5)
-having the same
-.B rid
-value as the cookie.
+having the matching replication identifier in its definition.
 .SH EXAMPLES
 To start 
 .I slapd
index 87f497c4a027beeb7aaed31c3d980a81316b1acf..510e37b7f1338b640b7b1be84d10440b56482d82 100644 (file)
 #define LDAP_ENV_PREFIX "LDAP"
 
 /* default ldapi:// socket */
-#define LDAPI_SOCK LDAP_RUNDIR LDAP_DIRSEP "ldapi"
-
-/*
- * MAIL500 MAILER DEFINITIONS
- */
-       /* max number of ambiguous matches reported */
-#define MAIL500_MAXAMBIGUOUS   10
-       /* max subscribers allowed (size limit when searching for them ) */
-#define MAIL500_MAXGROUPMEMBERS        LDAP_NO_LIMIT
-       /* timeout for all searches */
-#define MAIL500_TIMEOUT                180
-       /* sendmail location - mail500 needs to exec this */
-#define MAIL500_SENDMAIL       LDAP_SENDMAIL
-
-/*
- * UD DEFINITIONS
- */
-       /* default config file locations */
-#define FILTERFILE     LDAP_SYSCONFDIR LDAP_DIRSEP "ldapfilter.conf"
-       /* ud configuration file */
-#define UD_CONFIG_FILE         LDAP_SYSCONFDIR LDAP_DIRSEP "ud.conf"
-       /* default editor */
-#define UD_DEFAULT_EDITOR      LDAP_EDITOR
-       /* default bbasename of user config file */
-#define UD_USER_CONFIG_FILE    ".udrc"
-       /* default base where groups are created */
-#define UD_WHERE_GROUPS_ARE_CREATED    ""
-       /* default base below which all groups live */
-#define UD_WHERE_ALL_GROUPS_LIVE       ""
+#define LDAPI_SOCK LDAP_RUNDIR LDAP_DIRSEP "run" LDAP_DIRSEP "ldapi"
 
 /*
  * SLAPD DEFINITIONS
index fdf7c1f4dfb86aa3d18a070226178413ed4beb69..9178c89ef60c8cda6d8f784b06db7cd2bdf0d347 100644 (file)
@@ -1,26 +1,23 @@
-/******************************************************************************
+/* $OpenLDAP$
+ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright (C) 2000 Pierangelo Masarati, <ando@sys-net.it>
+ * Copyright 2000-2003 The OpenLDAP Foundation.
+ * Portions Copyright 2000-2003 Pierangelo Masarati.
  * All rights reserved.
  *
- * Permission is granted to anyone to use this software for any purpose
- * on any computer system, and to alter it and redistribute it, subject
- * to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of this
- * software, no matter how awful, even if they arise from flaws in it.
- *
- * 2. The origin of this software must not be misrepresented, either by
- * explicit claim or by omission.  Since few users ever read sources,
- * credits should appear in the documentation.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
  *
- * 3. Altered versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.  Since few users
- * ever read sources, credits should appear in the documentation.
- *
- * 4. This notice may not be removed or altered.
- *
- ******************************************************************************/
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENT:
+ * This work was initially developed by Pierangelo Masarati for
+ * inclusion in OpenLDAP Software.
+ */
 
 #ifndef REWRITE_H
 #define REWRITE_H
 #define REWRITE_REGEXEC_OK              0x0000
 #define REWRITE_REGEXEC_ERR             0x0001
 #define REWRITE_REGEXEC_STOP            0x0002
-#define REWRITE_REGEXEC_UNWILLING       0x0004
+#define REWRITE_REGEXEC_UNWILLING       0x0003
+#define REWRITE_REGEXEC_USER           0x0004 /* and above ... */
+
+/*
+ * Rewrite variable flags
+ *     REWRITE_VAR_INSERT              insert mode (default) when adding
+ *                                     a variable; if not set during value
+ *                                     update, the variable is not inserted
+ *                                     if not present
+ *     REWRITE_VAR_UPDATE              update mode (default) when updating
+ *                                     a variable; if not set during insert,
+ *                                     the value is not updated if the
+ *                                     variable already exists
+ *     REWRITE_VAR_COPY_NAME           copy the variable name; if not set,
+ *                                     the name is not copied; be sure the
+ *                                     referenced string is available for
+ *                                     the entire life scope of the variable.
+ *     REWRITE_VAR_COPY_VALUE          copy the variable value; if not set,
+ *                                     the value is not copied; be sure the
+ *                                     referenced string is available for
+ *                                     the entire life scope of the variable.
+ */
+#define REWRITE_VAR_NONE               0x0000
+#define REWRITE_VAR_INSERT             0x0001
+#define REWRITE_VAR_UPDATE             0x0002
+#define REWRITE_VAR_COPY_NAME          0x0004
+#define REWRITE_VAR_COPY_VALUE         0x0008
 
 /*
  * Rewrite info
@@ -177,13 +200,18 @@ rewrite_session_init(
  * Defines and inits a variable with session scope
  */
 LDAP_REWRITE_F (int)
-rewrite_session_var_set(
+rewrite_session_var_set_f(
                struct rewrite_info *info,
                const void *cookie,
                const char *name,
-               const char *value
+               const char *value,
+               int flags
 );
 
+#define rewrite_session_var_set(info, cookie, name, value) \
+       rewrite_session_var_set_f((info), (cookie), (name), (value), \
+                       REWRITE_VAR_INSERT|REWRITE_VAR_UPDATE|REWRITE_VAR_COPY_NAME|REWRITE_VAR_COPY_VALUE)
+
 /*
  * Deletes a session
  */
index 551e3d2e9055be92be075fb0ef1674dc39903734..a7a46a7aa78f049727ea76671a2291bbde9f74da 100644 (file)
  * <http://www.OpenLDAP.org/license.html>.
  */
 
+/*
+ * This header is used in development of SLAPI plugins for
+ * OpenLDAP slapd(8) and other directory servers supporting
+ * this interface.  Your portability mileage may vary.
+ */
+
 #ifndef _SLAPI_PLUGIN_H
 #define _SLAPI_PLUGIN_H
 
index 09fa94e01e4c9add84274e9fc5d9902475259f72..c3687a439781e71b33323590e4512c6d34587728 100644 (file)
@@ -585,10 +585,15 @@ ldap_host_connected_to( Sockbuf *sb, const char *host )
                break;
        }
 
-#if 0
        {
                char *herr;
+#ifdef NI_MAXHOST
                char hbuf[NI_MAXHOST];
+#elif defined( MAXHOSTNAMELEN
+               char hbuf[MAXHOSTNAMELEN];
+#else
+               char hbuf[256];
+#endif
                hbuf[0] = 0;
 
                if (ldap_pvt_get_hname( sa, len, hbuf, sizeof(hbuf), &herr ) == 0
@@ -597,7 +602,6 @@ ldap_host_connected_to( Sockbuf *sb, const char *host )
                        return LDAP_STRDUP( hbuf );   
                }
        }
-#endif
 
        return host ? LDAP_STRDUP( host ) : NULL;
 }
index 9cf3ad98dc45f6c5f2de29fb0d647ba464567398..da33b467a5ff3173c7e4d79b2ad5ba2797c0ee94 100644 (file)
@@ -39,7 +39,7 @@ rewrite_parse_builtin_map(
  * lines handled are of the form:
  *
  *      rewriteEngine          {on|off}
- *      rewriteMaxPasses        numPasses
+ *      rewriteMaxPasses        numPasses [numPassesPerRule]
  *      rewriteContext                 contextName [alias aliasedContextName]
  *      rewriteRule            pattern substPattern [ruleFlags]
  *      rewriteMap             mapType mapName [mapArgs]
@@ -103,7 +103,25 @@ rewrite_parse(
                                        fname, lineno, "" );
                        return -1;
                }
+
                info->li_max_passes = atoi( argv[ 1 ] );
+               if ( info->li_max_passes <= 0 ) {
+                       Debug( LDAP_DEBUG_ANY,
+                                       "[%s:%d] negative or null rewriteMaxPasses'\n",
+                                       fname, lineno, 0 );
+               }
+
+               if ( argc > 2 ) {
+                       info->li_max_passes_per_rule = atoi( argv[ 2 ] );
+                       if ( info->li_max_passes_per_rule <= 0 ) {
+                               Debug( LDAP_DEBUG_ANY,
+                                               "[%s:%d] negative or null rewriteMaxPassesPerRule'\n",
+                                               fname, lineno, 0 );
+                       }
+
+               } else {
+                       info->li_max_passes_per_rule = info->li_max_passes;
+               }
                rc = REWRITE_SUCCESS;
        
        /*
index 281fbb4550c7761a3830a17f12801f0dcc788d88..bfa1b77d17c5604aeecd212b3a68faf8e3c03523 100644 (file)
@@ -357,6 +357,15 @@ rewrite_context_apply(
                                                        goto rc_end_of_context;
                                                }
                                                break;
+
+                                       /*
+                                        * This ends the rewrite context
+                                        * and returns a user-defined
+                                        * error code
+                                        */
+                                       case REWRITE_ACTION_USER:
+                                               return_code = ((int *)action->la_args)[ 0 ];
+                                               goto rc_end_of_context;
                                        
                                        default:
                                                /* ... */
@@ -385,10 +394,17 @@ rewrite_context_apply(
                 * This will instruct the server to return
                 * an `unwilling to perform' error message
                 */
-                case REWRITE_REGEXEC_UNWILLING:
+               case REWRITE_REGEXEC_UNWILLING:
                        return_code = REWRITE_REGEXEC_UNWILLING;
                        goto rc_end_of_context;
 
+               /*
+                * A user-defined error code has propagated ...
+                */
+               default:
+                       assert( rc >= REWRITE_REGEXEC_USER );
+                       goto rc_end_of_context;
+
                }
                
 rc_continue:;  /* sent here by actions that require to continue */
index ef95f5da840df9cfd5b24df326b88cb8eeb9697b..faa2424c3fd92935961dcd93bbffb5e26143ac84 100644 (file)
@@ -67,6 +67,7 @@ rewrite_info_init(
 
        info->li_state = REWRITE_DEFAULT;
        info->li_max_passes = REWRITE_MAX_PASSES;
+       info->li_max_passes_per_rule = REWRITE_MAX_PASSES;
        info->li_rewrite_mode = mode;
 
        /*
@@ -259,11 +260,13 @@ rewrite_session(
         */
        case REWRITE_REGEXEC_UNWILLING:
        case REWRITE_REGEXEC_ERR:
-       default:
                if ( *result != NULL ) {
                        free( *result );
                        *result = NULL;
                }
+
+       default:
+               break;
        }
 
 rc_return:;
index 3f14b0c16030f63b3f8c3fbe582089708f998212..bfdbff1220ef44a3bc54e0f15e0b60c961e33938 100644 (file)
@@ -71,6 +71,8 @@
 #define REWRITE_FLAG_STOP                      '@'
 #define REWRITE_FLAG_UNWILLING                 '#'
 #define REWRITE_FLAG_GOTO                      'G'     /* requires an arg */
+#define REWRITE_FLAG_USER                      'U'     /* requires an arg */
+#define REWRITE_FLAG_MAX_PASSES                        'M'     /* requires an arg */
 #define REWRITE_FLAG_IGNORE_ERR                        'I'
 
 /*
@@ -97,6 +99,7 @@ struct rewrite_action {
 #define REWRITE_ACTION_UNWILLING       0x0002
 #define REWRITE_ACTION_GOTO            0x0003
 #define REWRITE_ACTION_IGNORE_ERR      0x0004
+#define REWRITE_ACTION_USER            0x0005
        int                             la_type;
        void                           *la_args;
 };
@@ -217,6 +220,7 @@ struct rewrite_rule {
 #define REWRITE_RECURSE                        0x0001
 #define REWRITE_EXEC_ONCE              0x0002
        int                             lr_mode;
+       int                             lr_max_passes;
 
        struct rewrite_action          *lr_action;
 };
@@ -248,6 +252,7 @@ struct rewrite_session {
  */
 struct rewrite_var {
        char                           *lv_name;
+       int                             lv_flags;
        struct berval                   lv_value;
 };
 
@@ -301,6 +306,7 @@ struct rewrite_info {
         */
 #define REWRITE_MAXPASSES              100
        int                             li_max_passes;
+       int                             li_max_passes_per_rule;
 
        /*
         * Behavior in case a NULL or non-existent context is required
@@ -459,11 +465,12 @@ rewrite_session_find(
  * Defines and inits a variable with session scope
  */
 LDAP_REWRITE_F (int)
-rewrite_session_var_set(
+rewrite_session_var_set_f(
                 struct rewrite_info *info,
                 const void *cookie,
                 const char *name,
-                const char *value
+                const char *value,
+               int flags
 );
 
 /*
@@ -508,27 +515,46 @@ rewrite_var_find(
                 const char *name
 );
 
+/*
+ * Replaces the value of a variable
+ */
+LDAP_REWRITE_F (int)
+rewrite_var_replace(
+               struct rewrite_var *var,
+               const char *value,
+               int flags
+);
+
 /*
  * Inserts a newly created var
  */
 LDAP_REWRITE_F (struct rewrite_var *)
-rewrite_var_insert(
+rewrite_var_insert_f(
                 Avlnode **tree,
                 const char *name,
-                const char *value
+                const char *value,
+               int flags
 );
 
+#define rewrite_var_insert(tree, name, value) \
+       rewrite_var_insert_f((tree), (name), (value), \
+                       REWRITE_VAR_UPDATE|REWRITE_VAR_COPY_NAME|REWRITE_VAR_COPY_VALUE)
+
 /*
  * Sets/inserts a var
  */
 LDAP_REWRITE_F (struct rewrite_var *)
-rewrite_var_set(
+rewrite_var_set_f(
                 Avlnode **tree,
                 const char *name,
                 const char *value,
-                int insert
+                int flags
 );
 
+#define rewrite_var_set(tree, name, value, insert) \
+       rewrite_var_set_f((tree), (name), (value), \
+                       REWRITE_VAR_UPDATE|REWRITE_VAR_COPY_NAME|REWRITE_VAR_COPY_VALUE|((insert)? REWRITE_VAR_INSERT : 0))
+
 /*
  * Deletes a var tree
  */
index 927e1e382c6db330de2bf2f3959c01cf80cceece..40d83d8a74adde9a3a3d5319b1142b76e6010af7 100644 (file)
@@ -62,6 +62,8 @@ apply(
                        rewriteContext != NULL;
                        rewriteContext = sep,
                        sep ? sep = strchr( rewriteContext, ',' ) : NULL ) {
+               char    *errmsg = "";
+
                if ( sep != NULL ) {
                        sep[ 0 ] = '\0';
                        sep++;
@@ -70,8 +72,35 @@ apply(
                rc = rewrite_session( info, rewriteContext, string,
                                cookie, &result );
                
-               fprintf( stdout, "%s -> %s\n", string, 
-                               ( result ? result : "unwilling to perform" ) );
+               switch ( rc ) {
+               case REWRITE_REGEXEC_OK:
+                       errmsg = "ok";
+                       break;
+
+               case REWRITE_REGEXEC_ERR:
+                       errmsg = "error";
+                       break;
+
+               case REWRITE_REGEXEC_STOP:
+                       errmsg = "stop";
+                       break;
+
+               case REWRITE_REGEXEC_UNWILLING:
+                       errmsg = "unwilling to perform";
+                       break;
+
+               default:
+                       if (rc >= REWRITE_REGEXEC_USER) {
+                               errmsg = "user-defined";
+                       } else {
+                               errmsg = "unknown";
+                       }
+                       break;
+               }
+               
+               fprintf( stdout, "%s -> %s [%d:%s]\n", string, 
+                               ( result ? result : "(null)" ),
+                               rc, errmsg );
                if ( result == NULL ) {
                        break;
                }
index 60531735fe3629d69f0921f6e3b589b146b202ef..e5a0732703426cad12032ff8ee62a54e60c1d62e 100644 (file)
@@ -50,17 +50,17 @@ append_rule(
  */
 static int
 append_action(
-               struct rewrite_action *base,
+               struct rewrite_action **pbase,
                struct rewrite_action *action
 )
 {
-       struct rewrite_action *a;
+       struct rewrite_action **pa;
 
-       assert( base != NULL );
+       assert( pbase != NULL );
        assert( action != NULL );
        
-       for ( a = base; a->la_next != NULL; a = a->la_next );
-       a->la_next = action;
+       for ( pa = pbase; *pa != NULL; pa = &(*pa)->la_next );
+       *pa = action;
        
        return REWRITE_SUCCESS;
 }
@@ -79,7 +79,8 @@ destroy_action(
 
        /* do something */
        switch ( action->la_type ) {
-       case REWRITE_FLAG_GOTO: {
+       case REWRITE_FLAG_GOTO:
+       case REWRITE_FLAG_USER: {
                int *pi = (int *)action->la_args;
 
                if ( pi ) {
@@ -115,6 +116,7 @@ rewrite_rule_compile(
 {
        int flags = REWRITE_REGEX_EXTENDED | REWRITE_REGEX_ICASE;
        int mode = REWRITE_RECURSE;
+       int max_passes = info->li_max_passes_per_rule;
 
        struct rewrite_rule *rule = NULL;
        struct rewrite_subst *subst = NULL;
@@ -188,8 +190,8 @@ rewrite_rule_compile(
                                return REWRITE_ERR;
                        }
                        
-                       mode &= ~REWRITE_RECURSE;
-                       mode |= REWRITE_EXEC_ONCE;
+                       //mode &= ~REWRITE_RECURSE;
+                       //mode |= REWRITE_EXEC_ONCE;
                        action->la_type = REWRITE_ACTION_STOP;
                        break;
                        
@@ -208,13 +210,17 @@ rewrite_rule_compile(
                        action->la_type = REWRITE_ACTION_UNWILLING;
                        break;
 
-               case REWRITE_FLAG_GOTO: {                       /* 'G' */
+               case REWRITE_FLAG_GOTO:                         /* 'G' */
                        /*
                         * After applying rule, jump N rules
                         */
 
-                       char buf[16], *q;
-                       size_t l;
+               case REWRITE_FLAG_USER: {                       /* 'U' */
+                       /*
+                        * After applying rule, return user-defined
+                        * error code
+                        */
+                       char *next = NULL;
                        int *d;
                        
                        if ( p[ 1 ] != '{' ) {
@@ -222,36 +228,66 @@ rewrite_rule_compile(
                                return REWRITE_ERR;
                        }
 
-                       q = strchr( p + 2, '}' );
-                       if ( q == NULL ) {
-                               /* XXX Need to free stuff */
-                               return REWRITE_ERR;
-                       }
-
-                       l = q - p + 2;
-                       if ( l >= sizeof( buf ) ) {
+                       d = malloc( sizeof( int ) );
+                       if ( d == NULL ) {
                                /* XXX Need to free stuff */
                                return REWRITE_ERR;
                        }
-                       AC_MEMCPY( buf, p + 2, l );
-                       buf[ l ] = '\0';
 
-                       d = malloc( sizeof( int ) );
-                       if ( d == NULL ) {
+                       d[ 0 ] = strtol( &p[ 2 ], &next, 0 );
+                       if ( next == NULL || next == &p[ 2 ] || next[0] != '}' ) {
                                /* XXX Need to free stuff */
                                return REWRITE_ERR;
                        }
-                       d[ 0 ] = atoi( buf );
 
                        action = calloc( sizeof( struct rewrite_action ), 1 );
                        if ( action == NULL ) {
                                /* cleanup ... */       
                                return REWRITE_ERR;
                        }
-                       action->la_type = REWRITE_ACTION_GOTO;
+                       switch ( p[ 0 ] ) {
+                       case REWRITE_FLAG_GOTO:
+                               action->la_type = REWRITE_ACTION_GOTO;
+                               break;
+
+                       case REWRITE_FLAG_USER:
+                               action->la_type = REWRITE_ACTION_USER;
+                               break;
+
+                       default:
+                               assert(0);
+                       }
+
                        action->la_args = (void *)d;
 
-                       p = q;  /* p is incremented by the for ... */
+                       p = next;       /* p is incremented by the for ... */
+               
+                       break;
+               }
+
+               case REWRITE_FLAG_MAX_PASSES: {                 /* 'U' */
+                       /*
+                        * Set the number of max passes per rule
+                        */
+                       char *next = NULL;
+                       
+                       if ( p[ 1 ] != '{' ) {
+                               /* XXX Need to free stuff */
+                               return REWRITE_ERR;
+                       }
+
+                       max_passes = strtol( &p[ 2 ], &next, 0 );
+                       if ( next == NULL || next == &p[ 2 ] || next[0] != '}' ) {
+                               /* XXX Need to free stuff */
+                               return REWRITE_ERR;
+                       }
+
+                       if ( max_passes < 1 ) {
+                               /* FIXME: nonsense ... */
+                               max_passes = 1;
+                       }
+
+                       p = next;       /* p is incremented by the for ... */
                
                        break;
                }
@@ -283,11 +319,7 @@ rewrite_rule_compile(
                 * Stupid way to append to a list ...
                 */
                if ( action != NULL ) {
-                       if ( first_action == NULL ) {
-                               first_action = action;
-                       } else {
-                               append_action( first_action, action );
-                       }
+                       append_action( &first_action, action );
                        action = NULL;
                }
        }
@@ -333,6 +365,7 @@ rewrite_rule_compile(
         */
        rule->lr_flags = flags;         /* don't really need any longer ... */
        rule->lr_mode = mode;
+       rule->lr_max_passes = max_passes;
        rule->lr_action = first_action;
        
        /*
@@ -383,8 +416,8 @@ rewrite_rule_apply(
 recurse:;
 
        Debug( LDAP_DEBUG_TRACE, "==> rewrite_rule_apply"
-                       " rule='%s' string='%s'\n", 
-                       rule->lr_pattern, string, 0 );
+                       " rule='%s' string='%s' [%s pass(es)]\n", 
+                       rule->lr_pattern, string, strcnt + 1 );
        
        op->lo_num_passes++;
        if ( regexec( &rule->lr_regex, string, nmatch, match, 0 ) != 0 ) {
@@ -414,9 +447,9 @@ recurse:;
        }
 
        if ( ( rule->lr_mode & REWRITE_RECURSE ) == REWRITE_RECURSE 
-                       && op->lo_num_passes <= info->li_max_passes ) {
+                       && op->lo_num_passes < info->li_max_passes
+                       && ++strcnt < rule->lr_max_passes ) {
                string = *result;
-               strcnt++;
 
                goto recurse;
        }
index 3a09fb40d2be1a82371621a9556a665a2754cea0..34feb4959ed0213c04bbb3438c8e542d6cc1d210 100644 (file)
@@ -185,11 +185,12 @@ rewrite_session_return(
  * Defines and inits a var with session scope
  */
 int
-rewrite_session_var_set(
+rewrite_session_var_set_f(
                struct rewrite_info *info,
                const void *cookie,
                const char *name,
-               const char *value
+               const char *value,
+               int flags
 )
 {
        struct rewrite_session *session;
@@ -212,11 +213,11 @@ rewrite_session_var_set(
        var = rewrite_var_find( session->ls_vars, name );
        if ( var != NULL ) {
                assert( var->lv_value.bv_val != NULL );
-               free( var->lv_value.bv_val );
-               var->lv_value.bv_val = strdup( value );
-               var->lv_value.bv_len = strlen( value );
+
+               (void)rewrite_var_replace( var, value, flags );
+
        } else {
-               var = rewrite_var_insert( &session->ls_vars, name, value );
+               var = rewrite_var_insert_f( &session->ls_vars, name, value, flags );
                if ( var == NULL ) {
 #ifdef USE_REWRITE_LDAP_PVT_THREADS
                        ldap_pvt_thread_rdwr_wunlock( &session->ls_vars_mutex );
index ee32dbd76f96ec92df051759b29c5962c3a877ec..fe055a35ccae4afb35cfc1a9e54151d3e7c51e2e 100644 (file)
@@ -27,7 +27,7 @@
 struct rewrite_subst *
 rewrite_subst_compile(
                struct rewrite_info *info,
-               const char *result
+               const char *str
 )
 {
        size_t subs_len;
@@ -36,11 +36,16 @@ rewrite_subst_compile(
 
        struct rewrite_subst *s = NULL;
 
-       const char *begin, *p;
+       char *result, *begin, *p;
        int nsub = 0, l;
 
        assert( info != NULL );
-       assert( result != NULL );
+       assert( str != NULL );
+
+       result = strdup( str );
+       if ( result == NULL ) {
+               return NULL;
+       }
 
        /*
         * Take care of substitution string
@@ -63,8 +68,7 @@ rewrite_subst_compile(
                tmps = ( struct berval * )realloc( subs,
                                sizeof( struct berval )*( nsub + 1 ) );
                if ( tmps == NULL ) {
-                       /* FIXME: cleanup */
-                       return NULL;
+                       goto cleanup;
                }
                subs = tmps;
                
@@ -78,7 +82,7 @@ rewrite_subst_compile(
                        subs[ nsub ].bv_len = l;
                        subs[ nsub ].bv_val = malloc( l + 1 );
                        if ( subs[ nsub ].bv_val == NULL ) {
-                               return NULL;
+                               goto cleanup;
                        }
                        AC_MEMCPY( subs[ nsub ].bv_val, begin, l );
                        subs[ nsub ].bv_val[ l ] = '\0';
@@ -101,8 +105,7 @@ rewrite_subst_compile(
                        tmpsm = ( struct rewrite_submatch * )realloc( submatch,
                                        sizeof( struct rewrite_submatch )*( nsub + 1 ) );
                        if ( tmpsm == NULL ) {
-                               /* cleanup */
-                               return NULL;
+                               goto cleanup;
                        }
                        submatch = tmpsm;
                        submatch[ nsub ].ls_submatch = d;
@@ -124,10 +127,9 @@ rewrite_subst_compile(
                                        REWRITE_SUBMATCH_XMAP;
 
                                map = rewrite_xmap_parse( info,
-                                               p + 3, &begin );
+                                               p + 3, (const char **)&begin );
                                if ( map == NULL ) {
-                                       /* cleanup */
-                                       return NULL;
+                                       goto cleanup;
                                }
                                submatch[ nsub ].ls_map = map;
                                p = begin - 1;
@@ -140,10 +142,10 @@ rewrite_subst_compile(
                        struct rewrite_map *map;
                        struct rewrite_submatch *tmpsm;
 
-                       map = rewrite_map_parse( info, p + 2, &begin );
+                       map = rewrite_map_parse( info, p + 2,
+                                       (const char **)&begin );
                        if ( map == NULL ) {
-                               /* cleanup */
-                               return NULL;
+                               goto cleanup;
                        }
                        p = begin - 1;
 
@@ -153,13 +155,22 @@ rewrite_subst_compile(
                        tmpsm = ( struct rewrite_submatch * )realloc( submatch,
                                        sizeof( struct rewrite_submatch )*( nsub + 1 ) );
                        if ( tmpsm == NULL ) {
-                               /* cleanup */
-                               return NULL;
+                               goto cleanup;
                        }
                        submatch = tmpsm;
                        submatch[ nsub ].ls_type =
                                REWRITE_SUBMATCH_MAP_W_ARG;
                        submatch[ nsub ].ls_map = map;
+
+               /*
+                * Escape '%' ...
+                */
+               } else if ( p[ 1 ] == '%' ) {
+                       AC_MEMCPY( &p[ 1 ], &p[ 2 ], strlen( &p[ 1 ] ) );
+                       continue;
+
+               } else {
+                       goto cleanup;
                }
 
                nsub++;
@@ -174,7 +185,7 @@ rewrite_subst_compile(
                 * XXX need to free the value subst stuff!
                 */
                free( subs );
-               return NULL;
+               goto cleanup;
        }
        subs = tmps;
        l = p - begin;
@@ -191,8 +202,7 @@ rewrite_subst_compile(
 
        s = calloc( sizeof( struct rewrite_subst ), 1 );
        if ( s == NULL ) {
-               /* cleanup */
-               return NULL;
+               goto cleanup;
        }
 
        s->lt_subs_len = subs_len;
@@ -200,6 +210,9 @@ rewrite_subst_compile(
         s->lt_num_submatch = nsub;
         s->lt_submatch = submatch;
 
+cleanup:;
+       free( result );
+
        return s;
 }
 
@@ -321,7 +334,6 @@ rewrite_subst_apply(
                        }
                        
                        if ( rc != REWRITE_SUCCESS ) {
-                               rc = REWRITE_REGEXEC_ERR;
                                goto cleanup;
                        }
                        break;
@@ -372,7 +384,7 @@ rewrite_subst_apply(
                        rc = REWRITE_ERR;
                        break;
                }
-               
+
                if ( rc != REWRITE_SUCCESS ) {
                        rc = REWRITE_REGEXEC_ERR;
                }
index 6f8469789459bf1c01b6cce0e0db82c2c0ee016f..80bba9f1824c699b78e8157b25593d7f8f6d3a3f 100644 (file)
@@ -65,6 +65,39 @@ rewrite_var_dup(
        return ( strcasecmp( v1->lv_name, v2->lv_name ) == 0 ? -1 : 0 );
 }
 
+/*
+ * Frees a var
+ */
+static void 
+rewrite_var_free(
+               void *v_var
+)
+{
+       struct rewrite_var *var = v_var;
+       assert( var != NULL );
+
+       assert( var->lv_name != NULL );
+       assert( var->lv_value.bv_val != NULL );
+
+       if ( var->lv_flags & REWRITE_VAR_COPY_NAME )
+               free( var->lv_name );
+       if ( var->lv_flags & REWRITE_VAR_COPY_VALUE )
+               free( var->lv_value.bv_val );
+       free( var );
+}
+
+/*
+ * Deletes a var tree
+ */
+int
+rewrite_var_delete(
+               Avlnode *tree
+)
+{
+       avl_free( tree, rewrite_var_free );
+       return REWRITE_SUCCESS;
+}
+
 /*
  * Finds a var
  */
@@ -83,51 +116,112 @@ rewrite_var_find(
                        ( caddr_t )&var, rewrite_var_cmp );
 }
 
+int
+rewrite_var_replace(
+               struct rewrite_var *var,
+               const char *value,
+               int flags
+)
+{
+       ber_len_t       len = strlen( value );
+
+       if ( var->lv_flags & REWRITE_VAR_COPY_VALUE ) {
+               if ( flags & REWRITE_VAR_COPY_VALUE ) {
+                       if ( len <= var->lv_value.bv_len ) {
+                               AC_MEMCPY(var->lv_value.bv_val, value, len + 1);
+
+                       } else {
+                               free( var->lv_value.bv_val );
+                               var->lv_value.bv_val = strdup( value );
+                       }
+
+               } else {
+                       free( var->lv_value.bv_val );
+                       var->lv_value.bv_val = (char *)value;
+                       var->lv_flags &= ~REWRITE_VAR_COPY_VALUE;
+               }
+
+       } else {
+               if ( flags & REWRITE_VAR_COPY_VALUE ) {
+                       var->lv_value.bv_val = strdup( value );
+                       var->lv_flags |= REWRITE_VAR_COPY_VALUE;
+
+               } else {
+                       var->lv_value.bv_val = (char *)value;
+               }
+       }
+
+       var->lv_value.bv_len = len;
+
+       return 0;
+}
+
 /*
  * Inserts a newly created var
  */
 struct rewrite_var *
-rewrite_var_insert(
+rewrite_var_insert_f(
                Avlnode **tree,
                const char *name,
-               const char *value
+               const char *value,
+               int flags
 )
 {
        struct rewrite_var *var;
-       int rc;
+       int rc = 0;
 
        assert( tree != NULL );
        assert( name != NULL );
        assert( value != NULL );
        
+       var = rewrite_var_find( *tree, name );
+       if ( var != NULL ) {
+               if ( flags & REWRITE_VAR_UPDATE ) {
+                       (void)rewrite_var_replace( var, value, flags );
+                       goto cleanup;
+               }
+               rc = -1;
+               goto cleanup;
+       }
+
        var = calloc( sizeof( struct rewrite_var ), 1 );
        if ( var == NULL ) {
                return NULL;
        }
+
        memset( var, 0, sizeof( struct rewrite_var ) );
-       var->lv_name = strdup( name );
-       if ( var->lv_name == NULL ) {
-               rc = -1;
-               goto cleanup;
+
+       if ( flags & REWRITE_VAR_COPY_NAME ) {
+               var->lv_name = strdup( name );
+               if ( var->lv_name == NULL ) {
+                       rc = -1;
+                       goto cleanup;
+               }
+               var->lv_flags |= REWRITE_VAR_COPY_NAME;
+
+       } else {
+               var->lv_name = (char *)name;
        }
-       var->lv_value.bv_val = strdup( value );
-       if ( var->lv_value.bv_val == NULL ) {
-               rc = -1;
-               goto cleanup;
+
+       if ( flags & REWRITE_VAR_COPY_VALUE ) {
+               var->lv_value.bv_val = strdup( value );
+               if ( var->lv_value.bv_val == NULL ) {
+                       rc = -1;
+                       goto cleanup;
+               }
+               var->lv_flags |= REWRITE_VAR_COPY_VALUE;
+               
+       } else {
+               var->lv_value.bv_val = (char *)value;
        }
        var->lv_value.bv_len = strlen( value );
        rc = avl_insert( tree, ( caddr_t )var,
                        rewrite_var_cmp, rewrite_var_dup );
-       if ( rc != 0 ) { 
-               rc = -1;
-               goto cleanup;
-       }
 
 cleanup:;
-       if ( rc != 0 ) {
-               free( var->lv_name );
-               free( var->lv_value.bv_val );
-               free( var );
+       if ( rc != 0 && var ) {
+               avl_delete( tree, ( caddr_t )var, rewrite_var_cmp );
+               rewrite_var_free( var );
                var = NULL;
        }
 
@@ -138,11 +232,11 @@ cleanup:;
  * Sets/inserts a var
  */
 struct rewrite_var *
-rewrite_var_set(
+rewrite_var_set_f(
                Avlnode **tree,
                const char *name,
                const char *value,
-               int insert
+               int flags
 )
 {
        struct rewrite_var *var;
@@ -153,50 +247,19 @@ rewrite_var_set(
        
        var = rewrite_var_find( *tree, name );
        if ( var == NULL ) {
-               if ( insert ) {
-                       return rewrite_var_insert( tree, name, value );
+               if ( flags & REWRITE_VAR_INSERT ) {
+                       return rewrite_var_insert_f( tree, name, value, flags );
+
                } else {
                        return NULL;
                }
+
        } else {
                assert( var->lv_value.bv_val != NULL );
 
-               free( var->lv_value.bv_val );
-               var->lv_value.bv_val = ( char * )value;
-               var->lv_value.bv_len = strlen( value );
+               (void)rewrite_var_replace( var, value, flags );
        }
 
        return var;
 }
 
-/*
- * Frees a var
- */
-static void 
-rewrite_var_free(
-               void *v_var
-)
-{
-       struct rewrite_var *var = v_var;
-       assert( var != NULL );
-
-       assert( var->lv_name != NULL );
-       assert( var->lv_value.bv_val != NULL );
-
-       free( var->lv_name );
-       free( var->lv_value.bv_val );
-       free( var );
-}
-
-/*
- * Deletes a var tree
- */
-int
-rewrite_var_delete(
-               Avlnode *tree
-)
-{
-       avl_free( tree, rewrite_var_free );
-       return REWRITE_SUCCESS;
-}
-
index 7dfe72d35ec9214406d6c8e0b672d5e5c20dda0b..1934b6e86d4df104fb427674bdd6c2e4db63beb3 100644 (file)
@@ -343,7 +343,7 @@ install-local-srv: install-slapd install-conf install-schema install-tools
 
 install-slapd: FORCE
        -$(MKDIR) $(DESTDIR)$(libexecdir)
-       -$(MKDIR) $(DESTDIR)$(localstatedir)
+       -$(MKDIR) $(DESTDIR)$(localstatedir)/run
        $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
                slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
        @for i in $(SUBDIRS); do \
index 57f740af989a171e22a7652d03ece9b8db626ff0..6a56c98cf9b549924619ae425e3eaa34bc17a984 100644 (file)
 #include "sets.h"
 #include "lber_pvt.h"
 
+#ifdef LDAP_SLAPI
+#include "slapi/slapi.h"
+#endif /* LDAPI_SLAPI */
+
 #define ACL_BUF_SIZE   1024    /* use most appropriate size */
 
 /*
index 609a2b5f12ee042e0f1d8d727ccc30dd9843c782..913ac99f190029218e3ccab908a93f997e92d768 100644 (file)
@@ -184,7 +184,8 @@ parse_acl(
                                                a->acl_dn_style = ACL_STYLE_BASE;
                                                ber_str2bv( right, 0, 1, &a->acl_dn_pat );
 
-                                       } else if ( strcasecmp( style, "one" ) == 0 ) {
+                                       } else if ( strcasecmp( style, "onelevel" ) == 0
+                                               || strcasecmp( style, "one" ) == 0 ) {
                                                a->acl_dn_style = ACL_STYLE_ONE;
                                                ber_str2bv( right, 0, 1, &a->acl_dn_pat );
 
@@ -245,7 +246,8 @@ parse_acl(
                                                acl_usage();
                                        }
 
-                               } else if ( strncasecmp( left, "attr", 4 ) == 0 ) {
+                               } else if ( strcasecmp( left, "attr" ) == 0
+                                               || strcasecmp( left, "attrs" ) == 0 ) {
                                        a->acl_attrs = str2anlist( a->acl_attrs,
                                                right, "," );
                                        if ( a->acl_attrs == NULL ) {
@@ -401,7 +403,8 @@ parse_acl(
                                {
                                        sty = ACL_STYLE_BASE;
 
-                               } else if ( strcasecmp( style, "one" ) == 0 ) {
+                               } else if ( strcasecmp( style, "onelevel" ) == 0 ||
+                                       strcasecmp( style, "one" ) == 0 ) {
                                        sty = ACL_STYLE_ONE;
 
                                } else if ( strcasecmp( style, "subtree" ) == 0 ||
@@ -1396,7 +1399,7 @@ acl_usage( void )
                "<style> ::= regex | base | exact\n"
                "<access> ::= [self]{<level>|<priv>}\n"
                "<level> ::= none | auth | compare | search | read | write\n"
-               "<priv> ::= {=|+|-}{w|r|s|c|x}+\n"
+               "<priv> ::= {=|+|-}{w|r|s|c|x|0}+\n"
                "<control> ::= [ stop | continue | break ]\n"
        );
        exit( EXIT_FAILURE );
index ed9a8e37a57a23e5f64290660709bb608c6f55db..5e469d854df6a58a30b6a9dc5c2d179f7b1f11c9 100644 (file)
 #include "slap.h"
 
 #ifdef LDAP_SLAPI
-#include "slapi.h"
-static void initAddPlugin( Operation *op,
-       struct berval *dn, Entry *e, int manageDSAit );
-static int doPreAddPluginFNs( Operation *op );
-static void doPostAddPluginFNs( Operation *op );
+#include "slapi/slapi.h"
+
+static void init_add_pblock( Operation *op, struct berval *dn, Entry *e, int manageDSAit );
+static int call_add_preop_plugins( Operation *op );
+static void call_add_postop_plugins( Operation *op );
 #endif /* LDAP_SLAPI */
 
 int
@@ -239,7 +239,7 @@ do_add( Operation *op, SlapReply *rs )
        }
 
 #ifdef LDAP_SLAPI
-       if ( op->o_pb ) initAddPlugin( op, &dn, e, manageDSAit );
+       if ( op->o_pb ) init_add_pblock( op, &dn, e, manageDSAit );
 #endif /* LDAP_SLAPI */
 
        /*
@@ -261,6 +261,7 @@ do_add( Operation *op, SlapReply *rs )
                        int update = op->o_bd->be_update_ndn.bv_len;
                        char textbuf[SLAP_TEXT_BUFLEN];
                        size_t textlen = sizeof textbuf;
+                       slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
 
                        rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
                                                                                  textbuf, textlen, NULL );
@@ -299,7 +300,7 @@ do_add( Operation *op, SlapReply *rs )
                         * will actually contain something.
                         */
                        if ( op->o_pb ) {
-                               rs->sr_err = doPreAddPluginFNs( op );
+                               rs->sr_err = call_add_preop_plugins( op );
                                if ( rs->sr_err != LDAP_SUCCESS ) {
                                        /* plugin will have sent result */
                                        goto done;
@@ -308,13 +309,14 @@ do_add( Operation *op, SlapReply *rs )
 #endif /* LDAP_SLAPI */
 
                        op->ora_e = e;
-                       if ( (op->o_bd->be_add)( op, rs ) == 0 ) {
 #ifdef SLAPD_MULTIMASTER
-                               if ( !repl_user )
+                       if ( !repl_user )
 #endif
-                               {
-                                       replog( op );
-                               }
+                       {
+                               cb.sc_next = op->o_callback;
+                               op->o_callback = &cb;
+                       }
+                       if ( (op->o_bd->be_add)( op, rs ) == 0 ) {
                                be_entry_release_w( op, e );
                                e = NULL;
                        }
@@ -328,7 +330,7 @@ do_add( Operation *op, SlapReply *rs )
                         * on replicas (for now, it involves the minimum code intrusion).
                         */
                        if ( op->o_pb ) {
-                               rs->sr_err = doPreAddPluginFNs( op );
+                               rs->sr_err = call_add_preop_plugins( op );
                                if ( rs->sr_err != LDAP_SUCCESS ) {
                                        /* plugin will have sent result */
                                        goto done;
@@ -367,7 +369,7 @@ do_add( Operation *op, SlapReply *rs )
        } else {
 #ifdef LDAP_SLAPI
                if ( op->o_pb ) {
-                       rs->sr_err = doPreAddPluginFNs( op );
+                       rs->sr_err = call_add_preop_plugins( op );
                        if ( rs->sr_err != LDAP_SUCCESS ) {
                                /* plugin will have sent result */
                                goto done;
@@ -385,7 +387,7 @@ do_add( Operation *op, SlapReply *rs )
        }
 
 #ifdef LDAP_SLAPI
-       if ( op->o_pb ) doPostAddPluginFNs( op );
+       if ( op->o_pb ) call_add_postop_plugins( op );
 #endif /* LDAP_SLAPI */
 
 done:
@@ -652,7 +654,7 @@ slap_entry2mods(
 }
 
 #ifdef LDAP_SLAPI
-static void initAddPlugin( Operation *op,
+static void init_add_pblock( Operation *op,
        struct berval *dn, Entry *e, int manageDSAit )
 {
        slapi_int_pblock_set_operation( op->o_pb, op );
@@ -661,11 +663,11 @@ static void initAddPlugin( Operation *op,
        slapi_pblock_set( op->o_pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
 }
 
-static int doPreAddPluginFNs( Operation *op )
+static int call_add_preop_plugins( Operation *op )
 {
        int rc;
 
-       rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_ADD_FN, op->o_pb );
+       rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_ADD_FN, op->o_pb );
        if ( rc < 0 ) {
                /*
                 * A preoperation plugin failure will abort the
@@ -693,11 +695,11 @@ static int doPreAddPluginFNs( Operation *op )
        return rc;
 }
 
-static void doPostAddPluginFNs( Operation *op )
+static void call_add_postop_plugins( Operation *op )
 {
        int rc;
 
-       rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_ADD_FN, op->o_pb );
+       rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_ADD_FN, op->o_pb );
        if ( rc < 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, INFO,
index a96e590161e48c57f068e680cb69e24b982429c9..e08f764c4cca4c36835bde5f738aefac94624bf7 100644 (file)
@@ -465,51 +465,41 @@ retry:    /* transaction retry */
                }
 
        } else {
-               char gid[DB_XIDDATASIZE];
-
-               memset( gid, 0, sizeof(gid) );
-               snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx",
-                       bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid );
-
-               if (( rs->sr_err=TXN_PREPARE( ltid, gid )) != 0 ) {
-                       rs->sr_text = "txn_prepare failed";
+               struct berval nrdn;
+               Entry *e = entry_dup( op->ora_e );
 
+               if (pdn.bv_len) {
+                       nrdn.bv_val = e->e_nname.bv_val;
+                       nrdn.bv_len = pdn.bv_val - op->ora_e->e_nname.bv_val - 1;
                } else {
-                       struct berval nrdn;
-
-                       if (pdn.bv_len) {
-                               nrdn.bv_val = op->ora_e->e_nname.bv_val;
-                               nrdn.bv_len = pdn.bv_val - nrdn.bv_val - 1;
-                       } else {
-                               nrdn = op->ora_e->e_nname;
-                       }
+                       nrdn = e->e_nname;
+               }
 
-                       bdb_cache_add( bdb, ei, op->oq_add.rs_e, &nrdn, locker );
+               bdb_cache_add( bdb, ei, e, &nrdn, locker );
 
-                       if ( suffix_ei == NULL ) {
-                               suffix_ei = op->oq_add.rs_e->e_private;
-                       }
+               if ( suffix_ei == NULL ) {
+                       suffix_ei = e->e_private;
+               }
 
-                       if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                               if ( ctxcsn_added ) {
-                                       bdb_cache_add( bdb, suffix_ei, ctxcsn_e,
-                                                       (struct berval *)&slap_ldapsync_cn_bv, locker );
-                               }
+               if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
+                       if ( ctxcsn_added ) {
+                               bdb_cache_add( bdb, suffix_ei, ctxcsn_e,
+                                               (struct berval *)&slap_ldapsync_cn_bv, locker );
                        }
+               }
 
-                       if ( rs->sr_err == LDAP_SUCCESS && !noop && !op->o_no_psearch ) {
-                               ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
-                               LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-                                       bdb_psearch( op, rs, ps_list, op->oq_add.rs_e, LDAP_PSEARCH_BY_ADD );
-                               }
-                               ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
+               if ( rs->sr_err == LDAP_SUCCESS && !noop && !op->o_no_psearch ) {
+                       ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
+                       LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
+                               bdb_psearch( op, rs, ps_list, op->oq_add.rs_e, LDAP_PSEARCH_BY_ADD );
                        }
+                       ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
+               }
 
-                       if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) {
-                               rs->sr_text = "txn_commit failed";
-                       } else {
-                               rs->sr_err = LDAP_SUCCESS;
-                       }
+               if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) {
+                       rs->sr_text = "txn_commit failed";
+               } else {
+                       rs->sr_err = LDAP_SUCCESS;
                }
        }
 
index 439f938f07ea156c372f028fe47e8c89c3c10b3b..eca84dcfeec8675e85dfa9fddf90b9dc0f8505d9 100644 (file)
@@ -141,15 +141,62 @@ retry:    /* transaction retry */
        if ( rs->sr_err == 0 ) {
                e = ei->bei_e;
                eip = ei->bei_parent;
-               bdb_cache_find_id( op, ltid, eip->bei_id, &eip,
-                       0, locker, &plock );
        } else {
                matched = ei->bei_e;
        }
-       if ( eip ) {
-               p = eip->bei_e;
+
+       /* FIXME : dn2entry() should return non-glue entry */
+       if ( e == NULL || ( !manageDSAit && is_entry_glue( e ))) {
+#ifdef NEW_LOGGING
+               LDAP_LOG ( OPERATION, ARGS, 
+                       "<=- bdb_delete: no such object %s\n", op->o_req_dn.bv_val, 0, 0);
+#else
+               Debug( LDAP_DEBUG_ARGS,
+                       "<=- bdb_delete: no such object %s\n",
+                       op->o_req_dn.bv_val, 0, 0);
+#endif
+
+               if ( matched != NULL ) {
+                       rs->sr_matched = ch_strdup( matched->e_dn );
+                       rs->sr_ref = is_entry_referral( matched )
+                               ? get_entry_referrals( op, matched )
+                               : NULL;
+                       bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, matched);
+                       matched = NULL;
+
+               } else {
+                       BerVarray deref = NULL;
+                       if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
+                               syncinfo_t *si;
+                               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
+                                       struct berval tmpbv;
+                                       ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
+                                       ber_bvarray_add( &deref, &tmpbv );
+                               }
+                       } else {
+                               deref = default_referral;
+                       }
+                       rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
+                               LDAP_SCOPE_DEFAULT );
+               }
+
+               rs->sr_err = LDAP_REFERRAL;
+               send_ldap_result( op, rs );
+
+               if ( rs->sr_ref != default_referral ) {
+                       ber_bvarray_free( rs->sr_ref );
+               }
+               free( (char *)rs->sr_matched );
+               rs->sr_ref = NULL;
+               rs->sr_matched = NULL;
+
+               rs->sr_err = -1;
+               goto done;
        }
 
+       bdb_cache_find_id( op, ltid, eip->bei_id, &eip, 0, locker, &plock );
+       if ( eip ) p = eip->bei_e;
+
        if ( pdn.bv_len != 0 ) {
                if( p == NULL || !bvmatch( &pdn, &p->e_nname )) {
 #ifdef NEW_LOGGING
@@ -240,55 +287,6 @@ retry:     /* transaction retry */
                }
        }
 
-       /* FIXME : dn2entry() should return non-glue entry */
-       if ( e == NULL || ( !manageDSAit && is_entry_glue( e ))) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( OPERATION, ARGS, 
-                       "<=- bdb_delete: no such object %s\n", op->o_req_dn.bv_val, 0, 0);
-#else
-               Debug( LDAP_DEBUG_ARGS,
-                       "<=- bdb_delete: no such object %s\n",
-                       op->o_req_dn.bv_val, 0, 0);
-#endif
-
-               if ( matched != NULL ) {
-                       rs->sr_matched = ch_strdup( matched->e_dn );
-                       rs->sr_ref = is_entry_referral( matched )
-                               ? get_entry_referrals( op, matched )
-                               : NULL;
-                       bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, matched);
-                       matched = NULL;
-
-               } else {
-                       BerVarray deref = NULL;
-                       if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                               syncinfo_t *si;
-                               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
-                                       struct berval tmpbv;
-                                       ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
-                                       ber_bvarray_add( &deref, &tmpbv );
-                               }
-                       } else {
-                               deref = default_referral;
-                       }
-                       rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
-                               LDAP_SCOPE_DEFAULT );
-               }
-
-               rs->sr_err = LDAP_REFERRAL;
-               send_ldap_result( op, rs );
-
-               if ( rs->sr_ref != default_referral ) {
-                       ber_bvarray_free( rs->sr_ref );
-               }
-               free( (char *)rs->sr_matched );
-               rs->sr_ref = NULL;
-               rs->sr_matched = NULL;
-
-               rs->sr_err = -1;
-               goto done;
-       }
-
        if ( get_assert( op ) &&
                ( test_filter( op, e, get_assertion( op )) != LDAP_COMPARE_TRUE ))
        {
index 087f9571a89b775b1f6cdc367ede65244b81a92e..9debb6c59cda4619e9c8134fff62df805dbf5bc9 100644 (file)
@@ -617,8 +617,6 @@ retry:      /* transaction retry */
                        rs->sr_err = LDAP_SUCCESS;
                }
        } else {
-               EntryInfo *ctx_ei;
-
                bdb_cache_modify( e, dummy.e_attrs, bdb->bi_dbenv, locker, &lock );
 
                if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
index 50f0ad614326e48e2a7bf1598a14f487fc8030ac..f1d58647f8faa3e1a5ee9c471de67e117f2a1818 100644 (file)
@@ -980,49 +980,39 @@ retry:    /* transaction retry */
                }
 
        } else {
-               char gid[DB_XIDDATASIZE];
+               bdb_cache_modrdn( save, &op->orr_nnewrdn, e, neip,
+                       bdb->bi_dbenv, locker, &lock );
 
-               memset( gid, 0, sizeof(gid) );
-               snprintf( gid, sizeof( gid ), "%s-%08lx-%08lx",
-                       bdb_uuid.bv_val, (long) op->o_connid, (long) op->o_opid );
-
-               if(( rs->sr_err=TXN_PREPARE( ltid, gid )) != 0 ) {
-                       rs->sr_text = "txn_prepare failed";
-               } else {
-                       bdb_cache_modrdn( save, &op->orr_nnewrdn, e, neip,
-                               bdb->bi_dbenv, locker, &lock );
-
-                       if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
-                               if ( ctxcsn_added ) {
-                                       bdb_cache_add( bdb, suffix_ei, ctxcsn_e,
-                                               (struct berval *)&slap_ldapsync_cn_bv, locker );
-                               }
+               if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
+                       if ( ctxcsn_added ) {
+                               bdb_cache_add( bdb, suffix_ei, ctxcsn_e,
+                                       (struct berval *)&slap_ldapsync_cn_bv, locker );
                        }
+               }
 
-                       if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
-                               /* Loop through in-scope entries for each psearch spec */
-                               ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
-                               LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-                                       bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
-                               }
-                               ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
-                               pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
-                               while ( pm_list != NULL ) {
-                                       bdb_psearch(op, rs, pm_list->ps_op,
-                                                               e, LDAP_PSEARCH_BY_SCOPEOUT);
-                                       pm_prev = pm_list;
-                                       LDAP_LIST_REMOVE ( pm_list, ps_link );
-                                       pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
-                                       ch_free( pm_prev );
-                               }
+               if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
+                       /* Loop through in-scope entries for each psearch spec */
+                       ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
+                       LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
+                               bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
                        }
-
-                       if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) {
-                               rs->sr_text = "txn_commit failed";
-                       } else {
-                               rs->sr_err = LDAP_SUCCESS;
+                       ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
+                       pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
+                       while ( pm_list != NULL ) {
+                               bdb_psearch(op, rs, pm_list->ps_op,
+                                                       e, LDAP_PSEARCH_BY_SCOPEOUT);
+                               pm_prev = pm_list;
+                               LDAP_LIST_REMOVE ( pm_list, ps_link );
+                               pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
+                               ch_free( pm_prev );
                        }
                }
+
+               if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) {
+                       rs->sr_text = "txn_commit failed";
+               } else {
+                       rs->sr_err = LDAP_SUCCESS;
+               }
        }
  
        ltid = NULL;
index 5ec84fd975748e70bf545222800868b59c665b1b..f8867cbdda2b8fecca58a93537ffd85735f0c422 100644 (file)
@@ -40,7 +40,7 @@
 #include "ldap_rq.h"
 
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 /*
@@ -753,7 +753,7 @@ backend_unbind( Operation *op, SlapReply *rs )
                        int rc;
                        if ( i == 0 ) slapi_int_pblock_set_operation( op->o_pb, op );
                        slapi_pblock_set( op->o_pb, SLAPI_BACKEND, (void *)&backends[i] );
-                       rc = doPluginFNs( &backends[i], SLAPI_PLUGIN_PRE_UNBIND_FN,
+                       rc = slapi_int_call_plugins( &backends[i], SLAPI_PLUGIN_PRE_UNBIND_FN,
                                        (Slapi_PBlock *)op->o_pb );
                        if ( rc < 0 ) {
                                /*
@@ -778,7 +778,7 @@ backend_unbind( Operation *op, SlapReply *rs )
                }
 
 #if defined( LDAP_SLAPI )
-               if ( op->o_pb && doPluginFNs( &backends[i], SLAPI_PLUGIN_POST_UNBIND_FN,
+               if ( op->o_pb != NULL && slapi_int_call_plugins( &backends[i], SLAPI_PLUGIN_POST_UNBIND_FN,
                                (Slapi_PBlock *)op->o_pb ) < 0 ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG( OPERATION, INFO, "do_unbind: Unbind postoperation plugins "
index be2b7e93d1167615af11bd4ae922272ac4e190ce..7a41120a0847bd48fa44f172848e7c80adc979c5 100644 (file)
@@ -177,6 +177,8 @@ glue_back_db_destroy (
 
 typedef struct glue_state {
        int err;
+       int is_slimit;
+       int slimit;
        int matchlen;
        char *matched;
        int nrefs;
@@ -190,12 +192,23 @@ glue_back_response ( Operation *op, SlapReply *rs )
 
        switch(rs->sr_type) {
        case REP_SEARCH:
+               if ( gs->is_slimit && rs->sr_nentries >= gs->slimit ) {
+                       gs->err = LDAP_SIZELIMIT_EXCEEDED;
+                       return -1;
+               }
+               /* fallthru */
        case REP_SEARCHREF:
                return SLAP_CB_CONTINUE;
 
        default:
-               if (rs->sr_err == LDAP_SUCCESS || gs->err != LDAP_SUCCESS)
+               if ( gs->is_slimit && rs->sr_err == LDAP_SIZELIMIT_EXCEEDED
+                               && rs->sr_nentries >= gs->slimit ) {
+                       gs->err = LDAP_SIZELIMIT_EXCEEDED;
+                       return -1;
+               }
+               if (rs->sr_err == LDAP_SUCCESS || gs->err != LDAP_SUCCESS) {
                        gs->err = rs->sr_err;
+               }
                if (gs->err == LDAP_SUCCESS && gs->matched) {
                        ch_free (gs->matched);
                        gs->matched = NULL;
@@ -242,11 +255,13 @@ glue_back_search ( Operation *op, SlapReply *rs )
        glueinfo *gi = (glueinfo *) b0->bd_info;
        int i;
        long stoptime = 0;
-       glue_state gs = {0, 0, NULL, 0, NULL};
+       glue_state gs = {0, 0, 0, 0, NULL, 0, NULL};
        slap_callback cb = { NULL, glue_back_response, NULL, NULL };
        int scope0, slimit0, tlimit0;
        struct berval dn, ndn;
 
+       gs.is_slimit = ( op->ors_slimit > 0 );
+
        cb.sc_private = &gs;
 
        cb.sc_next = op->o_callback;
@@ -272,7 +287,9 @@ glue_back_search ( Operation *op, SlapReply *rs )
                op->o_callback = &cb;
                rs->sr_err = gs.err = LDAP_UNWILLING_TO_PERFORM;
                scope0 = op->ors_scope;
-               slimit0 = op->ors_slimit;
+               if ( gs.is_slimit ) {
+                       slimit0 = gs.slimit = op->ors_slimit;
+               }
                tlimit0 = op->ors_tlimit;
                dn = op->o_req_dn;
                ndn = op->o_req_ndn;
@@ -290,9 +307,9 @@ glue_back_search ( Operation *op, SlapReply *rs )
                                        break;
                                }
                        }
-                       if (slimit0) {
+                       if ( gs.is_slimit ) {
                                op->ors_slimit = slimit0 - rs->sr_nentries;
-                               if (op->ors_slimit <= 0) {
+                               if (op->ors_slimit < 0) {
                                        rs->sr_err = gs.err = LDAP_SIZELIMIT_EXCEEDED;
                                        break;
                                }
@@ -339,7 +356,9 @@ glue_back_search ( Operation *op, SlapReply *rs )
                }
 end_of_loop:;
                op->ors_scope = scope0;
-               op->ors_slimit = slimit0;
+               if ( gs.is_slimit ) {
+                       op->ors_slimit = slimit0;
+               }
                op->ors_tlimit = tlimit0;
                op->o_req_dn = dn;
                op->o_req_ndn = ndn;
index 46bd7a439e808a93634a997631aa1e9efe308e09..f63ac792a96ad6b0e2eeb4cccc92aa084a5864f3 100644 (file)
@@ -318,6 +318,7 @@ overlay_config( BackendDB *be, const char *ov )
                be->bd_info = bi;
        }
 
+#if 0
        /* Walk to the end of the list of overlays, add the new
         * one onto the end
         */
@@ -332,6 +333,16 @@ overlay_config( BackendDB *be, const char *ov )
        *on2 = *on;
        on2->on_next = NULL;
        on2->on_info = oi;
+#else
+       /* Insert new overlay on head of list. Overlays are executed
+        * in reverse of config order...
+        */
+       on2 = ch_calloc( 1, sizeof(slap_overinst) );
+       *on2 = *on;
+       on2->on_info = oi;
+       on2->on_next = oi->oi_list;
+       oi->oi_list = on2;
+#endif
 
        /* Any initialization needed? */
        if ( on->on_bi.bi_db_init ) {
index e881ba6bb8d415918ffbace75ff61562917d4a5d..0c13bad30bc6f2c22fc4457cf0aeebd7a69542b1 100644 (file)
@@ -34,7 +34,7 @@
 #include "ldap_pvt.h"
 #include "slap.h"
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 
@@ -373,7 +373,7 @@ do_bind(
                        slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)method );
                        slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
                        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
-                       (void) doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb );
+                       (void) slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb );
                }
 #endif /* LDAP_SLAPI */
 
@@ -538,7 +538,7 @@ do_bind(
                slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
                slapi_pblock_set( pb, SLAPI_CONN_DN, (void *)(0) );
 
-               rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb );
+               rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb );
 
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, INFO,
@@ -670,7 +670,7 @@ do_bind(
        }
 
 #if defined( LDAP_SLAPI )
-       if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb ) < 0 ) {
+       if ( pb != NULL && slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb ) < 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, INFO,
                        "do_bind: Bind postoperation plugins failed\n",
index fdfccea5193fe8ad345aee050ae58846b595ac8a..51e016d18a0d52c2d8cd4e9bf60ccd20fb33784d 100644 (file)
@@ -32,7 +32,7 @@
 #include "ldap_pvt.h"
 #include "slap.h"
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 static int compare_entry(
@@ -266,7 +266,7 @@ do_compare(
                slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)desc.bv_val );
                slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&value );
 
-               rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_COMPARE_FN, pb );
+               rs->sr_err = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_COMPARE_FN, pb );
                if ( rs->sr_err < 0 ) {
                        /*
                         * A preoperation plugin failure will abort the
@@ -297,7 +297,7 @@ do_compare(
        }
 
 #if defined( LDAP_SLAPI )
-       if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_COMPARE_FN, pb ) < 0 ) {
+       if ( pb != NULL && slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_COMPARE_FN, pb ) < 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, INFO, "do_compare: compare postoperation plugins "
                                "failed\n", 0, 0, 0 );
index 56295fed6fdc5065683981a63f57682af6b3eaa1..9b7bcf6e3fa003347b000c666839afda67097438 100644 (file)
@@ -37,7 +37,7 @@
 #include "ldap_pvt.h"
 #include "slap.h"
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 #include "lutil.h"
 
@@ -2423,7 +2423,7 @@ read_config( const char *fname, int depth )
                        }
 #endif /* notdef */
 
-                       if ( netscape_plugin( be, fname, lineno, cargc, cargv ) 
+                       if ( slapi_int_read_config( be, fname, lineno, cargc, cargv ) 
                                        != LDAP_SUCCESS ) {
                                return( 1 );
                        }
index d2883e1fd43d500a7f6542c1e07430c8347fcf71..01b17e58869d6f9a486e5796b2b3f0a3e97f93af 100644 (file)
@@ -39,7 +39,7 @@
 #include "slap.h"
 
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 /* protected by connections_mutex */
index a7bdc337f0a8cdec66a36a89846ce6c54207c709..825c80aec8cd57115adca7488a462aa2f15c5ba2 100644 (file)
@@ -750,46 +750,17 @@ static int parseProxyAuthz (
                return LDAP_SUCCESS;
        }
 
-       /* FIXME: how can we get the realm? */
-       {
-               int     rc;
-               char            buf[ SLAP_LDAPDN_MAXLEN ];
-               struct berval   id,
-                               user = { 0, NULL },
-                               realm = { 0, NULL },
-                               mech = { 0, NULL };
-
-               if ( sizeof( buf ) <= ctrl->ldctl_value.bv_len ) {
-                       return LDAP_INVALID_SYNTAX;
-               }
-
-               id.bv_len = ctrl->ldctl_value.bv_len;
-               id.bv_val = buf;
-               strncpy( buf, ctrl->ldctl_value.bv_val, sizeof( buf ) );
+       rc = slap_sasl_getdn( op->o_conn, op,
+                       ctrl->ldctl_value.bv_val, ctrl->ldctl_value.bv_len,
+                       NULL, &dn, SLAP_GETDN_AUTHZID );
 
-               rc = slap_parse_user( &id, &user, &realm, &mech );
-               if ( rc == LDAP_SUCCESS ) {
-                       struct berval authz = BER_BVC( "AUTHZ" );
-
-                       if ( mech.bv_len && !bvmatch( &mech, &authz) ) {
-                               rs->sr_text = "mech not allowed in authzId";
-                               return LDAP_PROXY_AUTHZ_FAILURE;
-                       }
-               } else {
-                       user = ctrl->ldctl_value;
+       if( rc != LDAP_SUCCESS || !dn.bv_len ) {
+               if ( dn.bv_val ) {
+                       ch_free( dn.bv_val );
                }
+               rs->sr_text = "authzId mapping failed";
+               return LDAP_PROXY_AUTHZ_FAILURE;
 
-               rc = slap_sasl_getdn( op->o_conn, op,
-                               user.bv_val, user.bv_len,
-                               realm.bv_val, &dn, SLAP_GETDN_AUTHZID );
-
-               if( rc != LDAP_SUCCESS || !dn.bv_len ) {
-                       if ( dn.bv_val ) {
-                               ch_free( dn.bv_val );
-                       }
-                       rs->sr_text = "authzId mapping failed";
-                       return LDAP_PROXY_AUTHZ_FAILURE;
-               }
        }
 
 #ifdef NEW_LOGGING
index 90d2a95ff0e65c690898d4f16132e9f30111c0c2..c3edc3b79bc14c6fbc01ec5538012a2203c8b053 100644 (file)
@@ -36,7 +36,7 @@
 #include "lutil.h"
 
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 int
@@ -168,7 +168,7 @@ do_delete(
                slapi_pblock_set( pb, SLAPI_DELETE_TARGET, (void *)dn.bv_val );
                slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
 
-               rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_DELETE_FN, pb );
+               rs->sr_err = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_DELETE_FN, pb );
                if ( rs->sr_err < 0 ) {
                        /*
                         * A preoperation plugin failure will abort the
@@ -206,6 +206,7 @@ do_delete(
                if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo ))
 #endif
                {
+                       slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
 
                        if ( !repl_user ) {
                                struct berval csn = { 0 , NULL };
@@ -213,14 +214,14 @@ do_delete(
                                slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
                        }
 
-                       if ( (op->o_bd->be_delete)( op, rs ) == 0 ) {
 #ifdef SLAPD_MULTIMASTER
-                               if ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
+                       if ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
 #endif
-                               {
-                                       replog( op );
-                               }
+                       {
+                               cb.sc_next = op->o_callback;
+                               op->o_callback = &cb;
                        }
+                       op->o_bd->be_delete( op, rs );
 #ifndef SLAPD_MULTIMASTER
                } else {
                        BerVarray defref = NULL;
@@ -257,7 +258,7 @@ do_delete(
        }
 
 #if defined( LDAP_SLAPI )
-       if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_DELETE_FN, pb ) < 0) {
+       if ( pb != NULL && slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_DELETE_FN, pb ) < 0) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, INFO, "do_delete: delete postoperation plugins "
                                "failed\n", 0, 0, 0 );
index cb72c4fabf05ef7e2253f688d0561c77d742a6d9..83e9af4a8b2c5296d06f3ae172bf386348422fdd 100644 (file)
@@ -40,7 +40,7 @@
 #include "lber_pvt.h"
 
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 #define UNSUPPORTED_EXTENDEDOP "unsupported extended operation"
@@ -184,7 +184,7 @@ do_extended(
        }
 
 #ifdef LDAP_SLAPI
-       getPluginFunc( &op->ore_reqoid, &funcAddr ); /* NS-SLAPI extended operation */
+       slapi_int_get_extop_plugin( &op->ore_reqoid, &funcAddr ); /* NS-SLAPI extended operation */
        if( !funcAddr && !(ext = find_extop(supp_ext_list, &op->ore_reqoid )))
 #else
        if( !(ext = find_extop(supp_ext_list, &op->ore_reqoid )))
index 6ab72623220e8579b275ff378ea5b78a3545cc0f..8a2bd8282c5ffc0d5417ce244e99bf6012af9a89 100644 (file)
@@ -35,7 +35,7 @@
 #include "slap.h"
 #include "lber_pvt.h"
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 /*
@@ -205,7 +205,7 @@ int slap_startup( Backend *be )
        if( rc == 0 ) {
                Slapi_PBlock *pb = slapi_pblock_new();
 
-               if ( doPluginFNs( NULL, SLAPI_PLUGIN_START_FN, pb ) < 0 ) {
+               if ( slapi_int_call_plugins( NULL, SLAPI_PLUGIN_START_FN, pb ) < 0 ) {
                        rc = -1;
                }
                slapi_pblock_destroy( pb );
@@ -238,8 +238,8 @@ int slap_shutdown( Backend *be )
        rc = backend_shutdown( be ); 
 
 #ifdef LDAP_SLAPI
-       pb = slapi_pblock_new( );
-       (void) doPluginFNs( NULL, SLAPI_PLUGIN_CLOSE_FN, pb );
+       pb = slapi_pblock_new();
+       (void) slapi_int_call_plugins( NULL, SLAPI_PLUGIN_CLOSE_FN, pb );
        slapi_pblock_destroy( pb );
 #endif /* LDAP_SLAPI */
 
index d656dec7d1dd45a601a27d59b36ed4357272a815..609e184365ccf35026df9a32478a8c2359d07f7f 100644 (file)
@@ -41,7 +41,7 @@
 #include "ldif.h"
 
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 #ifdef LDAP_SIGCHLD
@@ -474,7 +474,7 @@ int main( int argc, char **argv )
 #endif
 
 #ifdef LDAP_SLAPI
-       if ( slapi_init() != 0 ) {
+       if ( slapi_int_initialize() != 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, CRIT, "main: slapi initialization error\n", 0, 0, 0 );
 #else
index 9ab73b0725b944b6a92a721eaab0f8204f0712b0..3b2aeb91aa84731d5f281991f507e07d1a609931 100644 (file)
@@ -34,7 +34,7 @@
 #include "ldap_pvt.h"
 #include "slap.h"
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 #include "lutil.h"
 
@@ -398,7 +398,7 @@ do_modify(
                modv = slapi_int_modifications2ldapmods( &modlist );
                slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
 
-               rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
+               rs->sr_err = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
                if ( rs->sr_err < 0 ) {
                        /*
                         * A preoperation plugin failure will abort the
@@ -472,6 +472,7 @@ do_modify(
                        int update = op->o_bd->be_update_ndn.bv_len;
                        char textbuf[SLAP_TEXT_BUFLEN];
                        size_t textlen = sizeof textbuf;
+                       slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
 
                        rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
                                textbuf, textlen, NULL );
@@ -498,14 +499,15 @@ do_modify(
                        }
 
                        op->orm_modlist = modlist;
-                       if ( (op->o_bd->be_modify)( op, rs ) == 0
 #ifdef SLAPD_MULTIMASTER
-                               && !repl_user
+                       if ( !repl_user )
 #endif
-                       {
+                       {
                                /* but we log only the ones not from a replicator user */
-                               replog( op );
+                               cb.sc_next = op->o_callback;
+                               op->o_callback = &cb;
                        }
+                       op->o_bd->be_modify( op, rs );
 
 #ifndef SLAPD_MULTIMASTER
                /* send a referral */
@@ -547,7 +549,7 @@ do_modify(
 #if defined( LDAP_SLAPI )
        } /* modlist != NULL */
 
-       if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
+       if ( pb != NULL && slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
                                "failed\n", 0, 0, 0 );
index e6137f13b6a5e38ac872200854dbb2fe2c406ea1..91f0442bee5615d1b3babc99baca7dc984e9fd56 100644 (file)
@@ -41,7 +41,7 @@
 #include "ldap_pvt.h"
 #include "slap.h"
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 int
@@ -324,7 +324,7 @@ do_modrdn(
                slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
                slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
 
-               rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODRDN_FN, pb );
+               rs->sr_err = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_MODRDN_FN, pb );
                if ( rs->sr_err < 0 ) {
                        /*
                         * A preoperation plugin failure will abort the
@@ -362,14 +362,17 @@ do_modrdn(
                if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo ))
 #endif
                {
+                       slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
                        op->orr_deleteoldrdn = deloldrdn;
-                       if ( (op->o_bd->be_modrdn)( op, rs ) == 0
 #ifdef SLAPD_MULTIMASTER
-                               && ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
+                       if ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
 #endif
-                       ) {
-                               replog( op );
+                       {
+                               cb.sc_next = op->o_callback;
+                               op->o_callback = &cb;
                        }
+                       op->o_bd->be_modrdn( op, rs );
+
 #ifndef SLAPD_MULTIMASTER
                } else {
                        BerVarray defref = NULL;
@@ -406,7 +409,7 @@ do_modrdn(
        }
 
 #if defined( LDAP_SLAPI )
-       if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODRDN_FN, pb ) < 0 ) {
+       if ( pb != NULL && slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_MODRDN_FN, pb ) < 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn postoperation plugins "
                                "failed\n", 0, 0, 0 );
index 2ffbdbef39c2fa0d6cacdd886aedff06da0398f8..1c5478f01fb943ecd9da565fd6787d8b73c732b8 100644 (file)
@@ -34,7 +34,7 @@
 #include "slap.h"
 
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 static ldap_pvt_thread_mutex_t slap_op_mutex;
index e69f51a127cce6f7f0b6d8432380528ca3ff62c2..0ffb615d09860499eaaf60bf4b52bdb0e9e9be32 100644 (file)
@@ -108,8 +108,7 @@ typedef struct query_manager_s {
 
 /* LDAP query cache manager */
 typedef struct cache_manager_s {
-       BackendInfo *bi;        /* underlying database info */
-       void *be_private;       /* for the underlying database */
+       BackendDB       db;     /* underlying database */
        unsigned long   num_cached_queries;             /* total number of cached queries */
        unsigned long   max_queries;                    /* upper bound on # of cached queries */
        int     numattrsets;                    /* number of attribute sets */
@@ -1073,17 +1072,13 @@ cache_entries(
        struct berval   crp_uuid;
        char            uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
        Operation op_tmp = *op;
-       BackendDB db = *op->o_bd;
 
        query_uuid->bv_len = lutil_uuidstr(uuidbuf, sizeof(uuidbuf));
        ber_str2bv(uuidbuf, query_uuid->bv_len, 1, query_uuid);
 
-       op_tmp.o_bd = &db;
-       op_tmp.o_dn = db.be_rootdn;
-       op_tmp.o_ndn = db.be_rootndn;
-       db.bd_info = cm->bi;
-       db.be_private =cm->be_private;
-       db.be_flags |= SLAP_BFLAG_NO_SCHEMA_CHECK;
+       op_tmp.o_bd = &cm->db;
+       op_tmp.o_dn = cm->db.be_rootdn;
+       op_tmp.o_ndn = cm->db.be_rootndn;
 
 #ifdef NEW_LOGGING
        LDAP_LOG( BACK_META, DETAIL1, "UUID for query being added = %s\n",
@@ -1377,7 +1372,7 @@ proxy_cache_search(
        op->o_tmpfree( tempstr.bv_val, op->o_tmpmemctx );
 
        if (answerable) {
-               BackendDB db, *be;
+               BackendDB *be = op->o_bd;
 #ifdef NEW_LOGGING
                LDAP_LOG( BACK_META, DETAIL1, "QUERY ANSWERABLE\n", 0, 0, 0 );
 #else /* !NEW_LOGGING */
@@ -1385,12 +1380,8 @@ proxy_cache_search(
 #endif /* !NEW_LOGGING */
                free(filter_attrs);
                ldap_pvt_thread_rdwr_runlock(&qm->templates[i].t_rwlock);
-               db = *op->o_bd;
-               db.bd_info = cm->bi;
-               db.be_private = cm->be_private;
-               be = op->o_bd;
-               op->o_bd = &db;
-               i = cm->bi->bi_op_search( op, rs );
+               op->o_bd = &cm->db;
+               i = cm->db.bd_info->bi_op_search( op, rs );
                op->o_bd = be;
                return i;
        }
@@ -1525,24 +1516,20 @@ consistency_check(
        cache_manager *cm = on->on_bi.bi_private;
        query_manager *qm = cm->qm;
        Operation op = {0};
-       BackendDB be = on->on_info->oi_bd;
 
        SlapReply rs = {REP_RESULT};
        CachedQuery* query, *query_prev;
        int i, return_val, pause = 1;
        QueryTemplate* templ;
 
-       op.o_bd = &be;
-       op.o_dn = be.be_rootdn;
-       op.o_ndn = be.be_rootndn;
+       op.o_bd = &cm->db;
+       op.o_dn = cm->db.be_rootdn;
+       op.o_ndn = cm->db.be_rootndn;
        op.o_threadctx = ctx;
 
        op.o_tmpmemctx = sl_mem_create( SLMALLOC_SLAB_SIZE, ctx );
        op.o_tmpmfuncs = &sl_mfuncs;
 
-       be.bd_info = cm->bi;
-       be.be_private = cm->be_private;
-
        cm->cc_arg = arg;
 
        for (i=0; qm->templates[i].querystr.bv_val; i++) {
@@ -1651,7 +1638,6 @@ proxy_cache_config(
        AttributeName*  attr_name;
        AttributeName*  attrarray;
        const char*     text=NULL;
-       void *private = be->be_private;
 
        int             index, i;
        int             num;
@@ -1664,17 +1650,13 @@ proxy_cache_config(
                        return( 1 );
                }
 
-               cm->bi = backend_info( argv[1] );
-               if ( !cm->bi ) {
+               cm->db.bd_info = backend_info( argv[1] );
+               if ( !cm->db.bd_info ) {
                        fprintf( stderr, "%s: line %d: backend %s unknown\n",
                                fname, lineno, argv[1] );
                        return( 1 );
                }
-               be->be_private = NULL;
-               i = cm->bi->bi_db_init( be );
-               cm->be_private = be->be_private;
-               be->be_private = private;
-               if ( i ) return( 1 );
+               if ( cm->db.bd_info->bi_db_init( &cm->db ) ) return( 1 );
 
                cm->max_entries = atoi( argv[2] );
 
@@ -1820,10 +1802,7 @@ proxy_cache_config(
        }
        /* anything else */
        else {
-               be->be_private = cm->be_private;
-               i = cm->bi->bi_db_config( be, fname, lineno, argc, argv );
-               be->be_private = private;
-               return i;
+               return cm->db.bd_info->bi_db_config( &cm->db, fname, lineno, argc, argv );
        }
        return 0;
 }
@@ -1842,6 +1821,9 @@ proxy_cache_init(
 
        qm = (query_manager*)ch_malloc(sizeof(query_manager));
 
+       cm->db = *be;
+       cm->db.be_flags |= SLAP_BFLAG_NO_SCHEMA_CHECK;
+       cm->db.be_private = NULL;
        cm->qm = qm;
        cm->numattrsets = 0;
        cm->numtemplates = 0; 
@@ -1875,13 +1857,10 @@ proxy_cache_open(
 {
        slap_overinst *on = (slap_overinst *)be->bd_info;
        cache_manager *cm = on->on_bi.bi_private;
-       void *private = be->be_private;
        int rc = 0;
 
-       if ( cm->be_private && cm->bi->bi_db_open ) {
-               be->be_private = cm->be_private;
-               rc = cm->bi->bi_db_open( be );
-               be->be_private = private;
+       if ( cm->db.bd_info->bi_db_open ) {
+               rc = cm->db.bd_info->bi_db_open( &cm->db );
        }
 
        ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex );
@@ -1900,13 +1879,10 @@ proxy_cache_close(
        slap_overinst *on = (slap_overinst *)be->bd_info;
        cache_manager *cm = on->on_bi.bi_private;
        query_manager *qm = cm->qm;
-       void *private = be->be_private;
        int i, j, rc = 0;
 
-       if ( cm->be_private && cm->bi->bi_db_close ) {
-               be->be_private = cm->be_private;
-               rc = cm->bi->bi_db_close( be );
-               be->be_private = private;
+       if ( cm->db.bd_info->bi_db_close ) {
+               rc = cm->db.bd_info->bi_db_close( &cm->db );
        }
        for ( i=0; i<cm->numtemplates; i++ ) {
                CachedQuery *qc, *qn;
@@ -1941,13 +1917,10 @@ proxy_cache_destroy(
        slap_overinst *on = (slap_overinst *)be->bd_info;
        cache_manager *cm = on->on_bi.bi_private;
        query_manager *qm = cm->qm;
-       void *private = be->be_private;
        int rc = 0;
 
-       if ( cm->be_private && cm->bi->bi_db_destroy ) {
-               be->be_private = cm->be_private;
-               rc = cm->bi->bi_db_destroy( be );
-               be->be_private = private;
+       if ( cm->db.bd_info->bi_db_destroy ) {
+               rc = cm->db.bd_info->bi_db_destroy( &cm->db );
        }
        ldap_pvt_thread_mutex_destroy(&qm->lru_mutex);
        ldap_pvt_thread_mutex_destroy(&cm->cache_mutex);
index 79e9e3f0cc38c1f92776f001329b4638afa36bb1..113f13f5d8f32b5907ec5a28abc48eabf9ffb9ce 100644 (file)
@@ -37,6 +37,7 @@ int passwd_extop(
        Modifications ml, **modtail;
        Operation op2;
        slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
+       slap_callback cb2 = { &cb, slap_replog_cb, NULL, NULL };
 
        assert( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, &op->ore_reqoid ) == 0 );
 
@@ -156,7 +157,7 @@ int passwd_extop(
 
        op2 = *op;
        op2.o_tag = LDAP_REQ_MODIFY;
-       op2.o_callback = &cb;
+       op2.o_callback = &cb2;
        op2.o_req_dn = dn;
        op2.o_req_ndn = ndn;
        op2.orm_modlist = &ml;
@@ -169,7 +170,6 @@ int passwd_extop(
                rs->sr_err = op2.o_bd->be_modify( &op2, rs );
        }
        if ( rs->sr_err == LDAP_SUCCESS ) {
-               replog( &op2 );
                rs->sr_rspdata = rsp;
        } else if ( rsp ) {
                ber_bvfree( rsp );
index 4e8f412aabe1876160823a012f006c3223976dbb..6227b18fcd3f77bff0e23d03463eb48974f1008b 100644 (file)
@@ -926,6 +926,7 @@ LDAP_SLAPD_F (void) slap_send_search_result LDAP_P(( Operation *op, SlapReply *r
 LDAP_SLAPD_F (int) slap_send_search_reference LDAP_P(( Operation *op, SlapReply *rs ));
 LDAP_SLAPD_F (int) slap_send_search_entry LDAP_P(( Operation *op, SlapReply *rs ));
 LDAP_SLAPD_F (int) slap_null_cb LDAP_P(( Operation *op, SlapReply *rs ));
+LDAP_SLAPD_F (int) slap_replog_cb LDAP_P(( Operation *op, SlapReply *rs ));
 
 LDAP_SLAPD_V( const struct berval ) slap_pre_read_bv;
 LDAP_SLAPD_V( const struct berval ) slap_post_read_bv;
index c8f96ec02da786e254268692c79529ad6c094281..5285dbdd888f89cba312841e40148e8bb40972fc 100644 (file)
@@ -38,7 +38,7 @@
 #include "slap.h"
 
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 int slap_null_cb( Operation *op, SlapReply *rs )
@@ -46,6 +46,14 @@ int slap_null_cb( Operation *op, SlapReply *rs )
        return 0;
 }
 
+int slap_replog_cb( Operation *op, SlapReply *rs )
+{
+       if ( rs->sr_err == LDAP_SUCCESS ) {
+               replog( op );
+       }
+       return SLAP_CB_CONTINUE;
+}
+
 static char *v2ref( BerVarray ref, const char *text )
 {
        size_t len = 0, i = 0;
@@ -248,7 +256,7 @@ send_ldap_controls( Operation *o, BerElement *ber, LDAPControl **c )
         * plugin.
         */
 
-       if ( slapi_pblock_get( o->o_pb, SLAPI_RESCONTROLS, &sctrls ) != 0 ) {
+       if ( o->o_pb && slapi_pblock_get( o->o_pb, SLAPI_RESCONTROLS, &sctrls ) != 0 ) {
                sctrls = NULL;
        }
 
@@ -585,13 +593,13 @@ slap_send_ldap_result( Operation *op, SlapReply *rs )
         * should just set SLAPI_RESULT_CODE rather than sending a
         * result if they wish to change the result.
         */
-       if ( op->o_pb ) {
+       if ( op->o_pb != NULL ) {
                slapi_int_pblock_set_operation( op->o_pb, op );
                slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
                slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
                slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
 
-               (void) doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN, op->o_pb );
+               (void) slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN, op->o_pb );
        }
 #endif /* LDAP_SLAPI */
 
index 91db21e13d5edd125f0ccb02c837f4c2994e6fda..3babefa9ae83c2172324c9369f33b2fbd04dff14 100644 (file)
@@ -25,7 +25,7 @@
 #include "lber_pvt.h"
 
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
 #endif
 
 static struct berval supportedFeatures[] = {
@@ -153,7 +153,7 @@ root_dse_info(
 
 #ifdef LDAP_SLAPI
        /* netscape supportedExtension */
-       for ( i = 0; (bv = ns_get_supported_extop(i)) != NULL; i++ ) {
+       for ( i = 0; (bv = slapi_int_get_supported_extop(i)) != NULL; i++ ) {
                vals[0] = *bv;
                if( attr_merge( e, ad_supportedExtension, vals, NULL )) {
                        return LDAP_OTHER;
index 60e9db716dde422360101cb4d508e018359c8f0f..f186eb7c0c95003c9363d7f5b67d5ce52f4ae799 100644 (file)
@@ -1881,29 +1881,6 @@ int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len,
 
                len = dn->bv_len + sizeof("uid=")-1 + sizeof(",cn=auth")-1;
 
-#if 0
-               /* username may have embedded realm name */
-               /* FIXME:
-                * userids can legally have embedded '@' chars;
-                * the realm should be set by those mechanisms
-                * that support it by means of the user_realm
-                * variable
-                */
-               if( ( realm.bv_val = strrchr( dn->bv_val, '@') ) ) {
-                       char *r = realm.bv_val;
-
-                       realm.bv_val++;
-                       realm.bv_len = dn->bv_len - ( realm.bv_val - dn->bv_val );
-                       len += sizeof( ",cn=" ) - 2;
-                       c1.bv_len -= realm.bv_len + 1;
-
-                       if ( strchr( dn->bv_val, '@') == r ) {
-                               /* FIXME: ambiguity, is it the realm 
-                                * or something else? */
-                       }       
-                       
-               } else
-#endif
                if( user_realm && *user_realm ) {
                        realm.bv_val = user_realm;
                        realm.bv_len = strlen( user_realm );
index b79694540d21c466dc6c1dd03983e3be123916ea..87e2920abac7fb899918e181199cc288674d0744 100644 (file)
 #include "slap.h"
 
 #ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
+
 static char **anlist2charray( Operation *op, AttributeName *an );
-static void initSearchPlugin( Operation *op, char **attrs, int managedsait );
-static int doPreSearchPluginFNs( Operation *op );
-static int doSearchRewriteFNs( Operation *op );
-static void doPostSearchPluginFNs( Operation *op );
+static void init_search_pblock( Operation *op, char **attrs, int managedsait );
+static int call_search_preop_plugins( Operation *op );
+static int call_search_rewrite_plugins( Operation *op );
+static void call_search_postop_plugins( Operation *op );
 #endif /* LDAPI_SLAPI */
 
 int
@@ -273,10 +274,10 @@ do_search(
 #ifdef LDAP_SLAPI
                        if ( op->o_pb ) {
                                attrs = anlist2charray( op, op->ors_attrs );
-                               initSearchPlugin( op, attrs, manageDSAit );
-                               rs->sr_err = doPreSearchPluginFNs( op );
+                               init_search_pblock( op, attrs, manageDSAit );
+                               rs->sr_err = call_search_preop_plugins( op );
                                if ( rs->sr_err ) break;
-                               doSearchRewriteFNs( op );
+                               call_search_rewrite_plugins( op );
                        }
 #endif /* LDAP_SLAPI */
                        rs->sr_err = root_dse_info( op->o_conn, &entry, &rs->sr_text );
@@ -291,10 +292,10 @@ do_search(
 #ifdef LDAP_SLAPI
                        if ( op->o_pb ) {
                                attrs = anlist2charray( op, op->ors_attrs );
-                               initSearchPlugin( op, attrs, manageDSAit );
-                               rs->sr_err = doPreSearchPluginFNs( op );
+                               init_search_pblock( op, attrs, manageDSAit );
+                               rs->sr_err = call_search_preop_plugins( op );
                                if ( rs->sr_err ) break;
-                               doSearchRewriteFNs( op );
+                               call_search_rewrite_plugins( op );
                        }
 #endif /* LDAP_SLAPI */
                        rs->sr_err = schema_info( &entry, &rs->sr_text );
@@ -303,7 +304,7 @@ do_search(
                if( rs->sr_err != LDAP_SUCCESS ) {
                        send_ldap_result( op, rs );
 #ifdef LDAP_SLAPI
-                       if ( op->o_pb ) doPostSearchPluginFNs( op );
+                       if ( op->o_pb ) call_search_postop_plugins( op );
 #endif /* LDAP_SLAPI */
                        goto return_results;
 
@@ -321,7 +322,7 @@ do_search(
                        rs->sr_err = LDAP_SUCCESS;
                        send_ldap_result( op, rs );
 #ifdef LDAP_SLAPI
-                       if ( op->o_pb ) doPostSearchPluginFNs( op );
+                       if ( op->o_pb ) call_search_postop_plugins( op );
 #endif /* LDAP_SLAPI */
                        goto return_results;
                }
@@ -382,13 +383,13 @@ do_search(
 #ifdef LDAP_SLAPI
        if ( op->o_pb ) {
                attrs = anlist2charray( op, op->ors_attrs );
-               initSearchPlugin( op, attrs, manageDSAit );
-               rs->sr_err = doPreSearchPluginFNs( op );
+               init_search_pblock( op, attrs, manageDSAit );
+               rs->sr_err = call_search_preop_plugins( op );
                if ( rs->sr_err != LDAP_SUCCESS ) {
                        goto return_results;
                }
 
-               doSearchRewriteFNs( op );
+               call_search_rewrite_plugins( op );
        }
 #endif /* LDAP_SLAPI */
 
@@ -401,7 +402,7 @@ do_search(
        }
 
 #ifdef LDAP_SLAPI
-       if ( op->o_pb ) doPostSearchPluginFNs( op );
+       if ( op->o_pb ) call_search_postop_plugins( op );
 #endif /* LDAP_SLAPI */
 
 return_results:;
@@ -447,7 +448,7 @@ static char **anlist2charray( Operation *op, AttributeName *an )
        return attrs;
 }
 
-static void initSearchPlugin( Operation *op,
+static void init_search_pblock( Operation *op,
        char **attrs, int managedsait )
 {
        slapi_int_pblock_set_operation( op->o_pb, op );
@@ -463,21 +464,21 @@ static void initSearchPlugin( Operation *op,
        slapi_pblock_set( op->o_pb, SLAPI_MANAGEDSAIT, (void *)managedsait );
 }
 
-static int doPreSearchPluginFNs( Operation *op )
+static int call_search_preop_plugins( Operation *op )
 {
        int rc;
 
-       rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_SEARCH_FN, op->o_pb );
+       rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_SEARCH_FN, op->o_pb );
        if ( rc < 0 ) {
                /*
                 * A preoperation plugin failure will abort the
                 * entire operation.
                 */
 #ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, INFO, "doPreSearchPluginFNs: search preoperation plugin "
+               LDAP_LOG( OPERATION, INFO, "call_search_preop_plugins: search preoperation plugin "
                                "returned %d\n", rc, 0, 0 );
 #else
-               Debug(LDAP_DEBUG_TRACE, "doPreSearchPluginFNs: search preoperation plugin "
+               Debug(LDAP_DEBUG_TRACE, "call_search_preop_plugins: search preoperation plugin "
                                "returned %d.\n", rc, 0, 0);
 #endif
                if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 ) ||
@@ -491,9 +492,9 @@ static int doPreSearchPluginFNs( Operation *op )
        return rc;
 }
 
-static int doSearchRewriteFNs( Operation *op )
+static int call_search_rewrite_plugins( Operation *op )
 {
-       if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, op->o_pb ) == 0 ) {
+       if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, op->o_pb ) == 0 ) {
                int rc;
 
                /*
@@ -526,7 +527,7 @@ static int doSearchRewriteFNs( Operation *op )
 
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, ARGS, 
-                       "doSearchRewriteFNs: after compute_rewrite_search filter: %s\n", 
+                       "call_search_rewrite_plugins: after compute_rewrite_search filter: %s\n", 
                        op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
 #else
                Debug( LDAP_DEBUG_ARGS, "    after compute_rewrite_search filter: %s\n",
@@ -537,20 +538,20 @@ static int doSearchRewriteFNs( Operation *op )
        return LDAP_SUCCESS;
 }
 
-static void doPostSearchPluginFNs( Operation *op )
+static void call_search_postop_plugins( Operation *op )
 {
-       if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_SEARCH_FN, op->o_pb ) < 0 ) {
+       if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_SEARCH_FN, op->o_pb ) < 0 ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, INFO, "doPostSearchPluginFNs: search postoperation plugins "
+               LDAP_LOG( OPERATION, INFO, "call_search_postop_plugins: search postoperation plugins "
                                "failed\n", 0, 0, 0 );
 #else
-               Debug(LDAP_DEBUG_TRACE, "doPostSearchPluginFNs: search postoperation plugins "
+               Debug(LDAP_DEBUG_TRACE, "call_search_postop_plugins: search postoperation plugins "
                                "failed.\n", 0, 0, 0);
 #endif
        }
 }
 
-void dummy(void)
+void slapi_int_dummy(void)
 {
        /*
         * XXX slapi_search_internal() was no getting pulled
index 6ea1eab79d976e5c4b89bba317fda09a9c25678c..f7f251113d7088dfc1fc4fe79a01bf792e0fec25 100644 (file)
@@ -10,8 +10,8 @@ include               %SYSCONFDIR%/schema/core.schema
 # service AND an understanding of referrals.
 #referral      ldap://root.openldap.org
 
-pidfile                %LOCALSTATEDIR%/slapd.pid
-argsfile       %LOCALSTATEDIR%/slapd.args
+pidfile                %LOCALSTATEDIR%/run/slapd.pid
+argsfile       %LOCALSTATEDIR%/run/slapd.args
 
 # Load dynamic backend modules:
 # modulepath   %MODULEDIR%
index e2c87669642d2f3f600db8952eadf880eedb834c..23ff7151d691cffd2d758843cffbc0d06c78c64f 100644 (file)
@@ -30,7 +30,7 @@
  */
 #include <ltdl.h>
 
-static int loadPlugin( Slapi_PBlock *, const char *, const char *, int, 
+static int slapi_int_load_plugin( Slapi_PBlock *, const char *, const char *, int, 
        SLAPI_FUNC *, lt_dlhandle * );
 
 /* pointer to link list of extended objects */
@@ -39,7 +39,7 @@ static ExtendedOp *pGExtendedOps = NULL;
 static Slapi_PBlock *pGPlugins = NULL;
 
 /*********************************************************************
- * Function Name:      newPlugin
+ * Function Name:      plugin_pblock_new
  *
  * Description:        This routine creates a new Slapi_PBlock structure,
  *                     loads in the plugin module and executes the init
@@ -61,8 +61,8 @@ static Slapi_PBlock *pGPlugins = NULL;
  * Messages:           None
  *********************************************************************/
 
-Slapi_PBlock *
-newPlugin(
+static Slapi_PBlock *
+plugin_pblock_new(
        int type, 
        const char *path, 
        const char *initfunc, 
@@ -95,14 +95,14 @@ newPlugin(
                goto done;
        }
 
-       rc = loadPlugin( pPlugin, path, initfunc, TRUE, NULL, &hdLoadHandle );
+       rc = slapi_int_load_plugin( pPlugin, path, initfunc, TRUE, NULL, &hdLoadHandle );
        if ( rc != 0 ) {
                goto done;
        }
 
        if ( slapi_pblock_get( pPlugin, SLAPI_PLUGIN_DESCRIPTION, (void **)&pPluginDesc ) == 0 &&
             pPluginDesc != NULL ) {
-               slapi_log_error(SLAPI_LOG_TRACE, "newPlugin",
+               slapi_log_error(SLAPI_LOG_TRACE, "plugin_pblock_new",
                                "Registered plugin %s %s [%s] (%s)\n",
                                pPluginDesc->spd_id,
                                pPluginDesc->spd_version,
@@ -120,7 +120,7 @@ done:
 } 
 
 /*********************************************************************
- * Function Name:      insertPlugin
+ * Function Name:      slapi_int_register_plugin
  *
  * Description:        insert the slapi_pblock structure to the end of the plugin
  *                     list 
@@ -136,7 +136,7 @@ done:
  * Messages:           None
  *********************************************************************/
 int 
-insertPlugin(
+slapi_int_register_plugin(
        Backend *be, 
        Slapi_PBlock *pPB )
 { 
@@ -174,7 +174,7 @@ insertPlugin(
 }
        
 /*********************************************************************
- * Function Name:      getAllPluginFuncs
+ * Function Name:      slapi_int_get_plugins
  *
  * Description:        get the desired type of function pointers defined 
  *                     in all the plugins 
@@ -190,7 +190,7 @@ insertPlugin(
  * Messages:           None
  *********************************************************************/
 int 
-getAllPluginFuncs(
+slapi_int_get_plugins(
        Backend *be,            
        int functype, 
        SLAPI_FUNC **ppFuncPtrs )
@@ -331,7 +331,7 @@ createExtendedOp()
 
 
 /*********************************************************************
- * Function Name:      removeExtendedOp
+ * Function Name:      slapi_int_unregister_extop
  *
  * Description:        This routine removes the ExtendedOp structures 
  *                                        asscoiated with a particular extended operation 
@@ -349,7 +349,7 @@ createExtendedOp()
  * Messages:           None
  *********************************************************************/
 void
-removeExtendedOp(
+slapi_int_unregister_extop(
        Backend *pBE, 
        ExtendedOp **opList, 
        Slapi_PBlock *pPB )
@@ -398,7 +398,7 @@ removeExtendedOp(
 
 
 /*********************************************************************
- * Function Name:      newExtendedOp
+ * Function Name:      slapi_int_register_extop
  *
  * Description:        This routine creates a new ExtendedOp structure, loads
  *                     in the extended op module and put the extended op function address
@@ -417,7 +417,7 @@ removeExtendedOp(
  * Messages:           None
  *********************************************************************/
 int 
-newExtendedOp(
+slapi_int_register_extop(
        Backend *pBE,   
        ExtendedOp **opList, 
        Slapi_PBlock *pPB )
@@ -449,7 +449,7 @@ newExtendedOp(
        }
 
        rc = slapi_pblock_get( pPB,SLAPI_PLUGIN_EXT_OP_OIDLIST, &pTmpOIDs );
-       if ( rc != LDAP_SUCCESS ) {
+       if ( rc != 0 ) {
                rc = LDAP_OTHER;
                goto error_return;
        }
@@ -485,7 +485,7 @@ error_return:
 }
 
 /*********************************************************************
- * Function Name:      getPluginFunc
+ * Function Name:      slapi_int_get_extop_plugin
  *
  * Description:        This routine gets the function address for a given function
  *                     name.
@@ -501,7 +501,7 @@ error_return:
  * Messages:           None
  *********************************************************************/
 int 
-getPluginFunc(
+slapi_int_get_extop_plugin(
        struct berval *reqoid,          
        SLAPI_FUNC *pFuncAddr ) 
 {
@@ -532,12 +532,12 @@ getPluginFunc(
 }
 
 /***************************************************************************
- * This function is similar to getPluginFunc above. except it returns one OID
+ * This function is similar to slapi_int_get_extop_plugin above. except it returns one OID
  * per call. It is called from root_dse_info (root_dse.c).
  * The function is a modified version of get_supported_extop (file extended.c).
  ***************************************************************************/
 struct berval *
-ns_get_supported_extop( int index )
+slapi_int_get_supported_extop( int index )
 {
         ExtendedOp     *ext;
 
@@ -554,7 +554,7 @@ ns_get_supported_extop( int index )
 }
 
 /*********************************************************************
- * Function Name:      loadPlugin
+ * Function Name:      slapi_int_load_plugin
  *
  * Description:        This routine loads the specified DLL, gets and executes the init function
  *                     if requested.
@@ -578,7 +578,7 @@ ns_get_supported_extop( int index )
  *********************************************************************/
 
 static int 
-loadPlugin(
+slapi_int_load_plugin(
        Slapi_PBlock    *pPlugin,
        const char      *path,
        const char      *initfunc, 
@@ -624,7 +624,7 @@ loadPlugin(
  * Special support for computed attribute plugins
  */
 int 
-doPluginFNs(
+slapi_int_call_plugins(
        Backend         *be,    
        int             funcType, 
        Slapi_PBlock    *pPB )
@@ -637,7 +637,7 @@ doPluginFNs(
                return 1;
        }
 
-       rc = getAllPluginFuncs( be, funcType, &tmpPlugin );
+       rc = slapi_int_get_plugins( be, funcType, &tmpPlugin );
        if ( rc != LDAP_SUCCESS || tmpPlugin == NULL ) {
                /* Nothing to do, front-end should ignore. */
                return 1;
@@ -672,7 +672,7 @@ doPluginFNs(
 }
 
 int
-netscape_plugin(
+slapi_int_read_config(
        Backend         *be,            
        const char      *fname, 
        int             lineno, 
@@ -720,24 +720,24 @@ netscape_plugin(
                int rc;
                Slapi_PBlock *pPlugin;
 
-               pPlugin = newPlugin( iType, argv[2], argv[3], 
+               pPlugin = plugin_pblock_new( iType, argv[2], argv[3], 
                                        numPluginArgc, ppPluginArgv );
                if (pPlugin == NULL) {
                        return 1;
                }
 
                if (iType == SLAPI_PLUGIN_EXTENDEDOP) {
-                       rc = newExtendedOp(be, &pGExtendedOps, pPlugin);
+                       rc = slapi_int_register_extop(be, &pGExtendedOps, pPlugin);
                        if ( rc != LDAP_SUCCESS ) {
                                slapi_pblock_destroy( pPlugin );
                                return 1;
                        }
                }
 
-               rc = insertPlugin( be, pPlugin );
+               rc = slapi_int_register_plugin( be, pPlugin );
                if ( rc != LDAP_SUCCESS ) {
                        if ( iType == SLAPI_PLUGIN_EXTENDEDOP ) {
-                               removeExtendedOp( be, &pGExtendedOps, pPlugin );
+                               slapi_int_unregister_extop( be, &pGExtendedOps, pPlugin );
                        }
                        slapi_pblock_destroy( pPlugin );
                        return 1;
@@ -748,7 +748,7 @@ netscape_plugin(
 }
 
 int
-slapi_init(void)
+slapi_int_initialize(void)
 {
        if ( ldap_pvt_thread_mutex_init( &slapi_hn_mutex ) ) {
                return -1;
index 5cafa3cbd557621d6461172a6f5994b0c1bfa7a9..916674776b6f34a2212d412334c8c509ef2c9371 100644 (file)
@@ -40,7 +40,7 @@ char                  *slapi_log_file = NULL;
 int                    slapi_log_level = SLAPI_LOG_PLUGIN;
 
 int 
-vLogError(
+slapi_int_log_error(
        int             level,  
        char            *subsystem, 
        char            *fmt, 
index 329499107c94906f2c6f7bf1e67916f514f1cf30..e994c5f47f28be856c01a4795bfc39d6b962cff0 100644 (file)
@@ -267,16 +267,14 @@ extern int slapi_int_pblock_get_next( Slapi_PBlock **pb );
  * Was: plugin.h
  */
 
-extern Slapi_PBlock *newPlugin ( int type, const char *path, const char *initfunc,
-               int argc, char *argv[] );
-extern int insertPlugin(Backend *be, Slapi_PBlock *pPB);
-extern int doPluginFNs(Backend *be, int funcType, Slapi_PBlock * pPB);
-extern int getAllPluginFuncs(Backend *be, int functype, SLAPI_FUNC **ppFuncPtrs);
-extern int newExtendedOp(Backend *pBE, ExtendedOp **opList, Slapi_PBlock *pPB);
-extern int getPluginFunc(struct berval  *reqoid, SLAPI_FUNC *pFuncAddr );
-extern int netscape_plugin(Backend *be, const char *fname, int lineno,
+extern int slapi_int_register_plugin(Backend *be, Slapi_PBlock *pPB);
+extern int slapi_int_call_plugins(Backend *be, int funcType, Slapi_PBlock * pPB);
+extern int slapi_int_get_plugins(Backend *be, int functype, SLAPI_FUNC **ppFuncPtrs);
+extern int slapi_int_register_extop(Backend *pBE, ExtendedOp **opList, Slapi_PBlock *pPB);
+extern int slapi_int_get_extop_plugin(struct berval  *reqoid, SLAPI_FUNC *pFuncAddr );
+extern int slapi_int_read_config(Backend *be, const char *fname, int lineno,
                int argc, char **argv );
-extern int slapi_init(void);
+extern int slapi_int_initialize(void);
 
 
 /*
@@ -285,9 +283,6 @@ extern int slapi_init(void);
 
 extern Slapi_PBlock *slapi_search_internal( char *base, int scope, char *filter, 
                LDAPControl **controls, char **attrs, int attrsonly );
-extern Slapi_PBlock *slapi_search_internal_bind( char *bindDN, char *base,
-               int scope, char *filter, LDAPControl **controls,
-               char **attrs, int attrsonly ); /* d58508 */
 extern Slapi_PBlock *slapi_modify_internal( char *dn, LDAPMod **mods,
         LDAPControl **controls, int log_change );
 extern Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e,
@@ -300,14 +295,8 @@ extern Slapi_PBlock *slapi_delete_internal( char * dn,  LDAPControl **controls,
                int log_change );
 extern Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn,
                int deloldrdn, LDAPControl **controls, int log_change);
-#if 0
-extern Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn,
-               char *newParent, int deloldrdn, LDAPControl **controls,
-               int log_change);
-#endif
 extern char **slapi_get_supported_extended_ops(void);
-extern int duplicateBVMod( LDAPMod *pMod, LDAPMod **ppNewMod );
-
+extern struct berval *slapi_int_get_supported_extop( int );
 
 /*
  * Was: slapi_cl.h
index 9bbaeb81953aebde0f10521e1d4809dd2def1ac4..c761c373f739f9e8975986995827f463e53ef055 100644 (file)
@@ -72,8 +72,6 @@ typedef struct strlist {
 } StrList;
 #endif
 
-extern struct berval *ns_get_supported_extop( int );
-
 /*
  * Was: slapi_utils.h
  */
index d785490fbda6473cfe41b67aab8a97b534d15b05..c922061430c2bae04533a8aadb29a43da96863aa 100644 (file)
@@ -58,7 +58,7 @@ struct slapi_extension_block {
        void **extensions;
 };
 
-static int getExtensionBlock(int objecttype, void *object, struct slapi_extension_block **eblock, void **parent)
+static int get_extension_block(int objecttype, void *object, struct slapi_extension_block **eblock, void **parent)
 {
        switch ((slapi_extension_t) objecttype) {
        case SLAPI_X_EXT_CONNECTION:
@@ -81,7 +81,7 @@ static int getExtensionBlock(int objecttype, void *object, struct slapi_extensio
        return 0;
 }
 
-static int mapExtensionType(const char *objectname, slapi_extension_t *type)
+static int map_extension_type(const char *objectname, slapi_extension_t *type)
 {
        if ( strcasecmp( objectname, SLAPI_EXT_CONNECTION ) == 0 ) {
                *type = SLAPI_X_EXT_CONNECTION;
@@ -94,7 +94,9 @@ static int mapExtensionType(const char *objectname, slapi_extension_t *type)
        return 0;
 }
 
-static void newExtension(struct slapi_extension_block *eblock, int objecttype, void *object, void *parent, int extensionhandle )
+static void new_extension(struct slapi_extension_block *eblock,
+       int objecttype, void *object, void *parent,
+       int extensionhandle )
 {
        slapi_extension_constructor_fnptr constructor;
 
@@ -113,7 +115,7 @@ static void newExtension(struct slapi_extension_block *eblock, int objecttype, v
        }
 }
 
-static void freeExtension(struct slapi_extension_block *eblock, int objecttype, void *object, void *parent, int extensionhandle )
+static void free_extension(struct slapi_extension_block *eblock, int objecttype, void *object, void *parent, int extensionhandle )
 {
        slapi_extension_destructor_fnptr destructor;
 
@@ -137,7 +139,7 @@ void *slapi_get_object_extension(int objecttype, void *object, int extensionhand
        struct slapi_extension_block *eblock;
        void *parent;
 
-       if ( getExtensionBlock( objecttype, object, &eblock, &parent ) != 0 ) {
+       if ( get_extension_block( objecttype, object, &eblock, &parent ) != 0 ) {
                return NULL;
        }
 
@@ -157,13 +159,13 @@ void slapi_set_object_extension(int objecttype, void *object, int extensionhandl
        struct slapi_extension_block *eblock;
        void *parent;
 
-       if ( getExtensionBlock( objecttype, object, &eblock, &parent ) != 0 ) {
+       if ( get_extension_block( objecttype, object, &eblock, &parent ) != 0 ) {
                return;
        }
 
        if ( extensionhandle < registered_extensions.extensions[objecttype].count ) {
                /* free the old one */
-               freeExtension( eblock, objecttype, object, parent, extensionhandle );
+               free_extension( eblock, objecttype, object, parent, extensionhandle );
 
                /* constructed by caller */
                eblock->extensions[extensionhandle] = extension;
@@ -186,7 +188,7 @@ int slapi_register_object_extension(
 
        ldap_pvt_thread_mutex_lock( &registered_extensions.mutex );
 
-       rc = mapExtensionType( objectname, &type );
+       rc = map_extension_type( objectname, &type );
        if ( rc != 0 ) {
                ldap_pvt_thread_mutex_unlock( &registered_extensions.mutex );
                return rc;
@@ -271,7 +273,7 @@ int slapi_int_create_object_extensions(int objecttype, void *object)
        if ( registered_extensions.extensions[objecttype].count ) {
                eblock->extensions = (void **)slapi_ch_calloc( registered_extensions.extensions[objecttype].count, sizeof(void *) );
                for ( i = 0; i < registered_extensions.extensions[objecttype].count; i++ ) {
-                       newExtension( eblock, objecttype, object, parent, i );
+                       new_extension( eblock, objecttype, object, parent, i );
                }
        } else {
                eblock->extensions = NULL;
@@ -311,7 +313,7 @@ int slapi_int_free_object_extensions(int objecttype, void *object)
 
        if ( eblock->extensions != NULL ) {
                for ( i = registered_extensions.extensions[objecttype].count - 1; i >= 0; --i ) {
-                       freeExtension( eblock, objecttype, object, parent, i );
+                       free_extension( eblock, objecttype, object, parent, i );
                }
 
                slapi_ch_free( (void **)&eblock->extensions );
@@ -333,7 +335,7 @@ int slapi_int_clear_object_extensions(int objecttype, void *object)
        struct slapi_extension_block *eblock;
        void *parent;
 
-       if ( getExtensionBlock( objecttype, object, &eblock, &parent ) != 0 ) {
+       if ( get_extension_block( objecttype, object, &eblock, &parent ) != 0 ) {
                return -1;
        }
 
@@ -343,11 +345,11 @@ int slapi_int_clear_object_extensions(int objecttype, void *object)
        }
 
        for ( i = registered_extensions.extensions[objecttype].count - 1; i >= 0; --i ) {
-               freeExtension( eblock, objecttype, object, parent, i );
+               free_extension( eblock, objecttype, object, parent, i );
        }
 
        for ( i = 0; i < registered_extensions.extensions[objecttype].count; i++ ) {
-               newExtension( eblock, objecttype, object, parent, i );
+               new_extension( eblock, objecttype, object, parent, i );
        }
 
        return 0;
index f423d550e6d89c7cc17cbd4637e5d0f1d967817b..1e97caf751b97adca85e0e636333fbe6fb57f595 100644 (file)
@@ -120,7 +120,7 @@ internal_search_reference(
 }
 
 static Connection *
-slapiConnectionInit(
+slapi_int_init_connection(
        char *DN, 
        int OpType ) 
 { 
@@ -225,7 +225,7 @@ slapiConnectionInit(
        return pConn;
 }
 
-static void slapiConnectionDestroy( Connection **pConn )
+static void slapi_int_connection_destroy( Connection **pConn )
 {
        Connection *conn = *pConn;
        Operation *op;
@@ -330,15 +330,15 @@ bvptr2obj_copy(
 }
 
 /*
- * Function : LDAPModToEntry 
+ * Function : slapi_int_ldapmod_to_entry 
  * convert a dn plus an array of LDAPMod struct ptrs to an entry structure
  * with a link list of the correspondent attributes.
  * Return value : LDAP_SUCCESS
  *                LDAP_NO_MEMORY
  *                LDAP_OTHER
 */
-Entry *
-LDAPModToEntry(
+static Entry *
+slapi_int_ldapmod_to_entry(
        char *ldn, 
        LDAPMod **mods )
 {
@@ -526,7 +526,7 @@ slapi_delete_internal(
                goto cleanup;
        }
 
-       pConn = slapiConnectionInit( NULL, LDAP_REQ_DELETE );
+       pConn = slapi_int_init_connection( NULL, LDAP_REQ_DELETE );
        if (pConn == NULL) {
                rs.sr_err = LDAP_NO_MEMORY;
                goto cleanup;
@@ -559,11 +559,9 @@ slapi_delete_internal(
        if ( op->o_bd->be_delete ) {
                int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
                if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
-                       if ( (*op->o_bd->be_delete)( op, &rs ) == 0 ) {
-                               if ( log_change ) {
-                                       replog( op );
-                               }
-                       } else {
+                       slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
+                       if ( log_change ) op->o_callback = &cb;
+                       if ( (*op->o_bd->be_delete)( op, &rs ) ) {
                                rs.sr_err = LDAP_OTHER;
                        }
                } else {
@@ -584,7 +582,7 @@ cleanup:
                pSavePB = pPB;
        }
 
-       slapiConnectionDestroy( &pConn );
+       slapi_int_connection_destroy( &pConn );
 
        return (pSavePB);
 #else
@@ -594,7 +592,7 @@ cleanup:
 
 #ifdef LDAP_SLAPI
 static Slapi_PBlock * 
-slapi_add_entry_internal_locked(
+slapi_int_add_entry_locked(
        Slapi_Entry **e, 
        LDAPControl **controls, 
        int log_changes ) 
@@ -612,7 +610,7 @@ slapi_add_entry_internal_locked(
                goto cleanup;
        }
        
-       pConn = slapiConnectionInit( NULL, LDAP_REQ_ADD );
+       pConn = slapi_int_init_connection( NULL, LDAP_REQ_ADD );
        if ( pConn == NULL ) {
                rs.sr_err = LDAP_NO_MEMORY;
                goto cleanup;
@@ -640,10 +638,9 @@ slapi_add_entry_internal_locked(
        if ( op->o_bd->be_add ) {
                int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
                if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
+                       slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
+                       if ( log_changes ) op->o_callback = &cb;
                        if ( (*op->o_bd->be_add)( op, &rs ) == 0 ) {
-                               if ( log_changes ) {
-                                       replog( op );
-                               }
                                be_entry_release_w( op, *e );
                                *e = NULL;
                        }
@@ -664,7 +661,7 @@ cleanup:
                pSavePB = pPB;
        }
 
-       slapiConnectionDestroy( &pConn );
+       slapi_int_connection_destroy( &pConn );
 
        return( pSavePB );
 }
@@ -685,7 +682,7 @@ slapi_add_entry_internal(
         * by the caller being placed in the cache.
         */
        entry = slapi_entry_dup( e );
-       pb = slapi_add_entry_internal_locked( &entry, controls, log_changes );
+       pb = slapi_int_add_entry_locked( &entry, controls, log_changes );
        if ( entry != NULL ) {
                slapi_entry_free( entry );
        }
@@ -714,7 +711,7 @@ slapi_add_internal(
 
        if ( rc == LDAP_SUCCESS ) {
                for ( i = 0, pMod = mods[0]; pMod != NULL; pMod = mods[++i] ) {
-                       if ( (pMod->mod_op & ~LDAP_MOD_BVALUES) != LDAP_MOD_ADD ) {
+                       if ( (pMod->mod_op & LDAP_MOD_OP ) != LDAP_MOD_ADD ) {
                                rc = LDAP_OTHER;
                                break;
                        }
@@ -722,7 +719,7 @@ slapi_add_internal(
        }
 
        if ( rc == LDAP_SUCCESS ) {
-               pEntry = LDAPModToEntry( dn, mods );
+               pEntry = slapi_int_ldapmod_to_entry( dn, mods );
                if ( pEntry == NULL ) {
                        rc = LDAP_OTHER;
                }
@@ -732,7 +729,7 @@ slapi_add_internal(
                pb = slapi_pblock_new();
                slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
        } else {
-               pb = slapi_add_entry_internal_locked( &pEntry, controls, log_changes );
+               pb = slapi_int_add_entry_locked( &pEntry, controls, log_changes );
        }
 
        if ( pEntry != NULL ) {
@@ -776,7 +773,7 @@ slapi_modrdn_internal(
        int                     isCritical;
        SlapReply               rs = { REP_RESULT };
 
-       pConn = slapiConnectionInit( NULL,  LDAP_REQ_MODRDN);
+       pConn = slapi_int_init_connection( NULL,  LDAP_REQ_MODRDN);
        if ( pConn == NULL) {
                rs.sr_err = LDAP_NO_MEMORY;
                goto cleanup;
@@ -832,11 +829,9 @@ slapi_modrdn_internal(
        if ( op->o_bd->be_modrdn ) {
                int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
                if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
-                       if ( (*op->o_bd->be_modrdn)( op, &rs ) == 0 ) {
-                               if ( log_change ) {
-                                       replog( op );
-                               }
-                       } else {
+                       slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
+                       if ( log_change ) op->o_callback = &cb;
+                       if ( (*op->o_bd->be_modrdn)( op, &rs ) ) {
                                rs.sr_err = LDAP_OTHER;
                        }
                } else {
@@ -866,7 +861,7 @@ cleanup:
                pSavePB = pPB;
        }
 
-       slapiConnectionDestroy( &pConn );
+       slapi_int_connection_destroy( &pConn );
 
        return( pSavePB );
 #else
@@ -916,7 +911,7 @@ slapi_modify_internal(
                goto cleanup;
        }
 
-       pConn = slapiConnectionInit( NULL,  LDAP_REQ_MODIFY );
+       pConn = slapi_int_init_connection( NULL,  LDAP_REQ_MODIFY );
        if ( pConn == NULL ) {
                rs.sr_err = LDAP_NO_MEMORY;
                goto cleanup;
@@ -969,7 +964,7 @@ slapi_modify_internal(
 
                        mod  = (Modifications *)ch_malloc( sizeof(Modifications) );
 
-                       mod->sml_op = pMod->mod_op;
+                       mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
                        mod->sml_next = NULL;
                        mod->sml_desc = NULL;
                        mod->sml_type = tmp.sml_type;
@@ -986,7 +981,7 @@ slapi_modify_internal(
 
                        mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
 
-                       mod->sml_op = pMod->mod_op;
+                       mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
                        mod->sml_next = NULL;
                        mod->sml_desc = NULL;
                        mod->sml_type = tmp.sml_type;
@@ -996,7 +991,7 @@ slapi_modify_internal(
                *modtail = mod;
                modtail = &mod->sml_next;
 
-               switch( pMod->mod_op ) {
+               switch( pMod->mod_op & LDAP_MOD_OP ) {
                case LDAP_MOD_ADD:
                if ( mod->sml_bvalues == NULL ) {
                        rs.sr_err = LDAP_PROTOCOL_ERROR;
@@ -1029,6 +1024,7 @@ slapi_modify_internal(
                        const char *text = NULL;
                        char textbuf[SLAP_TEXT_BUFLEN];
                        size_t textlen = sizeof( textbuf );
+                       slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
 
                        rs.sr_err = slap_mods_check( modlist, update,
                                        &text, textbuf, textlen, NULL );
@@ -1044,11 +1040,8 @@ slapi_modify_internal(
                                        goto cleanup;
                                }
                        }
-                       if ( (*op->o_bd->be_modify)( op, &rs ) == 0 ) {
-                               if ( log_change ) {
-                                       replog( op );
-                               }
-                       } else {
+                       if ( log_change ) op->o_callback = &cb;
+                       if ( (*op->o_bd->be_modify)( op, &rs ) ) {
                                rs.sr_err = LDAP_OTHER;
                        }
                } else {
@@ -1073,7 +1066,7 @@ cleanup:
                pSavePB = pPB;
        }
 
-       slapiConnectionDestroy( &pConn );
+       slapi_int_connection_destroy( &pConn );
 
        return ( pSavePB );
 #else
@@ -1082,8 +1075,7 @@ cleanup:
 }
 
 Slapi_PBlock *
-slapi_search_internal_bind(
-       char *bindDN, 
+slapi_search_internal(
        char *ldn, 
        int scope, 
        char *filStr, 
@@ -1108,7 +1100,7 @@ slapi_search_internal_bind(
 
        SlapReply               rs = { REP_RESULT };
 
-       c = slapiConnectionInit( NULL, LDAP_REQ_SEARCH );
+       c = slapi_int_init_connection( NULL, LDAP_REQ_SEARCH );
        if ( c == NULL ) {
                rs.sr_err = LDAP_NO_MEMORY;
                goto cleanup;
@@ -1257,7 +1249,7 @@ cleanup:
                pSavePB = ptr;
        }
 
-       slapiConnectionDestroy( &c );
+       slapi_int_connection_destroy( &c );
 
        return( pSavePB );
 #else
@@ -1265,20 +1257,3 @@ cleanup:
 #endif /* LDAP_SLAPI */
 }
 
-Slapi_PBlock * 
-slapi_search_internal(
-       char *base,
-       int scope,
-       char *filStr, 
-       LDAPControl **controls,
-       char **attrs,
-       int attrsonly ) 
-{
-#ifdef LDAP_SLAPI
-       return slapi_search_internal_bind( NULL, base, scope, filStr,
-                       controls, attrs, attrsonly );
-#else
-       return NULL;
-#endif /* LDAP_SLAPI */
-}
-
index 7805a319a1506518fc1651bcec9815154a2253ef..e6b0f523e3deeb8680fd202d2ddc3e6ae0c2d930 100644 (file)
@@ -1323,7 +1323,7 @@ slapiControlOp2SlapControlMask(unsigned long slapi_mask,
 }
 
 static int
-parseSlapiControl(
+slapi_int_parse_control(
        Operation *op,
        SlapReply *rs,
        LDAPControl *ctrl )
@@ -1344,7 +1344,7 @@ slapi_register_supported_control(
 
        slapiControlOp2SlapControlMask( controlops, &controlmask );
 
-       register_supported_control( controloid, controlmask, NULL, parseSlapiControl );
+       register_supported_control( controloid, controlmask, NULL, slapi_int_parse_control );
 #endif /* LDAP_SLAPI */
 }
 
@@ -1425,7 +1425,7 @@ slapi_get_supported_extended_ops( void )
                ;
        }
        
-       for ( j = 0; ns_get_supported_extop( j ) != NULL; j++ ) {
+       for ( j = 0; slapi_int_get_supported_extop( j ) != NULL; j++ ) {
                ;
        }
 
@@ -1447,7 +1447,7 @@ slapi_get_supported_extended_ops( void )
        for ( ; k < j; k++ ) {
                struct berval   *bv;
 
-               bv = ns_get_supported_extop( k );
+               bv = slapi_int_get_supported_extop( k );
                assert( bv != NULL );
 
                ppExtOpOID[ i + k ] = bv->bv_val;
@@ -2148,7 +2148,7 @@ slapi_get_hostname( void )
 /*
  * FIXME: this should go in an appropriate header ...
  */
-extern int vLogError( int level, char *subsystem, char *fmt, va_list arglist );
+extern int slapi_int_log_error( int level, char *subsystem, char *fmt, va_list arglist );
 
 int 
 slapi_log_error(
@@ -2162,7 +2162,7 @@ slapi_log_error(
        va_list         arglist;
 
        va_start( arglist, fmt );
-       rc = vLogError( severity, subsystem, fmt, arglist );
+       rc = slapi_int_log_error( severity, subsystem, fmt, arglist );
        va_end( arglist );
 
        return rc;
@@ -2275,7 +2275,7 @@ slapi_free_search_results_internal( Slapi_PBlock *pb )
 /*
  * Internal API to prime a Slapi_PBlock with a Backend.
  */
-static int initBackendPB( Slapi_PBlock *pb, Backend *be )
+static int slapi_int_pblock_set_backend( Slapi_PBlock *pb, Backend *be )
 {
        int rc;
        
@@ -2337,7 +2337,7 @@ static char *Authorization2AuthType( AuthorizationInformation *authz, int is_tls
 /*
  * Internal API to prime a Slapi_PBlock with a Connection.
  */
-static int initConnectionPB( Slapi_PBlock *pb, Connection *conn )
+static int slapi_int_pblock_set_connection( Slapi_PBlock *pb, Connection *conn )
 {
        char *connAuthType;
        int rc;
@@ -2443,11 +2443,11 @@ int slapi_int_pblock_set_operation( Slapi_PBlock *pb, Operation *op )
                isUpdateDn = be_isupdate( op->o_bd, &op->o_ndn );
        }
 
-       rc = initBackendPB( pb, op->o_bd );
+       rc = slapi_int_pblock_set_backend( pb, op->o_bd );
        if ( rc != LDAP_SUCCESS )
                return rc;
 
-       rc = initConnectionPB( pb, op->o_conn );
+       rc = slapi_int_pblock_set_connection( pb, op->o_conn );
        if ( rc != LDAP_SUCCESS )
                return rc;
 
@@ -3035,7 +3035,7 @@ static int checkBVString(const struct berval *bv)
 
        return 1;
 }
-#endif
+#endif /* LDAP_SLAPI */
 
 int slapi_value_get_int(const Slapi_Value *value)
 {
@@ -3456,6 +3456,7 @@ Modifications *slapi_int_ldapmods2modifications (LDAPMod **mods)
                                }
                        }
                        mod->sml_bvalues[i].bv_val = NULL;
+                       mod->sml_bvalues[i].bv_len = 0;
                }
                mod->sml_nvalues = NULL;
 
@@ -3638,7 +3639,7 @@ int slapi_compute_add_evaluator(slapi_compute_callback_t function)
                goto done;
        }
 
-       rc = insertPlugin( NULL, pPlugin );
+       rc = slapi_int_register_plugin( NULL, pPlugin );
        if ( rc != 0 ) {
                rc = LDAP_OTHER;
                goto done;
@@ -3683,7 +3684,7 @@ int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function)
                goto done;
        }
 
-       rc = insertPlugin( NULL, pPlugin );
+       rc = slapi_int_register_plugin( NULL, pPlugin );
        if ( rc != 0 ) {
                rc = LDAP_OTHER;
                goto done;
@@ -3712,7 +3713,7 @@ int compute_evaluator(computed_attr_context *c, char *type, Slapi_Entry *e, slap
        int rc = 0;
        slapi_compute_callback_t *pGetPlugin, *tmpPlugin;
 
-       rc = getAllPluginFuncs( NULL, SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN, (SLAPI_FUNC **)&tmpPlugin );
+       rc = slapi_int_get_plugins( NULL, SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN, (SLAPI_FUNC **)&tmpPlugin );
        if ( rc != LDAP_SUCCESS || tmpPlugin == NULL ) {
                /* Nothing to do; front-end should ignore. */
                return 0;
@@ -3749,7 +3750,7 @@ int compute_rewrite_search_filter(Slapi_PBlock *pb)
                return rc;
        }
 
-       return doPluginFNs( be, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, pb );
+       return slapi_int_call_plugins( be, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, pb );
 #else
        return -1;
 #endif /* LDAP_SLAPI */
@@ -3916,7 +3917,7 @@ int slapi_int_access_allowed( Operation *op,
                break;
         }
 
-       rc = getAllPluginFuncs( op->o_bd, SLAPI_PLUGIN_ACL_ALLOW_ACCESS, (SLAPI_FUNC **)&tmpPlugin );
+       rc = slapi_int_get_plugins( op->o_bd, SLAPI_PLUGIN_ACL_ALLOW_ACCESS, (SLAPI_FUNC **)&tmpPlugin );
        if ( rc != LDAP_SUCCESS || tmpPlugin == NULL ) {
                /* nothing to do; allowed access */
                return 1;
index 2c9cd1c364ef1e98e9f6f8b7138a31b3e72d54c3..044d8c164ebe7888a56f55a3ec774822d42d266f 100644 (file)
@@ -62,6 +62,14 @@ slap_null_cb(
        assert(0);
 }
 
+int
+slap_replog_cb(
+    Operation  *op, SlapReply *rs
+)
+{
+       assert(0);
+}
+
 void
 slap_send_ldap_extended(
     Operation  *op, SlapReply *rs
index b147cc2b220636f10b434e0799ec9fd30dd73973..399d77305cce8a52c1490f5a6e36e1bc82d05f1b 100644 (file)
@@ -108,11 +108,11 @@ write_reject(
 #endif
     } else {
        fseek( rfp, 0, 2 );
-       if ( errmsg != NULL ) {
-           fprintf( rfp, "%s: %s\n", ERROR_STR, errmsg );
-       } else {
-           fprintf( rfp, "%s: %s\n", ERROR_STR, ldap_err2string( lderr ));
+       fprintf( rfp, "%s: %s", ERROR_STR, ldap_err2string( lderr ));
+       if ( errmsg && *errmsg ) {
+           fprintf( rfp, ": %s", errmsg );
        }
+       fprintf( rfp, "\n" );
        if ((rc = re->re_write( ri, re, rfp )) < 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG ( SLURPD, ERR, "write_reject: "
index 78860f01f1d22c7ce84ce7e6cc1a59f027edfe28..4660a87afba4441d0db88eff28039658a3ca18c8 100644 (file)
@@ -292,8 +292,11 @@ do_addel(
 
                }
 
+#if 0
                /* wait a second for the add to really complete */
+               /* This masks some race conditions though. */
                sleep( 1 );
+#endif
 
                /* now delete the entry again */
                if ( ldap_delete_s( ld, entry ) != LDAP_SUCCESS ) {