Commit 9effc2b8 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

cleanup of rewrite code and docs

parent 47e79480
......@@ -188,15 +188,15 @@ 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.
.B `:U{32}'
returns the value `32' (indicating noSuchObject) 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.
Positive errors are allowed, indicating the related LDAP error codes
as specified in \fIdraft-ietf-ldapbis-protocol\fP.
.LP
The ordering of the flags can be significant.
For instance: `IG{2}' means ignore errors and jump two lines ahead
......@@ -400,26 +400,29 @@ rwm-rewriteEngine on
rwm-rewriteEngine on
# all dataflow from client to server referring to DNs
rwm-rewriteContext default
rwm-rewriteRule "(.*)<virtualnamingcontext>$" "$1<realnamingcontext>" ":"
rwm-rewriteRule "(.+,)?<virtualnamingcontext>$" "$1<realnamingcontext>" ":"
# empty filter rule
rwm-rewriteContext searchFilter
# all dataflow from server to client
rwm-rewriteContext searchEntryDN
rwm-rewriteRule "(.*)<realnamingcontext>$" "$1<virtualnamingcontext>" ":"
rwm-rewriteRule "(.+,)?<realnamingcontext>$" "$1<virtualnamingcontext>" ":"
rwm-rewriteContext searchAttrDN alias searchEntryDN
rwm-rewriteContext matchedDN alias searchEntryDN
# misc empty rules
rwm-rewriteContext referralAttrDN
rwm-rewriteContext referralDN
# Everything defined here goes into the `default' context.
# This rule changes the naming context of anything sent
# to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
rwm-rewriteRule "(.*)dc=home,[ ]?dc=net$"
rwm-rewriteRule "(.+,)?dc=home,[ ]?dc=net$"
"$1dc=OpenLDAP, dc=org" ":"
# since a pretty/normalized DN does not include spaces
# after rdn separators, e.g. `,', this rule suffices:
rwm-rewriteRule "(.*)dc=home,dc=net$"
rwm-rewriteRule "(.+,)?dc=home,dc=net$"
"$1dc=OpenLDAP,dc=org" ":"
# Start a new context (ends input of the previous one).
......
......@@ -38,8 +38,7 @@
* Rewrite internal status returns
*/
#define REWRITE_SUCCESS LDAP_SUCCESS
#define REWRITE_ERR LDAP_OPERATIONS_ERROR
#define REWRITE_NO_SUCH_OBJECT LDAP_NO_SUCH_OBJECT
#define REWRITE_ERR LDAP_OTHER
/*
* Rewrite modes (input values for rewrite_info_init); determine the
......@@ -66,11 +65,11 @@
* REWRITE_REGEXEC_UNWILLING the server should issue an 'unwilling
* to perform' error
*/
#define REWRITE_REGEXEC_OK 0x0000
#define REWRITE_REGEXEC_ERR 0x0001
#define REWRITE_REGEXEC_STOP 0x0002
#define REWRITE_REGEXEC_UNWILLING 0x0003
#define REWRITE_REGEXEC_USER 0x0004 /* and above ... */
#define REWRITE_REGEXEC_OK (0)
#define REWRITE_REGEXEC_ERR (-1)
#define REWRITE_REGEXEC_STOP (-2)
#define REWRITE_REGEXEC_UNWILLING (-3)
#define REWRITE_REGEXEC_USER (1) /* and above: LDAP errors */
/*
* Rewrite variable flags
......
......@@ -259,7 +259,7 @@ rewrite_xmap_apply(
ldap_pvt_thread_mutex_unlock( &xpasswd_mutex );
#endif /* USE_REWRITE_LDAP_PVT_THREADS */
rc = REWRITE_NO_SUCH_OBJECT;
rc = LDAP_NO_SUCH_OBJECT;
break;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment