.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.
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
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'
.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:"
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
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
# 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
"%{**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
# 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)):"
.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 ...)
.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.
.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
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>
.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
.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 .
.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)
.B SBINDIR/slapcat
.B [\-v]
.B [\-c]
+.B [\-k]
+.B [\-m]
.B [\-d level]
.B [\-b suffix]
.B [\-n dbnum]
.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"
option is given.
.TP
.BI \-f " slapd.conf"
-specify an alternative
+Specify an alternative
.BR slapd.conf (5)
file.
.TP
.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
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,
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
#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
-/******************************************************************************
+/* $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
* 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
*/
* <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
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
return LDAP_STRDUP( hbuf );
}
}
-#endif
return host ? LDAP_STRDUP( host ) : NULL;
}
* 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]
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;
/*
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:
/* ... */
* 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 */
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;
/*
*/
case REWRITE_REGEXEC_UNWILLING:
case REWRITE_REGEXEC_ERR:
- default:
if ( *result != NULL ) {
free( *result );
*result = NULL;
}
+
+ default:
+ break;
}
rc_return:;
#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'
/*
#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;
};
#define REWRITE_RECURSE 0x0001
#define REWRITE_EXEC_ONCE 0x0002
int lr_mode;
+ int lr_max_passes;
struct rewrite_action *lr_action;
};
*/
struct rewrite_var {
char *lv_name;
+ int lv_flags;
struct berval lv_value;
};
*/
#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
* 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
);
/*
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
*/
rewriteContext != NULL;
rewriteContext = sep,
sep ? sep = strchr( rewriteContext, ',' ) : NULL ) {
+ char *errmsg = "";
+
if ( sep != NULL ) {
sep[ 0 ] = '\0';
sep++;
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;
}
*/
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;
}
/* 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 ) {
{
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;
return REWRITE_ERR;
}
- mode &= ~REWRITE_RECURSE;
- mode |= REWRITE_EXEC_ONCE;
+ //mode &= ~REWRITE_RECURSE;
+ //mode |= REWRITE_EXEC_ONCE;
action->la_type = REWRITE_ACTION_STOP;
break;
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 ] != '{' ) {
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;
}
* 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;
}
}
*/
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;
/*
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 ) {
}
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;
}
* 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;
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 );
struct rewrite_subst *
rewrite_subst_compile(
struct rewrite_info *info,
- const char *result
+ const char *str
)
{
size_t subs_len;
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
tmps = ( struct berval * )realloc( subs,
sizeof( struct berval )*( nsub + 1 ) );
if ( tmps == NULL ) {
- /* FIXME: cleanup */
- return NULL;
+ goto cleanup;
}
subs = tmps;
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';
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;
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;
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;
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++;
* XXX need to free the value subst stuff!
*/
free( subs );
- return NULL;
+ goto cleanup;
}
subs = tmps;
l = p - begin;
s = calloc( sizeof( struct rewrite_subst ), 1 );
if ( s == NULL ) {
- /* cleanup */
- return NULL;
+ goto cleanup;
}
s->lt_subs_len = subs_len;
s->lt_num_submatch = nsub;
s->lt_submatch = submatch;
+cleanup:;
+ free( result );
+
return s;
}
}
if ( rc != REWRITE_SUCCESS ) {
- rc = REWRITE_REGEXEC_ERR;
goto cleanup;
}
break;
rc = REWRITE_ERR;
break;
}
-
+
if ( rc != REWRITE_SUCCESS ) {
rc = REWRITE_REGEXEC_ERR;
}
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
*/
( 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;
}
* 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;
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;
-}
-
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 \
#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 */
/*
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 );
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 ) {
{
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 ||
"<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 );
#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
}
#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 */
/*
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 );
* 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;
#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;
}
* 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;
} 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;
}
#ifdef LDAP_SLAPI
- if ( op->o_pb ) doPostAddPluginFNs( op );
+ if ( op->o_pb ) call_add_postop_plugins( op );
#endif /* LDAP_SLAPI */
done:
}
#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 );
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
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,
}
} 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;
}
}
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
}
}
- /* 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 ))
{
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 )) {
}
} 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;
#include "ldap_rq.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
/*
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 ) {
/*
}
#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 "
typedef struct glue_state {
int err;
+ int is_slimit;
+ int slimit;
int matchlen;
char *matched;
int nrefs;
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;
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;
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;
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;
}
}
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;
be->bd_info = bi;
}
+#if 0
/* Walk to the end of the list of overlays, add the new
* one onto the end
*/
*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 ) {
#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
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 */
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,
}
#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",
#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
static int compare_entry(
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
}
#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 );
#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
#include "lutil.h"
}
#endif /* notdef */
- if ( netscape_plugin( be, fname, lineno, cargc, cargv )
+ if ( slapi_int_read_config( be, fname, lineno, cargc, cargv )
!= LDAP_SUCCESS ) {
return( 1 );
}
#include "slap.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
/* protected by connections_mutex */
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
#include "lutil.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
int
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
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 };
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;
}
#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 );
#include "lber_pvt.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
#define UNSUPPORTED_EXTENDEDOP "unsupported extended operation"
}
#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 )))
#include "slap.h"
#include "lber_pvt.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
/*
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 );
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 */
#include "ldif.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
#ifdef LDAP_SIGCHLD
#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
#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
#include "lutil.h"
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
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 );
}
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 */
#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 );
#include "ldap_pvt.h"
#include "slap.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
int
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
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;
}
#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 );
#include "slap.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
static ldap_pvt_thread_mutex_t slap_op_mutex;
/* 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 */
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",
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 */
#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;
}
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++) {
AttributeName* attr_name;
AttributeName* attrarray;
const char* text=NULL;
- void *private = be->be_private;
int index, i;
int num;
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] );
}
/* 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;
}
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;
{
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 );
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;
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);
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 );
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;
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 );
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;
#include "slap.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
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;
* 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;
}
* 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 */
#include "lber_pvt.h"
#ifdef LDAP_SLAPI
-#include "slapi.h"
+#include "slapi/slapi.h"
#endif
static struct berval supportedFeatures[] = {
#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;
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 );
#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
#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 );
#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 );
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;
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;
}
#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 */
}
#ifdef LDAP_SLAPI
- if ( op->o_pb ) doPostSearchPluginFNs( op );
+ if ( op->o_pb ) call_search_postop_plugins( op );
#endif /* LDAP_SLAPI */
return_results:;
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 );
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 ) ||
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;
/*
#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",
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
# 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%
*/
#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 */
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
* Messages: None
*********************************************************************/
-Slapi_PBlock *
-newPlugin(
+static Slapi_PBlock *
+plugin_pblock_new(
int type,
const char *path,
const char *initfunc,
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,
}
/*********************************************************************
- * Function Name: insertPlugin
+ * Function Name: slapi_int_register_plugin
*
* Description: insert the slapi_pblock structure to the end of the plugin
* list
* Messages: None
*********************************************************************/
int
-insertPlugin(
+slapi_int_register_plugin(
Backend *be,
Slapi_PBlock *pPB )
{
}
/*********************************************************************
- * Function Name: getAllPluginFuncs
+ * Function Name: slapi_int_get_plugins
*
* Description: get the desired type of function pointers defined
* in all the plugins
* Messages: None
*********************************************************************/
int
-getAllPluginFuncs(
+slapi_int_get_plugins(
Backend *be,
int functype,
SLAPI_FUNC **ppFuncPtrs )
/*********************************************************************
- * Function Name: removeExtendedOp
+ * Function Name: slapi_int_unregister_extop
*
* Description: This routine removes the ExtendedOp structures
* asscoiated with a particular extended operation
* Messages: None
*********************************************************************/
void
-removeExtendedOp(
+slapi_int_unregister_extop(
Backend *pBE,
ExtendedOp **opList,
Slapi_PBlock *pPB )
/*********************************************************************
- * 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
* Messages: None
*********************************************************************/
int
-newExtendedOp(
+slapi_int_register_extop(
Backend *pBE,
ExtendedOp **opList,
Slapi_PBlock *pPB )
}
rc = slapi_pblock_get( pPB,SLAPI_PLUGIN_EXT_OP_OIDLIST, &pTmpOIDs );
- if ( rc != LDAP_SUCCESS ) {
+ if ( rc != 0 ) {
rc = LDAP_OTHER;
goto error_return;
}
}
/*********************************************************************
- * Function Name: getPluginFunc
+ * Function Name: slapi_int_get_extop_plugin
*
* Description: This routine gets the function address for a given function
* name.
* Messages: None
*********************************************************************/
int
-getPluginFunc(
+slapi_int_get_extop_plugin(
struct berval *reqoid,
SLAPI_FUNC *pFuncAddr )
{
}
/***************************************************************************
- * 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;
}
/*********************************************************************
- * Function Name: loadPlugin
+ * Function Name: slapi_int_load_plugin
*
* Description: This routine loads the specified DLL, gets and executes the init function
* if requested.
*********************************************************************/
static int
-loadPlugin(
+slapi_int_load_plugin(
Slapi_PBlock *pPlugin,
const char *path,
const char *initfunc,
* Special support for computed attribute plugins
*/
int
-doPluginFNs(
+slapi_int_call_plugins(
Backend *be,
int funcType,
Slapi_PBlock *pPB )
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;
}
int
-netscape_plugin(
+slapi_int_read_config(
Backend *be,
const char *fname,
int lineno,
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;
}
int
-slapi_init(void)
+slapi_int_initialize(void)
{
if ( ldap_pvt_thread_mutex_init( &slapi_hn_mutex ) ) {
return -1;
int slapi_log_level = SLAPI_LOG_PLUGIN;
int
-vLogError(
+slapi_int_log_error(
int level,
char *subsystem,
char *fmt,
* 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);
/*
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,
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
} StrList;
#endif
-extern struct berval *ns_get_supported_extop( int );
-
/*
* Was: slapi_utils.h
*/
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:
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;
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;
}
}
-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;
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;
}
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;
ldap_pvt_thread_mutex_lock( ®istered_extensions.mutex );
- rc = mapExtensionType( objectname, &type );
+ rc = map_extension_type( objectname, &type );
if ( rc != 0 ) {
ldap_pvt_thread_mutex_unlock( ®istered_extensions.mutex );
return rc;
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;
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 );
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;
}
}
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;
}
static Connection *
-slapiConnectionInit(
+slapi_int_init_connection(
char *DN,
int OpType )
{
return pConn;
}
-static void slapiConnectionDestroy( Connection **pConn )
+static void slapi_int_connection_destroy( Connection **pConn )
{
Connection *conn = *pConn;
Operation *op;
}
/*
- * 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 )
{
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;
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 {
pSavePB = pPB;
}
- slapiConnectionDestroy( &pConn );
+ slapi_int_connection_destroy( &pConn );
return (pSavePB);
#else
#ifdef LDAP_SLAPI
static Slapi_PBlock *
-slapi_add_entry_internal_locked(
+slapi_int_add_entry_locked(
Slapi_Entry **e,
LDAPControl **controls,
int log_changes )
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;
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;
}
pSavePB = pPB;
}
- slapiConnectionDestroy( &pConn );
+ slapi_int_connection_destroy( &pConn );
return( pSavePB );
}
* 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 );
}
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;
}
}
if ( rc == LDAP_SUCCESS ) {
- pEntry = LDAPModToEntry( dn, mods );
+ pEntry = slapi_int_ldapmod_to_entry( dn, mods );
if ( pEntry == NULL ) {
rc = LDAP_OTHER;
}
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 ) {
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;
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 {
pSavePB = pPB;
}
- slapiConnectionDestroy( &pConn );
+ slapi_int_connection_destroy( &pConn );
return( pSavePB );
#else
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;
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;
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;
*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;
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 );
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 {
pSavePB = pPB;
}
- slapiConnectionDestroy( &pConn );
+ slapi_int_connection_destroy( &pConn );
return ( pSavePB );
#else
}
Slapi_PBlock *
-slapi_search_internal_bind(
- char *bindDN,
+slapi_search_internal(
char *ldn,
int scope,
char *filStr,
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;
pSavePB = ptr;
}
- slapiConnectionDestroy( &c );
+ slapi_int_connection_destroy( &c );
return( pSavePB );
#else
#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 */
-}
-
}
static int
-parseSlapiControl(
+slapi_int_parse_control(
Operation *op,
SlapReply *rs,
LDAPControl *ctrl )
slapiControlOp2SlapControlMask( controlops, &controlmask );
- register_supported_control( controloid, controlmask, NULL, parseSlapiControl );
+ register_supported_control( controloid, controlmask, NULL, slapi_int_parse_control );
#endif /* LDAP_SLAPI */
}
;
}
- for ( j = 0; ns_get_supported_extop( j ) != NULL; j++ ) {
+ for ( j = 0; slapi_int_get_supported_extop( j ) != NULL; j++ ) {
;
}
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;
/*
* 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(
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;
/*
* 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;
/*
* 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;
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;
return 1;
}
-#endif
+#endif /* LDAP_SLAPI */
int slapi_value_get_int(const Slapi_Value *value)
{
}
}
mod->sml_bvalues[i].bv_val = NULL;
+ mod->sml_bvalues[i].bv_len = 0;
}
mod->sml_nvalues = NULL;
goto done;
}
- rc = insertPlugin( NULL, pPlugin );
+ rc = slapi_int_register_plugin( NULL, pPlugin );
if ( rc != 0 ) {
rc = LDAP_OTHER;
goto done;
goto done;
}
- rc = insertPlugin( NULL, pPlugin );
+ rc = slapi_int_register_plugin( NULL, pPlugin );
if ( rc != 0 ) {
rc = LDAP_OTHER;
goto done;
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;
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 */
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;
assert(0);
}
+int
+slap_replog_cb(
+ Operation *op, SlapReply *rs
+)
+{
+ assert(0);
+}
+
void
slap_send_ldap_extended(
Operation *op, SlapReply *rs
#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: "
}
+#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 ) {