Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jaak Ristioja
OpenLDAP
Commits
c860ba6a
Commit
c860ba6a
authored
21 years ago
by
Pierangelo Masarati
Browse files
Options
Downloads
Patches
Plain Diff
fix, clarify and document previous commit
parent
8b797f70
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/man/man5/slapd-meta.5
+30
-9
30 additions, 9 deletions
doc/man/man5/slapd-meta.5
libraries/librewrite/info.c
+3
-1
3 additions, 1 deletion
libraries/librewrite/info.c
libraries/librewrite/rule.c
+8
-18
8 additions, 18 deletions
libraries/librewrite/rule.c
with
41 additions
and
28 deletions
doc/man/man5/slapd-meta.5
+
30
−
9
View file @
c860ba6a
...
...
@@ -362,20 +362,41 @@ use POSIX Basic Regular Expressions (default is Extended)
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.
.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 is significant.
For instance: `IG{2}' means ignore errors and jump two lines ahead
...
...
@@ -616,7 +637,7 @@ rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
# regular DNs, because the definition of a bindDn
# rewrite context overrides the default definition.
rewriteContext bindDn
rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" "@I"
rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" "
:
@I"
# This is a rather sophisticated example. It massages a
# search filter in case who performs the search has
...
...
@@ -645,7 +666,7 @@ rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
"%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
":I"
rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
"%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" "@I"
"%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" "
:
@I"
rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
# This example shows how to strip unwanted DN-valued
...
...
@@ -655,7 +676,7 @@ rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
# The second rule matches everything else and causes
# the value to be rejected.
rewriteContext searchResult
rewriteRule ".*,ou=People,dc=example,dc=com" "%0" "@"
rewriteRule ".*,ou=People,dc=example,dc=com" "%0" "
:
@"
rewriteRule ".*" "" "#"
.fi
.SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
...
...
@@ -666,16 +687,16 @@ E.g.:
.LP
.nf
rewriteRule '^cn=root,.*' '%0' 'G{3}'
rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' '@'
rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' '@'
rewriteRule '.*' 'ldap://ldap3.my.org/%0' '@'
rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' '
:
@'
rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' '
:
@'
rewriteRule '.*' 'ldap://ldap3.my.org/%0' '
:
@'
.fi
.LP
(Rule 1 is simply there to illustrate the `G{n}' action; it could have
been written:
.LP
.nf
rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' '@'
rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' '
:
@'
.fi
.LP
with the advantage of saving one rewrite pass ...)
...
...
This diff is collapsed.
Click to expand it.
libraries/librewrite/info.c
+
3
−
1
View file @
c860ba6a
...
...
@@ -259,11 +259,13 @@ rewrite_session(
*/
case
REWRITE_REGEXEC_UNWILLING
:
case
REWRITE_REGEXEC_ERR
:
default:
if
(
*
result
!=
NULL
)
{
free
(
*
result
);
*
result
=
NULL
;
}
default:
break
;
}
rc_return:
;
...
...
This diff is collapsed.
Click to expand it.
libraries/librewrite/rule.c
+
8
−
18
View file @
c860ba6a
...
...
@@ -189,8 +189,8 @@ rewrite_rule_compile(
return
REWRITE_ERR
;
}
mode
&=
~
REWRITE_RECURSE
;
mode
|=
REWRITE_EXEC_ONCE
;
//
mode &= ~REWRITE_RECURSE;
//
mode |= REWRITE_EXEC_ONCE;
action
->
la_type
=
REWRITE_ACTION_STOP
;
break
;
...
...
@@ -219,8 +219,7 @@ rewrite_rule_compile(
* After applying rule, return user-defined
* error code
*/
char
buf
[
16
],
*
q
;
size_t
l
;
char
*
next
=
NULL
;
int
*
d
;
if
(
p
[
1
]
!=
'{'
)
{
...
...
@@ -228,26 +227,17 @@ rewrite_rule_compile(
return
REWRITE_ERR
;
}
q
=
strchr
(
p
+
2
,
'}'
);
if
(
q
==
NULL
)
{
/* XXX Need to free stuff */
return
REWRITE_ERR
;
}
l
=
q
-
p
+
1
;
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
)
{
...
...
@@ -269,7 +259,7 @@ rewrite_rule_compile(
action
->
la_args
=
(
void
*
)
d
;
p
=
q
;
/* p is incremented by the for ... */
p
=
next
;
/* p is incremented by the for ... */
break
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment