Merge ~sergiodj/ubuntu/+source/openldap:MRE-2.5.17-jammy into ubuntu/+source/openldap:ubuntu/jammy-devel
- Git
- lp:~sergiodj/ubuntu/+source/openldap
- MRE-2.5.17-jammy
- Merge into ubuntu/jammy-devel
Status: | Merged |
---|---|
Approved by: | git-ubuntu bot |
Approved revision: | not available |
Merged at revision: | a2130beb84a0617b364fd2d7beca33aac443a08b |
Proposed branch: | ~sergiodj/ubuntu/+source/openldap:MRE-2.5.17-jammy |
Merge into: | ubuntu/+source/openldap:ubuntu/jammy-devel |
Diff against target: |
4842 lines (+1607/-800) 50 files modified
CHANGES (+32/-0) build/version.var (+4/-4) clients/tools/common.c (+4/-3) clients/tools/ldappasswd.c (+12/-2) clients/tools/ldapvc.c (+7/-2) contrib/slapd-modules/lastmod/lastmod.c (+10/-2) debian/changelog (+19/-0) doc/guide/admin/guide.html (+1/-1) doc/man/man5/lloadd.conf.5 (+26/-26) doc/man/man5/slapo-dynlist.5 (+7/-0) doc/man/man5/slapo-homedir.5 (+28/-1) doc/man/man8/slapd.8 (+3/-1) include/ac/string.h (+3/-3) libraries/liblber/debug.c (+4/-1) libraries/libldap/getdn.c (+8/-0) libraries/libldap/init.c (+0/-3) libraries/libldap/open.c (+1/-0) libraries/libldap/tls2.c (+13/-1) libraries/libldap/tls_o.c (+14/-4) libraries/libldap/url.c (+4/-0) libraries/libldap/util-int.c (+51/-123) libraries/liblmdb/CHANGES (+6/-0) libraries/liblmdb/Makefile (+1/-0) libraries/liblmdb/lmdb.h (+2/-2) libraries/liblmdb/mdb.c (+112/-37) libraries/liblmdb/mdb_load.c (+4/-2) libraries/liblmdb/midl.h (+2/-0) libraries/liblmdb/mplay.c (+582/-0) servers/lloadd/daemon.c (+15/-1) servers/lloadd/libevent_support.c (+7/-1) servers/lloadd/module_init.c (+0/-1) servers/lloadd/upstream.c (+8/-3) servers/slapd/aci.c (+14/-12) servers/slapd/aclparse.c (+416/-448) servers/slapd/back-asyncmeta/map.c (+11/-1) servers/slapd/back-ldap/chain.c (+1/-1) servers/slapd/back-null/null.c (+2/-2) servers/slapd/bconfig.c (+30/-17) servers/slapd/controls.c (+1/-0) servers/slapd/overlays/dynlist.c (+35/-20) servers/slapd/proto-slap.h (+1/-3) servers/slapd/slap-config.h (+22/-22) servers/slapd/slap.h (+4/-2) servers/slapd/slapi/Makefile.in (+6/-6) servers/slapd/slapi/plugin.c (+35/-36) servers/slapd/slapi/printmsg.c (+20/-0) servers/slapd/slapi/proto-slapi.h (+1/-2) servers/slapd/slapi/slapi_utils.c (+6/-0) servers/slapd/slappasswd.c (+9/-4) tests/progs/slapd-tester.c (+3/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
git-ubuntu bot | Approve | ||
Bryce Harrington (community) | Approve | ||
Canonical Server Reporter | Pending | ||
Review via email: mp+460353@code.launchpad.net |
Commit message
Description of the change
This is the MRE of OpenLDAP 2.5.17 to Jammy.
Nothing major to report here. Instead of trying to decide for a small set of upstream changes to list on d/changelog, I'm now listing everything.
PPA: https:/
dep8 results will be posted soon.
git-ubuntu bot (git-ubuntu-bot) wrote : | # |
Approvers: sergiodj, bryce
Uploaders: sergiodj, bryce
MP auto-approved
Sergio Durigan Junior (sergiodj) wrote : | # |
On Friday, February 09 2024, Bryce Harrington wrote:
> LGTM, +1, presuming the autopkgtests pass.
Thanks, Bryce.
I just got the results:
Results: (from http://
openldap @ amd64:
http://
09.02.24 22:58:23 ✅ Triggers: openldap/
openldap @ arm64:
http://
09.02.24 23:03:58 ✅ Triggers: openldap/
openldap @ armhf:
http://
09.02.24 23:01:14 ✅ Triggers: openldap/
openldap @ ppc64el:
http://
09.02.24 23:12:13 ✅ Triggers: openldap/
openldap @ s390x:
http://
09.02.24 22:58:40 ✅ Triggers: openldap/
Therefore, I'm uploading the package now:
$ dput openldap_
Trying to upload package to ubuntu
Checking signature on .changes
gpg: /home/sergio/
Checking signature on .dsc
gpg: /home/sergio/
Package includes an .orig.tar.gz file although the debian revision suggests
that it might not be required. Multiple uploads of the .orig.tar.gz may be
rejected by the upload queue management software.
Uploading to ubuntu (via ftp to upload.ubuntu.com):
Uploading openldap_
Uploading openldap_
Uploading openldap_
Uploading openldap_
Uploading openldap_
Successfully uploaded packages.
--
Sergio
GPG key ID: E92F D0B3 6B14 F1F4 D8E0 EB2F 106D A1C8 C3CB BF14
Preview Diff
1 | diff --git a/CHANGES b/CHANGES | |||
2 | index 23c0e5e..8b691f0 100644 | |||
3 | --- a/CHANGES | |||
4 | +++ b/CHANGES | |||
5 | @@ -1,5 +1,37 @@ | |||
6 | 1 | OpenLDAP 2.5 Change Log | 1 | OpenLDAP 2.5 Change Log |
7 | 2 | 2 | ||
8 | 3 | OpenLDAP 2.5.17 Release (2024/01/29) | ||
9 | 4 | Added slapo-dynlist option to disable filter support (ITS#10025) | ||
10 | 5 | Fixed liblber missing newline on long msg (ITS#10105) | ||
11 | 6 | Fixed libldap exit handling with OpenSSL3 (ITS#9952) | ||
12 | 7 | Fixed libldap with TLS and multiple ldap URIs (ITS#10101) | ||
13 | 8 | Fixed libldap OpenSSL cipher suite handling (ITS#10094) | ||
14 | 9 | Fixed libldap OpenSSL 3.0 and Diffie-Hellman param files (ITS#10124) | ||
15 | 10 | Fixed libldap timestamps on Windows (ITS#10100) | ||
16 | 11 | Fixed lloadd to work when resolv.conf is missing (ITS#10070) | ||
17 | 12 | Fixed lloadd handling of closing connection (ITS#10083) | ||
18 | 13 | Fixed slapd to honour disclose in matchedDN handling (ITS#10139) | ||
19 | 14 | Fixed slapd handling of regex testing in ACLs (ITS#10089) | ||
20 | 15 | Fixed slapd-asyncmeta when remote suffix is empty (ITS#10076) | ||
21 | 16 | Fixed slapo-dynlist so it can't be global (ITS#10091) | ||
22 | 17 | Build | ||
23 | 18 | Fixed lloadd type mismatches (ITS#10074) | ||
24 | 19 | Fixed builds for Windows (ITS#10117) | ||
25 | 20 | Fixed build with clang16 (ITS#10123 | ||
26 | 21 | Documentation | ||
27 | 22 | Fixed slapo-homedir(5) attribute name for olcHomedirArchivePath (ITS#10057) | ||
28 | 23 | Minor Cleanup | ||
29 | 24 | ITS#10059 | ||
30 | 25 | ITS#10068 | ||
31 | 26 | ITS#10109 | ||
32 | 27 | ITS#10110 | ||
33 | 28 | ITS#10129 | ||
34 | 29 | ITS#10130 | ||
35 | 30 | ITS#10135 | ||
36 | 31 | ITS#10144 | ||
37 | 32 | ITS#10145 | ||
38 | 33 | ITS#10153 | ||
39 | 34 | |||
40 | 3 | OpenLDAP 2.5.16 Release (2023/07/31) | 35 | OpenLDAP 2.5.16 Release (2023/07/31) |
41 | 4 | Fixed slapd cn=config incorrect handling of paused (ITS#10045) | 36 | Fixed slapd cn=config incorrect handling of paused (ITS#10045) |
42 | 5 | Fixed slapd-meta to account for MOD ops being optional (ITS#10067) | 37 | Fixed slapd-meta to account for MOD ops being optional (ITS#10067) |
43 | diff --git a/build/version.var b/build/version.var | |||
44 | index cd4e7aa..e2d54d0 100644 | |||
45 | --- a/build/version.var | |||
46 | +++ b/build/version.var | |||
47 | @@ -15,9 +15,9 @@ | |||
48 | 15 | ol_package=OpenLDAP | 15 | ol_package=OpenLDAP |
49 | 16 | ol_major=2 | 16 | ol_major=2 |
50 | 17 | ol_minor=5 | 17 | ol_minor=5 |
53 | 18 | ol_patch=16 | 18 | ol_patch=17 |
54 | 19 | ol_api_inc=20516 | 19 | ol_api_inc=20517 |
55 | 20 | ol_api_current=1 | 20 | ol_api_current=1 |
57 | 21 | ol_api_revision=11 | 21 | ol_api_revision=12 |
58 | 22 | ol_api_age=1 | 22 | ol_api_age=1 |
60 | 23 | ol_release_date="2023/07/31" | 23 | ol_release_date="2024/01/29" |
61 | diff --git a/clients/tools/common.c b/clients/tools/common.c | |||
62 | index b88f219..9dfbb53 100644 | |||
63 | --- a/clients/tools/common.c | |||
64 | +++ b/clients/tools/common.c | |||
65 | @@ -1472,10 +1472,11 @@ tool_bind( LDAP *ld ) | |||
66 | 1472 | 1472 | ||
67 | 1473 | } else { | 1473 | } else { |
68 | 1474 | char *pw = getpassphrase( _("Enter LDAP Password: ") ); | 1474 | char *pw = getpassphrase( _("Enter LDAP Password: ") ); |
72 | 1475 | if ( pw ) { | 1475 | if ( pw == NULL ) { /* Allow EOF to exit. */ |
73 | 1476 | passwd.bv_val = ber_strdup( pw ); | 1476 | tool_exit( ld, EXIT_FAILURE ); |
71 | 1477 | passwd.bv_len = strlen( passwd.bv_val ); | ||
74 | 1478 | } | 1477 | } |
75 | 1478 | passwd.bv_val = ber_strdup( pw ); | ||
76 | 1479 | passwd.bv_len = strlen( passwd.bv_val ); | ||
77 | 1479 | } | 1480 | } |
78 | 1480 | } | 1481 | } |
79 | 1481 | 1482 | ||
80 | diff --git a/clients/tools/ldappasswd.c b/clients/tools/ldappasswd.c | |||
81 | index 2cf14d1..036e5e1 100644 | |||
82 | --- a/clients/tools/ldappasswd.c | |||
83 | +++ b/clients/tools/ldappasswd.c | |||
84 | @@ -206,7 +206,12 @@ main( int argc, char *argv[] ) | |||
85 | 206 | if( want_oldpw && oldpw.bv_val == NULL ) { | 206 | if( want_oldpw && oldpw.bv_val == NULL ) { |
86 | 207 | /* prompt for old password */ | 207 | /* prompt for old password */ |
87 | 208 | char *ckoldpw; | 208 | char *ckoldpw; |
89 | 209 | oldpw.bv_val = strdup(getpassphrase(_("Old password: "))); | 209 | ckoldpw = getpassphrase(_("Old password: ")); |
90 | 210 | if ( ckoldpw == NULL ) { /* Allow EOF to exit. */ | ||
91 | 211 | rc = EXIT_FAILURE; | ||
92 | 212 | goto done; | ||
93 | 213 | } | ||
94 | 214 | oldpw.bv_val = strdup( ckoldpw ); | ||
95 | 210 | ckoldpw = getpassphrase(_("Re-enter old password: ")); | 215 | ckoldpw = getpassphrase(_("Re-enter old password: ")); |
96 | 211 | 216 | ||
97 | 212 | if( oldpw.bv_val == NULL || ckoldpw == NULL || | 217 | if( oldpw.bv_val == NULL || ckoldpw == NULL || |
98 | @@ -231,7 +236,12 @@ main( int argc, char *argv[] ) | |||
99 | 231 | if( want_newpw && newpw.bv_val == NULL ) { | 236 | if( want_newpw && newpw.bv_val == NULL ) { |
100 | 232 | /* prompt for new password */ | 237 | /* prompt for new password */ |
101 | 233 | char *cknewpw; | 238 | char *cknewpw; |
103 | 234 | newpw.bv_val = strdup(getpassphrase(_("New password: "))); | 239 | cknewpw = getpassphrase(_("New password: ")); |
104 | 240 | if ( cknewpw == NULL ) { /* Allow EOF to exit. */ | ||
105 | 241 | rc = EXIT_FAILURE; | ||
106 | 242 | goto done; | ||
107 | 243 | } | ||
108 | 244 | newpw.bv_val = strdup( cknewpw ); | ||
109 | 235 | cknewpw = getpassphrase(_("Re-enter new password: ")); | 245 | cknewpw = getpassphrase(_("Re-enter new password: ")); |
110 | 236 | 246 | ||
111 | 237 | if( newpw.bv_val == NULL || cknewpw == NULL || | 247 | if( newpw.bv_val == NULL || cknewpw == NULL || |
112 | diff --git a/clients/tools/ldapvc.c b/clients/tools/ldapvc.c | |||
113 | index 4f35025..264f293 100644 | |||
114 | --- a/clients/tools/ldapvc.c | |||
115 | +++ b/clients/tools/ldapvc.c | |||
116 | @@ -309,8 +309,13 @@ main( int argc, char *argv[] ) | |||
117 | 309 | #endif | 309 | #endif |
118 | 310 | && !cred.bv_val) | 310 | && !cred.bv_val) |
119 | 311 | { | 311 | { |
122 | 312 | cred.bv_val = strdup(getpassphrase(_("User's password: "))); | 312 | char *userpw = getpassphrase(_("User's password: ")); |
123 | 313 | cred.bv_len = strlen(cred.bv_val); | 313 | if ( userpw == NULL ) /* Allow EOF to exit. */ |
124 | 314 | { | ||
125 | 315 | tool_exit( ld, EXIT_FAILURE ); | ||
126 | 316 | } | ||
127 | 317 | cred.bv_val = strdup(userpw); | ||
128 | 318 | cred.bv_len = strlen(cred.bv_val); | ||
129 | 314 | } | 319 | } |
130 | 315 | 320 | ||
131 | 316 | #ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS_INTERACTIVE | 321 | #ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS_INTERACTIVE |
132 | diff --git a/contrib/slapd-modules/lastmod/lastmod.c b/contrib/slapd-modules/lastmod/lastmod.c | |||
133 | index 116b9ae..b329ef7 100644 | |||
134 | --- a/contrib/slapd-modules/lastmod/lastmod.c | |||
135 | +++ b/contrib/slapd-modules/lastmod/lastmod.c | |||
136 | @@ -372,7 +372,7 @@ best_guess( Operation *op, | |||
137 | 372 | 372 | ||
138 | 373 | entryCSN.bv_val = csnbuf; | 373 | entryCSN.bv_val = csnbuf; |
139 | 374 | entryCSN.bv_len = sizeof( csnbuf ); | 374 | entryCSN.bv_len = sizeof( csnbuf ); |
141 | 375 | slap_get_csn( NULL, &entryCSN, 0 ); | 375 | slap_get_csn( op, &entryCSN, 0 ); |
142 | 376 | 376 | ||
143 | 377 | ber_dupbv( bv_entryCSN, &entryCSN ); | 377 | ber_dupbv( bv_entryCSN, &entryCSN ); |
144 | 378 | ber_dupbv( bv_nentryCSN, &entryCSN ); | 378 | ber_dupbv( bv_nentryCSN, &entryCSN ); |
145 | @@ -833,6 +833,11 @@ lastmod_db_open( BackendDB *be, ConfigReply *cr ) | |||
146 | 833 | static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ]; | 833 | static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ]; |
147 | 834 | 834 | ||
148 | 835 | char csnbuf[ LDAP_PVT_CSNSTR_BUFSIZE ]; | 835 | char csnbuf[ LDAP_PVT_CSNSTR_BUFSIZE ]; |
149 | 836 | void *thrctx = ldap_pvt_thread_pool_context(); | ||
150 | 837 | Connection conn = { 0 }; | ||
151 | 838 | OperationBuffer opbuf; | ||
152 | 839 | Operation *op; | ||
153 | 840 | |||
154 | 836 | struct berval entryCSN; | 841 | struct berval entryCSN; |
155 | 837 | struct berval timestamp; | 842 | struct berval timestamp; |
156 | 838 | 843 | ||
157 | @@ -841,6 +846,9 @@ lastmod_db_open( BackendDB *be, ConfigReply *cr ) | |||
158 | 841 | return -1; | 846 | return -1; |
159 | 842 | } | 847 | } |
160 | 843 | 848 | ||
161 | 849 | connection_fake_init2( &conn, &opbuf, thrctx, 0 ); | ||
162 | 850 | op = &opbuf.ob_op; | ||
163 | 851 | |||
164 | 844 | /* | 852 | /* |
165 | 845 | * Start | 853 | * Start |
166 | 846 | */ | 854 | */ |
167 | @@ -850,7 +858,7 @@ lastmod_db_open( BackendDB *be, ConfigReply *cr ) | |||
168 | 850 | 858 | ||
169 | 851 | entryCSN.bv_val = csnbuf; | 859 | entryCSN.bv_val = csnbuf; |
170 | 852 | entryCSN.bv_len = sizeof( csnbuf ); | 860 | entryCSN.bv_len = sizeof( csnbuf ); |
172 | 853 | slap_get_csn( NULL, &entryCSN, 0 ); | 861 | slap_get_csn( op, &entryCSN, 0 ); |
173 | 854 | 862 | ||
174 | 855 | if ( BER_BVISNULL( &lmi->lmi_rdnvalue ) ) { | 863 | if ( BER_BVISNULL( &lmi->lmi_rdnvalue ) ) { |
175 | 856 | ber_str2bv( "Lastmod", 0, 1, &lmi->lmi_rdnvalue ); | 864 | ber_str2bv( "Lastmod", 0, 1, &lmi->lmi_rdnvalue ); |
176 | diff --git a/debian/changelog b/debian/changelog | |||
177 | index 96e71ea..5b5eb53 100644 | |||
178 | --- a/debian/changelog | |||
179 | +++ b/debian/changelog | |||
180 | @@ -1,3 +1,22 @@ | |||
181 | 1 | openldap (2.5.17+dfsg-0ubuntu0.22.04.1) jammy; urgency=medium | ||
182 | 2 | |||
183 | 3 | * New upstream version (LP: #2040465). | ||
184 | 4 | - Added slapo-dynlist option to disable filter support (ITS#10025) | ||
185 | 5 | - Fixed liblber missing newline on long msg (ITS#10105) | ||
186 | 6 | - Fixed libldap exit handling with OpenSSL3 (ITS#9952) | ||
187 | 7 | - Fixed libldap with TLS and multiple ldap URIs (ITS#10101) | ||
188 | 8 | - Fixed libldap OpenSSL cipher suite handling (ITS#10094) | ||
189 | 9 | - Fixed libldap OpenSSL 3.0 and Diffie-Hellman param files (ITS#10124) | ||
190 | 10 | - Fixed libldap timestamps on Windows (ITS#10100) | ||
191 | 11 | - Fixed lloadd to work when resolv.conf is missing (ITS#10070) | ||
192 | 12 | - Fixed lloadd handling of closing connection (ITS#10083) | ||
193 | 13 | - Fixed slapd to honour disclose in matchedDN handling (ITS#10139) | ||
194 | 14 | - Fixed slapd handling of regex testing in ACLs (ITS#10089) | ||
195 | 15 | - Fixed slapd-asyncmeta when remote suffix is empty (ITS#10076) | ||
196 | 16 | - Fixed slapo-dynlist so it can't be global (ITS#10091) | ||
197 | 17 | |||
198 | 18 | -- Sergio Durigan Junior <sergio.durigan@canonical.com> Fri, 09 Feb 2024 15:12:07 -0500 | ||
199 | 19 | |||
200 | 1 | openldap (2.5.16+dfsg-0ubuntu0.22.04.2) jammy-security; urgency=medium | 20 | openldap (2.5.16+dfsg-0ubuntu0.22.04.2) jammy-security; urgency=medium |
201 | 2 | 21 | ||
202 | 3 | * No change rebuild to fix CVE-2023-2953 in the -security pocket. | 22 | * No change rebuild to fix CVE-2023-2953 in the -security pocket. |
203 | diff --git a/doc/guide/admin/guide.html b/doc/guide/admin/guide.html | |||
204 | index 679b61e..dc31ac2 100644 | |||
205 | --- a/doc/guide/admin/guide.html | |||
206 | +++ b/doc/guide/admin/guide.html | |||
207 | @@ -23,7 +23,7 @@ | |||
208 | 23 | <DIV CLASS="title"> | 23 | <DIV CLASS="title"> |
209 | 24 | <H1 CLASS="doc-title">OpenLDAP Software 2.5 Administrator's Guide</H1> | 24 | <H1 CLASS="doc-title">OpenLDAP Software 2.5 Administrator's Guide</H1> |
210 | 25 | <ADDRESS CLASS="doc-author">The OpenLDAP Project <<A HREF="https://www.openldap.org/">https://www.openldap.org/</A>></ADDRESS> | 25 | <ADDRESS CLASS="doc-author">The OpenLDAP Project <<A HREF="https://www.openldap.org/">https://www.openldap.org/</A>></ADDRESS> |
212 | 26 | <ADDRESS CLASS="doc-modified">31 July 2023</ADDRESS> | 26 | <ADDRESS CLASS="doc-modified">29 January 2024</ADDRESS> |
213 | 27 | <BR CLEAR="All"> | 27 | <BR CLEAR="All"> |
214 | 28 | </DIV> | 28 | </DIV> |
215 | 29 | <DIV CLASS="contents"> | 29 | <DIV CLASS="contents"> |
216 | diff --git a/doc/man/man5/lloadd.conf.5 b/doc/man/man5/lloadd.conf.5 | |||
217 | index 49c72b9..50269b3 100644 | |||
218 | --- a/doc/man/man5/lloadd.conf.5 | |||
219 | +++ b/doc/man/man5/lloadd.conf.5 | |||
220 | @@ -598,7 +598,16 @@ option. The authentication configuration is shared between them. | |||
221 | 598 | .B [secprops=<properties>] | 598 | .B [secprops=<properties>] |
222 | 599 | .B [timeout=<seconds>] | 599 | .B [timeout=<seconds>] |
223 | 600 | .B [network\-timeout=<seconds>] | 600 | .B [network\-timeout=<seconds>] |
224 | 601 | .B [keepalive=<idle>:<probes>:<interval>] | ||
225 | 601 | .B [tcp\-user\-timeout=<milliseconds>] | 602 | .B [tcp\-user\-timeout=<milliseconds>] |
226 | 603 | .B [tls_cert=<file>] | ||
227 | 604 | .B [tls_key=<file>] | ||
228 | 605 | .B [tls_cacert=<file>] | ||
229 | 606 | .B [tls_cacertdir=<path>] | ||
230 | 607 | .B [tls_reqcert=never|allow|try|demand] | ||
231 | 608 | .B [tls_cipher_suite=<ciphers>] | ||
232 | 609 | .B [tls_crlcheck=none|peer|all] | ||
233 | 610 | .B [tls_protocol_min=<major>[.<minor>]] | ||
234 | 602 | 611 | ||
235 | 603 | Specifies the bind credentials | 612 | Specifies the bind credentials |
236 | 604 | .B lloadd | 613 | .B lloadd |
237 | @@ -658,6 +667,23 @@ Timeout set to 0 means no timeout is in effect and by default, no timeouts are | |||
238 | 658 | in effect. | 667 | in effect. |
239 | 659 | 668 | ||
240 | 660 | The | 669 | The |
241 | 670 | .B keepalive | ||
242 | 671 | parameter sets the values of \fIidle\fP, \fIprobes\fP, and \fIinterval\fP | ||
243 | 672 | used to check whether a socket is alive; | ||
244 | 673 | .I idle | ||
245 | 674 | is the number of seconds a connection needs to remain idle before TCP | ||
246 | 675 | starts sending keepalive probes; | ||
247 | 676 | .I probes | ||
248 | 677 | is the maximum number of keepalive probes TCP should send before dropping | ||
249 | 678 | the connection; | ||
250 | 679 | .I interval | ||
251 | 680 | is interval in seconds between individual keepalive probes. | ||
252 | 681 | Only some systems support the customization of these values; | ||
253 | 682 | the | ||
254 | 683 | .B keepalive | ||
255 | 684 | parameter is ignored otherwise, and system-wide settings are used. | ||
256 | 685 | |||
257 | 686 | The | ||
258 | 661 | .B tcp\-user\-timeout | 687 | .B tcp\-user\-timeout |
259 | 662 | parameter, if non-zero, corresponds to the | 688 | parameter, if non-zero, corresponds to the |
260 | 663 | .B TCP_USER_TIMEOUT | 689 | .B TCP_USER_TIMEOUT |
261 | @@ -671,16 +697,7 @@ ignored otherwise and system-wide settings are used. | |||
262 | 671 | .B backend-server | 697 | .B backend-server |
263 | 672 | .B uri=ldap[s]://<hostname>[:port] | 698 | .B uri=ldap[s]://<hostname>[:port] |
264 | 673 | .B [retry=<retry interval in ms>] | 699 | .B [retry=<retry interval in ms>] |
265 | 674 | .B [keepalive=<idle>:<probes>:<interval>] | ||
266 | 675 | .B [starttls=yes|critical] | 700 | .B [starttls=yes|critical] |
267 | 676 | .B [tls_cert=<file>] | ||
268 | 677 | .B [tls_key=<file>] | ||
269 | 678 | .B [tls_cacert=<file>] | ||
270 | 679 | .B [tls_cacertdir=<path>] | ||
271 | 680 | .B [tls_reqcert=never|allow|try|demand] | ||
272 | 681 | .B [tls_cipher_suite=<ciphers>] | ||
273 | 682 | .B [tls_crlcheck=none|peer|all] | ||
274 | 683 | .B [tls_protocol_min=<major>[.<minor>]] | ||
275 | 684 | .B [numconns=<conns>] | 701 | .B [numconns=<conns>] |
276 | 685 | .B [bindconns=<conns>] | 702 | .B [bindconns=<conns>] |
277 | 686 | .B [max-pending-ops=<ops>] | 703 | .B [max-pending-ops=<ops>] |
278 | @@ -725,23 +742,6 @@ connections, | |||
279 | 725 | the default, means no limit will be imposed for this backend. | 742 | the default, means no limit will be imposed for this backend. |
280 | 726 | 743 | ||
281 | 727 | The | 744 | The |
282 | 728 | .B keepalive | ||
283 | 729 | parameter sets the values of \fIidle\fP, \fIprobes\fP, and \fIinterval\fP | ||
284 | 730 | used to check whether a socket is alive; | ||
285 | 731 | .I idle | ||
286 | 732 | is the number of seconds a connection needs to remain idle before TCP | ||
287 | 733 | starts sending keepalive probes; | ||
288 | 734 | .I probes | ||
289 | 735 | is the maximum number of keepalive probes TCP should send before dropping | ||
290 | 736 | the connection; | ||
291 | 737 | .I interval | ||
292 | 738 | is interval in seconds between individual keepalive probes. | ||
293 | 739 | Only some systems support the customization of these values; | ||
294 | 740 | the | ||
295 | 741 | .B keepalive | ||
296 | 742 | parameter is ignored otherwise, and system-wide settings are used. | ||
297 | 743 | |||
298 | 744 | The | ||
299 | 745 | .B starttls | 745 | .B starttls |
300 | 746 | parameter specifies use of the StartTLS extended operation | 746 | parameter specifies use of the StartTLS extended operation |
301 | 747 | to establish a TLS session before Binding to the provider. If the | 747 | to establish a TLS session before Binding to the provider. If the |
302 | diff --git a/doc/man/man5/slapo-dynlist.5 b/doc/man/man5/slapo-dynlist.5 | |||
303 | index 49a3d50..7fe0f70 100644 | |||
304 | --- a/doc/man/man5/slapo-dynlist.5 | |||
305 | +++ b/doc/man/man5/slapo-dynlist.5 | |||
306 | @@ -134,6 +134,13 @@ character is also specified, then the member and memberOf values will be | |||
307 | 134 | populated recursively, for nested groups. Note that currently nesting is | 134 | populated recursively, for nested groups. Note that currently nesting is |
308 | 135 | only supported for Search operations, not Compares. | 135 | only supported for Search operations, not Compares. |
309 | 136 | 136 | ||
310 | 137 | .TP | ||
311 | 138 | .B dynlist\-simple TRUE | FALSE | ||
312 | 139 | This option downgrades to the behavior of the OpenLDAP 2.4 dynlist overlay. | ||
313 | 140 | It disables memberOf processing, nested group support, and filter evaluation | ||
314 | 141 | of dynamically generated values. | ||
315 | 142 | The default is FALSE. | ||
316 | 143 | |||
317 | 137 | .LP | 144 | .LP |
318 | 138 | The dynlist overlay may be used with any backend, but it is mainly | 145 | The dynlist overlay may be used with any backend, but it is mainly |
319 | 139 | intended for use with local storage backends. | 146 | intended for use with local storage backends. |
320 | diff --git a/doc/man/man5/slapo-homedir.5 b/doc/man/man5/slapo-homedir.5 | |||
321 | index 5cd4ee8..cb1ac5b 100644 | |||
322 | --- a/doc/man/man5/slapo-homedir.5 | |||
323 | +++ b/doc/man/man5/slapo-homedir.5 | |||
324 | @@ -77,7 +77,7 @@ IGNORE. | |||
325 | 77 | .TP | 77 | .TP |
326 | 78 | .B homedir\-archive\-path <pathname> | 78 | .B homedir\-archive\-path <pathname> |
327 | 79 | .TP | 79 | .TP |
329 | 80 | .B olcArchivePath: pathname | 80 | .B olcHomedirArchivePath: pathname |
330 | 81 | These options specify the destination path for TAR files created by | 81 | These options specify the destination path for TAR files created by |
331 | 82 | the ARCHIVE delete style. | 82 | the ARCHIVE delete style. |
332 | 83 | .SH REPLICATION | 83 | .SH REPLICATION |
333 | @@ -90,6 +90,32 @@ for more information on configure syncrepl. | |||
334 | 90 | 90 | ||
335 | 91 | Partial replication (e.g. with filters) is especially useful for | 91 | Partial replication (e.g. with filters) is especially useful for |
336 | 92 | providing different provisioning options to different sets of users. | 92 | providing different provisioning options to different sets of users. |
337 | 93 | .SH EXAMPLE | ||
338 | 94 | The following LDIF could be used to add this overlay to | ||
339 | 95 | .B cn=config | ||
340 | 96 | (adjust to suit) | ||
341 | 97 | .LP | ||
342 | 98 | .RS | ||
343 | 99 | .nf | ||
344 | 100 | dn: cn=module{0},cn=config | ||
345 | 101 | changetype: modify | ||
346 | 102 | add: olcModuleLoad | ||
347 | 103 | olcModuleLoad: homedir | ||
348 | 104 | |||
349 | 105 | dn: olcOverlay=homedir,olcDatabase={1}mdb,cn=config | ||
350 | 106 | changetype: add | ||
351 | 107 | objectClass: olcOverlayConfig | ||
352 | 108 | objectClass: olcHomedirConfig | ||
353 | 109 | olcOverlay: homedir | ||
354 | 110 | olcSkeletonPath: /etc/skel | ||
355 | 111 | olcMinimumUidNumber: 1000 | ||
356 | 112 | olcHomedirRegexp: ^(/home/[-_/a-z0-9]+)$ /export/$1 | ||
357 | 113 | olcHomedirDeleteStyle: ARCHIVE | ||
358 | 114 | olcHomedirArchivePath: /archive | ||
359 | 115 | .fi | ||
360 | 116 | .RE | ||
361 | 117 | .LP | ||
362 | 118 | |||
363 | 93 | .SH BUGS | 119 | .SH BUGS |
364 | 94 | DELETE, MOD, and MODRDN operations that remove the unix attributes | 120 | DELETE, MOD, and MODRDN operations that remove the unix attributes |
365 | 95 | when delete style is set to DELETE will recursively delete the (regex | 121 | when delete style is set to DELETE will recursively delete the (regex |
366 | @@ -113,6 +139,7 @@ resolve uid/gid into symbolic names. | |||
367 | 113 | 139 | ||
368 | 114 | No attempt is made to try to mkdir() the parent directories needed for | 140 | No attempt is made to try to mkdir() the parent directories needed for |
369 | 115 | a given home directory or archive path. | 141 | a given home directory or archive path. |
370 | 142 | |||
371 | 116 | .SH FILES | 143 | .SH FILES |
372 | 117 | .TP | 144 | .TP |
373 | 118 | ETCDIR/slapd.conf | 145 | ETCDIR/slapd.conf |
374 | diff --git a/doc/man/man8/slapd.8 b/doc/man/man8/slapd.8 | |||
375 | index a93fcbc..809f9e7 100644 | |||
376 | --- a/doc/man/man8/slapd.8 | |||
377 | +++ b/doc/man/man8/slapd.8 | |||
378 | @@ -12,7 +12,7 @@ slapd \- Stand-alone LDAP Daemon | |||
379 | 12 | .BR \-4 | \-6 ] | 12 | .BR \-4 | \-6 ] |
380 | 13 | [\c | 13 | [\c |
381 | 14 | .BR \-T \ { acl \||\| a [ dd ]\||\| auth \||\| c [ at ]\||\| | 14 | .BR \-T \ { acl \||\| a [ dd ]\||\| auth \||\| c [ at ]\||\| |
383 | 15 | .BR d [ n ]\||\| i [ ndex ]\||\| p [ asswd ]\||\| s [ chema ]\||\| t [ est ]}] | 15 | .BR d [ n ]\||\| i [ ndex ]\||\| m [ odify ]\||\| p [ asswd ]\||\| s [ chema ]\||\| t [ est ]}] |
384 | 16 | [\c | 16 | [\c |
385 | 17 | .BI \-d \ debug-level\fR] | 17 | .BI \-d \ debug-level\fR] |
386 | 18 | [\c | 18 | [\c |
387 | @@ -87,6 +87,7 @@ Run in Tool mode. The \fItool\fP argument selects whether to run as | |||
388 | 87 | .IR slapcat , | 87 | .IR slapcat , |
389 | 88 | .IR slapdn , | 88 | .IR slapdn , |
390 | 89 | .IR slapindex , | 89 | .IR slapindex , |
391 | 90 | .IR slapmodify , | ||
392 | 90 | .IR slappasswd , | 91 | .IR slappasswd , |
393 | 91 | .IR slapschema , | 92 | .IR slapschema , |
394 | 92 | or | 93 | or |
395 | @@ -366,6 +367,7 @@ To test whether the configuration file is correct or not, type: | |||
396 | 366 | .BR slapcat (8), | 367 | .BR slapcat (8), |
397 | 367 | .BR slapdn (8), | 368 | .BR slapdn (8), |
398 | 368 | .BR slapindex (8), | 369 | .BR slapindex (8), |
399 | 370 | .BR slapmodify (8), | ||
400 | 369 | .BR slappasswd (8), | 371 | .BR slappasswd (8), |
401 | 370 | .BR slapschema (8), | 372 | .BR slapschema (8), |
402 | 371 | .BR slaptest (8). | 373 | .BR slaptest (8). |
403 | diff --git a/include/ac/string.h b/include/ac/string.h | |||
404 | index c4c1354..20a68d7 100644 | |||
405 | --- a/include/ac/string.h | |||
406 | +++ b/include/ac/string.h | |||
407 | @@ -58,7 +58,7 @@ LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str, | |||
408 | 58 | #elif !defined(_WIN32) | 58 | #elif !defined(_WIN32) |
409 | 59 | /* some systems fail to declare strdup */ | 59 | /* some systems fail to declare strdup */ |
410 | 60 | /* Windows does not require this declaration */ | 60 | /* Windows does not require this declaration */ |
412 | 61 | LDAP_LIBC_F(char *) (strdup)(); | 61 | LDAP_LIBC_F(char *) (strdup) LDAP_P((const char *s)); |
413 | 62 | #endif | 62 | #endif |
414 | 63 | 63 | ||
415 | 64 | /* | 64 | /* |
416 | @@ -68,8 +68,8 @@ LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str, | |||
417 | 68 | 68 | ||
418 | 69 | /* we don't want these declared for Windows or Mingw */ | 69 | /* we don't want these declared for Windows or Mingw */ |
419 | 70 | #ifndef _WIN32 | 70 | #ifndef _WIN32 |
422 | 71 | int (strcasecmp)(); | 71 | LDAP_LIBC_F(int) (strcasecmp) LDAP_P((const char *s1, const char *s2)); |
423 | 72 | int (strncasecmp)(); | 72 | LDAP_LIBC_F(int) (strncasecmp) LDAP_P((const char *s1, const char *s2, size_t n)); |
424 | 73 | #endif | 73 | #endif |
425 | 74 | 74 | ||
426 | 75 | #ifndef SAFEMEMCPY | 75 | #ifndef SAFEMEMCPY |
427 | diff --git a/libraries/liblber/debug.c b/libraries/liblber/debug.c | |||
428 | index 1744e58..1f4fdbb 100644 | |||
429 | --- a/libraries/liblber/debug.c | |||
430 | +++ b/libraries/liblber/debug.c | |||
431 | @@ -43,12 +43,15 @@ void (lutil_debug)( int debug, int level, const char *fmt, ... ) | |||
432 | 43 | { | 43 | { |
433 | 44 | char buffer[4096]; | 44 | char buffer[4096]; |
434 | 45 | va_list vl; | 45 | va_list vl; |
435 | 46 | int len; | ||
436 | 46 | 47 | ||
437 | 47 | if ( !(level & debug ) ) return; | 48 | if ( !(level & debug ) ) return; |
438 | 48 | 49 | ||
439 | 49 | va_start( vl, fmt ); | 50 | va_start( vl, fmt ); |
441 | 50 | vsnprintf( buffer, sizeof(buffer), fmt, vl ); | 51 | len = vsnprintf( buffer, sizeof(buffer), fmt, vl ); |
442 | 51 | va_end( vl ); | 52 | va_end( vl ); |
443 | 53 | if ( len >= sizeof(buffer)-2 ) | ||
444 | 54 | buffer[sizeof(buffer)-2] = '\n'; | ||
445 | 52 | ber_pvt_log_print( buffer ); | 55 | ber_pvt_log_print( buffer ); |
446 | 53 | } | 56 | } |
447 | 54 | 57 | ||
448 | diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c | |||
449 | index 6170596..7d8b52f 100644 | |||
450 | --- a/libraries/libldap/getdn.c | |||
451 | +++ b/libraries/libldap/getdn.c | |||
452 | @@ -2562,6 +2562,8 @@ rdn2strlen( LDAPRDN rdn, unsigned flags, ber_len_t *len, | |||
453 | 2562 | l += vl; | 2562 | l += vl; |
454 | 2563 | } | 2563 | } |
455 | 2564 | } | 2564 | } |
456 | 2565 | if ( !iAVA ) | ||
457 | 2566 | return( -1 ); /* RDN ::= SET SIZE (1..MAX) OF AVA */ | ||
458 | 2565 | 2567 | ||
459 | 2566 | *len = l; | 2568 | *len = l; |
460 | 2567 | 2569 | ||
461 | @@ -2635,6 +2637,8 @@ rdn2DCEstrlen( LDAPRDN rdn, unsigned flags, ber_len_t *len ) | |||
462 | 2635 | l += vl; | 2637 | l += vl; |
463 | 2636 | } | 2638 | } |
464 | 2637 | } | 2639 | } |
465 | 2640 | if ( !iAVA ) | ||
466 | 2641 | return( -1 ); /* RDN ::= SET SIZE (1..MAX) OF AVA */ | ||
467 | 2638 | 2642 | ||
468 | 2639 | *len = l; | 2643 | *len = l; |
469 | 2640 | 2644 | ||
470 | @@ -2716,6 +2720,8 @@ rdn2UFNstrlen( LDAPRDN rdn, unsigned flags, ber_len_t *len ) | |||
471 | 2716 | l += vl; | 2720 | l += vl; |
472 | 2717 | } | 2721 | } |
473 | 2718 | } | 2722 | } |
474 | 2723 | if ( !iAVA ) | ||
475 | 2724 | return( -1 ); /* RDN ::= SET SIZE (1..MAX) OF AVA */ | ||
476 | 2719 | 2725 | ||
477 | 2720 | *len = l; | 2726 | *len = l; |
478 | 2721 | 2727 | ||
479 | @@ -2794,6 +2800,8 @@ rdn2ADstrlen( LDAPRDN rdn, unsigned flags, ber_len_t *len ) | |||
480 | 2794 | l += vl; | 2800 | l += vl; |
481 | 2795 | } | 2801 | } |
482 | 2796 | } | 2802 | } |
483 | 2803 | if ( !iAVA ) | ||
484 | 2804 | return( -1 ); /* RDN ::= SET SIZE (1..MAX) OF AVA */ | ||
485 | 2797 | 2805 | ||
486 | 2798 | *len = l; | 2806 | *len = l; |
487 | 2799 | 2807 | ||
488 | diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c | |||
489 | index 3a81790..b991553 100644 | |||
490 | --- a/libraries/libldap/init.c | |||
491 | +++ b/libraries/libldap/init.c | |||
492 | @@ -544,9 +544,6 @@ ldap_int_destroy_global_options(void) | |||
493 | 544 | gopts->ldo_def_sasl_authcid = NULL; | 544 | gopts->ldo_def_sasl_authcid = NULL; |
494 | 545 | } | 545 | } |
495 | 546 | #endif | 546 | #endif |
496 | 547 | #ifdef HAVE_TLS | ||
497 | 548 | ldap_int_tls_destroy( gopts ); | ||
498 | 549 | #endif | ||
499 | 550 | } | 547 | } |
500 | 551 | 548 | ||
501 | 552 | /* | 549 | /* |
502 | diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c | |||
503 | index bfdbb25..93720eb 100644 | |||
504 | --- a/libraries/libldap/open.c | |||
505 | +++ b/libraries/libldap/open.c | |||
506 | @@ -543,6 +543,7 @@ ldap_int_open_connection( | |||
507 | 543 | LDAP_MUTEX_UNLOCK( &lo->ldo_mutex ); | 543 | LDAP_MUTEX_UNLOCK( &lo->ldo_mutex ); |
508 | 544 | } | 544 | } |
509 | 545 | ber_int_sb_close( conn->lconn_sb ); | 545 | ber_int_sb_close( conn->lconn_sb ); |
510 | 546 | ber_int_sb_destroy( conn->lconn_sb ); | ||
511 | 546 | return -1; | 547 | return -1; |
512 | 547 | } | 548 | } |
513 | 548 | } | 549 | } |
514 | diff --git a/libraries/libldap/tls2.c b/libraries/libldap/tls2.c | |||
515 | index 4a5d42b..f9dcbfc 100644 | |||
516 | --- a/libraries/libldap/tls2.c | |||
517 | +++ b/libraries/libldap/tls2.c | |||
518 | @@ -160,6 +160,14 @@ ldap_pvt_tls_destroy( void ) | |||
519 | 160 | tls_imp->ti_tls_destroy(); | 160 | tls_imp->ti_tls_destroy(); |
520 | 161 | } | 161 | } |
521 | 162 | 162 | ||
522 | 163 | static void | ||
523 | 164 | ldap_exit_tls_destroy( void ) | ||
524 | 165 | { | ||
525 | 166 | struct ldapoptions *lo = LDAP_INT_GLOBAL_OPT(); | ||
526 | 167 | |||
527 | 168 | ldap_int_tls_destroy( lo ); | ||
528 | 169 | } | ||
529 | 170 | |||
530 | 163 | /* | 171 | /* |
531 | 164 | * Initialize a particular TLS implementation. | 172 | * Initialize a particular TLS implementation. |
532 | 165 | * Called once per implementation. | 173 | * Called once per implementation. |
533 | @@ -168,6 +176,7 @@ static int | |||
534 | 168 | tls_init(tls_impl *impl, int do_threads ) | 176 | tls_init(tls_impl *impl, int do_threads ) |
535 | 169 | { | 177 | { |
536 | 170 | static int tls_initialized = 0; | 178 | static int tls_initialized = 0; |
537 | 179 | int rc; | ||
538 | 171 | 180 | ||
539 | 172 | if ( !tls_initialized++ ) { | 181 | if ( !tls_initialized++ ) { |
540 | 173 | #ifdef LDAP_R_COMPILE | 182 | #ifdef LDAP_R_COMPILE |
541 | @@ -183,7 +192,10 @@ tls_init(tls_impl *impl, int do_threads ) | |||
542 | 183 | #endif | 192 | #endif |
543 | 184 | } | 193 | } |
544 | 185 | 194 | ||
546 | 186 | return impl->ti_tls_init(); | 195 | rc = impl->ti_tls_init(); |
547 | 196 | |||
548 | 197 | atexit( ldap_exit_tls_destroy ); | ||
549 | 198 | return rc; | ||
550 | 187 | } | 199 | } |
551 | 188 | 200 | ||
552 | 189 | /* | 201 | /* |
553 | diff --git a/libraries/libldap/tls_o.c b/libraries/libldap/tls_o.c | |||
554 | index d6405bc..055d140 100644 | |||
555 | --- a/libraries/libldap/tls_o.c | |||
556 | +++ b/libraries/libldap/tls_o.c | |||
557 | @@ -294,7 +294,7 @@ tlso_stecpy( char *dst, const char *src, const char *end ) | |||
558 | 294 | * Try to find any TLS1.3 ciphers in the given list of suites. | 294 | * Try to find any TLS1.3 ciphers in the given list of suites. |
559 | 295 | */ | 295 | */ |
560 | 296 | static void | 296 | static void |
562 | 297 | tlso_ctx_cipher13( tlso_ctx *ctx, char *suites ) | 297 | tlso_ctx_cipher13( tlso_ctx *ctx, char *suites, char **oldsuites ) |
563 | 298 | { | 298 | { |
564 | 299 | char tls13_suites[1024], *ts = tls13_suites, *te = tls13_suites + sizeof(tls13_suites); | 299 | char tls13_suites[1024], *ts = tls13_suites, *te = tls13_suites + sizeof(tls13_suites); |
565 | 300 | char *ptr, *colon, *nptr; | 300 | char *ptr, *colon, *nptr; |
566 | @@ -303,6 +303,8 @@ tlso_ctx_cipher13( tlso_ctx *ctx, char *suites ) | |||
567 | 303 | SSL *s = SSL_new( ctx ); | 303 | SSL *s = SSL_new( ctx ); |
568 | 304 | int ret; | 304 | int ret; |
569 | 305 | 305 | ||
570 | 306 | *oldsuites = NULL; | ||
571 | 307 | |||
572 | 306 | if ( !s ) | 308 | if ( !s ) |
573 | 307 | return; | 309 | return; |
574 | 308 | 310 | ||
575 | @@ -334,8 +336,15 @@ tlso_ctx_cipher13( tlso_ctx *ctx, char *suites ) | |||
576 | 334 | if ( tls13_suites[0] ) | 336 | if ( tls13_suites[0] ) |
577 | 335 | ts = tlso_stecpy( ts, ":", te ); | 337 | ts = tlso_stecpy( ts, ":", te ); |
578 | 336 | ts = tlso_stecpy( ts, nptr, te ); | 338 | ts = tlso_stecpy( ts, nptr, te ); |
579 | 339 | } else if (! *oldsuites) { | ||
580 | 340 | /* should never happen, set_ciphersuites should | ||
581 | 341 | * only succeed for TLSv1.3 and above | ||
582 | 342 | */ | ||
583 | 343 | *oldsuites = ptr; | ||
584 | 337 | } | 344 | } |
585 | 338 | } | 345 | } |
586 | 346 | } else if (! *oldsuites) { | ||
587 | 347 | *oldsuites = ptr; | ||
588 | 339 | } | 348 | } |
589 | 340 | if ( !colon || ts >= te ) | 349 | if ( !colon || ts >= te ) |
590 | 341 | break; | 350 | break; |
591 | @@ -415,10 +424,11 @@ tlso_ctx_init( struct ldapoptions *lo, struct ldaptls *lt, int is_server ) | |||
592 | 415 | } | 424 | } |
593 | 416 | 425 | ||
594 | 417 | if ( lo->ldo_tls_ciphersuite ) { | 426 | if ( lo->ldo_tls_ciphersuite ) { |
595 | 427 | char *oldsuites = lt->lt_ciphersuite; | ||
596 | 418 | #if OPENSSL_VERSION_NUMBER >= 0x10101000 | 428 | #if OPENSSL_VERSION_NUMBER >= 0x10101000 |
598 | 419 | tlso_ctx_cipher13( ctx, lt->lt_ciphersuite ); | 429 | tlso_ctx_cipher13( ctx, lt->lt_ciphersuite, &oldsuites ); |
599 | 420 | #endif | 430 | #endif |
601 | 421 | if ( !SSL_CTX_set_cipher_list( ctx, lt->lt_ciphersuite ) ) | 431 | if ( oldsuites && !SSL_CTX_set_cipher_list( ctx, oldsuites ) ) |
602 | 422 | { | 432 | { |
603 | 423 | Debug1( LDAP_DEBUG_ANY, | 433 | Debug1( LDAP_DEBUG_ANY, |
604 | 424 | "TLS: could not set cipher list %s.\n", | 434 | "TLS: could not set cipher list %s.\n", |
605 | @@ -529,7 +539,7 @@ tlso_ctx_init( struct ldapoptions *lo, struct ldaptls *lt, int is_server ) | |||
606 | 529 | if ( is_server && lo->ldo_tls_dhfile ) { | 539 | if ( is_server && lo->ldo_tls_dhfile ) { |
607 | 530 | #if OPENSSL_VERSION_MAJOR >= 3 | 540 | #if OPENSSL_VERSION_MAJOR >= 3 |
608 | 531 | EVP_PKEY *dh; | 541 | EVP_PKEY *dh; |
610 | 532 | #define bio_params( bio, dh ) dh = PEM_read_bio_Parameters( bio, &dh ) | 542 | #define bio_params( bio, dh ) dh = PEM_read_bio_Parameters( bio, NULL ) |
611 | 533 | #else | 543 | #else |
612 | 534 | DH *dh; | 544 | DH *dh; |
613 | 535 | #define bio_params( bio, dh ) dh = PEM_read_bio_DHparams( bio, NULL, NULL, NULL ) | 545 | #define bio_params( bio, dh ) dh = PEM_read_bio_DHparams( bio, NULL, NULL, NULL ) |
614 | diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c | |||
615 | index 493fd7c..a56af30 100644 | |||
616 | --- a/libraries/libldap/url.c | |||
617 | +++ b/libraries/libldap/url.c | |||
618 | @@ -867,6 +867,10 @@ ldap_url_parse_ext( LDAP_CONST char *url_in, LDAPURLDesc **ludpp, unsigned flags | |||
619 | 867 | } | 867 | } |
620 | 868 | 868 | ||
621 | 869 | if ( enclosed ) { | 869 | if ( enclosed ) { |
622 | 870 | if ( ! *url ) { | ||
623 | 871 | LDAP_FREE( url ); | ||
624 | 872 | return LDAP_URL_ERR_BADENCLOSURE; | ||
625 | 873 | } | ||
626 | 870 | p = &url[strlen(url)-1]; | 874 | p = &url[strlen(url)-1]; |
627 | 871 | 875 | ||
628 | 872 | if( *p != '>' ) { | 876 | if( *p != '>' ) { |
629 | diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c | |||
630 | index 57c6523..7cab9ea 100644 | |||
631 | --- a/libraries/libldap/util-int.c | |||
632 | +++ b/libraries/libldap/util-int.c | |||
633 | @@ -182,116 +182,65 @@ static int _ldap_pvt_gt_subs; | |||
634 | 182 | * This is pretty clunky. | 182 | * This is pretty clunky. |
635 | 183 | */ | 183 | */ |
636 | 184 | static LARGE_INTEGER _ldap_pvt_gt_freq; | 184 | static LARGE_INTEGER _ldap_pvt_gt_freq; |
639 | 185 | static LARGE_INTEGER _ldap_pvt_gt_prev; | 185 | static LARGE_INTEGER _ldap_pvt_gt_start_count; |
640 | 186 | static int _ldap_pvt_gt_offset; | 186 | static long _ldap_pvt_gt_start_sec; |
641 | 187 | static long _ldap_pvt_gt_start_nsec; | ||
642 | 188 | static double _ldap_pvt_gt_nanoticks; | ||
643 | 187 | 189 | ||
644 | 188 | #define SEC_TO_UNIX_EPOCH 11644473600LL | 190 | #define SEC_TO_UNIX_EPOCH 11644473600LL |
645 | 189 | #define TICKS_PER_SECOND 10000000 | 191 | #define TICKS_PER_SECOND 10000000 |
646 | 190 | #define BILLION 1000000000L | 192 | #define BILLION 1000000000L |
647 | 191 | 193 | ||
648 | 192 | static int | 194 | static int |
650 | 193 | ldap_pvt_gettimensec(int *sec) | 195 | ldap_pvt_gettimensec(long *sec) |
651 | 194 | { | 196 | { |
652 | 195 | LARGE_INTEGER count; | 197 | LARGE_INTEGER count; |
653 | 198 | LARGE_INTEGER freq; | ||
654 | 199 | int nsec; | ||
655 | 196 | 200 | ||
662 | 197 | QueryPerformanceCounter( &count ); | 201 | QueryPerformanceFrequency( &freq ); |
657 | 198 | |||
658 | 199 | /* It shouldn't ever go backwards, but multiple CPUs might | ||
659 | 200 | * be able to hit in the same tick. | ||
660 | 201 | */ | ||
661 | 202 | LDAP_MUTEX_LOCK( &ldap_int_gettime_mutex ); | ||
663 | 203 | /* We assume Windows has at least a vague idea of | 202 | /* We assume Windows has at least a vague idea of |
664 | 204 | * when a second begins. So we align our nanosecond count | 203 | * when a second begins. So we align our nanosecond count |
672 | 205 | * with the Windows millisecond count using this offset. | 204 | * with the Windows millisecond count. |
666 | 206 | * We retain the submillisecond portion of our own count. | ||
667 | 207 | * | ||
668 | 208 | * Note - this also assumes that the relationship between | ||
669 | 209 | * the PerformanceCounter and SystemTime stays constant; | ||
670 | 210 | * that assumption breaks if the SystemTime is adjusted by | ||
671 | 211 | * an external action. | ||
673 | 212 | */ | 205 | */ |
676 | 213 | if ( !_ldap_pvt_gt_freq.QuadPart ) { | 206 | if ( freq.QuadPart != _ldap_pvt_gt_freq.QuadPart ) { |
675 | 214 | LARGE_INTEGER c2; | ||
677 | 215 | ULARGE_INTEGER ut; | 207 | ULARGE_INTEGER ut; |
678 | 216 | FILETIME ft0, ft1; | 208 | FILETIME ft0, ft1; |
685 | 217 | long long t; | 209 | /* initialize */ |
686 | 218 | int nsec; | 210 | LDAP_MUTEX_LOCK( &ldap_int_gettime_mutex ); |
681 | 219 | |||
682 | 220 | /* Initialize our offset */ | ||
683 | 221 | QueryPerformanceFrequency( &_ldap_pvt_gt_freq ); | ||
684 | 222 | |||
687 | 223 | /* Wait for a tick of the system time: 10-15ms */ | 211 | /* Wait for a tick of the system time: 10-15ms */ |
688 | 224 | GetSystemTimeAsFileTime( &ft0 ); | 212 | GetSystemTimeAsFileTime( &ft0 ); |
689 | 225 | do { | 213 | do { |
690 | 226 | GetSystemTimeAsFileTime( &ft1 ); | 214 | GetSystemTimeAsFileTime( &ft1 ); |
691 | 227 | } while ( ft1.dwLowDateTime == ft0.dwLowDateTime ); | 215 | } while ( ft1.dwLowDateTime == ft0.dwLowDateTime ); |
692 | 216 | QueryPerformanceCounter( &_ldap_pvt_gt_start_count ); | ||
693 | 228 | 217 | ||
694 | 229 | ut.LowPart = ft1.dwLowDateTime; | 218 | ut.LowPart = ft1.dwLowDateTime; |
695 | 230 | ut.HighPart = ft1.dwHighDateTime; | 219 | ut.HighPart = ft1.dwHighDateTime; |
709 | 231 | QueryPerformanceCounter( &c2 ); | 220 | _ldap_pvt_gt_start_nsec = ut.QuadPart % TICKS_PER_SECOND * 100; |
710 | 232 | 221 | _ldap_pvt_gt_start_sec = ut.QuadPart / TICKS_PER_SECOND - SEC_TO_UNIX_EPOCH; | |
711 | 233 | /* get second and fraction portion of counter */ | 222 | _ldap_pvt_gt_freq = freq; |
712 | 234 | t = c2.QuadPart % (_ldap_pvt_gt_freq.QuadPart*10); | 223 | _ldap_pvt_gt_nanoticks = (double)BILLION / freq.QuadPart; |
713 | 235 | 224 | LDAP_MUTEX_UNLOCK( &ldap_int_gettime_mutex ); | |
701 | 236 | /* convert to nanoseconds */ | ||
702 | 237 | t *= BILLION; | ||
703 | 238 | nsec = t / _ldap_pvt_gt_freq.QuadPart; | ||
704 | 239 | |||
705 | 240 | ut.QuadPart /= 10; | ||
706 | 241 | ut.QuadPart %= (10 * BILLION); | ||
707 | 242 | _ldap_pvt_gt_offset = nsec - ut.QuadPart; | ||
708 | 243 | count = c2; | ||
714 | 244 | } | 225 | } |
720 | 245 | if ( count.QuadPart <= _ldap_pvt_gt_prev.QuadPart ) { | 226 | QueryPerformanceCounter( &count ); |
721 | 246 | _ldap_pvt_gt_subs++; | 227 | count.QuadPart -= _ldap_pvt_gt_start_count.QuadPart; |
722 | 247 | } else { | 228 | *sec = _ldap_pvt_gt_start_sec + count.QuadPart / freq.QuadPart; |
723 | 248 | _ldap_pvt_gt_subs = 0; | 229 | nsec = _ldap_pvt_gt_start_nsec + (double)(count.QuadPart % freq.QuadPart) * _ldap_pvt_gt_nanoticks; |
724 | 249 | _ldap_pvt_gt_prev = count; | 230 | if ( nsec > BILLION) { |
725 | 231 | nsec -= BILLION; | ||
726 | 232 | (*sec)++; | ||
727 | 250 | } | 233 | } |
746 | 251 | LDAP_MUTEX_UNLOCK( &ldap_int_gettime_mutex ); | 234 | return nsec; |
729 | 252 | |||
730 | 253 | /* convert to nanoseconds */ | ||
731 | 254 | count.QuadPart %= _ldap_pvt_gt_freq.QuadPart*10; | ||
732 | 255 | count.QuadPart *= BILLION; | ||
733 | 256 | count.QuadPart /= _ldap_pvt_gt_freq.QuadPart; | ||
734 | 257 | count.QuadPart -= _ldap_pvt_gt_offset; | ||
735 | 258 | |||
736 | 259 | /* We've extracted the 1s and nanoseconds. | ||
737 | 260 | * The 1sec digit is used to detect wraparound in nanosecnds. | ||
738 | 261 | */ | ||
739 | 262 | if (count.QuadPart < 0) | ||
740 | 263 | count.QuadPart += (10 * BILLION); | ||
741 | 264 | else if (count.QuadPart >= (10 * BILLION)) | ||
742 | 265 | count.QuadPart -= (10 * BILLION); | ||
743 | 266 | |||
744 | 267 | *sec = count.QuadPart / BILLION; | ||
745 | 268 | return count.QuadPart % BILLION; | ||
747 | 269 | } | 235 | } |
748 | 270 | 236 | ||
749 | 271 | |||
750 | 272 | /* emulate POSIX clock_gettime */ | 237 | /* emulate POSIX clock_gettime */ |
751 | 273 | int | 238 | int |
752 | 274 | ldap_pvt_clock_gettime( int clk_id, struct timespec *tv ) | 239 | ldap_pvt_clock_gettime( int clk_id, struct timespec *tv ) |
753 | 275 | { | 240 | { |
773 | 276 | FILETIME ft; | 241 | long sec; |
774 | 277 | ULARGE_INTEGER ut; | 242 | tv->tv_nsec = ldap_pvt_gettimensec( &sec ); |
775 | 278 | int sec, sec0; | 243 | tv->tv_sec = sec; |
757 | 279 | |||
758 | 280 | GetSystemTimeAsFileTime( &ft ); | ||
759 | 281 | ut.LowPart = ft.dwLowDateTime; | ||
760 | 282 | ut.HighPart = ft.dwHighDateTime; | ||
761 | 283 | |||
762 | 284 | /* convert to sec */ | ||
763 | 285 | ut.QuadPart /= TICKS_PER_SECOND; | ||
764 | 286 | |||
765 | 287 | tv->tv_nsec = ldap_pvt_gettimensec(&sec); | ||
766 | 288 | tv->tv_sec = ut.QuadPart - SEC_TO_UNIX_EPOCH; | ||
767 | 289 | |||
768 | 290 | /* check for carry from microseconds */ | ||
769 | 291 | sec0 = tv->tv_sec % 10; | ||
770 | 292 | if (sec0 < sec || (sec0 == 9 && !sec)) | ||
771 | 293 | tv->tv_sec++; | ||
772 | 294 | |||
776 | 295 | return 0; | 244 | return 0; |
777 | 296 | } | 245 | } |
778 | 297 | 246 | ||
779 | @@ -306,6 +255,8 @@ ldap_pvt_gettimeofday( struct timeval *tv, void *unused ) | |||
780 | 306 | return 0; | 255 | return 0; |
781 | 307 | } | 256 | } |
782 | 308 | 257 | ||
783 | 258 | static long _ldap_pvt_gt_prevsec; | ||
784 | 259 | static int _ldap_pvt_gt_prevnsec; | ||
785 | 309 | 260 | ||
786 | 310 | /* return a broken out time, with nanoseconds | 261 | /* return a broken out time, with nanoseconds |
787 | 311 | */ | 262 | */ |
788 | @@ -313,17 +264,18 @@ void | |||
789 | 313 | ldap_pvt_gettime( struct lutil_tm *tm ) | 264 | ldap_pvt_gettime( struct lutil_tm *tm ) |
790 | 314 | { | 265 | { |
791 | 315 | SYSTEMTIME st; | 266 | SYSTEMTIME st; |
795 | 316 | int sec, sec0; | 267 | LARGE_INTEGER ft; |
796 | 317 | static const char daysPerMonth[] = { | 268 | long sec; |
794 | 318 | 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | ||
797 | 319 | 269 | ||
799 | 320 | GetSystemTime( &st ); | 270 | /* Convert sec/nsec to Windows FILETIME, |
800 | 271 | * then turn that into broken out SYSTEMTIME */ | ||
801 | 321 | tm->tm_nsec = ldap_pvt_gettimensec(&sec); | 272 | tm->tm_nsec = ldap_pvt_gettimensec(&sec); |
803 | 322 | tm->tm_usub = _ldap_pvt_gt_subs; | 273 | ft.QuadPart = sec; |
804 | 274 | ft.QuadPart += SEC_TO_UNIX_EPOCH; | ||
805 | 275 | ft.QuadPart *= TICKS_PER_SECOND; | ||
806 | 276 | ft.QuadPart += tm->tm_nsec / 100; | ||
807 | 277 | FileTimeToSystemTime( (FILETIME *)&ft, &st ); | ||
808 | 323 | 278 | ||
809 | 324 | /* any difference larger than nanoseconds is | ||
810 | 325 | * already reflected in st | ||
811 | 326 | */ | ||
812 | 327 | tm->tm_sec = st.wSecond; | 279 | tm->tm_sec = st.wSecond; |
813 | 328 | tm->tm_min = st.wMinute; | 280 | tm->tm_min = st.wMinute; |
814 | 329 | tm->tm_hour = st.wHour; | 281 | tm->tm_hour = st.wHour; |
815 | @@ -331,42 +283,18 @@ ldap_pvt_gettime( struct lutil_tm *tm ) | |||
816 | 331 | tm->tm_mon = st.wMonth - 1; | 283 | tm->tm_mon = st.wMonth - 1; |
817 | 332 | tm->tm_year = st.wYear - 1900; | 284 | tm->tm_year = st.wYear - 1900; |
818 | 333 | 285 | ||
854 | 334 | /* check for carry from nanoseconds */ | 286 | LDAP_MUTEX_LOCK( &ldap_int_gettime_mutex ); |
855 | 335 | sec0 = tm->tm_sec % 10; | 287 | if ( tm->tm_sec < _ldap_pvt_gt_prevsec |
856 | 336 | if (sec0 < sec || (sec0 == 9 && !sec)) { | 288 | || ( tm->tm_sec == _ldap_pvt_gt_prevsec |
857 | 337 | tm->tm_sec++; | 289 | && tm->tm_nsec <= _ldap_pvt_gt_prevnsec )) { |
858 | 338 | /* FIXME: we don't handle leap seconds */ | 290 | _ldap_pvt_gt_subs++; |
859 | 339 | if (tm->tm_sec > 59) { | 291 | } else { |
860 | 340 | tm->tm_sec = 0; | 292 | _ldap_pvt_gt_subs = 0; |
861 | 341 | tm->tm_min++; | 293 | _ldap_pvt_gt_prevsec = sec; |
862 | 342 | if (tm->tm_min > 59) { | 294 | _ldap_pvt_gt_prevnsec = tm->tm_nsec; |
828 | 343 | tm->tm_min = 0; | ||
829 | 344 | tm->tm_hour++; | ||
830 | 345 | if (tm->tm_hour > 23) { | ||
831 | 346 | int days = daysPerMonth[tm->tm_mon]; | ||
832 | 347 | tm->tm_hour = 0; | ||
833 | 348 | tm->tm_mday++; | ||
834 | 349 | |||
835 | 350 | /* if it's February of a leap year, | ||
836 | 351 | * add 1 day to this month | ||
837 | 352 | */ | ||
838 | 353 | if (tm->tm_mon == 1 && | ||
839 | 354 | ((!(st.wYear % 4) && (st.wYear % 100)) || | ||
840 | 355 | !(st.wYear % 400))) | ||
841 | 356 | days++; | ||
842 | 357 | |||
843 | 358 | if (tm->tm_mday > days) { | ||
844 | 359 | tm->tm_mday = 1; | ||
845 | 360 | tm->tm_mon++; | ||
846 | 361 | if (tm->tm_mon > 11) { | ||
847 | 362 | tm->tm_mon = 0; | ||
848 | 363 | tm->tm_year++; | ||
849 | 364 | } | ||
850 | 365 | } | ||
851 | 366 | } | ||
852 | 367 | } | ||
853 | 368 | } | ||
863 | 369 | } | 295 | } |
864 | 296 | LDAP_MUTEX_UNLOCK( &ldap_int_gettime_mutex ); | ||
865 | 297 | tm->tm_usub = _ldap_pvt_gt_subs; | ||
866 | 370 | } | 298 | } |
867 | 371 | #else | 299 | #else |
868 | 372 | 300 | ||
869 | diff --git a/libraries/liblmdb/CHANGES b/libraries/liblmdb/CHANGES | |||
870 | index 76dd591..10e81d5 100644 | |||
871 | --- a/libraries/liblmdb/CHANGES | |||
872 | +++ b/libraries/liblmdb/CHANGES | |||
873 | @@ -1,5 +1,11 @@ | |||
874 | 1 | LMDB 0.9 Change Log | 1 | LMDB 0.9 Change Log |
875 | 2 | 2 | ||
876 | 3 | LMDB 0.9.32 Release (2024/01/29) | ||
877 | 4 | ITS#9378 - Add ability to replay log and replay log tool | ||
878 | 5 | ITS#10095 - partial revert of ITS#9278. The patch was incorrect and introduced numerous race conditions. | ||
879 | 6 | ITS#10125 - mdb_load: fix cursor reinit in Append mode | ||
880 | 7 | ITS#10137 - Allow users to define MDB_IDL_LOGN | ||
881 | 8 | |||
882 | 3 | LMDB 0.9.31 Release (2023/07/10) | 9 | LMDB 0.9.31 Release (2023/07/10) |
883 | 4 | ITS#8447 - Fix cursor_put(MDB_CURRENT) on DUPSORT DB with different sized data | 10 | ITS#8447 - Fix cursor_put(MDB_CURRENT) on DUPSORT DB with different sized data |
884 | 5 | 11 | ||
885 | diff --git a/libraries/liblmdb/Makefile b/libraries/liblmdb/Makefile | |||
886 | index f254511..000f1f9 100644 | |||
887 | --- a/libraries/liblmdb/Makefile | |||
888 | +++ b/libraries/liblmdb/Makefile | |||
889 | @@ -78,6 +78,7 @@ mtest3: mtest3.o liblmdb.a | |||
890 | 78 | mtest4: mtest4.o liblmdb.a | 78 | mtest4: mtest4.o liblmdb.a |
891 | 79 | mtest5: mtest5.o liblmdb.a | 79 | mtest5: mtest5.o liblmdb.a |
892 | 80 | mtest6: mtest6.o liblmdb.a | 80 | mtest6: mtest6.o liblmdb.a |
893 | 81 | mplay: mplay.o liblmdb.a | ||
894 | 81 | 82 | ||
895 | 82 | mdb.o: mdb.c lmdb.h midl.h | 83 | mdb.o: mdb.c lmdb.h midl.h |
896 | 83 | $(CC) $(CFLAGS) $(CPPFLAGS) -c mdb.c | 84 | $(CC) $(CFLAGS) $(CPPFLAGS) -c mdb.c |
897 | diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h | |||
898 | index ff03c22..d638a67 100644 | |||
899 | --- a/libraries/liblmdb/lmdb.h | |||
900 | +++ b/libraries/liblmdb/lmdb.h | |||
901 | @@ -200,7 +200,7 @@ typedef int mdb_filehandle_t; | |||
902 | 200 | /** Library minor version */ | 200 | /** Library minor version */ |
903 | 201 | #define MDB_VERSION_MINOR 9 | 201 | #define MDB_VERSION_MINOR 9 |
904 | 202 | /** Library patch version */ | 202 | /** Library patch version */ |
906 | 203 | #define MDB_VERSION_PATCH 31 | 203 | #define MDB_VERSION_PATCH 32 |
907 | 204 | 204 | ||
908 | 205 | /** Combine args a,b,c into a single integer for easy version comparisons */ | 205 | /** Combine args a,b,c into a single integer for easy version comparisons */ |
909 | 206 | #define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c)) | 206 | #define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c)) |
910 | @@ -210,7 +210,7 @@ typedef int mdb_filehandle_t; | |||
911 | 210 | MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH) | 210 | MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH) |
912 | 211 | 211 | ||
913 | 212 | /** The release date of this library version */ | 212 | /** The release date of this library version */ |
915 | 213 | #define MDB_VERSION_DATE "July 10, 2023" | 213 | #define MDB_VERSION_DATE "January 29, 2024" |
916 | 214 | 214 | ||
917 | 215 | /** A stringifier for the version info */ | 215 | /** A stringifier for the version info */ |
918 | 216 | #define MDB_VERSTR(a,b,c,d) "LMDB " #a "." #b "." #c ": (" d ")" | 216 | #define MDB_VERSTR(a,b,c,d) "LMDB " #a "." #b "." #c ": (" d ")" |
919 | diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c | |||
920 | index deb6779..0570dea 100644 | |||
921 | --- a/libraries/liblmdb/mdb.c | |||
922 | +++ b/libraries/liblmdb/mdb.c | |||
923 | @@ -481,18 +481,26 @@ typedef MDB_ID txnid_t; | |||
924 | 481 | #define MDB_DEBUG 0 | 481 | #define MDB_DEBUG 0 |
925 | 482 | #endif | 482 | #endif |
926 | 483 | 483 | ||
927 | 484 | #define MDB_DBG_INFO 1 | ||
928 | 485 | #define MDB_DBG_TRACE 2 | ||
929 | 486 | |||
930 | 484 | #if MDB_DEBUG | 487 | #if MDB_DEBUG |
932 | 485 | static int mdb_debug; | 488 | static int mdb_debug = MDB_DBG_TRACE; |
933 | 486 | static txnid_t mdb_debug_start; | 489 | static txnid_t mdb_debug_start; |
934 | 487 | 490 | ||
935 | 488 | /** Print a debug message with printf formatting. | 491 | /** Print a debug message with printf formatting. |
936 | 489 | * Requires double parenthesis around 2 or more args. | 492 | * Requires double parenthesis around 2 or more args. |
937 | 490 | */ | 493 | */ |
939 | 491 | # define DPRINTF(args) ((void) ((mdb_debug) && DPRINTF0 args)) | 494 | # define DPRINTF(args) ((void) ((mdb_debug & MDB_DBG_INFO) && DPRINTF0 args)) |
940 | 492 | # define DPRINTF0(fmt, ...) \ | 495 | # define DPRINTF0(fmt, ...) \ |
941 | 493 | fprintf(stderr, "%s:%d " fmt "\n", mdb_func_, __LINE__, __VA_ARGS__) | 496 | fprintf(stderr, "%s:%d " fmt "\n", mdb_func_, __LINE__, __VA_ARGS__) |
942 | 497 | /** Trace info for replaying */ | ||
943 | 498 | # define MDB_TRACE(args) ((void) ((mdb_debug & MDB_DBG_TRACE) && DPRINTF1 args)) | ||
944 | 499 | # define DPRINTF1(fmt, ...) \ | ||
945 | 500 | fprintf(stderr, ">%d:%s: " fmt "\n", getpid(), mdb_func_, __VA_ARGS__) | ||
946 | 494 | #else | 501 | #else |
947 | 495 | # define DPRINTF(args) ((void) 0) | 502 | # define DPRINTF(args) ((void) 0) |
948 | 503 | # define MDB_TRACE(args) ((void) 0) | ||
949 | 496 | #endif | 504 | #endif |
950 | 497 | /** Print a debug string. | 505 | /** Print a debug string. |
951 | 498 | * The string is printed literally, with no format processing. | 506 | * The string is printed literally, with no format processing. |
952 | @@ -589,6 +597,11 @@ static txnid_t mdb_debug_start; | |||
953 | 589 | * This is used for printing a hex dump of a key's contents. | 597 | * This is used for printing a hex dump of a key's contents. |
954 | 590 | */ | 598 | */ |
955 | 591 | #define DKBUF char kbuf[DKBUF_MAXKEYSIZE*2+1] | 599 | #define DKBUF char kbuf[DKBUF_MAXKEYSIZE*2+1] |
956 | 600 | /** A data value buffer. | ||
957 | 601 | * @ingroup debug | ||
958 | 602 | * This is used for printing a hex dump of a #MDB_DUPSORT value's contents. | ||
959 | 603 | */ | ||
960 | 604 | #define DDBUF char dbuf[DKBUF_MAXKEYSIZE*2+1+2] | ||
961 | 592 | /** Display a key in hex. | 605 | /** Display a key in hex. |
962 | 593 | * @ingroup debug | 606 | * @ingroup debug |
963 | 594 | * Invoke a function to display a key in hex. | 607 | * Invoke a function to display a key in hex. |
964 | @@ -596,6 +609,7 @@ static txnid_t mdb_debug_start; | |||
965 | 596 | #define DKEY(x) mdb_dkey(x, kbuf) | 609 | #define DKEY(x) mdb_dkey(x, kbuf) |
966 | 597 | #else | 610 | #else |
967 | 598 | #define DKBUF | 611 | #define DKBUF |
968 | 612 | #define DDBUF | ||
969 | 599 | #define DKEY(x) 0 | 613 | #define DKEY(x) 0 |
970 | 600 | #endif | 614 | #endif |
971 | 601 | 615 | ||
972 | @@ -1423,6 +1437,9 @@ static int mdb_update_key(MDB_cursor *mc, MDB_val *key); | |||
973 | 1423 | static void mdb_cursor_pop(MDB_cursor *mc); | 1437 | static void mdb_cursor_pop(MDB_cursor *mc); |
974 | 1424 | static int mdb_cursor_push(MDB_cursor *mc, MDB_page *mp); | 1438 | static int mdb_cursor_push(MDB_cursor *mc, MDB_page *mp); |
975 | 1425 | 1439 | ||
976 | 1440 | static int _mdb_cursor_del(MDB_cursor *mc, unsigned int flags); | ||
977 | 1441 | static int _mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data, unsigned int flags); | ||
978 | 1442 | |||
979 | 1426 | static int mdb_cursor_del0(MDB_cursor *mc); | 1443 | static int mdb_cursor_del0(MDB_cursor *mc); |
980 | 1427 | static int mdb_del0(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data, unsigned flags); | 1444 | static int mdb_del0(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data, unsigned flags); |
981 | 1428 | static int mdb_cursor_sibling(MDB_cursor *mc, int move_right); | 1445 | static int mdb_cursor_sibling(MDB_cursor *mc, int move_right); |
982 | @@ -1614,6 +1631,18 @@ mdb_dkey(MDB_val *key, char *buf) | |||
983 | 1614 | return buf; | 1631 | return buf; |
984 | 1615 | } | 1632 | } |
985 | 1616 | 1633 | ||
986 | 1634 | static char * | ||
987 | 1635 | mdb_dval(MDB_txn *txn, MDB_dbi dbi, MDB_val *data, char *buf) | ||
988 | 1636 | { | ||
989 | 1637 | if (txn->mt_dbs[dbi].md_flags & MDB_DUPSORT) { | ||
990 | 1638 | mdb_dkey(data, buf+1); | ||
991 | 1639 | *buf = '['; | ||
992 | 1640 | strcpy(buf + data->mv_size * 2 + 1, "]"); | ||
993 | 1641 | } else | ||
994 | 1642 | *buf = '\0'; | ||
995 | 1643 | return buf; | ||
996 | 1644 | } | ||
997 | 1645 | |||
998 | 1617 | static const char * | 1646 | static const char * |
999 | 1618 | mdb_leafnode_type(MDB_node *n) | 1647 | mdb_leafnode_type(MDB_node *n) |
1000 | 1619 | { | 1648 | { |
1001 | @@ -2786,7 +2815,7 @@ mdb_txn_renew0(MDB_txn *txn) | |||
1002 | 2786 | txn->mt_txnid++; | 2815 | txn->mt_txnid++; |
1003 | 2787 | #if MDB_DEBUG | 2816 | #if MDB_DEBUG |
1004 | 2788 | if (txn->mt_txnid == mdb_debug_start) | 2817 | if (txn->mt_txnid == mdb_debug_start) |
1006 | 2789 | mdb_debug = 1; | 2818 | mdb_debug = MDB_DBG_INFO; |
1007 | 2790 | #endif | 2819 | #endif |
1008 | 2791 | txn->mt_child = NULL; | 2820 | txn->mt_child = NULL; |
1009 | 2792 | txn->mt_loose_pgs = NULL; | 2821 | txn->mt_loose_pgs = NULL; |
1010 | @@ -2945,6 +2974,7 @@ renew: | |||
1011 | 2945 | txn->mt_txnid, (flags & MDB_RDONLY) ? 'r' : 'w', | 2974 | txn->mt_txnid, (flags & MDB_RDONLY) ? 'r' : 'w', |
1012 | 2946 | (void *) txn, (void *) env, txn->mt_dbs[MAIN_DBI].md_root)); | 2975 | (void *) txn, (void *) env, txn->mt_dbs[MAIN_DBI].md_root)); |
1013 | 2947 | } | 2976 | } |
1014 | 2977 | MDB_TRACE(("%p, %p, %u = %p", env, parent, flags, txn)); | ||
1015 | 2948 | 2978 | ||
1016 | 2949 | return rc; | 2979 | return rc; |
1017 | 2950 | } | 2980 | } |
1018 | @@ -3080,18 +3110,25 @@ mdb_txn_reset(MDB_txn *txn) | |||
1019 | 3080 | mdb_txn_end(txn, MDB_END_RESET); | 3110 | mdb_txn_end(txn, MDB_END_RESET); |
1020 | 3081 | } | 3111 | } |
1021 | 3082 | 3112 | ||
1024 | 3083 | void | 3113 | static void |
1025 | 3084 | mdb_txn_abort(MDB_txn *txn) | 3114 | _mdb_txn_abort(MDB_txn *txn) |
1026 | 3085 | { | 3115 | { |
1027 | 3086 | if (txn == NULL) | 3116 | if (txn == NULL) |
1028 | 3087 | return; | 3117 | return; |
1029 | 3088 | 3118 | ||
1030 | 3089 | if (txn->mt_child) | 3119 | if (txn->mt_child) |
1032 | 3090 | mdb_txn_abort(txn->mt_child); | 3120 | _mdb_txn_abort(txn->mt_child); |
1033 | 3091 | 3121 | ||
1034 | 3092 | mdb_txn_end(txn, MDB_END_ABORT|MDB_END_SLOT|MDB_END_FREE); | 3122 | mdb_txn_end(txn, MDB_END_ABORT|MDB_END_SLOT|MDB_END_FREE); |
1035 | 3093 | } | 3123 | } |
1036 | 3094 | 3124 | ||
1037 | 3125 | void | ||
1038 | 3126 | mdb_txn_abort(MDB_txn *txn) | ||
1039 | 3127 | { | ||
1040 | 3128 | MDB_TRACE(("%p", txn)); | ||
1041 | 3129 | _mdb_txn_abort(txn); | ||
1042 | 3130 | } | ||
1043 | 3131 | |||
1044 | 3095 | /** Save the freelist as of this transaction to the freeDB. | 3132 | /** Save the freelist as of this transaction to the freeDB. |
1045 | 3096 | * This changes the freelist. Keep trying until it stabilizes. | 3133 | * This changes the freelist. Keep trying until it stabilizes. |
1046 | 3097 | */ | 3134 | */ |
1047 | @@ -3182,7 +3219,7 @@ mdb_freelist_save(MDB_txn *txn) | |||
1048 | 3182 | pglast = head_id = *(txnid_t *)key.mv_data; | 3219 | pglast = head_id = *(txnid_t *)key.mv_data; |
1049 | 3183 | total_room = head_room = 0; | 3220 | total_room = head_room = 0; |
1050 | 3184 | mdb_tassert(txn, pglast <= env->me_pglast); | 3221 | mdb_tassert(txn, pglast <= env->me_pglast); |
1052 | 3185 | rc = mdb_cursor_del(&mc, 0); | 3222 | rc = _mdb_cursor_del(&mc, 0); |
1053 | 3186 | if (rc) | 3223 | if (rc) |
1054 | 3187 | return rc; | 3224 | return rc; |
1055 | 3188 | } | 3225 | } |
1056 | @@ -3202,7 +3239,7 @@ mdb_freelist_save(MDB_txn *txn) | |||
1057 | 3202 | do { | 3239 | do { |
1058 | 3203 | freecnt = free_pgs[0]; | 3240 | freecnt = free_pgs[0]; |
1059 | 3204 | data.mv_size = MDB_IDL_SIZEOF(free_pgs); | 3241 | data.mv_size = MDB_IDL_SIZEOF(free_pgs); |
1061 | 3205 | rc = mdb_cursor_put(&mc, &key, &data, MDB_RESERVE); | 3242 | rc = _mdb_cursor_put(&mc, &key, &data, MDB_RESERVE); |
1062 | 3206 | if (rc) | 3243 | if (rc) |
1063 | 3207 | return rc; | 3244 | return rc; |
1064 | 3208 | /* Retry if mt_free_pgs[] grew during the Put() */ | 3245 | /* Retry if mt_free_pgs[] grew during the Put() */ |
1065 | @@ -3251,7 +3288,7 @@ mdb_freelist_save(MDB_txn *txn) | |||
1066 | 3251 | key.mv_size = sizeof(head_id); | 3288 | key.mv_size = sizeof(head_id); |
1067 | 3252 | key.mv_data = &head_id; | 3289 | key.mv_data = &head_id; |
1068 | 3253 | data.mv_size = (head_room + 1) * sizeof(pgno_t); | 3290 | data.mv_size = (head_room + 1) * sizeof(pgno_t); |
1070 | 3254 | rc = mdb_cursor_put(&mc, &key, &data, MDB_RESERVE); | 3291 | rc = _mdb_cursor_put(&mc, &key, &data, MDB_RESERVE); |
1071 | 3255 | if (rc) | 3292 | if (rc) |
1072 | 3256 | return rc; | 3293 | return rc; |
1073 | 3257 | /* IDL is initially empty, zero out at least the length */ | 3294 | /* IDL is initially empty, zero out at least the length */ |
1074 | @@ -3306,7 +3343,7 @@ mdb_freelist_save(MDB_txn *txn) | |||
1075 | 3306 | data.mv_data = mop -= len; | 3343 | data.mv_data = mop -= len; |
1076 | 3307 | save = mop[0]; | 3344 | save = mop[0]; |
1077 | 3308 | mop[0] = len; | 3345 | mop[0] = len; |
1079 | 3309 | rc = mdb_cursor_put(&mc, &key, &data, MDB_CURRENT); | 3346 | rc = _mdb_cursor_put(&mc, &key, &data, MDB_CURRENT); |
1080 | 3310 | mop[0] = save; | 3347 | mop[0] = save; |
1081 | 3311 | if (rc || !(mop_len -= len)) | 3348 | if (rc || !(mop_len -= len)) |
1082 | 3312 | break; | 3349 | break; |
1083 | @@ -3467,8 +3504,8 @@ done: | |||
1084 | 3467 | return MDB_SUCCESS; | 3504 | return MDB_SUCCESS; |
1085 | 3468 | } | 3505 | } |
1086 | 3469 | 3506 | ||
1089 | 3470 | int | 3507 | static int |
1090 | 3471 | mdb_txn_commit(MDB_txn *txn) | 3508 | _mdb_txn_commit(MDB_txn *txn) |
1091 | 3472 | { | 3509 | { |
1092 | 3473 | int rc; | 3510 | int rc; |
1093 | 3474 | unsigned int i, end_mode; | 3511 | unsigned int i, end_mode; |
1094 | @@ -3481,7 +3518,7 @@ mdb_txn_commit(MDB_txn *txn) | |||
1095 | 3481 | end_mode = MDB_END_EMPTY_COMMIT|MDB_END_UPDATE|MDB_END_SLOT|MDB_END_FREE; | 3518 | end_mode = MDB_END_EMPTY_COMMIT|MDB_END_UPDATE|MDB_END_SLOT|MDB_END_FREE; |
1096 | 3482 | 3519 | ||
1097 | 3483 | if (txn->mt_child) { | 3520 | if (txn->mt_child) { |
1099 | 3484 | rc = mdb_txn_commit(txn->mt_child); | 3521 | rc = _mdb_txn_commit(txn->mt_child); |
1100 | 3485 | if (rc) | 3522 | if (rc) |
1101 | 3486 | goto fail; | 3523 | goto fail; |
1102 | 3487 | } | 3524 | } |
1103 | @@ -3661,7 +3698,7 @@ mdb_txn_commit(MDB_txn *txn) | |||
1104 | 3661 | goto fail; | 3698 | goto fail; |
1105 | 3662 | } | 3699 | } |
1106 | 3663 | data.mv_data = &txn->mt_dbs[i]; | 3700 | data.mv_data = &txn->mt_dbs[i]; |
1108 | 3664 | rc = mdb_cursor_put(&mc, &txn->mt_dbxs[i].md_name, &data, | 3701 | rc = _mdb_cursor_put(&mc, &txn->mt_dbxs[i].md_name, &data, |
1109 | 3665 | F_SUBDATA); | 3702 | F_SUBDATA); |
1110 | 3666 | if (rc) | 3703 | if (rc) |
1111 | 3667 | goto fail; | 3704 | goto fail; |
1112 | @@ -3692,10 +3729,17 @@ done: | |||
1113 | 3692 | return MDB_SUCCESS; | 3729 | return MDB_SUCCESS; |
1114 | 3693 | 3730 | ||
1115 | 3694 | fail: | 3731 | fail: |
1117 | 3695 | mdb_txn_abort(txn); | 3732 | _mdb_txn_abort(txn); |
1118 | 3696 | return rc; | 3733 | return rc; |
1119 | 3697 | } | 3734 | } |
1120 | 3698 | 3735 | ||
1121 | 3736 | int | ||
1122 | 3737 | mdb_txn_commit(MDB_txn *txn) | ||
1123 | 3738 | { | ||
1124 | 3739 | MDB_TRACE(("%p", txn)); | ||
1125 | 3740 | return _mdb_txn_commit(txn); | ||
1126 | 3741 | } | ||
1127 | 3742 | |||
1128 | 3699 | /** Read the environment parameters of a DB environment before | 3743 | /** Read the environment parameters of a DB environment before |
1129 | 3700 | * mapping it into memory. | 3744 | * mapping it into memory. |
1130 | 3701 | * @param[in] env the environment handle | 3745 | * @param[in] env the environment handle |
1131 | @@ -3992,6 +4036,7 @@ mdb_env_create(MDB_env **env) | |||
1132 | 3992 | GET_PAGESIZE(e->me_os_psize); | 4036 | GET_PAGESIZE(e->me_os_psize); |
1133 | 3993 | VGMEMP_CREATE(e,0,0); | 4037 | VGMEMP_CREATE(e,0,0); |
1134 | 3994 | *env = e; | 4038 | *env = e; |
1135 | 4039 | MDB_TRACE(("%p", e)); | ||
1136 | 3995 | return MDB_SUCCESS; | 4040 | return MDB_SUCCESS; |
1137 | 3996 | } | 4041 | } |
1138 | 3997 | 4042 | ||
1139 | @@ -4115,6 +4160,7 @@ mdb_env_set_mapsize(MDB_env *env, size_t size) | |||
1140 | 4115 | env->me_mapsize = size; | 4160 | env->me_mapsize = size; |
1141 | 4116 | if (env->me_psize) | 4161 | if (env->me_psize) |
1142 | 4117 | env->me_maxpg = env->me_mapsize / env->me_psize; | 4162 | env->me_maxpg = env->me_mapsize / env->me_psize; |
1143 | 4163 | MDB_TRACE(("%p, %"Yu"", env, size)); | ||
1144 | 4118 | return MDB_SUCCESS; | 4164 | return MDB_SUCCESS; |
1145 | 4119 | } | 4165 | } |
1146 | 4120 | 4166 | ||
1147 | @@ -4124,6 +4170,7 @@ mdb_env_set_maxdbs(MDB_env *env, MDB_dbi dbs) | |||
1148 | 4124 | if (env->me_map) | 4170 | if (env->me_map) |
1149 | 4125 | return EINVAL; | 4171 | return EINVAL; |
1150 | 4126 | env->me_maxdbs = dbs + CORE_DBS; | 4172 | env->me_maxdbs = dbs + CORE_DBS; |
1151 | 4173 | MDB_TRACE(("%p, %u", env, dbs)); | ||
1152 | 4127 | return MDB_SUCCESS; | 4174 | return MDB_SUCCESS; |
1153 | 4128 | } | 4175 | } |
1154 | 4129 | 4176 | ||
1155 | @@ -4133,6 +4180,7 @@ mdb_env_set_maxreaders(MDB_env *env, unsigned int readers) | |||
1156 | 4133 | if (env->me_map || readers < 1) | 4180 | if (env->me_map || readers < 1) |
1157 | 4134 | return EINVAL; | 4181 | return EINVAL; |
1158 | 4135 | env->me_maxreaders = readers; | 4182 | env->me_maxreaders = readers; |
1159 | 4183 | MDB_TRACE(("%p, %u", env, readers)); | ||
1160 | 4136 | return MDB_SUCCESS; | 4184 | return MDB_SUCCESS; |
1161 | 4137 | } | 4185 | } |
1162 | 4138 | 4186 | ||
1163 | @@ -5076,6 +5124,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode | |||
1164 | 5076 | } | 5124 | } |
1165 | 5077 | 5125 | ||
1166 | 5078 | leave: | 5126 | leave: |
1167 | 5127 | MDB_TRACE(("%p, %s, %u, %04o", env, path, flags & (CHANGEABLE|CHANGELESS), mode)); | ||
1168 | 5079 | if (rc) { | 5128 | if (rc) { |
1169 | 5080 | mdb_env_close0(env, excl); | 5129 | mdb_env_close0(env, excl); |
1170 | 5081 | } | 5130 | } |
1171 | @@ -5162,17 +5211,6 @@ mdb_env_close0(MDB_env *env, int excl) | |||
1172 | 5162 | sem_unlink(env->me_txns->mti_wmname); | 5211 | sem_unlink(env->me_txns->mti_wmname); |
1173 | 5163 | } | 5212 | } |
1174 | 5164 | } | 5213 | } |
1175 | 5165 | #elif defined(MDB_ROBUST_SUPPORTED) | ||
1176 | 5166 | /* If we have the filelock: If we are the | ||
1177 | 5167 | * only remaining user, clean up robust | ||
1178 | 5168 | * mutexes. | ||
1179 | 5169 | */ | ||
1180 | 5170 | if (excl == 0) | ||
1181 | 5171 | mdb_env_excl_lock(env, &excl); | ||
1182 | 5172 | if (excl > 0) { | ||
1183 | 5173 | pthread_mutex_destroy(env->me_txns->mti_rmutex); | ||
1184 | 5174 | pthread_mutex_destroy(env->me_txns->mti_wmutex); | ||
1185 | 5175 | } | ||
1186 | 5176 | #endif | 5214 | #endif |
1187 | 5177 | munmap((void *)env->me_txns, (env->me_maxreaders-1)*sizeof(MDB_reader)+sizeof(MDB_txninfo)); | 5215 | munmap((void *)env->me_txns, (env->me_maxreaders-1)*sizeof(MDB_reader)+sizeof(MDB_txninfo)); |
1188 | 5178 | } | 5216 | } |
1189 | @@ -5199,6 +5237,7 @@ mdb_env_close(MDB_env *env) | |||
1190 | 5199 | if (env == NULL) | 5237 | if (env == NULL) |
1191 | 5200 | return; | 5238 | return; |
1192 | 5201 | 5239 | ||
1193 | 5240 | MDB_TRACE(("%p", env)); | ||
1194 | 5202 | VGMEMP_DESTROY(env); | 5241 | VGMEMP_DESTROY(env); |
1195 | 5203 | while ((dp = env->me_dpages) != NULL) { | 5242 | while ((dp = env->me_dpages) != NULL) { |
1196 | 5204 | VGMEMP_DEFINED(&dp->mp_next, sizeof(dp->mp_next)); | 5243 | VGMEMP_DEFINED(&dp->mp_next, sizeof(dp->mp_next)); |
1197 | @@ -6570,8 +6609,8 @@ mdb_cursor_touch(MDB_cursor *mc) | |||
1198 | 6570 | /** Do not spill pages to disk if txn is getting full, may fail instead */ | 6609 | /** Do not spill pages to disk if txn is getting full, may fail instead */ |
1199 | 6571 | #define MDB_NOSPILL 0x8000 | 6610 | #define MDB_NOSPILL 0x8000 |
1200 | 6572 | 6611 | ||
1203 | 6573 | int | 6612 | static int |
1204 | 6574 | mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data, | 6613 | _mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data, |
1205 | 6575 | unsigned int flags) | 6614 | unsigned int flags) |
1206 | 6576 | { | 6615 | { |
1207 | 6577 | MDB_env *env; | 6616 | MDB_env *env; |
1208 | @@ -7034,7 +7073,7 @@ put_sub: | |||
1209 | 7034 | new_dupdata = (int)dkey.mv_size; | 7073 | new_dupdata = (int)dkey.mv_size; |
1210 | 7035 | /* converted, write the original data first */ | 7074 | /* converted, write the original data first */ |
1211 | 7036 | if (dkey.mv_size) { | 7075 | if (dkey.mv_size) { |
1213 | 7037 | rc = mdb_cursor_put(&mc->mc_xcursor->mx_cursor, &dkey, &xdata, xflags); | 7076 | rc = _mdb_cursor_put(&mc->mc_xcursor->mx_cursor, &dkey, &xdata, xflags); |
1214 | 7038 | if (rc) | 7077 | if (rc) |
1215 | 7039 | goto bad_sub; | 7078 | goto bad_sub; |
1216 | 7040 | /* we've done our job */ | 7079 | /* we've done our job */ |
1217 | @@ -7062,7 +7101,7 @@ put_sub: | |||
1218 | 7062 | ecount = mc->mc_xcursor->mx_db.md_entries; | 7101 | ecount = mc->mc_xcursor->mx_db.md_entries; |
1219 | 7063 | if (flags & MDB_APPENDDUP) | 7102 | if (flags & MDB_APPENDDUP) |
1220 | 7064 | xflags |= MDB_APPEND; | 7103 | xflags |= MDB_APPEND; |
1222 | 7065 | rc = mdb_cursor_put(&mc->mc_xcursor->mx_cursor, data, &xdata, xflags); | 7104 | rc = _mdb_cursor_put(&mc->mc_xcursor->mx_cursor, data, &xdata, xflags); |
1223 | 7066 | if (flags & F_SUBDATA) { | 7105 | if (flags & F_SUBDATA) { |
1224 | 7067 | void *db = NODEDATA(leaf); | 7106 | void *db = NODEDATA(leaf); |
1225 | 7068 | memcpy(db, &mc->mc_xcursor->mx_db, sizeof(MDB_db)); | 7107 | memcpy(db, &mc->mc_xcursor->mx_db, sizeof(MDB_db)); |
1226 | @@ -7103,7 +7142,20 @@ bad_sub: | |||
1227 | 7103 | } | 7142 | } |
1228 | 7104 | 7143 | ||
1229 | 7105 | int | 7144 | int |
1231 | 7106 | mdb_cursor_del(MDB_cursor *mc, unsigned int flags) | 7145 | mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data, |
1232 | 7146 | unsigned int flags) | ||
1233 | 7147 | { | ||
1234 | 7148 | DKBUF; | ||
1235 | 7149 | DDBUF; | ||
1236 | 7150 | int rc = _mdb_cursor_put(mc, key, data, flags); | ||
1237 | 7151 | MDB_TRACE(("%p, %"Z"u[%s], %"Z"u%s, %u", | ||
1238 | 7152 | mc, key ? key->mv_size:0, DKEY(key), data ? data->mv_size:0, | ||
1239 | 7153 | data ? mdb_dval(mc->mc_txn, mc->mc_dbi, data, dbuf):"", flags)); | ||
1240 | 7154 | return rc; | ||
1241 | 7155 | } | ||
1242 | 7156 | |||
1243 | 7157 | static int | ||
1244 | 7158 | _mdb_cursor_del(MDB_cursor *mc, unsigned int flags) | ||
1245 | 7107 | { | 7159 | { |
1246 | 7108 | MDB_node *leaf; | 7160 | MDB_node *leaf; |
1247 | 7109 | MDB_page *mp; | 7161 | MDB_page *mp; |
1248 | @@ -7141,7 +7193,7 @@ mdb_cursor_del(MDB_cursor *mc, unsigned int flags) | |||
1249 | 7141 | if (!F_ISSET(leaf->mn_flags, F_SUBDATA)) { | 7193 | if (!F_ISSET(leaf->mn_flags, F_SUBDATA)) { |
1250 | 7142 | mc->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(leaf); | 7194 | mc->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(leaf); |
1251 | 7143 | } | 7195 | } |
1253 | 7144 | rc = mdb_cursor_del(&mc->mc_xcursor->mx_cursor, MDB_NOSPILL); | 7196 | rc = _mdb_cursor_del(&mc->mc_xcursor->mx_cursor, MDB_NOSPILL); |
1254 | 7145 | if (rc) | 7197 | if (rc) |
1255 | 7146 | return rc; | 7198 | return rc; |
1256 | 7147 | /* If sub-DB still has entries, we're done */ | 7199 | /* If sub-DB still has entries, we're done */ |
1257 | @@ -7205,6 +7257,14 @@ fail: | |||
1258 | 7205 | return rc; | 7257 | return rc; |
1259 | 7206 | } | 7258 | } |
1260 | 7207 | 7259 | ||
1261 | 7260 | int | ||
1262 | 7261 | mdb_cursor_del(MDB_cursor *mc, unsigned int flags) | ||
1263 | 7262 | { | ||
1264 | 7263 | MDB_TRACE(("%p, %u", | ||
1265 | 7264 | mc, flags)); | ||
1266 | 7265 | return _mdb_cursor_del(mc, flags); | ||
1267 | 7266 | } | ||
1268 | 7267 | |||
1269 | 7208 | /** Allocate and initialize new pages for a database. | 7268 | /** Allocate and initialize new pages for a database. |
1270 | 7209 | * Set #MDB_TXN_ERROR on failure. | 7269 | * Set #MDB_TXN_ERROR on failure. |
1271 | 7210 | * @param[in] mc a cursor on the database being added to. | 7270 | * @param[in] mc a cursor on the database being added to. |
1272 | @@ -7698,6 +7758,7 @@ mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **ret) | |||
1273 | 7698 | return ENOMEM; | 7758 | return ENOMEM; |
1274 | 7699 | } | 7759 | } |
1275 | 7700 | 7760 | ||
1276 | 7761 | MDB_TRACE(("%p, %u = %p", txn, dbi, mc)); | ||
1277 | 7701 | *ret = mc; | 7762 | *ret = mc; |
1278 | 7702 | 7763 | ||
1279 | 7703 | return MDB_SUCCESS; | 7764 | return MDB_SUCCESS; |
1280 | @@ -7761,6 +7822,7 @@ mdb_cursor_count(MDB_cursor *mc, size_t *countp) | |||
1281 | 7761 | void | 7822 | void |
1282 | 7762 | mdb_cursor_close(MDB_cursor *mc) | 7823 | mdb_cursor_close(MDB_cursor *mc) |
1283 | 7763 | { | 7824 | { |
1284 | 7825 | MDB_TRACE(("%p", mc)); | ||
1285 | 7764 | if (mc && !mc->mc_backup) { | 7826 | if (mc && !mc->mc_backup) { |
1286 | 7765 | /* remove from txn, if tracked */ | 7827 | /* remove from txn, if tracked */ |
1287 | 7766 | if ((mc->mc_flags & C_UNTRACK) && mc->mc_txn->mt_cursors) { | 7828 | if ((mc->mc_flags & C_UNTRACK) && mc->mc_txn->mt_cursors) { |
1288 | @@ -8570,6 +8632,8 @@ int | |||
1289 | 8570 | mdb_del(MDB_txn *txn, MDB_dbi dbi, | 8632 | mdb_del(MDB_txn *txn, MDB_dbi dbi, |
1290 | 8571 | MDB_val *key, MDB_val *data) | 8633 | MDB_val *key, MDB_val *data) |
1291 | 8572 | { | 8634 | { |
1292 | 8635 | DKBUF; | ||
1293 | 8636 | DDBUF; | ||
1294 | 8573 | if (!key || !TXN_DBI_EXIST(txn, dbi, DB_USRVALID)) | 8637 | if (!key || !TXN_DBI_EXIST(txn, dbi, DB_USRVALID)) |
1295 | 8574 | return EINVAL; | 8638 | return EINVAL; |
1296 | 8575 | 8639 | ||
1297 | @@ -8581,6 +8645,9 @@ mdb_del(MDB_txn *txn, MDB_dbi dbi, | |||
1298 | 8581 | data = NULL; | 8645 | data = NULL; |
1299 | 8582 | } | 8646 | } |
1300 | 8583 | 8647 | ||
1301 | 8648 | MDB_TRACE(("%p, %u, %"Z"u[%s], %"Z"u%s", | ||
1302 | 8649 | txn, dbi, key ? key->mv_size:0, DKEY(key), data ? data->mv_size:0, | ||
1303 | 8650 | data ? mdb_dval(txn, dbi, data, dbuf):"")); | ||
1304 | 8584 | return mdb_del0(txn, dbi, key, data, 0); | 8651 | return mdb_del0(txn, dbi, key, data, 0); |
1305 | 8585 | } | 8652 | } |
1306 | 8586 | 8653 | ||
1307 | @@ -8621,7 +8688,7 @@ mdb_del0(MDB_txn *txn, MDB_dbi dbi, | |||
1308 | 8621 | mc.mc_flags |= C_UNTRACK; | 8688 | mc.mc_flags |= C_UNTRACK; |
1309 | 8622 | mc.mc_next = txn->mt_cursors[dbi]; | 8689 | mc.mc_next = txn->mt_cursors[dbi]; |
1310 | 8623 | txn->mt_cursors[dbi] = &mc; | 8690 | txn->mt_cursors[dbi] = &mc; |
1312 | 8624 | rc = mdb_cursor_del(&mc, flags); | 8691 | rc = _mdb_cursor_del(&mc, flags); |
1313 | 8625 | txn->mt_cursors[dbi] = mc.mc_next; | 8692 | txn->mt_cursors[dbi] = mc.mc_next; |
1314 | 8626 | } | 8693 | } |
1315 | 8627 | return rc; | 8694 | return rc; |
1316 | @@ -9063,6 +9130,8 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi, | |||
1317 | 9063 | MDB_cursor mc; | 9130 | MDB_cursor mc; |
1318 | 9064 | MDB_xcursor mx; | 9131 | MDB_xcursor mx; |
1319 | 9065 | int rc; | 9132 | int rc; |
1320 | 9133 | DKBUF; | ||
1321 | 9134 | DDBUF; | ||
1322 | 9066 | 9135 | ||
1323 | 9067 | if (!key || !data || !TXN_DBI_EXIST(txn, dbi, DB_USRVALID)) | 9136 | if (!key || !data || !TXN_DBI_EXIST(txn, dbi, DB_USRVALID)) |
1324 | 9068 | return EINVAL; | 9137 | return EINVAL; |
1325 | @@ -9073,10 +9142,12 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi, | |||
1326 | 9073 | if (txn->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_BLOCKED)) | 9142 | if (txn->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_BLOCKED)) |
1327 | 9074 | return (txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN; | 9143 | return (txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN; |
1328 | 9075 | 9144 | ||
1329 | 9145 | MDB_TRACE(("%p, %u, %"Z"u[%s], %"Z"u%s, %u", | ||
1330 | 9146 | txn, dbi, key ? key->mv_size:0, DKEY(key), data->mv_size, mdb_dval(txn, dbi, data, dbuf), flags)); | ||
1331 | 9076 | mdb_cursor_init(&mc, txn, dbi, &mx); | 9147 | mdb_cursor_init(&mc, txn, dbi, &mx); |
1332 | 9077 | mc.mc_next = txn->mt_cursors[dbi]; | 9148 | mc.mc_next = txn->mt_cursors[dbi]; |
1333 | 9078 | txn->mt_cursors[dbi] = &mc; | 9149 | txn->mt_cursors[dbi] = &mc; |
1335 | 9079 | rc = mdb_cursor_put(&mc, key, data, flags); | 9150 | rc = _mdb_cursor_put(&mc, key, data, flags); |
1336 | 9080 | txn->mt_cursors[dbi] = mc.mc_next; | 9151 | txn->mt_cursors[dbi] = mc.mc_next; |
1337 | 9081 | return rc; | 9152 | return rc; |
1338 | 9082 | } | 9153 | } |
1339 | @@ -9479,7 +9550,7 @@ finish: | |||
1340 | 9479 | my.mc_error = rc; | 9550 | my.mc_error = rc; |
1341 | 9480 | mdb_env_cthr_toggle(&my, 1 | MDB_EOF); | 9551 | mdb_env_cthr_toggle(&my, 1 | MDB_EOF); |
1342 | 9481 | rc = THREAD_FINISH(thr); | 9552 | rc = THREAD_FINISH(thr); |
1344 | 9482 | mdb_txn_abort(txn); | 9553 | _mdb_txn_abort(txn); |
1345 | 9483 | 9554 | ||
1346 | 9484 | done: | 9555 | done: |
1347 | 9485 | #ifdef _WIN32 | 9556 | #ifdef _WIN32 |
1348 | @@ -9591,7 +9662,7 @@ mdb_env_copyfd0(MDB_env *env, HANDLE fd) | |||
1349 | 9591 | } | 9662 | } |
1350 | 9592 | 9663 | ||
1351 | 9593 | leave: | 9664 | leave: |
1353 | 9594 | mdb_txn_abort(txn); | 9665 | _mdb_txn_abort(txn); |
1354 | 9595 | return rc; | 9666 | return rc; |
1355 | 9596 | } | 9667 | } |
1356 | 9597 | 9668 | ||
1357 | @@ -9806,6 +9877,7 @@ int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *db | |||
1358 | 9806 | } | 9877 | } |
1359 | 9807 | } | 9878 | } |
1360 | 9808 | mdb_default_cmp(txn, MAIN_DBI); | 9879 | mdb_default_cmp(txn, MAIN_DBI); |
1361 | 9880 | MDB_TRACE(("%p, (null), %u = %u", txn, flags, MAIN_DBI)); | ||
1362 | 9809 | return MDB_SUCCESS; | 9881 | return MDB_SUCCESS; |
1363 | 9810 | } | 9882 | } |
1364 | 9811 | 9883 | ||
1365 | @@ -9867,7 +9939,7 @@ int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *db | |||
1366 | 9867 | dummy.md_root = P_INVALID; | 9939 | dummy.md_root = P_INVALID; |
1367 | 9868 | dummy.md_flags = flags & PERSISTENT_FLAGS; | 9940 | dummy.md_flags = flags & PERSISTENT_FLAGS; |
1368 | 9869 | WITH_CURSOR_TRACKING(mc, | 9941 | WITH_CURSOR_TRACKING(mc, |
1370 | 9870 | rc = mdb_cursor_put(&mc, &key, &data, F_SUBDATA)); | 9942 | rc = _mdb_cursor_put(&mc, &key, &data, F_SUBDATA)); |
1371 | 9871 | dbflag |= DB_DIRTY; | 9943 | dbflag |= DB_DIRTY; |
1372 | 9872 | } | 9944 | } |
1373 | 9873 | 9945 | ||
1374 | @@ -9892,6 +9964,7 @@ int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *db | |||
1375 | 9892 | if (!unused) { | 9964 | if (!unused) { |
1376 | 9893 | txn->mt_numdbs++; | 9965 | txn->mt_numdbs++; |
1377 | 9894 | } | 9966 | } |
1378 | 9967 | MDB_TRACE(("%p, %s, %u = %u", txn, name, flags, slot)); | ||
1379 | 9895 | } | 9968 | } |
1380 | 9896 | 9969 | ||
1381 | 9897 | return rc; | 9970 | return rc; |
1382 | @@ -9923,6 +9996,7 @@ void mdb_dbi_close(MDB_env *env, MDB_dbi dbi) | |||
1383 | 9923 | ptr = env->me_dbxs[dbi].md_name.mv_data; | 9996 | ptr = env->me_dbxs[dbi].md_name.mv_data; |
1384 | 9924 | /* If there was no name, this was already closed */ | 9997 | /* If there was no name, this was already closed */ |
1385 | 9925 | if (ptr) { | 9998 | if (ptr) { |
1386 | 9999 | MDB_TRACE(("%p, %u", env, dbi)); | ||
1387 | 9926 | env->me_dbxs[dbi].md_name.mv_data = NULL; | 10000 | env->me_dbxs[dbi].md_name.mv_data = NULL; |
1388 | 9927 | env->me_dbxs[dbi].md_name.mv_size = 0; | 10001 | env->me_dbxs[dbi].md_name.mv_size = 0; |
1389 | 9928 | env->me_dbflags[dbi] = 0; | 10002 | env->me_dbflags[dbi] = 0; |
1390 | @@ -10057,6 +10131,7 @@ int mdb_drop(MDB_txn *txn, MDB_dbi dbi, int del) | |||
1391 | 10057 | if (rc) | 10131 | if (rc) |
1392 | 10058 | return rc; | 10132 | return rc; |
1393 | 10059 | 10133 | ||
1394 | 10134 | MDB_TRACE(("%u, %d", dbi, del)); | ||
1395 | 10060 | rc = mdb_drop0(mc, mc->mc_db->md_flags & MDB_DUPSORT); | 10135 | rc = mdb_drop0(mc, mc->mc_db->md_flags & MDB_DUPSORT); |
1396 | 10061 | /* Invalidate the dropped DB's cursors */ | 10136 | /* Invalidate the dropped DB's cursors */ |
1397 | 10062 | for (m2 = txn->mt_cursors[dbi]; m2; m2 = m2->mc_next) | 10137 | for (m2 = txn->mt_cursors[dbi]; m2; m2 = m2->mc_next) |
1398 | diff --git a/libraries/liblmdb/mdb_load.c b/libraries/liblmdb/mdb_load.c | |||
1399 | index d2a3cec..cba6c06 100644 | |||
1400 | --- a/libraries/liblmdb/mdb_load.c | |||
1401 | +++ b/libraries/liblmdb/mdb_load.c | |||
1402 | @@ -449,7 +449,7 @@ int main(int argc, char *argv[]) | |||
1403 | 449 | if (rc == MDB_KEYEXIST && putflags) | 449 | if (rc == MDB_KEYEXIST && putflags) |
1404 | 450 | continue; | 450 | continue; |
1405 | 451 | if (rc) { | 451 | if (rc) { |
1407 | 452 | fprintf(stderr, "mdb_cursor_put failed, error %d %s\n", rc, mdb_strerror(rc)); | 452 | fprintf(stderr, "%s: line %" Z "d: mdb_cursor_put failed, error %d %s\n", prog, lineno, rc, mdb_strerror(rc)); |
1408 | 453 | goto txn_abort; | 453 | goto txn_abort; |
1409 | 454 | } | 454 | } |
1410 | 455 | batch++; | 455 | batch++; |
1411 | @@ -470,9 +470,11 @@ int main(int argc, char *argv[]) | |||
1412 | 470 | fprintf(stderr, "mdb_cursor_open failed, error %d %s\n", rc, mdb_strerror(rc)); | 470 | fprintf(stderr, "mdb_cursor_open failed, error %d %s\n", rc, mdb_strerror(rc)); |
1413 | 471 | goto txn_abort; | 471 | goto txn_abort; |
1414 | 472 | } | 472 | } |
1416 | 473 | if (appflag & MDB_APPENDDUP) { | 473 | if (append) { |
1417 | 474 | MDB_val k, d; | 474 | MDB_val k, d; |
1418 | 475 | mdb_cursor_get(mc, &k, &d, MDB_LAST); | 475 | mdb_cursor_get(mc, &k, &d, MDB_LAST); |
1419 | 476 | memcpy(prevk.mv_data, k.mv_data, k.mv_size); | ||
1420 | 477 | prevk.mv_size = k.mv_size; | ||
1421 | 476 | } | 478 | } |
1422 | 477 | batch = 0; | 479 | batch = 0; |
1423 | 478 | } | 480 | } |
1424 | diff --git a/libraries/liblmdb/midl.h b/libraries/liblmdb/midl.h | |||
1425 | index 2075206..ff740ae 100644 | |||
1426 | --- a/libraries/liblmdb/midl.h | |||
1427 | +++ b/libraries/liblmdb/midl.h | |||
1428 | @@ -56,7 +56,9 @@ typedef MDB_ID *MDB_IDL; | |||
1429 | 56 | /* IDL sizes - likely should be even bigger | 56 | /* IDL sizes - likely should be even bigger |
1430 | 57 | * limiting factors: sizeof(ID), thread stack size | 57 | * limiting factors: sizeof(ID), thread stack size |
1431 | 58 | */ | 58 | */ |
1432 | 59 | #ifndef MDB_IDL_LOGN | ||
1433 | 59 | #define MDB_IDL_LOGN 16 /* DB_SIZE is 2^16, UM_SIZE is 2^17 */ | 60 | #define MDB_IDL_LOGN 16 /* DB_SIZE is 2^16, UM_SIZE is 2^17 */ |
1434 | 61 | #endif | ||
1435 | 60 | #define MDB_IDL_DB_SIZE (1<<MDB_IDL_LOGN) | 62 | #define MDB_IDL_DB_SIZE (1<<MDB_IDL_LOGN) |
1436 | 61 | #define MDB_IDL_UM_SIZE (1<<(MDB_IDL_LOGN+1)) | 63 | #define MDB_IDL_UM_SIZE (1<<(MDB_IDL_LOGN+1)) |
1437 | 62 | 64 | ||
1438 | diff --git a/libraries/liblmdb/mplay.c b/libraries/liblmdb/mplay.c | |||
1439 | 63 | new file mode 100644 | 65 | new file mode 100644 |
1440 | index 0000000..0fef74f | |||
1441 | --- /dev/null | |||
1442 | +++ b/libraries/liblmdb/mplay.c | |||
1443 | @@ -0,0 +1,582 @@ | |||
1444 | 1 | /* mplay.c - memory-mapped database log replay */ | ||
1445 | 2 | /* | ||
1446 | 3 | * Copyright 2011-2023 Howard Chu, Symas Corp. | ||
1447 | 4 | * All rights reserved. | ||
1448 | 5 | * | ||
1449 | 6 | * Redistribution and use in source and binary forms, with or without | ||
1450 | 7 | * modification, are permitted only as authorized by the OpenLDAP | ||
1451 | 8 | * Public License. | ||
1452 | 9 | * | ||
1453 | 10 | * A copy of this license is available in the file LICENSE in the | ||
1454 | 11 | * top-level directory of the distribution or, alternatively, at | ||
1455 | 12 | * <http://www.OpenLDAP.org/license.html>. | ||
1456 | 13 | */ | ||
1457 | 14 | #include <stdio.h> | ||
1458 | 15 | #include <stdlib.h> | ||
1459 | 16 | #include <unistd.h> | ||
1460 | 17 | #include <time.h> | ||
1461 | 18 | #include <string.h> | ||
1462 | 19 | #include <ctype.h> | ||
1463 | 20 | #include <assert.h> | ||
1464 | 21 | #include <sys/types.h> | ||
1465 | 22 | #include <sys/wait.h> | ||
1466 | 23 | |||
1467 | 24 | #include "lmdb.h" | ||
1468 | 25 | |||
1469 | 26 | #define E(expr) CHECK((rc = (expr)) == MDB_SUCCESS, #expr) | ||
1470 | 27 | #define RES(err, expr) ((rc = expr) == (err) || (CHECK(!rc, #expr), 0)) | ||
1471 | 28 | #define CHECK(test, msg) ((test) ? (void)0 : ((void)fprintf(stderr, \ | ||
1472 | 29 | "%s:%d: %s: %s\n", __FILE__, __LINE__, msg, mdb_strerror(rc)), abort())) | ||
1473 | 30 | |||
1474 | 31 | #define MDB_SCNy(t) "z" #t | ||
1475 | 32 | |||
1476 | 33 | #define SCMP(s) s, (sizeof(s)-1) | ||
1477 | 34 | char inbuf[8192]; | ||
1478 | 35 | char *dbuf, *kbuf; | ||
1479 | 36 | size_t dbufsize; | ||
1480 | 37 | int maxkey; | ||
1481 | 38 | |||
1482 | 39 | #define SOFF(s) (sizeof(s)+1) | ||
1483 | 40 | |||
1484 | 41 | #define MAXENVS 16 | ||
1485 | 42 | #define MAXTXNS 16 | ||
1486 | 43 | #define MAXCRSS 16 | ||
1487 | 44 | |||
1488 | 45 | #define MAXPIDS 16 | ||
1489 | 46 | |||
1490 | 47 | typedef struct crspair { | ||
1491 | 48 | void *tcrs; /* scanned text pointer */ | ||
1492 | 49 | MDB_cursor *rcrs; | ||
1493 | 50 | } crspair; | ||
1494 | 51 | |||
1495 | 52 | typedef struct txnpair { | ||
1496 | 53 | void *ttxn; /* scanned text pointer */ | ||
1497 | 54 | MDB_txn *rtxn; | ||
1498 | 55 | crspair cursors[MAXCRSS]; | ||
1499 | 56 | int ncursors; | ||
1500 | 57 | } txnpair; | ||
1501 | 58 | |||
1502 | 59 | typedef struct envpair { | ||
1503 | 60 | void *tenv; | ||
1504 | 61 | MDB_env *renv; | ||
1505 | 62 | txnpair txns[MAXTXNS]; | ||
1506 | 63 | int ntxns; | ||
1507 | 64 | } envpair; | ||
1508 | 65 | |||
1509 | 66 | envpair envs[MAXENVS]; | ||
1510 | 67 | int nenvs; | ||
1511 | 68 | |||
1512 | 69 | envpair *lastenv; | ||
1513 | 70 | txnpair *lasttxn; | ||
1514 | 71 | crspair *lastcrs; | ||
1515 | 72 | |||
1516 | 73 | typedef struct pidpair { | ||
1517 | 74 | int tpid; | ||
1518 | 75 | pid_t rpid; | ||
1519 | 76 | int fdout, fdin; | ||
1520 | 77 | } pidpair; | ||
1521 | 78 | |||
1522 | 79 | pidpair *lastpid; | ||
1523 | 80 | |||
1524 | 81 | pidpair pids[MAXPIDS]; | ||
1525 | 82 | int npids; | ||
1526 | 83 | |||
1527 | 84 | unsigned long lcount; | ||
1528 | 85 | |||
1529 | 86 | static int unhex(unsigned char *c2) | ||
1530 | 87 | { | ||
1531 | 88 | int x, c; | ||
1532 | 89 | x = *c2++ & 0x4f; | ||
1533 | 90 | if (x & 0x40) | ||
1534 | 91 | x -= 55; | ||
1535 | 92 | c = x << 4; | ||
1536 | 93 | x = *c2 & 0x4f; | ||
1537 | 94 | if (x & 0x40) | ||
1538 | 95 | x -= 55; | ||
1539 | 96 | c |= x; | ||
1540 | 97 | return c; | ||
1541 | 98 | } | ||
1542 | 99 | |||
1543 | 100 | int inhex(char *in, char *out) | ||
1544 | 101 | { | ||
1545 | 102 | char *c2 = out; | ||
1546 | 103 | while (isxdigit(*in)) { | ||
1547 | 104 | *c2++ = unhex((unsigned char *)in); | ||
1548 | 105 | in += 2; | ||
1549 | 106 | } | ||
1550 | 107 | return c2 - out; | ||
1551 | 108 | } | ||
1552 | 109 | |||
1553 | 110 | static void addenv(void *tenv, MDB_env *renv) | ||
1554 | 111 | { | ||
1555 | 112 | assert(nenvs < MAXENVS); | ||
1556 | 113 | envs[nenvs].tenv = tenv; | ||
1557 | 114 | envs[nenvs].renv = renv; | ||
1558 | 115 | envs[nenvs].ntxns = 0; | ||
1559 | 116 | lastenv = envs+nenvs; | ||
1560 | 117 | nenvs++; | ||
1561 | 118 | } | ||
1562 | 119 | |||
1563 | 120 | static envpair *findenv(void *tenv) | ||
1564 | 121 | { | ||
1565 | 122 | int i; | ||
1566 | 123 | if (!lastenv || lastenv->tenv != tenv) { | ||
1567 | 124 | for (i=0; i<nenvs; i++) | ||
1568 | 125 | if (envs[i].tenv == tenv) | ||
1569 | 126 | break; | ||
1570 | 127 | assert(i < nenvs); | ||
1571 | 128 | lastenv = &envs[i]; | ||
1572 | 129 | } | ||
1573 | 130 | return lastenv; | ||
1574 | 131 | } | ||
1575 | 132 | |||
1576 | 133 | static void delenv(envpair *ep) | ||
1577 | 134 | { | ||
1578 | 135 | int i = ep - envs; | ||
1579 | 136 | for (; i<nenvs-1; i++) | ||
1580 | 137 | envs[i] = envs[i+1]; | ||
1581 | 138 | nenvs--; | ||
1582 | 139 | lastenv = NULL; | ||
1583 | 140 | } | ||
1584 | 141 | |||
1585 | 142 | static void addtxn(void *tenv, void *ttxn, MDB_txn *rtxn) | ||
1586 | 143 | { | ||
1587 | 144 | envpair *ep; | ||
1588 | 145 | txnpair *tp; | ||
1589 | 146 | |||
1590 | 147 | ep = findenv(tenv); | ||
1591 | 148 | assert(ep->ntxns < MAXTXNS); | ||
1592 | 149 | tp = ep->txns+ep->ntxns; | ||
1593 | 150 | tp->ttxn = ttxn; | ||
1594 | 151 | tp->rtxn = rtxn; | ||
1595 | 152 | tp->ncursors = 0; | ||
1596 | 153 | ep->ntxns++; | ||
1597 | 154 | lasttxn = tp; | ||
1598 | 155 | } | ||
1599 | 156 | |||
1600 | 157 | static txnpair *findtxn(void *ttxn) | ||
1601 | 158 | { | ||
1602 | 159 | int i, j; | ||
1603 | 160 | if (lasttxn && lasttxn->ttxn == ttxn) | ||
1604 | 161 | return lasttxn; | ||
1605 | 162 | if (lastenv) { | ||
1606 | 163 | for (i=0; i<lastenv->ntxns; i++) { | ||
1607 | 164 | if (lastenv->txns[i].ttxn == ttxn) { | ||
1608 | 165 | lasttxn = lastenv->txns+i; | ||
1609 | 166 | return lasttxn; | ||
1610 | 167 | } | ||
1611 | 168 | } | ||
1612 | 169 | } | ||
1613 | 170 | for (i=0; i<nenvs; i++) { | ||
1614 | 171 | if (envs+i == lastenv) continue; | ||
1615 | 172 | for (j=0; j<envs[i].ntxns; j++) { | ||
1616 | 173 | if (envs[i].txns[j].ttxn == ttxn) { | ||
1617 | 174 | lastenv = envs+i; | ||
1618 | 175 | lasttxn = envs[i].txns+j; | ||
1619 | 176 | return lasttxn; | ||
1620 | 177 | } | ||
1621 | 178 | } | ||
1622 | 179 | } | ||
1623 | 180 | assert(0); /* should have found it */ | ||
1624 | 181 | } | ||
1625 | 182 | |||
1626 | 183 | static void deltxn(txnpair *tp) | ||
1627 | 184 | { | ||
1628 | 185 | int i = tp - lastenv->txns; | ||
1629 | 186 | for (; i<lastenv->ntxns-1; i++) | ||
1630 | 187 | lastenv->txns[i] = lastenv->txns[i+1]; | ||
1631 | 188 | lastenv->ntxns--; | ||
1632 | 189 | lasttxn = NULL; | ||
1633 | 190 | } | ||
1634 | 191 | |||
1635 | 192 | static void addcrs(txnpair *tp, void *tcrs, MDB_cursor *rcrs) | ||
1636 | 193 | { | ||
1637 | 194 | int j = tp->ncursors; | ||
1638 | 195 | assert(tp->ncursors < MAXCRSS); | ||
1639 | 196 | |||
1640 | 197 | tp->cursors[j].tcrs = tcrs; | ||
1641 | 198 | tp->cursors[j].rcrs = rcrs; | ||
1642 | 199 | tp->ncursors++; | ||
1643 | 200 | lastcrs = tp->cursors+j; | ||
1644 | 201 | } | ||
1645 | 202 | |||
1646 | 203 | static crspair *findcrs(void *tcrs) | ||
1647 | 204 | { | ||
1648 | 205 | int i, j, k; | ||
1649 | 206 | envpair *ep; | ||
1650 | 207 | txnpair *tp; | ||
1651 | 208 | crspair *cp; | ||
1652 | 209 | if (lastcrs && lastcrs->tcrs == tcrs) | ||
1653 | 210 | return lastcrs; | ||
1654 | 211 | if (lasttxn) { | ||
1655 | 212 | for (k=0, cp=lasttxn->cursors; k<lasttxn->ncursors; k++, cp++) { | ||
1656 | 213 | if (cp->tcrs == tcrs) { | ||
1657 | 214 | lastcrs = cp; | ||
1658 | 215 | return lastcrs; | ||
1659 | 216 | } | ||
1660 | 217 | } | ||
1661 | 218 | } | ||
1662 | 219 | if (lastenv) { | ||
1663 | 220 | for (j=0, tp=lastenv->txns; j<lastenv->ntxns; j++, tp++){ | ||
1664 | 221 | if (tp == lasttxn) | ||
1665 | 222 | continue; | ||
1666 | 223 | for (k=0, cp = tp->cursors; k<tp->ncursors; k++, cp++) { | ||
1667 | 224 | if (cp->tcrs == tcrs) { | ||
1668 | 225 | lastcrs = cp; | ||
1669 | 226 | lasttxn = tp; | ||
1670 | 227 | return lastcrs; | ||
1671 | 228 | } | ||
1672 | 229 | } | ||
1673 | 230 | } | ||
1674 | 231 | } | ||
1675 | 232 | for (i=0, ep=envs; i<nenvs; i++, ep++) { | ||
1676 | 233 | for (j=0, tp=ep->txns; j<ep->ntxns; j++, tp++) { | ||
1677 | 234 | if (tp == lasttxn) | ||
1678 | 235 | continue; | ||
1679 | 236 | for (k=0, cp = tp->cursors; k<tp->ncursors; k++, cp++) { | ||
1680 | 237 | if (cp->tcrs == tcrs) { | ||
1681 | 238 | lastcrs = cp; | ||
1682 | 239 | lasttxn = tp; | ||
1683 | 240 | lastenv = ep; | ||
1684 | 241 | return lastcrs; | ||
1685 | 242 | } | ||
1686 | 243 | } | ||
1687 | 244 | } | ||
1688 | 245 | } | ||
1689 | 246 | assert(0); /* should have found it already */ | ||
1690 | 247 | } | ||
1691 | 248 | |||
1692 | 249 | static void delcrs(void *tcrs) | ||
1693 | 250 | { | ||
1694 | 251 | int i; | ||
1695 | 252 | crspair *cp = findcrs(tcrs); | ||
1696 | 253 | mdb_cursor_close(cp->rcrs); | ||
1697 | 254 | for (i = cp - lasttxn->cursors; i<lasttxn->ncursors-1; i++) | ||
1698 | 255 | lasttxn->cursors[i] = lasttxn->cursors[i+1]; | ||
1699 | 256 | lasttxn->ncursors--; | ||
1700 | 257 | lastcrs = NULL; | ||
1701 | 258 | } | ||
1702 | 259 | |||
1703 | 260 | void child() | ||
1704 | 261 | { | ||
1705 | 262 | int rc; | ||
1706 | 263 | MDB_val key, data; | ||
1707 | 264 | char *ptr; | ||
1708 | 265 | |||
1709 | 266 | while (fgets(inbuf, sizeof(inbuf), stdin)) { | ||
1710 | 267 | ptr = inbuf; | ||
1711 | 268 | if (!strncmp(ptr, SCMP("exit"))) | ||
1712 | 269 | break; | ||
1713 | 270 | |||
1714 | 271 | if (!strncmp(ptr, SCMP("mdb_env_create"))) { | ||
1715 | 272 | void *tenv; | ||
1716 | 273 | MDB_env *renv; | ||
1717 | 274 | sscanf(ptr+SOFF("mdb_env_create"), "%p", &tenv); | ||
1718 | 275 | E(mdb_env_create(&renv)); | ||
1719 | 276 | addenv(tenv, renv); | ||
1720 | 277 | } else if (!strncmp(ptr, SCMP("mdb_env_set_maxdbs"))) { | ||
1721 | 278 | void *tenv; | ||
1722 | 279 | envpair *ep; | ||
1723 | 280 | unsigned int maxdbs; | ||
1724 | 281 | sscanf(ptr+SOFF("mdb_env_set_maxdbs"), "%p, %u", &tenv, &maxdbs); | ||
1725 | 282 | ep = findenv(tenv); | ||
1726 | 283 | E(mdb_env_set_maxdbs(ep->renv, maxdbs)); | ||
1727 | 284 | } else if (!strncmp(ptr, SCMP("mdb_env_set_mapsize"))) { | ||
1728 | 285 | void *tenv; | ||
1729 | 286 | envpair *ep; | ||
1730 | 287 | size_t mapsize; | ||
1731 | 288 | sscanf(ptr+SOFF("mdb_env_set_mapsize"), "%p, %"MDB_SCNy(u), &tenv, &mapsize); | ||
1732 | 289 | ep = findenv(tenv); | ||
1733 | 290 | E(mdb_env_set_mapsize(ep->renv, mapsize)); | ||
1734 | 291 | } else if (!strncmp(ptr, SCMP("mdb_env_open"))) { | ||
1735 | 292 | void *tenv; | ||
1736 | 293 | envpair *ep; | ||
1737 | 294 | char *path; | ||
1738 | 295 | int len; | ||
1739 | 296 | unsigned int flags, mode; | ||
1740 | 297 | sscanf(ptr+SOFF("mdb_env_open"), "%p, %n", &tenv, &len); | ||
1741 | 298 | path = ptr+SOFF("mdb_env_open")+len; | ||
1742 | 299 | ptr = strchr(path, ','); | ||
1743 | 300 | *ptr++ = '\0'; | ||
1744 | 301 | sscanf(ptr, "%u, %o", &flags, &mode); | ||
1745 | 302 | ep = findenv(tenv); | ||
1746 | 303 | E(mdb_env_open(ep->renv, path, flags, mode)); | ||
1747 | 304 | if (!maxkey) { | ||
1748 | 305 | maxkey = mdb_env_get_maxkeysize(ep->renv); | ||
1749 | 306 | kbuf = malloc(maxkey+2); | ||
1750 | 307 | dbuf = malloc(maxkey+2); | ||
1751 | 308 | dbufsize = maxkey; | ||
1752 | 309 | } | ||
1753 | 310 | } else if (!strncmp(ptr, SCMP("mdb_env_close"))) { | ||
1754 | 311 | void *tenv; | ||
1755 | 312 | envpair *ep; | ||
1756 | 313 | sscanf(ptr+SOFF("mdb_env_close"), "%p", &tenv); | ||
1757 | 314 | ep = findenv(tenv); | ||
1758 | 315 | mdb_env_close(ep->renv); | ||
1759 | 316 | delenv(ep); | ||
1760 | 317 | if (!nenvs) /* if no other envs left, this process is done */ | ||
1761 | 318 | break; | ||
1762 | 319 | } else if (!strncmp(ptr, SCMP("mdb_txn_begin"))) { | ||
1763 | 320 | unsigned int flags; | ||
1764 | 321 | void *tenv, *ttxn; | ||
1765 | 322 | envpair *ep; | ||
1766 | 323 | MDB_txn *rtxn; | ||
1767 | 324 | sscanf(ptr+SOFF("mdb_txn_begin"), "%p, %*p, %u = %p", &tenv, &flags, &ttxn); | ||
1768 | 325 | ep = findenv(tenv); | ||
1769 | 326 | E(mdb_txn_begin(ep->renv, NULL, flags, &rtxn)); | ||
1770 | 327 | addtxn(tenv, ttxn, rtxn); | ||
1771 | 328 | } else if (!strncmp(ptr, SCMP("mdb_txn_commit"))) { | ||
1772 | 329 | void *ttxn; | ||
1773 | 330 | txnpair *tp; | ||
1774 | 331 | sscanf(ptr+SOFF("mdb_txn_commit"), "%p", &ttxn); | ||
1775 | 332 | tp = findtxn(ttxn); | ||
1776 | 333 | E(mdb_txn_commit(tp->rtxn)); | ||
1777 | 334 | deltxn(tp); | ||
1778 | 335 | } else if (!strncmp(ptr, SCMP("mdb_txn_abort"))) { | ||
1779 | 336 | void *ttxn; | ||
1780 | 337 | txnpair *tp; | ||
1781 | 338 | sscanf(ptr+SOFF("mdb_txn_abort"), "%p", &ttxn); | ||
1782 | 339 | tp = findtxn(ttxn); | ||
1783 | 340 | mdb_txn_abort(tp->rtxn); | ||
1784 | 341 | deltxn(tp); | ||
1785 | 342 | } else if (!strncmp(ptr, SCMP("mdb_dbi_open"))) { | ||
1786 | 343 | void *ttxn; | ||
1787 | 344 | txnpair *tp; | ||
1788 | 345 | char *dbname; | ||
1789 | 346 | unsigned int flags; | ||
1790 | 347 | unsigned int tdbi; | ||
1791 | 348 | MDB_dbi dbi; | ||
1792 | 349 | sscanf(ptr+SOFF("mdb_dbi_open"), "%p, ", &ttxn); | ||
1793 | 350 | dbname = strchr(ptr+SOFF("mdb_dbi_open"), ','); | ||
1794 | 351 | dbname += 2; | ||
1795 | 352 | ptr = strchr(dbname, ','); | ||
1796 | 353 | *ptr++ = '\0'; | ||
1797 | 354 | if (!strcmp(dbname, "(null)")) | ||
1798 | 355 | dbname = NULL; | ||
1799 | 356 | sscanf(ptr, "%u = %u", &flags, &tdbi); | ||
1800 | 357 | tp = findtxn(ttxn); | ||
1801 | 358 | E(mdb_dbi_open(tp->rtxn, dbname, flags, &dbi)); | ||
1802 | 359 | } else if (!strncmp(ptr, SCMP("mdb_dbi_close"))) { | ||
1803 | 360 | void *tenv; | ||
1804 | 361 | envpair *ep; | ||
1805 | 362 | unsigned int tdbi; | ||
1806 | 363 | sscanf(ptr+SOFF("mdb_dbi_close"), "%p, %u", &tenv, &tdbi); | ||
1807 | 364 | ep = findenv(tenv); | ||
1808 | 365 | mdb_dbi_close(ep->renv, tdbi); | ||
1809 | 366 | } else if (!strncmp(ptr, SCMP("mdb_cursor_open"))) { | ||
1810 | 367 | void *ttxn, *tcrs; | ||
1811 | 368 | txnpair *tp; | ||
1812 | 369 | MDB_cursor *rcrs; | ||
1813 | 370 | unsigned int tdbi; | ||
1814 | 371 | sscanf(ptr+SOFF("mdb_cursor_open"), "%p, %u = %p", &ttxn, &tdbi, &tcrs); | ||
1815 | 372 | tp = findtxn(ttxn); | ||
1816 | 373 | E(mdb_cursor_open(tp->rtxn, tdbi, &rcrs)); | ||
1817 | 374 | addcrs(tp, tcrs, rcrs); | ||
1818 | 375 | } else if (!strncmp(ptr, SCMP("mdb_cursor_close"))) { | ||
1819 | 376 | void *tcrs; | ||
1820 | 377 | sscanf(ptr+SOFF("mdb_cursor_close"), "%p", &tcrs); | ||
1821 | 378 | delcrs(tcrs); | ||
1822 | 379 | } else if (!strncmp(ptr, SCMP("mdb_cursor_put"))) { | ||
1823 | 380 | void *tcrs; | ||
1824 | 381 | crspair *cp; | ||
1825 | 382 | unsigned int flags; | ||
1826 | 383 | int len; | ||
1827 | 384 | sscanf(ptr+SOFF("mdb_cursor_put"), "%p, ", &tcrs); | ||
1828 | 385 | cp = findcrs(tcrs); | ||
1829 | 386 | ptr = strchr(ptr+SOFF("mdb_cursor_put"), ','); | ||
1830 | 387 | sscanf(ptr+1, "%"MDB_SCNy(u)",", &key.mv_size); | ||
1831 | 388 | if (key.mv_size) { | ||
1832 | 389 | ptr = strchr(ptr, '['); | ||
1833 | 390 | inhex(ptr+1, kbuf); | ||
1834 | 391 | key.mv_data = kbuf; | ||
1835 | 392 | ptr += key.mv_size * 2 + 2; | ||
1836 | 393 | } | ||
1837 | 394 | ptr = strchr(ptr+1, ','); | ||
1838 | 395 | sscanf(ptr+1, "%"MDB_SCNy(u)"%n", &data.mv_size, &len); | ||
1839 | 396 | if (data.mv_size > dbufsize) { | ||
1840 | 397 | dbuf = realloc(dbuf, data.mv_size+2); | ||
1841 | 398 | assert(dbuf != NULL); | ||
1842 | 399 | dbufsize = data.mv_size; | ||
1843 | 400 | } | ||
1844 | 401 | ptr += len+1; | ||
1845 | 402 | if (*ptr == '[') { | ||
1846 | 403 | inhex(ptr+1, dbuf); | ||
1847 | 404 | data.mv_data = dbuf; | ||
1848 | 405 | ptr += data.mv_size * 2 + 2; | ||
1849 | 406 | } else { | ||
1850 | 407 | sprintf(dbuf, "%09ld", (long)mdb_txn_id(lasttxn->rtxn)); | ||
1851 | 408 | } | ||
1852 | 409 | sscanf(ptr+1, "%u", &flags); | ||
1853 | 410 | E(mdb_cursor_put(cp->rcrs, &key, &data, flags)); | ||
1854 | 411 | } else if (!strncmp(ptr, SCMP("mdb_cursor_del"))) { | ||
1855 | 412 | void *tcrs; | ||
1856 | 413 | crspair *cp; | ||
1857 | 414 | unsigned int flags; | ||
1858 | 415 | sscanf(ptr+SOFF("mdb_cursor_del"), "%p, %u", &tcrs, &flags); | ||
1859 | 416 | cp = findcrs(tcrs); | ||
1860 | 417 | E(mdb_cursor_del(cp->rcrs, flags)); | ||
1861 | 418 | } else if (!strncmp(ptr, SCMP("mdb_put"))) { | ||
1862 | 419 | void *ttxn; | ||
1863 | 420 | txnpair *tp; | ||
1864 | 421 | unsigned int tdbi, flags; | ||
1865 | 422 | int len; | ||
1866 | 423 | sscanf(ptr+SOFF("mdb_put"),"%p, %u, %"MDB_SCNy(u), &ttxn, &tdbi, &key.mv_size); | ||
1867 | 424 | tp = findtxn(ttxn); | ||
1868 | 425 | ptr = strchr(ptr+SOFF("mdb_put"), '['); | ||
1869 | 426 | inhex(ptr+1, kbuf); | ||
1870 | 427 | key.mv_data = kbuf; | ||
1871 | 428 | ptr += key.mv_size * 2 + 2; | ||
1872 | 429 | sscanf(ptr+1, "%"MDB_SCNy(u)"%n", &data.mv_size, &len); | ||
1873 | 430 | if (data.mv_size > dbufsize) { | ||
1874 | 431 | dbuf = realloc(dbuf, data.mv_size+2); | ||
1875 | 432 | assert(dbuf != NULL); | ||
1876 | 433 | dbufsize = data.mv_size; | ||
1877 | 434 | } | ||
1878 | 435 | ptr += len+1; | ||
1879 | 436 | if (*ptr == '[') { | ||
1880 | 437 | inhex(ptr+1, dbuf); | ||
1881 | 438 | ptr += data.mv_size * 2 + 2; | ||
1882 | 439 | } else { | ||
1883 | 440 | sprintf(dbuf, "%09ld", (long)mdb_txn_id(tp->rtxn)); | ||
1884 | 441 | } | ||
1885 | 442 | data.mv_data = dbuf; | ||
1886 | 443 | sscanf(ptr+1, "%u", &flags); | ||
1887 | 444 | RES(MDB_KEYEXIST,mdb_put(tp->rtxn, tdbi, &key, &data, flags)); | ||
1888 | 445 | } else if (!strncmp(ptr, SCMP("mdb_del"))) { | ||
1889 | 446 | void *ttxn; | ||
1890 | 447 | txnpair *tp; | ||
1891 | 448 | unsigned int tdbi; | ||
1892 | 449 | int len; | ||
1893 | 450 | sscanf(ptr+SOFF("mdb_del"),"%p, %u, %"MDB_SCNy(u), &ttxn, &tdbi, &key.mv_size); | ||
1894 | 451 | tp = findtxn(ttxn); | ||
1895 | 452 | ptr = strchr(ptr+SOFF("mdb_del"), '['); | ||
1896 | 453 | inhex(ptr+1, kbuf); | ||
1897 | 454 | key.mv_data = kbuf; | ||
1898 | 455 | ptr += key.mv_size * 2 + 2; | ||
1899 | 456 | sscanf(ptr+1, "%"MDB_SCNy(u)"%n", &data.mv_size, &len); | ||
1900 | 457 | if (data.mv_size > dbufsize) { | ||
1901 | 458 | dbuf = realloc(dbuf, data.mv_size+2); | ||
1902 | 459 | assert(dbuf != NULL); | ||
1903 | 460 | dbufsize = data.mv_size; | ||
1904 | 461 | } | ||
1905 | 462 | ptr += len+1; | ||
1906 | 463 | if (*ptr == '[') { | ||
1907 | 464 | inhex(ptr+1, dbuf); | ||
1908 | 465 | } else { | ||
1909 | 466 | sprintf(dbuf, "%09ld", (long)mdb_txn_id(tp->rtxn)); | ||
1910 | 467 | } | ||
1911 | 468 | data.mv_data = dbuf; | ||
1912 | 469 | RES(MDB_NOTFOUND,mdb_del(tp->rtxn, tdbi, &key, &data)); | ||
1913 | 470 | } | ||
1914 | 471 | write(1, "\n", 1); | ||
1915 | 472 | } | ||
1916 | 473 | exit(0); | ||
1917 | 474 | } | ||
1918 | 475 | |||
1919 | 476 | static pidpair *addpid(int tpid) | ||
1920 | 477 | { | ||
1921 | 478 | int fdout[2], fdin[2]; | ||
1922 | 479 | pid_t pid; | ||
1923 | 480 | assert(npids < MAXPIDS); | ||
1924 | 481 | pids[npids].tpid = tpid; | ||
1925 | 482 | pipe(fdout); | ||
1926 | 483 | pipe(fdin); | ||
1927 | 484 | if ((pid = fork()) == 0) { | ||
1928 | 485 | /* child */ | ||
1929 | 486 | fclose(stdin); | ||
1930 | 487 | fclose(stdout); | ||
1931 | 488 | dup2(fdout[0], 0); | ||
1932 | 489 | dup2(fdin[1], 1); | ||
1933 | 490 | stdin = fdopen(0, "r"); | ||
1934 | 491 | stdout = fdopen(1, "w"); | ||
1935 | 492 | child(); | ||
1936 | 493 | return 0; /* NOTREACHED */ | ||
1937 | 494 | } else { | ||
1938 | 495 | pids[npids].rpid = pid; | ||
1939 | 496 | pids[npids].fdout = fdout[1]; | ||
1940 | 497 | pids[npids].fdin = fdin[0]; | ||
1941 | 498 | lastpid = pids+npids; | ||
1942 | 499 | npids++; | ||
1943 | 500 | return lastpid; | ||
1944 | 501 | } | ||
1945 | 502 | } | ||
1946 | 503 | |||
1947 | 504 | static pidpair *findpid(int tpid) | ||
1948 | 505 | { | ||
1949 | 506 | int i; | ||
1950 | 507 | if (!lastpid || lastpid->tpid != tpid) { | ||
1951 | 508 | for (i=0; i<npids; i++) | ||
1952 | 509 | if (pids[i].tpid == tpid) | ||
1953 | 510 | break; | ||
1954 | 511 | if (i == npids) | ||
1955 | 512 | return NULL; | ||
1956 | 513 | lastpid = &pids[i]; | ||
1957 | 514 | } | ||
1958 | 515 | return lastpid; | ||
1959 | 516 | } | ||
1960 | 517 | |||
1961 | 518 | volatile pid_t killpid; | ||
1962 | 519 | |||
1963 | 520 | static void delpid(int tpid) | ||
1964 | 521 | { | ||
1965 | 522 | pidpair *pp = findpid(tpid); | ||
1966 | 523 | if (pp) { | ||
1967 | 524 | pid_t kpid = pp->rpid; | ||
1968 | 525 | killpid = kpid; | ||
1969 | 526 | write(pp->fdout, "exit\n", sizeof("exit")); | ||
1970 | 527 | while (killpid == kpid) | ||
1971 | 528 | usleep(10000); | ||
1972 | 529 | } | ||
1973 | 530 | } | ||
1974 | 531 | |||
1975 | 532 | static void reaper(int sig) | ||
1976 | 533 | { | ||
1977 | 534 | int status, i; | ||
1978 | 535 | pid_t pid = waitpid(-1, &status, 0); | ||
1979 | 536 | if (pid > 0) { | ||
1980 | 537 | fprintf(stderr, "# %s %d\n", WIFEXITED(status) ? "exited" : "killed", pid); | ||
1981 | 538 | for (i=0; i<npids; i++) | ||
1982 | 539 | if (pids[i].rpid == pid) | ||
1983 | 540 | break; | ||
1984 | 541 | assert(i < npids); | ||
1985 | 542 | close(pids[i].fdout); | ||
1986 | 543 | close(pids[i].fdin); | ||
1987 | 544 | for (;i<npids-1; i++) | ||
1988 | 545 | pids[i] = pids[i+1]; | ||
1989 | 546 | npids--; | ||
1990 | 547 | killpid = 0; | ||
1991 | 548 | } | ||
1992 | 549 | } | ||
1993 | 550 | |||
1994 | 551 | int main(int argc,char * argv[]) | ||
1995 | 552 | { | ||
1996 | 553 | signal(SIGCHLD, reaper); | ||
1997 | 554 | |||
1998 | 555 | while (fgets(inbuf, sizeof(inbuf), stdin)) { | ||
1999 | 556 | pidpair *pp; | ||
2000 | 557 | int tpid, len; | ||
2001 | 558 | char c, *ptr; | ||
2002 | 559 | lcount++; | ||
2003 | 560 | |||
2004 | 561 | if (inbuf[0] == '#' && !strncmp(inbuf+1, SCMP(" killed"))) { | ||
2005 | 562 | sscanf(inbuf+SOFF("killed"),"%d", &tpid); | ||
2006 | 563 | delpid(tpid); | ||
2007 | 564 | continue; | ||
2008 | 565 | } | ||
2009 | 566 | |||
2010 | 567 | if (inbuf[0] != '>') | ||
2011 | 568 | continue; | ||
2012 | 569 | ptr = inbuf+1; | ||
2013 | 570 | sscanf(ptr, "%d:%n", &tpid, &len); | ||
2014 | 571 | pp = findpid(tpid); | ||
2015 | 572 | if (!pp) | ||
2016 | 573 | pp = addpid(tpid); /* new process */ | ||
2017 | 574 | |||
2018 | 575 | ptr = inbuf+len+1; | ||
2019 | 576 | len = strlen(ptr); | ||
2020 | 577 | write(pp->fdout, ptr, len); /* send command and wait for ack */ | ||
2021 | 578 | read(pp->fdin, &c, 1); | ||
2022 | 579 | } | ||
2023 | 580 | while (npids) | ||
2024 | 581 | delpid(pids[0].tpid); | ||
2025 | 582 | } | ||
2026 | diff --git a/servers/lloadd/daemon.c b/servers/lloadd/daemon.c | |||
2027 | index b88fd68..e048936 100644 | |||
2028 | --- a/servers/lloadd/daemon.c | |||
2029 | +++ b/servers/lloadd/daemon.c | |||
2030 | @@ -92,6 +92,11 @@ struct event_base *listener_base = NULL; | |||
2031 | 92 | LloadListener **lload_listeners = NULL; | 92 | LloadListener **lload_listeners = NULL; |
2032 | 93 | static ldap_pvt_thread_t listener_tid, *daemon_tid; | 93 | static ldap_pvt_thread_t listener_tid, *daemon_tid; |
2033 | 94 | 94 | ||
2034 | 95 | #ifndef RESOLV_CONF_PATH | ||
2035 | 96 | #define RESOLV_CONF_PATH "/etc/resolv.conf" | ||
2036 | 97 | #endif | ||
2037 | 98 | char *lload_resolvconf_path = RESOLV_CONF_PATH; | ||
2038 | 99 | |||
2039 | 95 | struct event_base *daemon_base = NULL; | 100 | struct event_base *daemon_base = NULL; |
2040 | 96 | struct evdns_base *dnsbase; | 101 | struct evdns_base *dnsbase; |
2041 | 97 | 102 | ||
2042 | @@ -1238,13 +1243,22 @@ lloadd_daemon( struct event_base *daemon_base ) | |||
2043 | 1238 | 1243 | ||
2044 | 1239 | assert( daemon_base != NULL ); | 1244 | assert( daemon_base != NULL ); |
2045 | 1240 | 1245 | ||
2047 | 1241 | dnsbase = evdns_base_new( daemon_base, EVDNS_BASE_INITIALIZE_NAMESERVERS ); | 1246 | dnsbase = evdns_base_new( daemon_base, 0 ); |
2048 | 1242 | if ( !dnsbase ) { | 1247 | if ( !dnsbase ) { |
2049 | 1243 | Debug( LDAP_DEBUG_ANY, "lloadd startup: " | 1248 | Debug( LDAP_DEBUG_ANY, "lloadd startup: " |
2050 | 1244 | "failed to set up for async name resolution\n" ); | 1249 | "failed to set up for async name resolution\n" ); |
2051 | 1245 | return -1; | 1250 | return -1; |
2052 | 1246 | } | 1251 | } |
2053 | 1247 | 1252 | ||
2054 | 1253 | /* | ||
2055 | 1254 | * ITS#10070: Allow both operation without working DNS (test environments) | ||
2056 | 1255 | * and e.g. containers that don't have a /etc/resolv.conf but do have a | ||
2057 | 1256 | * server listening on 127.0.0.1 which is the default. | ||
2058 | 1257 | */ | ||
2059 | 1258 | (void)evdns_base_resolv_conf_parse( dnsbase, | ||
2060 | 1259 | DNS_OPTION_NAMESERVERS|DNS_OPTION_HOSTSFILE, | ||
2061 | 1260 | lload_resolvconf_path ); | ||
2062 | 1261 | |||
2063 | 1248 | if ( lload_daemon_threads > SLAPD_MAX_DAEMON_THREADS ) | 1262 | if ( lload_daemon_threads > SLAPD_MAX_DAEMON_THREADS ) |
2064 | 1249 | lload_daemon_threads = SLAPD_MAX_DAEMON_THREADS; | 1263 | lload_daemon_threads = SLAPD_MAX_DAEMON_THREADS; |
2065 | 1250 | 1264 | ||
2066 | diff --git a/servers/lloadd/libevent_support.c b/servers/lloadd/libevent_support.c | |||
2067 | index 2f94c5e..8d7378c 100644 | |||
2068 | --- a/servers/lloadd/libevent_support.c | |||
2069 | +++ b/servers/lloadd/libevent_support.c | |||
2070 | @@ -131,6 +131,12 @@ lload_libevent_cond_timedwait( | |||
2071 | 131 | return ldap_pvt_thread_cond_wait( cond, mutex ); | 131 | return ldap_pvt_thread_cond_wait( cond, mutex ); |
2072 | 132 | } | 132 | } |
2073 | 133 | 133 | ||
2074 | 134 | unsigned long | ||
2075 | 135 | lload_libevent_thread_self( void ) | ||
2076 | 136 | { | ||
2077 | 137 | return (unsigned long)ldap_pvt_thread_self(); | ||
2078 | 138 | } | ||
2079 | 139 | |||
2080 | 134 | int | 140 | int |
2081 | 135 | lload_libevent_init( void ) | 141 | lload_libevent_init( void ) |
2082 | 136 | { | 142 | { |
2083 | @@ -160,7 +166,7 @@ lload_libevent_init( void ) | |||
2084 | 160 | 166 | ||
2085 | 161 | evthread_set_lock_callbacks( &cbs ); | 167 | evthread_set_lock_callbacks( &cbs ); |
2086 | 162 | evthread_set_condition_callbacks( &cond_cbs ); | 168 | evthread_set_condition_callbacks( &cond_cbs ); |
2088 | 163 | evthread_set_id_callback( ldap_pvt_thread_self ); | 169 | evthread_set_id_callback( lload_libevent_thread_self ); |
2089 | 164 | return 0; | 170 | return 0; |
2090 | 165 | } | 171 | } |
2091 | 166 | 172 | ||
2092 | diff --git a/servers/lloadd/module_init.c b/servers/lloadd/module_init.c | |||
2093 | index 1475538..d4eebf6 100644 | |||
2094 | --- a/servers/lloadd/module_init.c | |||
2095 | +++ b/servers/lloadd/module_init.c | |||
2096 | @@ -145,7 +145,6 @@ lload_back_initialize( BackendInfo *bi ) | |||
2097 | 145 | { | 145 | { |
2098 | 146 | bi->bi_flags = SLAP_BFLAG_STANDALONE; | 146 | bi->bi_flags = SLAP_BFLAG_STANDALONE; |
2099 | 147 | bi->bi_open = lload_back_open; | 147 | bi->bi_open = lload_back_open; |
2100 | 148 | bi->bi_config = config_generic_wrapper; | ||
2101 | 149 | bi->bi_pause = lload_pause_cb; | 148 | bi->bi_pause = lload_pause_cb; |
2102 | 150 | bi->bi_unpause = lload_unpause_cb; | 149 | bi->bi_unpause = lload_unpause_cb; |
2103 | 151 | bi->bi_close = lload_back_close; | 150 | bi->bi_close = lload_back_close; |
2104 | diff --git a/servers/lloadd/upstream.c b/servers/lloadd/upstream.c | |||
2105 | index 6824fa8..5e64029 100644 | |||
2106 | --- a/servers/lloadd/upstream.c | |||
2107 | +++ b/servers/lloadd/upstream.c | |||
2108 | @@ -118,17 +118,22 @@ static int | |||
2109 | 118 | handle_unsolicited( LloadConnection *c, BerElement *ber ) | 118 | handle_unsolicited( LloadConnection *c, BerElement *ber ) |
2110 | 119 | { | 119 | { |
2111 | 120 | CONNECTION_ASSERT_LOCKED(c); | 120 | CONNECTION_ASSERT_LOCKED(c); |
2114 | 121 | if ( c->c_state != LLOAD_C_PREPARING ) { | 121 | |
2115 | 122 | c->c_state = LLOAD_C_CLOSING; | 122 | assert( c->c_state != LLOAD_C_INVALID ); |
2116 | 123 | if ( c->c_state == LLOAD_C_DYING ) { | ||
2117 | 124 | CONNECTION_UNLOCK(c); | ||
2118 | 125 | goto out; | ||
2119 | 123 | } | 126 | } |
2120 | 127 | c->c_state = LLOAD_C_CLOSING; | ||
2121 | 124 | 128 | ||
2122 | 125 | Debug( LDAP_DEBUG_STATS, "handle_unsolicited: " | 129 | Debug( LDAP_DEBUG_STATS, "handle_unsolicited: " |
2123 | 126 | "teardown for upstream connection connid=%lu\n", | 130 | "teardown for upstream connection connid=%lu\n", |
2124 | 127 | c->c_connid ); | 131 | c->c_connid ); |
2125 | 128 | 132 | ||
2126 | 129 | CONNECTION_DESTROY(c); | 133 | CONNECTION_DESTROY(c); |
2127 | 130 | ber_free( ber, 1 ); | ||
2128 | 131 | 134 | ||
2129 | 135 | out: | ||
2130 | 136 | ber_free( ber, 1 ); | ||
2131 | 132 | return -1; | 137 | return -1; |
2132 | 133 | } | 138 | } |
2133 | 134 | 139 | ||
2134 | diff --git a/servers/slapd/aci.c b/servers/slapd/aci.c | |||
2135 | index 33e6074..c8cc41d 100644 | |||
2136 | --- a/servers/slapd/aci.c | |||
2137 | +++ b/servers/slapd/aci.c | |||
2138 | @@ -39,6 +39,7 @@ | |||
2139 | 39 | #include "slap.h" | 39 | #include "slap.h" |
2140 | 40 | #include "lber_pvt.h" | 40 | #include "lber_pvt.h" |
2141 | 41 | #include "lutil.h" | 41 | #include "lutil.h" |
2142 | 42 | #include "slap-config.h" | ||
2143 | 42 | 43 | ||
2144 | 43 | /* use most appropriate size */ | 44 | /* use most appropriate size */ |
2145 | 44 | #define ACI_BUF_SIZE 1024 | 45 | #define ACI_BUF_SIZE 1024 |
2146 | @@ -741,8 +742,7 @@ aci_init( void ) | |||
2147 | 741 | 742 | ||
2148 | 742 | static int | 743 | static int |
2149 | 743 | dynacl_aci_parse( | 744 | dynacl_aci_parse( |
2152 | 744 | const char *fname, | 745 | ConfigArgs *c, |
2151 | 745 | int lineno, | ||
2153 | 746 | const char *opts, | 746 | const char *opts, |
2154 | 747 | slap_style_t sty, | 747 | slap_style_t sty, |
2155 | 748 | const char *right, | 748 | const char *right, |
2156 | @@ -752,17 +752,19 @@ dynacl_aci_parse( | |||
2157 | 752 | const char *text = NULL; | 752 | const char *text = NULL; |
2158 | 753 | 753 | ||
2159 | 754 | if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { | 754 | if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { |
2163 | 755 | fprintf( stderr, "%s: line %d: " | 755 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2164 | 756 | "inappropriate style \"%s\" in \"aci\" by clause\n", | 756 | "inappropriate style \"%s\" in \"aci\" by clause", |
2165 | 757 | fname, lineno, style_strings[sty] ); | 757 | style_strings[sty] ); |
2166 | 758 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
2167 | 758 | return -1; | 759 | return -1; |
2168 | 759 | } | 760 | } |
2169 | 760 | 761 | ||
2170 | 761 | if ( right != NULL && *right != '\0' ) { | 762 | if ( right != NULL && *right != '\0' ) { |
2171 | 762 | if ( slap_str2ad( right, &ad, &text ) != LDAP_SUCCESS ) { | 763 | if ( slap_str2ad( right, &ad, &text ) != LDAP_SUCCESS ) { |
2175 | 763 | fprintf( stderr, | 764 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2176 | 764 | "%s: line %d: aci \"%s\": %s\n", | 765 | "aci \"%s\": %s", |
2177 | 765 | fname, lineno, right, text ); | 766 | right, text ); |
2178 | 767 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
2179 | 766 | return -1; | 768 | return -1; |
2180 | 767 | } | 769 | } |
2181 | 768 | 770 | ||
2182 | @@ -771,10 +773,10 @@ dynacl_aci_parse( | |||
2183 | 771 | } | 773 | } |
2184 | 772 | 774 | ||
2185 | 773 | if ( !is_at_syntax( ad->ad_type, SLAPD_ACI_SYNTAX) ) { | 775 | if ( !is_at_syntax( ad->ad_type, SLAPD_ACI_SYNTAX) ) { |
2190 | 774 | fprintf( stderr, "%s: line %d: " | 776 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2191 | 775 | "aci \"%s\": inappropriate syntax: %s\n", | 777 | "aci \"%s\": inappropriate syntax: %s", |
2192 | 776 | fname, lineno, right, | 778 | right, ad->ad_type->sat_syntax_oid ); |
2193 | 777 | ad->ad_type->sat_syntax_oid ); | 779 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2194 | 778 | return -1; | 780 | return -1; |
2195 | 779 | } | 781 | } |
2196 | 780 | 782 | ||
2197 | diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c | |||
2198 | index 60b74e3..f08de6a 100644 | |||
2199 | --- a/servers/slapd/aclparse.c | |||
2200 | +++ b/servers/slapd/aclparse.c | |||
2201 | @@ -37,6 +37,7 @@ | |||
2202 | 37 | #include "slap.h" | 37 | #include "slap.h" |
2203 | 38 | #include "lber_pvt.h" | 38 | #include "lber_pvt.h" |
2204 | 39 | #include "lutil.h" | 39 | #include "lutil.h" |
2205 | 40 | #include "slap-config.h" | ||
2206 | 40 | 41 | ||
2207 | 41 | static const char style_base[] = "base"; | 42 | static const char style_base[] = "base"; |
2208 | 42 | const char *style_strings[] = { | 43 | const char *style_strings[] = { |
2209 | @@ -76,8 +77,7 @@ static int check_scope( BackendDB *be, AccessControl *a ); | |||
2210 | 76 | #ifdef SLAP_DYNACL | 77 | #ifdef SLAP_DYNACL |
2211 | 77 | static int | 78 | static int |
2212 | 78 | slap_dynacl_config( | 79 | slap_dynacl_config( |
2215 | 79 | const char *fname, | 80 | struct config_args_s *c, |
2214 | 80 | int lineno, | ||
2216 | 81 | Access *b, | 81 | Access *b, |
2217 | 82 | const char *name, | 82 | const char *name, |
2218 | 83 | const char *opts, | 83 | const char *opts, |
2219 | @@ -89,9 +89,10 @@ slap_dynacl_config( | |||
2220 | 89 | 89 | ||
2221 | 90 | for ( da = b->a_dynacl; da; da = da->da_next ) { | 90 | for ( da = b->a_dynacl; da; da = da->da_next ) { |
2222 | 91 | if ( strcasecmp( da->da_name, name ) == 0 ) { | 91 | if ( strcasecmp( da->da_name, name ) == 0 ) { |
2226 | 92 | Debug( LDAP_DEBUG_ANY, | 92 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2227 | 93 | "%s: line %d: dynacl \"%s\" already specified.\n", | 93 | "dynacl \"%s\" already specified", |
2228 | 94 | fname, lineno, name ); | 94 | name ); |
2229 | 95 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
2230 | 95 | return acl_usage(); | 96 | return acl_usage(); |
2231 | 96 | } | 97 | } |
2232 | 97 | } | 98 | } |
2233 | @@ -105,7 +106,7 @@ slap_dynacl_config( | |||
2234 | 105 | *tmp = *da; | 106 | *tmp = *da; |
2235 | 106 | 107 | ||
2236 | 107 | if ( tmp->da_parse ) { | 108 | if ( tmp->da_parse ) { |
2238 | 108 | rc = ( *tmp->da_parse )( fname, lineno, opts, sty, right, &tmp->da_private ); | 109 | rc = ( *tmp->da_parse )( c, opts, sty, right, &tmp->da_private ); |
2239 | 109 | if ( rc ) { | 110 | if ( rc ) { |
2240 | 110 | ch_free( tmp ); | 111 | ch_free( tmp ); |
2241 | 111 | return rc; | 112 | return rc; |
2242 | @@ -119,8 +120,8 @@ slap_dynacl_config( | |||
2243 | 119 | } | 120 | } |
2244 | 120 | #endif /* SLAP_DYNACL */ | 121 | #endif /* SLAP_DYNACL */ |
2245 | 121 | 122 | ||
2248 | 122 | static void | 123 | static int |
2249 | 123 | regtest(const char *fname, int lineno, char *pat) { | 124 | regtest(struct config_args_s *c, char *pat) { |
2250 | 124 | int e; | 125 | int e; |
2251 | 125 | regex_t re; | 126 | regex_t re; |
2252 | 126 | 127 | ||
2253 | @@ -156,25 +157,27 @@ regtest(const char *fname, int lineno, char *pat) { | |||
2254 | 156 | 157 | ||
2255 | 157 | *dp = '\0'; | 158 | *dp = '\0'; |
2256 | 158 | if ( size >= (sizeof(buf) - 1) ) { | 159 | if ( size >= (sizeof(buf) - 1) ) { |
2260 | 159 | Debug( LDAP_DEBUG_ANY, | 160 | snprintf( c->cr_msg, sizeof( c->cr_msg), |
2261 | 160 | "%s: line %d: regular expression \"%s\" too large\n", | 161 | "regular expression too large \"%s\"", pat); |
2262 | 161 | fname, lineno, pat ); | 162 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2263 | 162 | (void)acl_usage(); | 163 | (void)acl_usage(); |
2265 | 163 | exit( EXIT_FAILURE ); | 164 | return -1; |
2266 | 164 | } | 165 | } |
2267 | 165 | 166 | ||
2269 | 166 | if ((e = regcomp(&re, buf, REG_EXTENDED|REG_ICASE))) { | 167 | if ( (e = regcomp(&re, buf, REG_EXTENDED|REG_ICASE)) ) { |
2270 | 167 | char error[ SLAP_TEXT_BUFLEN ]; | 168 | char error[ SLAP_TEXT_BUFLEN ]; |
2271 | 168 | 169 | ||
2272 | 169 | regerror(e, &re, error, sizeof(error)); | 170 | regerror(e, &re, error, sizeof(error)); |
2273 | 170 | 171 | ||
2277 | 171 | Debug(LDAP_DEBUG_ANY, | 172 | snprintf( c->cr_msg, sizeof ( c->cr_msg ), |
2278 | 172 | "%s: line %d: regular expression \"%s\" bad because of %s\n", | 173 | "regular expression \"%s\" bad because of %s", pat, error); |
2279 | 173 | fname, lineno, pat, error ); | 174 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2280 | 174 | acl_usage(); | 175 | acl_usage(); |
2282 | 175 | exit( EXIT_FAILURE ); | 176 | regfree(&re); |
2283 | 177 | return -1; | ||
2284 | 176 | } | 178 | } |
2285 | 177 | regfree(&re); | 179 | regfree(&re); |
2286 | 180 | return 0; | ||
2287 | 178 | } | 181 | } |
2288 | 179 | 182 | ||
2289 | 180 | /* | 183 | /* |
2290 | @@ -212,7 +215,7 @@ check_scope( BackendDB *be, AccessControl *a ) | |||
2291 | 212 | ber_len_t rebuflen; | 215 | ber_len_t rebuflen; |
2292 | 213 | regex_t re; | 216 | regex_t re; |
2293 | 214 | int rc; | 217 | int rc; |
2295 | 215 | 218 | ||
2296 | 216 | /* add trailing '$' to database suffix to form | 219 | /* add trailing '$' to database suffix to form |
2297 | 217 | * a simple trial regex pattern "<suffix>$" */ | 220 | * a simple trial regex pattern "<suffix>$" */ |
2298 | 218 | AC_MEMCPY( dnbuf, be->be_nsuffix[0].bv_val, | 221 | AC_MEMCPY( dnbuf, be->be_nsuffix[0].bv_val, |
2299 | @@ -319,11 +322,7 @@ regex_done:; | |||
2300 | 319 | 322 | ||
2301 | 320 | int | 323 | int |
2302 | 321 | parse_acl( | 324 | parse_acl( |
2308 | 322 | Backend *be, | 325 | struct config_args_s *c, |
2304 | 323 | const char *fname, | ||
2305 | 324 | int lineno, | ||
2306 | 325 | int argc, | ||
2307 | 326 | char **argv, | ||
2309 | 327 | int pos ) | 326 | int pos ) |
2310 | 328 | { | 327 | { |
2311 | 329 | int i; | 328 | int i; |
2312 | @@ -333,14 +332,19 @@ parse_acl( | |||
2313 | 333 | Access *b = NULL; | 332 | Access *b = NULL; |
2314 | 334 | int rc; | 333 | int rc; |
2315 | 335 | const char *text; | 334 | const char *text; |
2316 | 335 | Backend *be = c->be; | ||
2317 | 336 | const char *fname = c->fname; | ||
2318 | 337 | int lineno = c->lineno; | ||
2319 | 338 | int argc = c->argc; | ||
2320 | 339 | char **argv = c->argv; | ||
2321 | 336 | 340 | ||
2322 | 337 | for ( i = 1; i < argc; i++ ) { | 341 | for ( i = 1; i < argc; i++ ) { |
2323 | 338 | /* to clause - select which entries are protected */ | 342 | /* to clause - select which entries are protected */ |
2324 | 339 | if ( strcasecmp( argv[i], "to" ) == 0 ) { | 343 | if ( strcasecmp( argv[i], "to" ) == 0 ) { |
2325 | 340 | if ( a != NULL ) { | 344 | if ( a != NULL ) { |
2329 | 341 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 345 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2330 | 342 | "only one to clause allowed in access line\n", | 346 | "only one to clause allowed in access line" ); |
2331 | 343 | fname, lineno ); | 347 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2332 | 344 | goto fail; | 348 | goto fail; |
2333 | 345 | } | 349 | } |
2334 | 346 | a = (AccessControl *) ch_calloc( 1, sizeof(AccessControl) ); | 350 | a = (AccessControl *) ch_calloc( 1, sizeof(AccessControl) ); |
2335 | @@ -355,10 +359,9 @@ parse_acl( | |||
2336 | 355 | if ( !BER_BVISEMPTY( &a->acl_dn_pat ) || | 359 | if ( !BER_BVISEMPTY( &a->acl_dn_pat ) || |
2337 | 356 | a->acl_dn_style != ACL_STYLE_REGEX ) | 360 | a->acl_dn_style != ACL_STYLE_REGEX ) |
2338 | 357 | { | 361 | { |
2343 | 358 | Debug( LDAP_DEBUG_ANY, | 362 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2344 | 359 | "%s: line %d: dn pattern" | 363 | "dn pattern already specified in to clause." ); |
2345 | 360 | " already specified in to clause.\n", | 364 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2342 | 361 | fname, lineno ); | ||
2346 | 362 | goto fail; | 365 | goto fail; |
2347 | 363 | } | 366 | } |
2348 | 364 | 367 | ||
2349 | @@ -370,9 +373,9 @@ parse_acl( | |||
2350 | 370 | split( left, '.', &left, &style ); | 373 | split( left, '.', &left, &style ); |
2351 | 371 | 374 | ||
2352 | 372 | if ( right == NULL ) { | 375 | if ( right == NULL ) { |
2356 | 373 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 376 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2357 | 374 | "missing \"=\" in \"%s\" in to clause\n", | 377 | "missing \"=\" in \"%s\" in to clause", left ); |
2358 | 375 | fname, lineno, left ); | 378 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2359 | 376 | goto fail; | 379 | goto fail; |
2360 | 377 | } | 380 | } |
2361 | 378 | 381 | ||
2362 | @@ -380,10 +383,9 @@ parse_acl( | |||
2363 | 380 | if ( !BER_BVISEMPTY( &a->acl_dn_pat ) || | 383 | if ( !BER_BVISEMPTY( &a->acl_dn_pat ) || |
2364 | 381 | a->acl_dn_style != ACL_STYLE_REGEX ) | 384 | a->acl_dn_style != ACL_STYLE_REGEX ) |
2365 | 382 | { | 385 | { |
2370 | 383 | Debug( LDAP_DEBUG_ANY, | 386 | snprintf( c->cr_msg, sizeof( c->cr_msg), |
2371 | 384 | "%s: line %d: dn pattern" | 387 | "dn pattern already specified in to clause" ); |
2372 | 385 | " already specified in to clause.\n", | 388 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2369 | 386 | fname, lineno ); | ||
2373 | 387 | goto fail; | 389 | goto fail; |
2374 | 388 | } | 390 | } |
2375 | 389 | 391 | ||
2376 | @@ -424,12 +426,12 @@ parse_acl( | |||
2377 | 424 | a->acl_dn_style = ACL_STYLE_BASE; | 426 | a->acl_dn_style = ACL_STYLE_BASE; |
2378 | 425 | ber_str2bv( right, 0, 1, &a->acl_dn_pat ); | 427 | ber_str2bv( right, 0, 1, &a->acl_dn_pat ); |
2379 | 426 | 428 | ||
2384 | 427 | } else if ( strcmp(right, "*") == 0 | 429 | } else if ( strcmp(right, "*") == 0 |
2385 | 428 | || strcmp(right, ".*") == 0 | 430 | || strcmp(right, ".*") == 0 |
2386 | 429 | || strcmp(right, ".*$") == 0 | 431 | || strcmp(right, ".*$") == 0 |
2387 | 430 | || strcmp(right, "^.*") == 0 | 432 | || strcmp(right, "^.*") == 0 |
2388 | 431 | || strcmp(right, "^.*$") == 0 | 433 | || strcmp(right, "^.*$") == 0 |
2390 | 432 | || strcmp(right, ".*$$") == 0 | 434 | || strcmp(right, ".*$$") == 0 |
2391 | 433 | || strcmp(right, "^.*$$") == 0 ) | 435 | || strcmp(right, "^.*$$") == 0 ) |
2392 | 434 | { | 436 | { |
2393 | 435 | ber_str2bv( "*", STRLENOF("*"), 1, &a->acl_dn_pat ); | 437 | ber_str2bv( "*", STRLENOF("*"), 1, &a->acl_dn_pat ); |
2394 | @@ -439,9 +441,9 @@ parse_acl( | |||
2395 | 439 | } | 441 | } |
2396 | 440 | 442 | ||
2397 | 441 | } else { | 443 | } else { |
2401 | 442 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 444 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2402 | 443 | "unknown dn style \"%s\" in to clause\n", | 445 | "unknown dn style \"%s\" in to clause", style ); |
2403 | 444 | fname, lineno, style ); | 446 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2404 | 445 | goto fail; | 447 | goto fail; |
2405 | 446 | } | 448 | } |
2406 | 447 | 449 | ||
2407 | @@ -450,9 +452,9 @@ parse_acl( | |||
2408 | 450 | 452 | ||
2409 | 451 | if ( strcasecmp( left, "filter" ) == 0 ) { | 453 | if ( strcasecmp( left, "filter" ) == 0 ) { |
2410 | 452 | if ( (a->acl_filter = str2filter( right )) == NULL ) { | 454 | if ( (a->acl_filter = str2filter( right )) == NULL ) { |
2414 | 453 | Debug( LDAP_DEBUG_ANY, | 455 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2415 | 454 | "%s: line %d: bad filter \"%s\" in to clause\n", | 456 | "bad filter \"%s\" in to clause", right ); |
2416 | 455 | fname, lineno, right ); | 457 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2417 | 456 | goto fail; | 458 | goto fail; |
2418 | 457 | } | 459 | } |
2419 | 458 | 460 | ||
2420 | @@ -460,37 +462,36 @@ parse_acl( | |||
2421 | 460 | || strcasecmp( left, "attrs" ) == 0 ) /* DOCUMENTED */ | 462 | || strcasecmp( left, "attrs" ) == 0 ) /* DOCUMENTED */ |
2422 | 461 | { | 463 | { |
2423 | 462 | if ( strcasecmp( left, "attr" ) == 0 ) { | 464 | if ( strcasecmp( left, "attr" ) == 0 ) { |
2429 | 463 | Debug( LDAP_DEBUG_ANY, | 465 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2430 | 464 | "%s: line %d: \"attr\" " | 466 | "\"attr\" is deprecated (and undocumented); " |
2431 | 465 | "is deprecated (and undocumented); " | 467 | "use \"attrs\" instead"); |
2432 | 466 | "use \"attrs\" instead.\n", | 468 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2428 | 467 | fname, lineno ); | ||
2433 | 468 | } | 469 | } |
2434 | 469 | 470 | ||
2435 | 470 | a->acl_attrs = str2anlist( a->acl_attrs, | 471 | a->acl_attrs = str2anlist( a->acl_attrs, |
2436 | 471 | right, "," ); | 472 | right, "," ); |
2437 | 472 | if ( a->acl_attrs == NULL ) { | 473 | if ( a->acl_attrs == NULL ) { |
2441 | 473 | Debug( LDAP_DEBUG_ANY, | 474 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2442 | 474 | "%s: line %d: unknown attr \"%s\" in to clause\n", | 475 | "unknown attr \"%s\" in to clause", right ); |
2443 | 475 | fname, lineno, right ); | 476 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2444 | 476 | goto fail; | 477 | goto fail; |
2445 | 477 | } | 478 | } |
2446 | 478 | 479 | ||
2447 | 479 | } else if ( strncasecmp( left, "val", 3 ) == 0 ) { | 480 | } else if ( strncasecmp( left, "val", 3 ) == 0 ) { |
2448 | 480 | struct berval bv; | 481 | struct berval bv; |
2449 | 481 | char *mr; | 482 | char *mr; |
2451 | 482 | 483 | ||
2452 | 483 | if ( !BER_BVISEMPTY( &a->acl_attrval ) ) { | 484 | if ( !BER_BVISEMPTY( &a->acl_attrval ) ) { |
2456 | 484 | Debug( LDAP_DEBUG_ANY, | 485 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2457 | 485 | "%s: line %d: attr val already specified in to clause.\n", | 486 | "attr val already specified in to clause" ); |
2458 | 486 | fname, lineno ); | 487 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2459 | 487 | goto fail; | 488 | goto fail; |
2460 | 488 | } | 489 | } |
2461 | 489 | if ( a->acl_attrs == NULL || !BER_BVISEMPTY( &a->acl_attrs[1].an_name ) ) | 490 | if ( a->acl_attrs == NULL || !BER_BVISEMPTY( &a->acl_attrs[1].an_name ) ) |
2462 | 490 | { | 491 | { |
2466 | 491 | Debug( LDAP_DEBUG_ANY, | 492 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2467 | 492 | "%s: line %d: attr val requires a single attribute.\n", | 493 | "attr val requires a single attribute"); |
2468 | 493 | fname, lineno ); | 494 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2469 | 494 | goto fail; | 495 | goto fail; |
2470 | 495 | } | 496 | } |
2471 | 496 | 497 | ||
2472 | @@ -504,23 +505,23 @@ parse_acl( | |||
2473 | 504 | 505 | ||
2474 | 505 | a->acl_attrval_mr = mr_find( mr ); | 506 | a->acl_attrval_mr = mr_find( mr ); |
2475 | 506 | if ( a->acl_attrval_mr == NULL ) { | 507 | if ( a->acl_attrval_mr == NULL ) { |
2479 | 507 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 508 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2480 | 508 | "invalid matching rule \"%s\".\n", | 509 | "invalid matching rule \"%s\"", mr); |
2481 | 509 | fname, lineno, mr ); | 510 | Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg ); |
2482 | 510 | goto fail; | 511 | goto fail; |
2483 | 511 | } | 512 | } |
2484 | 512 | 513 | ||
2485 | 513 | if( !mr_usable_with_at( a->acl_attrval_mr, a->acl_attrs[ 0 ].an_desc->ad_type ) ) | 514 | if( !mr_usable_with_at( a->acl_attrval_mr, a->acl_attrs[ 0 ].an_desc->ad_type ) ) |
2486 | 514 | { | 515 | { |
2492 | 515 | Debug(LDAP_DEBUG_ANY, | 516 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2493 | 516 | "%s: line %d: matching rule \"%s\" use " "with attr \"%s\" not appropriate.\n", | 517 | "matching rule \"%s\" use " "with attr \"%s\" not appropriate", |
2494 | 517 | fname, lineno, | 518 | mr, |
2495 | 518 | mr, | 519 | a->acl_attrs[0].an_name.bv_val ); |
2496 | 519 | a->acl_attrs[0].an_name.bv_val ); | 520 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c-> log, c->cr_msg ); |
2497 | 520 | goto fail; | 521 | goto fail; |
2498 | 521 | } | 522 | } |
2499 | 522 | } | 523 | } |
2501 | 523 | 524 | ||
2502 | 524 | if ( style != NULL ) { | 525 | if ( style != NULL ) { |
2503 | 525 | if ( strcasecmp( style, "regex" ) == 0 ) { | 526 | if ( strcasecmp( style, "regex" ) == 0 ) { |
2504 | 526 | int e = regcomp( &a->acl_attrval_re, bv.bv_val, | 527 | int e = regcomp( &a->acl_attrval_re, bv.bv_val, |
2505 | @@ -529,9 +530,10 @@ parse_acl( | |||
2506 | 529 | char err[SLAP_TEXT_BUFLEN]; | 530 | char err[SLAP_TEXT_BUFLEN]; |
2507 | 530 | 531 | ||
2508 | 531 | regerror( e, &a->acl_attrval_re, err, sizeof( err ) ); | 532 | regerror( e, &a->acl_attrval_re, err, sizeof( err ) ); |
2512 | 532 | Debug(LDAP_DEBUG_ANY, | 533 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2513 | 533 | "%s: line %d: regular expression \"%s\" bad because of %s\n", | 534 | "regular expression \"%s\" bad because of %s", |
2514 | 534 | fname, lineno, right, err ); | 535 | right, err ); |
2515 | 536 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
2516 | 535 | goto fail; | 537 | goto fail; |
2517 | 536 | } | 538 | } |
2518 | 537 | a->acl_attrval_style = ACL_STYLE_REGEX; | 539 | a->acl_attrval_style = ACL_STYLE_REGEX; |
2519 | @@ -561,34 +563,31 @@ parse_acl( | |||
2520 | 561 | } else if ( !strcasecmp( style, "children" ) ) { | 563 | } else if ( !strcasecmp( style, "children" ) ) { |
2521 | 562 | a->acl_attrval_style = ACL_STYLE_CHILDREN; | 564 | a->acl_attrval_style = ACL_STYLE_CHILDREN; |
2522 | 563 | } else { | 565 | } else { |
2527 | 564 | Debug(LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, | 566 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2528 | 565 | "%s: line %d: unknown val.<style> \"%s\" for attributeType \"%s\" " "with DN syntax.\n", | 567 | "unknown val.<style> \"%s\" for attributeType \"%s\" " "with DN syntax", |
2525 | 566 | fname, | ||
2526 | 567 | lineno, | ||
2529 | 568 | style, | 568 | style, |
2530 | 569 | a->acl_attrs[0].an_desc->ad_cname.bv_val ); | 569 | a->acl_attrs[0].an_desc->ad_cname.bv_val ); |
2531 | 570 | Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); | ||
2532 | 570 | goto fail; | 571 | goto fail; |
2533 | 571 | } | 572 | } |
2534 | 572 | 573 | ||
2535 | 573 | rc = dnNormalize( 0, NULL, NULL, &bv, &a->acl_attrval, NULL ); | 574 | rc = dnNormalize( 0, NULL, NULL, &bv, &a->acl_attrval, NULL ); |
2536 | 574 | if ( rc != LDAP_SUCCESS ) { | 575 | if ( rc != LDAP_SUCCESS ) { |
2541 | 575 | Debug(LDAP_DEBUG_ANY, | 576 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2542 | 576 | "%s: line %d: unable to normalize DN \"%s\" " "for attributeType \"%s\" (%d).\n", | 577 | "unable to normalize DN \"%s\" " "for attributeType \"%s\" (%d)", |
2539 | 577 | fname, | ||
2540 | 578 | lineno, | ||
2543 | 579 | bv.bv_val, | 578 | bv.bv_val, |
2544 | 580 | a->acl_attrs[0].an_desc->ad_cname.bv_val, | 579 | a->acl_attrs[0].an_desc->ad_cname.bv_val, |
2545 | 581 | rc ); | 580 | rc ); |
2546 | 581 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
2547 | 582 | goto fail; | 582 | goto fail; |
2548 | 583 | } | 583 | } |
2549 | 584 | 584 | ||
2550 | 585 | } else { | 585 | } else { |
2553 | 586 | Debug(LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, | 586 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2554 | 587 | "%s: line %d: unknown val.<style> \"%s\" for attributeType \"%s\".\n", | 587 | "unknown val.<style> \"%s\" for attributeType \"%s\"", |
2555 | 588 | fname, | 588 | fname, |
2556 | 589 | lineno, | ||
2557 | 590 | style, | ||
2558 | 591 | a->acl_attrs[0].an_desc->ad_cname.bv_val ); | 589 | a->acl_attrs[0].an_desc->ad_cname.bv_val ); |
2559 | 590 | Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); | ||
2560 | 592 | goto fail; | 591 | goto fail; |
2561 | 593 | } | 592 | } |
2562 | 594 | } | 593 | } |
2563 | @@ -607,9 +606,10 @@ parse_acl( | |||
2564 | 607 | } | 606 | } |
2565 | 608 | 607 | ||
2566 | 609 | if ( a->acl_attrval_mr == NULL ) { | 608 | if ( a->acl_attrval_mr == NULL ) { |
2570 | 610 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 609 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2571 | 611 | "attr \"%s\" does not have an EQUALITY matching rule.\n", | 610 | "attr \"%s\" does not have an EQUALITY matching rule", |
2572 | 612 | fname, lineno, a->acl_attrs[ 0 ].an_name.bv_val ); | 611 | a->acl_attrs[ 0 ].an_name.bv_val ); |
2573 | 612 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
2574 | 613 | goto fail; | 613 | goto fail; |
2575 | 614 | } | 614 | } |
2576 | 615 | 615 | ||
2577 | @@ -622,42 +622,43 @@ parse_acl( | |||
2578 | 622 | &text, | 622 | &text, |
2579 | 623 | NULL ); | 623 | NULL ); |
2580 | 624 | if ( rc != LDAP_SUCCESS ) { | 624 | if ( rc != LDAP_SUCCESS ) { |
2585 | 625 | Debug(LDAP_DEBUG_ANY, | 625 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2586 | 626 | "%s: line %d: %s: line %d: " " attr \"%s\" normalization failed (%d: %s).\n", | 626 | "attr \"%s\" normalization failed (%d: %s).\n", |
2583 | 627 | fname, lineno, | ||
2584 | 628 | fname, lineno, | ||
2587 | 629 | a->acl_attrs[0].an_name.bv_val, | 627 | a->acl_attrs[0].an_name.bv_val, |
2588 | 630 | rc, text ); | 628 | rc, text ); |
2589 | 629 | Debug(LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
2590 | 631 | goto fail; | 630 | goto fail; |
2591 | 632 | } | 631 | } |
2592 | 633 | } | 632 | } |
2593 | 634 | 633 | ||
2594 | 635 | } else { | 634 | } else { |
2598 | 636 | Debug( LDAP_DEBUG_ANY, | 635 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2599 | 637 | "%s: line %d: expecting <what> got \"%s\"\n", | 636 | "expecting <what> got \"%s\"", |
2600 | 638 | fname, lineno, left ); | 637 | left ); |
2601 | 638 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
2602 | 639 | goto fail; | 639 | goto fail; |
2603 | 640 | } | 640 | } |
2604 | 641 | } | 641 | } |
2605 | 642 | 642 | ||
2607 | 643 | if ( !BER_BVISNULL( &a->acl_dn_pat ) && | 643 | if ( !BER_BVISNULL( &a->acl_dn_pat ) && |
2608 | 644 | ber_bvccmp( &a->acl_dn_pat, '*' ) ) | 644 | ber_bvccmp( &a->acl_dn_pat, '*' ) ) |
2609 | 645 | { | 645 | { |
2610 | 646 | free( a->acl_dn_pat.bv_val ); | 646 | free( a->acl_dn_pat.bv_val ); |
2611 | 647 | BER_BVZERO( &a->acl_dn_pat ); | 647 | BER_BVZERO( &a->acl_dn_pat ); |
2612 | 648 | a->acl_dn_style = ACL_STYLE_REGEX; | 648 | a->acl_dn_style = ACL_STYLE_REGEX; |
2613 | 649 | } | 649 | } |
2615 | 650 | 650 | ||
2616 | 651 | if ( !BER_BVISEMPTY( &a->acl_dn_pat ) || | 651 | if ( !BER_BVISEMPTY( &a->acl_dn_pat ) || |
2618 | 652 | a->acl_dn_style != ACL_STYLE_REGEX ) | 652 | a->acl_dn_style != ACL_STYLE_REGEX ) |
2619 | 653 | { | 653 | { |
2620 | 654 | if ( a->acl_dn_style != ACL_STYLE_REGEX ) { | 654 | if ( a->acl_dn_style != ACL_STYLE_REGEX ) { |
2621 | 655 | struct berval bv; | 655 | struct berval bv; |
2622 | 656 | rc = dnNormalize( 0, NULL, NULL, &a->acl_dn_pat, &bv, NULL); | 656 | rc = dnNormalize( 0, NULL, NULL, &a->acl_dn_pat, &bv, NULL); |
2623 | 657 | if ( rc != LDAP_SUCCESS ) { | 657 | if ( rc != LDAP_SUCCESS ) { |
2627 | 658 | Debug( LDAP_DEBUG_ANY, | 658 | snprintf( c->cr_msg, sizeof(c->cr_msg ), |
2628 | 659 | "%s: line %d: bad DN \"%s\" in to DN clause\n", | 659 | "bad DN \"%s\" in to DN clause", |
2629 | 660 | fname, lineno, a->acl_dn_pat.bv_val ); | 660 | a->acl_dn_pat.bv_val ); |
2630 | 661 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
2631 | 661 | goto fail; | 662 | goto fail; |
2632 | 662 | } | 663 | } |
2633 | 663 | free( a->acl_dn_pat.bv_val ); | 664 | free( a->acl_dn_pat.bv_val ); |
2634 | @@ -670,9 +671,10 @@ parse_acl( | |||
2635 | 670 | char err[ SLAP_TEXT_BUFLEN ]; | 671 | char err[ SLAP_TEXT_BUFLEN ]; |
2636 | 671 | 672 | ||
2637 | 672 | regerror( e, &a->acl_dn_re, err, sizeof( err ) ); | 673 | regerror( e, &a->acl_dn_re, err, sizeof( err ) ); |
2641 | 673 | Debug(LDAP_DEBUG_ANY, | 674 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2642 | 674 | "%s: line %d: regular expression \"%s\" bad because of %s\n", | 675 | "regular expression \"%s\" bad because of %s", |
2643 | 675 | fname, lineno, right, err ); | 676 | right, err ); |
2644 | 677 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
2645 | 676 | goto fail; | 678 | goto fail; |
2646 | 677 | } | 679 | } |
2647 | 678 | } | 680 | } |
2648 | @@ -681,9 +683,9 @@ parse_acl( | |||
2649 | 681 | /* by clause - select who has what access to entries */ | 683 | /* by clause - select who has what access to entries */ |
2650 | 682 | } else if ( strcasecmp( argv[i], "by" ) == 0 ) { | 684 | } else if ( strcasecmp( argv[i], "by" ) == 0 ) { |
2651 | 683 | if ( a == NULL ) { | 685 | if ( a == NULL ) { |
2655 | 684 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 686 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2656 | 685 | "to clause required before by clause in access line\n", | 687 | "to clause required before by clause in access line"); |
2657 | 686 | fname, lineno ); | 688 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2658 | 687 | goto fail; | 689 | goto fail; |
2659 | 688 | } | 690 | } |
2660 | 689 | 691 | ||
2661 | @@ -692,9 +694,9 @@ parse_acl( | |||
2662 | 692 | */ | 694 | */ |
2663 | 693 | 695 | ||
2664 | 694 | if ( ++i == argc ) { | 696 | if ( ++i == argc ) { |
2668 | 695 | Debug( LDAP_DEBUG_ANY, | 697 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2669 | 696 | "%s: line %d: premature EOL: expecting <who>\n", | 698 | "premature EOL: expecting <who>"); |
2670 | 697 | fname, lineno ); | 699 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2671 | 698 | goto fail; | 700 | goto fail; |
2672 | 699 | } | 701 | } |
2673 | 700 | 702 | ||
2674 | @@ -722,16 +724,14 @@ parse_acl( | |||
2675 | 722 | if ( style_level != NULL ) { | 724 | if ( style_level != NULL ) { |
2676 | 723 | char *p = strchr( style_level, '}' ); | 725 | char *p = strchr( style_level, '}' ); |
2677 | 724 | if ( p == NULL ) { | 726 | if ( p == NULL ) { |
2682 | 725 | Debug( LDAP_DEBUG_ANY, | 727 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2683 | 726 | "%s: line %d: premature eol: " | 728 | "premature eol: expecting closing '}' in \"level{n}\""); |
2684 | 727 | "expecting closing '}' in \"level{n}\"\n", | 729 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2681 | 728 | fname, lineno ); | ||
2685 | 729 | goto fail; | 730 | goto fail; |
2686 | 730 | } else if ( p == style_level ) { | 731 | } else if ( p == style_level ) { |
2691 | 731 | Debug( LDAP_DEBUG_ANY, | 732 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2692 | 732 | "%s: line %d: empty level " | 733 | "empty level in \"level{n}\""); |
2693 | 733 | "in \"level{n}\"\n", | 734 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2690 | 734 | fname, lineno ); | ||
2694 | 735 | goto fail; | 735 | goto fail; |
2695 | 736 | } | 736 | } |
2696 | 737 | p[0] = '\0'; | 737 | p[0] = '\0'; |
2697 | @@ -762,10 +762,9 @@ parse_acl( | |||
2698 | 762 | } else if ( strcasecmp( style, "level" ) == 0 ) | 762 | } else if ( strcasecmp( style, "level" ) == 0 ) |
2699 | 763 | { | 763 | { |
2700 | 764 | if ( lutil_atoi( &level, style_level ) != 0 ) { | 764 | if ( lutil_atoi( &level, style_level ) != 0 ) { |
2705 | 765 | Debug( LDAP_DEBUG_ANY, | 765 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2706 | 766 | "%s: line %d: unable to parse level " | 766 | "unable to parse level in \"level{n}\""); |
2707 | 767 | "in \"level{n}\"\n", | 767 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2704 | 768 | fname, lineno ); | ||
2708 | 769 | goto fail; | 768 | goto fail; |
2709 | 770 | } | 769 | } |
2710 | 771 | 770 | ||
2711 | @@ -782,26 +781,25 @@ parse_acl( | |||
2712 | 782 | 781 | ||
2713 | 783 | } else if ( strcasecmp( style, "ipv6" ) == 0 ) { | 782 | } else if ( strcasecmp( style, "ipv6" ) == 0 ) { |
2714 | 784 | #ifndef LDAP_PF_INET6 | 783 | #ifndef LDAP_PF_INET6 |
2718 | 785 | Debug( LDAP_DEBUG_ANY, | 784 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2719 | 786 | "%s: line %d: IPv6 not supported\n", | 785 | "IPv6 not supported"); |
2720 | 787 | fname, lineno ); | 786 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2721 | 788 | #endif /* ! LDAP_PF_INET6 */ | 787 | #endif /* ! LDAP_PF_INET6 */ |
2722 | 789 | sty = ACL_STYLE_IPV6; | 788 | sty = ACL_STYLE_IPV6; |
2723 | 790 | 789 | ||
2724 | 791 | } else if ( strcasecmp( style, "path" ) == 0 ) { | 790 | } else if ( strcasecmp( style, "path" ) == 0 ) { |
2725 | 792 | sty = ACL_STYLE_PATH; | 791 | sty = ACL_STYLE_PATH; |
2726 | 793 | #ifndef LDAP_PF_LOCAL | 792 | #ifndef LDAP_PF_LOCAL |
2731 | 794 | Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, | 793 | snprintf( c->cr_msg, sizeof( c->cr_msg), |
2732 | 795 | "%s: line %d: " | 794 | "\"path\" style modifier is useless without local"); |
2733 | 796 | "\"path\" style modifier is useless without local.\n", | 795 | Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); |
2730 | 797 | fname, lineno ); | ||
2734 | 798 | goto fail; | 796 | goto fail; |
2735 | 799 | #endif /* LDAP_PF_LOCAL */ | 797 | #endif /* LDAP_PF_LOCAL */ |
2736 | 800 | 798 | ||
2737 | 801 | } else { | 799 | } else { |
2741 | 802 | Debug( LDAP_DEBUG_ANY, | 800 | snprintf( c->cr_msg, sizeof ( c->cr_msg ), |
2742 | 803 | "%s: line %d: unknown style \"%s\" in by clause\n", | 801 | "unknown style \"%s\" in by clause", style ); |
2743 | 804 | fname, lineno, style ); | 802 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2744 | 805 | goto fail; | 803 | goto fail; |
2745 | 806 | } | 804 | } |
2746 | 807 | 805 | ||
2747 | @@ -810,9 +808,9 @@ parse_acl( | |||
2748 | 810 | { | 808 | { |
2749 | 811 | switch ( sty ) { | 809 | switch ( sty ) { |
2750 | 812 | case ACL_STYLE_REGEX: | 810 | case ACL_STYLE_REGEX: |
2754 | 813 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 811 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2755 | 814 | "\"regex\" style implies \"expand\" modifier.\n", | 812 | "\"regex\" style implies \"expand\" modifier" ); |
2756 | 815 | fname, lineno ); | 813 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2757 | 816 | goto fail; | 814 | goto fail; |
2758 | 817 | break; | 815 | break; |
2759 | 818 | 816 | ||
2760 | @@ -903,15 +901,15 @@ parse_acl( | |||
2761 | 903 | } else { | 901 | } else { |
2762 | 904 | acl_regex_normalized_dn( right, &bv ); | 902 | acl_regex_normalized_dn( right, &bv ); |
2763 | 905 | if ( !ber_bvccmp( &bv, '*' ) ) { | 903 | if ( !ber_bvccmp( &bv, '*' ) ) { |
2765 | 906 | regtest( fname, lineno, bv.bv_val ); | 904 | if ( regtest( c, bv.bv_val ) != 0) |
2766 | 905 | goto fail; | ||
2767 | 907 | } | 906 | } |
2768 | 908 | } | 907 | } |
2769 | 909 | 908 | ||
2770 | 910 | } else if ( right == NULL || *right == '\0' ) { | 909 | } else if ( right == NULL || *right == '\0' ) { |
2775 | 911 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 910 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2776 | 912 | "missing \"=\" in (or value after) \"%s\" " | 911 | "missing \"=\" in (or value after) \"%s\" in by clause", left ); |
2777 | 913 | "in by clause\n", | 912 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2774 | 914 | fname, lineno, left ); | ||
2778 | 915 | goto fail; | 913 | goto fail; |
2779 | 916 | 914 | ||
2780 | 917 | } else { | 915 | } else { |
2781 | @@ -924,9 +922,9 @@ parse_acl( | |||
2782 | 924 | 922 | ||
2783 | 925 | if ( !BER_BVISNULL( &bv ) ) { | 923 | if ( !BER_BVISNULL( &bv ) ) { |
2784 | 926 | if ( !BER_BVISEMPTY( &bdn->a_pat ) ) { | 924 | if ( !BER_BVISEMPTY( &bdn->a_pat ) ) { |
2788 | 927 | Debug( LDAP_DEBUG_ANY, | 925 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2789 | 928 | "%s: line %d: dn pattern already specified.\n", | 926 | "dn pattern already specified" ); |
2790 | 929 | fname, lineno ); | 927 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2791 | 930 | goto fail; | 928 | goto fail; |
2792 | 931 | } | 929 | } |
2793 | 932 | 930 | ||
2794 | @@ -939,9 +937,9 @@ parse_acl( | |||
2795 | 939 | rc = dnNormalize(0, NULL, NULL, | 937 | rc = dnNormalize(0, NULL, NULL, |
2796 | 940 | &bv, &bdn->a_pat, NULL); | 938 | &bv, &bdn->a_pat, NULL); |
2797 | 941 | if ( rc != LDAP_SUCCESS ) { | 939 | if ( rc != LDAP_SUCCESS ) { |
2801 | 942 | Debug( LDAP_DEBUG_ANY, | 940 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2802 | 943 | "%s: line %d: bad DN \"%s\" in by DN clause\n", | 941 | "bad DN \"%s\" in by DN clause", bv.bv_val ); |
2803 | 944 | fname, lineno, bv.bv_val ); | 942 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2804 | 945 | goto fail; | 943 | goto fail; |
2805 | 946 | } | 944 | } |
2806 | 947 | free( bv.bv_val ); | 945 | free( bv.bv_val ); |
2807 | @@ -950,10 +948,9 @@ parse_acl( | |||
2808 | 950 | && !BER_BVISNULL( &be->be_rootndn ) | 948 | && !BER_BVISNULL( &be->be_rootndn ) |
2809 | 951 | && dn_match( &bdn->a_pat, &be->be_rootndn ) ) | 949 | && dn_match( &bdn->a_pat, &be->be_rootndn ) ) |
2810 | 952 | { | 950 | { |
2815 | 953 | Debug( LDAP_DEBUG_ANY, | 951 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2816 | 954 | "%s: line %d: rootdn is always granted " | 952 | "rootdn is always granted unlimited privileges" ); |
2817 | 955 | "unlimited privileges.\n", | 953 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2814 | 956 | fname, lineno ); | ||
2818 | 957 | } | 954 | } |
2819 | 958 | 955 | ||
2820 | 959 | } else { | 956 | } else { |
2821 | @@ -980,32 +977,29 @@ parse_acl( | |||
2822 | 980 | bdn->a_expand = expand; | 977 | bdn->a_expand = expand; |
2823 | 981 | 978 | ||
2824 | 982 | } else { | 979 | } else { |
2828 | 983 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 980 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2829 | 984 | "\"expand\" used with no expansions in \"pattern\".\n", | 981 | "\"expand\" used with no expansions in \"pattern\""); |
2830 | 985 | fname, lineno ); | 982 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2831 | 986 | goto fail; | 983 | goto fail; |
2833 | 987 | } | 984 | } |
2834 | 988 | } | 985 | } |
2835 | 989 | if ( sty == ACL_STYLE_SELF ) { | 986 | if ( sty == ACL_STYLE_SELF ) { |
2836 | 990 | bdn->a_self_level = level; | 987 | bdn->a_self_level = level; |
2837 | 991 | 988 | ||
2838 | 992 | } else { | 989 | } else { |
2839 | 993 | if ( level < 0 ) { | 990 | if ( level < 0 ) { |
2844 | 994 | Debug( LDAP_DEBUG_ANY, | 991 | snprintf( c->cr_msg, sizeof( c ->cr_msg ), |
2845 | 995 | "%s: line %d: bad negative level \"%d\" " | 992 | "bad negative level \"%d\" in by DN clause", level ); |
2846 | 996 | "in by DN clause\n", | 993 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2843 | 997 | fname, lineno, level ); | ||
2847 | 998 | goto fail; | 994 | goto fail; |
2848 | 999 | } else if ( level == 1 ) { | 995 | } else if ( level == 1 ) { |
2853 | 1000 | Debug( LDAP_DEBUG_ANY, | 996 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2854 | 1001 | "%s: line %d: \"onelevel\" should be used " | 997 | "\"onelevel\" should be used instead of \"level{1}\" in by DN clause" ); |
2855 | 1002 | "instead of \"level{1}\" in by DN clause\n", | 998 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2852 | 1003 | fname, lineno ); | ||
2856 | 1004 | } else if ( level == 0 && sty == ACL_STYLE_LEVEL ) { | 999 | } else if ( level == 0 && sty == ACL_STYLE_LEVEL ) { |
2861 | 1005 | Debug( LDAP_DEBUG_ANY, | 1000 | snprintf ( c->cr_msg, sizeof( c->cr_msg ), |
2862 | 1006 | "%s: line %d: \"base\" should be used " | 1001 | "\"base\" should be used instead of \"level{0}\" in by DN clause" ); |
2863 | 1007 | "instead of \"level{0}\" in by DN clause\n", | 1002 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2860 | 1008 | fname, lineno ); | ||
2864 | 1009 | } | 1003 | } |
2865 | 1010 | 1004 | ||
2866 | 1011 | bdn->a_level = level; | 1005 | bdn->a_level = level; |
2867 | @@ -1015,27 +1009,25 @@ parse_acl( | |||
2868 | 1015 | 1009 | ||
2869 | 1016 | if ( strcasecmp( left, "dnattr" ) == 0 ) { | 1010 | if ( strcasecmp( left, "dnattr" ) == 0 ) { |
2870 | 1017 | if ( right == NULL || right[0] == '\0' ) { | 1011 | if ( right == NULL || right[0] == '\0' ) { |
2875 | 1018 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1012 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2876 | 1019 | "missing \"=\" in (or value after) \"%s\" " | 1013 | "missing \"=\" in (or value after) \"%s\" in by clause", left ); |
2877 | 1020 | "in by clause\n", | 1014 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2874 | 1021 | fname, lineno, left ); | ||
2878 | 1022 | goto fail; | 1015 | goto fail; |
2879 | 1023 | } | 1016 | } |
2880 | 1024 | 1017 | ||
2881 | 1025 | if( bdn->a_at != NULL ) { | 1018 | if( bdn->a_at != NULL ) { |
2885 | 1026 | Debug( LDAP_DEBUG_ANY, | 1019 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2886 | 1027 | "%s: line %d: dnattr already specified.\n", | 1020 | "dnattr already specified" ); |
2887 | 1028 | fname, lineno ); | 1021 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2888 | 1029 | goto fail; | 1022 | goto fail; |
2889 | 1030 | } | 1023 | } |
2890 | 1031 | 1024 | ||
2891 | 1032 | rc = slap_str2ad( right, &bdn->a_at, &text ); | 1025 | rc = slap_str2ad( right, &bdn->a_at, &text ); |
2892 | 1033 | 1026 | ||
2893 | 1034 | if( rc != LDAP_SUCCESS ) { | 1027 | if( rc != LDAP_SUCCESS ) { |
2898 | 1035 | Debug(LDAP_DEBUG_ANY, | 1028 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2899 | 1036 | "%s: line %d: dnattr \"%s\": %s\n", | 1029 | "dnattr \"%s\": %s", right, text ); |
2900 | 1037 | fname, lineno, right, | 1030 | Debug(LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2897 | 1038 | text ); | ||
2901 | 1039 | goto fail; | 1031 | goto fail; |
2902 | 1040 | } | 1032 | } |
2903 | 1041 | 1033 | ||
2904 | @@ -1045,18 +1037,17 @@ parse_acl( | |||
2905 | 1045 | !is_at_syntax( bdn->a_at->ad_type, | 1037 | !is_at_syntax( bdn->a_at->ad_type, |
2906 | 1046 | SLAPD_NAMEUID_SYNTAX )) | 1038 | SLAPD_NAMEUID_SYNTAX )) |
2907 | 1047 | { | 1039 | { |
2912 | 1048 | Debug(LDAP_DEBUG_ANY, | 1040 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2913 | 1049 | "%s: line %d: dnattr \"%s\": " "inappropriate syntax: %s\n\n", | 1041 | "dnattr \"%s\": " "inappropriate syntax: %s", |
2914 | 1050 | fname, lineno, right, | 1042 | right, bdn->a_at->ad_type->sat_syntax_oid ); |
2915 | 1051 | bdn->a_at->ad_type->sat_syntax_oid ); | 1043 | Debug(LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2916 | 1052 | goto fail; | 1044 | goto fail; |
2917 | 1053 | } | 1045 | } |
2918 | 1054 | 1046 | ||
2919 | 1055 | if( bdn->a_at->ad_type->sat_equality == NULL ) { | 1047 | if( bdn->a_at->ad_type->sat_equality == NULL ) { |
2924 | 1056 | Debug( LDAP_DEBUG_ANY, | 1048 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2925 | 1057 | "%s: line %d: dnattr \"%s\": " | 1049 | "dnattr \"%s\": inappropriate matching (no EQUALITY)", right ); |
2926 | 1058 | "inappropriate matching (no EQUALITY)\n", | 1050 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2923 | 1059 | fname, lineno, right ); | ||
2927 | 1060 | goto fail; | 1051 | goto fail; |
2928 | 1061 | } | 1052 | } |
2929 | 1062 | 1053 | ||
2930 | @@ -1071,11 +1062,9 @@ parse_acl( | |||
2931 | 1071 | switch ( sty ) { | 1062 | switch ( sty ) { |
2932 | 1072 | case ACL_STYLE_REGEX: | 1063 | case ACL_STYLE_REGEX: |
2933 | 1073 | /* legacy, tolerated */ | 1064 | /* legacy, tolerated */ |
2939 | 1074 | Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, | 1065 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2940 | 1075 | "%s: line %d: " | 1066 | "deprecated group style \"regex\"; use \"expand\" instead" ); |
2941 | 1076 | "deprecated group style \"regex\"; " | 1067 | Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); |
2937 | 1077 | "use \"expand\" instead.\n", | ||
2938 | 1078 | fname, lineno ); | ||
2942 | 1079 | sty = ACL_STYLE_EXPAND; | 1068 | sty = ACL_STYLE_EXPAND; |
2943 | 1080 | break; | 1069 | break; |
2944 | 1081 | 1070 | ||
2945 | @@ -1087,26 +1076,23 @@ parse_acl( | |||
2946 | 1087 | 1076 | ||
2947 | 1088 | default: | 1077 | default: |
2948 | 1089 | /* unknown */ | 1078 | /* unknown */ |
2953 | 1090 | Debug( LDAP_DEBUG_ANY, | 1079 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2954 | 1091 | "%s: line %d: " | 1080 | "inappropriate style \"%s\" in by clause", style ); |
2955 | 1092 | "inappropriate style \"%s\" in by clause.\n", | 1081 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2952 | 1093 | fname, lineno, style ); | ||
2956 | 1094 | goto fail; | 1082 | goto fail; |
2957 | 1095 | } | 1083 | } |
2958 | 1096 | 1084 | ||
2959 | 1097 | if ( right == NULL || right[0] == '\0' ) { | 1085 | if ( right == NULL || right[0] == '\0' ) { |
2965 | 1098 | Debug( LDAP_DEBUG_ANY, | 1086 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2966 | 1099 | "%s: line %d: " | 1087 | "missing \"=\" in (or value after) \"%s\" in by clause", left ); |
2967 | 1100 | "missing \"=\" in (or value after) \"%s\" " | 1088 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2963 | 1101 | "in by clause.\n", | ||
2964 | 1102 | fname, lineno, left ); | ||
2968 | 1103 | goto fail; | 1089 | goto fail; |
2969 | 1104 | } | 1090 | } |
2970 | 1105 | 1091 | ||
2971 | 1106 | if ( !BER_BVISEMPTY( &b->a_group_pat ) ) { | 1092 | if ( !BER_BVISEMPTY( &b->a_group_pat ) ) { |
2975 | 1107 | Debug( LDAP_DEBUG_ANY, | 1093 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
2976 | 1108 | "%s: line %d: group pattern already specified.\n", | 1094 | "group pattern already specified" ); |
2977 | 1109 | fname, lineno ); | 1095 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
2978 | 1110 | goto fail; | 1096 | goto fail; |
2979 | 1111 | } | 1097 | } |
2980 | 1112 | 1098 | ||
2981 | @@ -1123,7 +1109,8 @@ parse_acl( | |||
2982 | 1123 | if ( sty == ACL_STYLE_EXPAND ) { | 1109 | if ( sty == ACL_STYLE_EXPAND ) { |
2983 | 1124 | acl_regex_normalized_dn( right, &bv ); | 1110 | acl_regex_normalized_dn( right, &bv ); |
2984 | 1125 | if ( !ber_bvccmp( &bv, '*' ) ) { | 1111 | if ( !ber_bvccmp( &bv, '*' ) ) { |
2986 | 1126 | regtest( fname, lineno, bv.bv_val ); | 1112 | if ( regtest( c, bv.bv_val ) != 0) |
2987 | 1113 | goto fail; | ||
2988 | 1127 | } | 1114 | } |
2989 | 1128 | b->a_group_pat = bv; | 1115 | b->a_group_pat = bv; |
2990 | 1129 | 1116 | ||
2991 | @@ -1132,9 +1119,9 @@ parse_acl( | |||
2992 | 1132 | rc = dnNormalize( 0, NULL, NULL, &bv, | 1119 | rc = dnNormalize( 0, NULL, NULL, &bv, |
2993 | 1133 | &b->a_group_pat, NULL ); | 1120 | &b->a_group_pat, NULL ); |
2994 | 1134 | if ( rc != LDAP_SUCCESS ) { | 1121 | if ( rc != LDAP_SUCCESS ) { |
2998 | 1135 | Debug( LDAP_DEBUG_ANY, | 1122 | snprintf( c->cr_msg, sizeof( c->cr_msg), |
2999 | 1136 | "%s: line %d: bad DN \"%s\".\n", | 1123 | "bad DN \"%s\"", right ); |
3000 | 1137 | fname, lineno, right ); | 1124 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3001 | 1138 | goto fail; | 1125 | goto fail; |
3002 | 1139 | } | 1126 | } |
3003 | 1140 | } | 1127 | } |
3004 | @@ -1144,10 +1131,9 @@ parse_acl( | |||
3005 | 1144 | *--value = '/'; | 1131 | *--value = '/'; |
3006 | 1145 | 1132 | ||
3007 | 1146 | if ( b->a_group_oc == NULL ) { | 1133 | if ( b->a_group_oc == NULL ) { |
3012 | 1147 | Debug( LDAP_DEBUG_ANY, | 1134 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3013 | 1148 | "%s: line %d: group objectclass " | 1135 | "group objectclass \"%s\" unknown", value ); |
3014 | 1149 | "\"%s\" unknown.\n", | 1136 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3011 | 1150 | fname, lineno, value ); | ||
3015 | 1151 | goto fail; | 1137 | goto fail; |
3016 | 1152 | } | 1138 | } |
3017 | 1153 | 1139 | ||
3018 | @@ -1155,10 +1141,9 @@ parse_acl( | |||
3019 | 1155 | b->a_group_oc = oc_find( SLAPD_GROUP_CLASS ); | 1141 | b->a_group_oc = oc_find( SLAPD_GROUP_CLASS ); |
3020 | 1156 | 1142 | ||
3021 | 1157 | if( b->a_group_oc == NULL ) { | 1143 | if( b->a_group_oc == NULL ) { |
3026 | 1158 | Debug( LDAP_DEBUG_ANY, | 1144 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3027 | 1159 | "%s: line %d: group default objectclass " | 1145 | "group default objectclass \"%s\" unknown", SLAPD_GROUP_CLASS ); |
3028 | 1160 | "\"%s\" unknown.\n", | 1146 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3025 | 1161 | fname, lineno, SLAPD_GROUP_CLASS ); | ||
3029 | 1162 | goto fail; | 1147 | goto fail; |
3030 | 1163 | } | 1148 | } |
3031 | 1164 | } | 1149 | } |
3032 | @@ -1166,20 +1151,18 @@ parse_acl( | |||
3033 | 1166 | if ( is_object_subclass( slap_schema.si_oc_referral, | 1151 | if ( is_object_subclass( slap_schema.si_oc_referral, |
3034 | 1167 | b->a_group_oc ) ) | 1152 | b->a_group_oc ) ) |
3035 | 1168 | { | 1153 | { |
3040 | 1169 | Debug( LDAP_DEBUG_ANY, | 1154 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3041 | 1170 | "%s: line %d: group objectclass \"%s\" " | 1155 | "group objectclass \"%s\" is subclass of referral", value ); |
3042 | 1171 | "is subclass of referral.\n", | 1156 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3039 | 1172 | fname, lineno, value ); | ||
3043 | 1173 | goto fail; | 1157 | goto fail; |
3044 | 1174 | } | 1158 | } |
3045 | 1175 | 1159 | ||
3046 | 1176 | if ( is_object_subclass( slap_schema.si_oc_alias, | 1160 | if ( is_object_subclass( slap_schema.si_oc_alias, |
3047 | 1177 | b->a_group_oc ) ) | 1161 | b->a_group_oc ) ) |
3048 | 1178 | { | 1162 | { |
3053 | 1179 | Debug( LDAP_DEBUG_ANY, | 1163 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3054 | 1180 | "%s: line %d: group objectclass \"%s\" " | 1164 | "group objectclass \"%s\" is subclass of alias", value ); |
3055 | 1181 | "is subclass of alias.\n", | 1165 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3052 | 1182 | fname, lineno, value ); | ||
3056 | 1183 | goto fail; | 1166 | goto fail; |
3057 | 1184 | } | 1167 | } |
3058 | 1185 | 1168 | ||
3059 | @@ -1191,10 +1174,9 @@ parse_acl( | |||
3060 | 1191 | 1174 | ||
3061 | 1192 | rc = slap_str2ad( attr_name, &b->a_group_at, &text ); | 1175 | rc = slap_str2ad( attr_name, &b->a_group_at, &text ); |
3062 | 1193 | if ( rc != LDAP_SUCCESS ) { | 1176 | if ( rc != LDAP_SUCCESS ) { |
3067 | 1194 | Debug(LDAP_DEBUG_ANY, | 1177 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3068 | 1195 | "%s: line %d: group \"%s\": %s.\n", | 1178 | "group \"%s\": %s", right, text ); |
3069 | 1196 | fname, lineno, right, | 1179 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3066 | 1197 | text ); | ||
3070 | 1198 | goto fail; | 1180 | goto fail; |
3071 | 1199 | } | 1181 | } |
3072 | 1200 | 1182 | ||
3073 | @@ -1205,11 +1187,10 @@ parse_acl( | |||
3074 | 1205 | && !is_at_subtype( b->a_group_at->ad_type, | 1187 | && !is_at_subtype( b->a_group_at->ad_type, |
3075 | 1206 | slap_schema.si_ad_labeledURI->ad_type ) /* e.g. memberURL */ ) | 1188 | slap_schema.si_ad_labeledURI->ad_type ) /* e.g. memberURL */ ) |
3076 | 1207 | { | 1189 | { |
3082 | 1208 | Debug(LDAP_DEBUG_ANY, | 1190 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3083 | 1209 | "%s: line %d: group \"%s\" attr \"%s\": inappropriate syntax: %s; " "must be " SLAPD_DN_SYNTAX " (DN), " SLAPD_NAMEUID_SYNTAX " (NameUID) " "or a subtype of labeledURI.\n", | 1191 | "group \"%s\" attr \"%s\": inappropriate syntax: %s; " "must be " SLAPD_DN_SYNTAX " (DN), " SLAPD_NAMEUID_SYNTAX " (NameUID) " "or a subtype of labeledURI", |
3084 | 1210 | fname, lineno, right, | 1192 | right, attr_name, at_syntax(b->a_group_at->ad_type) ); |
3085 | 1211 | attr_name, | 1193 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3081 | 1212 | at_syntax(b->a_group_at->ad_type) ); | ||
3086 | 1213 | goto fail; | 1194 | goto fail; |
3087 | 1214 | } | 1195 | } |
3088 | 1215 | 1196 | ||
3089 | @@ -1225,11 +1206,11 @@ parse_acl( | |||
3090 | 1225 | ocs, NULL ); | 1206 | ocs, NULL ); |
3091 | 1226 | 1207 | ||
3092 | 1227 | if( rc != 0 ) { | 1208 | if( rc != 0 ) { |
3096 | 1228 | Debug(LDAP_DEBUG_ANY, | 1209 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3097 | 1229 | "%s: line %d: group: \"%s\" not allowed by \"%s\".\n", | 1210 | "group: \"%s\" not allowed by \"%s\".\n", |
3095 | 1230 | fname, lineno, | ||
3098 | 1231 | b->a_group_at->ad_cname.bv_val, | 1211 | b->a_group_at->ad_cname.bv_val, |
3099 | 1232 | b->a_group_oc->soc_oid ); | 1212 | b->a_group_oc->soc_oid ); |
3100 | 1213 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
3101 | 1233 | goto fail; | 1214 | goto fail; |
3102 | 1234 | } | 1215 | } |
3103 | 1235 | } | 1216 | } |
3104 | @@ -1250,24 +1231,23 @@ parse_acl( | |||
3105 | 1250 | break; | 1231 | break; |
3106 | 1251 | 1232 | ||
3107 | 1252 | default: | 1233 | default: |
3111 | 1253 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1234 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3112 | 1254 | "inappropriate style \"%s\" in by clause.\n", | 1235 | "inappropriate style \"%s\" in by clause", style ); |
3113 | 1255 | fname, lineno, style ); | 1236 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3114 | 1256 | goto fail; | 1237 | goto fail; |
3115 | 1257 | } | 1238 | } |
3116 | 1258 | 1239 | ||
3117 | 1259 | if ( right == NULL || right[0] == '\0' ) { | 1240 | if ( right == NULL || right[0] == '\0' ) { |
3122 | 1260 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1241 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3123 | 1261 | "missing \"=\" in (or value after) \"%s\" " | 1242 | "missing \"=\" in (or value after) \"%s\" in by clause", left); |
3124 | 1262 | "in by clause.\n", | 1243 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3121 | 1263 | fname, lineno, left ); | ||
3125 | 1264 | goto fail; | 1244 | goto fail; |
3126 | 1265 | } | 1245 | } |
3127 | 1266 | 1246 | ||
3128 | 1267 | if ( !BER_BVISEMPTY( &b->a_peername_pat ) ) { | 1247 | if ( !BER_BVISEMPTY( &b->a_peername_pat ) ) { |
3132 | 1268 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1248 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3133 | 1269 | "peername pattern already specified.\n", | 1249 | "peername pattern already specified" ); |
3134 | 1270 | fname, lineno ); | 1250 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3135 | 1271 | goto fail; | 1251 | goto fail; |
3136 | 1272 | } | 1252 | } |
3137 | 1273 | 1253 | ||
3138 | @@ -1275,7 +1255,8 @@ parse_acl( | |||
3139 | 1275 | if ( sty == ACL_STYLE_REGEX ) { | 1255 | if ( sty == ACL_STYLE_REGEX ) { |
3140 | 1276 | acl_regex_normalized_dn( right, &bv ); | 1256 | acl_regex_normalized_dn( right, &bv ); |
3141 | 1277 | if ( !ber_bvccmp( &bv, '*' ) ) { | 1257 | if ( !ber_bvccmp( &bv, '*' ) ) { |
3143 | 1278 | regtest( fname, lineno, bv.bv_val ); | 1258 | if ( regtest( c, bv.bv_val ) != 0) |
3144 | 1259 | goto fail; | ||
3145 | 1279 | } | 1260 | } |
3146 | 1280 | b->a_peername_pat = bv; | 1261 | b->a_peername_pat = bv; |
3147 | 1281 | 1262 | ||
3148 | @@ -1293,9 +1274,9 @@ parse_acl( | |||
3149 | 1293 | b->a_peername_addr = inet_addr( addr ); | 1274 | b->a_peername_addr = inet_addr( addr ); |
3150 | 1294 | if ( b->a_peername_addr == (unsigned long)(-1) ) { | 1275 | if ( b->a_peername_addr == (unsigned long)(-1) ) { |
3151 | 1295 | /* illegal address */ | 1276 | /* illegal address */ |
3155 | 1296 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1277 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3156 | 1297 | "illegal peername address \"%s\".\n", | 1278 | "illegal peername address \"%s\"", addr ); |
3157 | 1298 | fname, lineno, addr ); | 1279 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3158 | 1299 | goto fail; | 1280 | goto fail; |
3159 | 1300 | } | 1281 | } |
3160 | 1301 | 1282 | ||
3161 | @@ -1306,13 +1287,12 @@ parse_acl( | |||
3162 | 1306 | (unsigned long)(-1) ) | 1287 | (unsigned long)(-1) ) |
3163 | 1307 | { | 1288 | { |
3164 | 1308 | /* illegal mask */ | 1289 | /* illegal mask */ |
3169 | 1309 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1290 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3170 | 1310 | "illegal peername address mask " | 1291 | "illegal peername address mask \"%s\"", mask ); |
3171 | 1311 | "\"%s\".\n", | 1292 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3168 | 1312 | fname, lineno, mask ); | ||
3172 | 1313 | goto fail; | 1293 | goto fail; |
3173 | 1314 | } | 1294 | } |
3175 | 1315 | } | 1295 | } |
3176 | 1316 | 1296 | ||
3177 | 1317 | b->a_peername_port = -1; | 1297 | b->a_peername_port = -1; |
3178 | 1318 | if ( port ) { | 1298 | if ( port ) { |
3179 | @@ -1321,10 +1301,9 @@ parse_acl( | |||
3180 | 1321 | b->a_peername_port = strtol( port, &end, 10 ); | 1301 | b->a_peername_port = strtol( port, &end, 10 ); |
3181 | 1322 | if ( end == port || end[0] != '}' ) { | 1302 | if ( end == port || end[0] != '}' ) { |
3182 | 1323 | /* illegal port */ | 1303 | /* illegal port */ |
3187 | 1324 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1304 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3188 | 1325 | "illegal peername port specification " | 1305 | "illegal peername port specification \"{%s}\"", port ); |
3189 | 1326 | "\"{%s}\".\n", | 1306 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3186 | 1327 | fname, lineno, port ); | ||
3190 | 1328 | goto fail; | 1307 | goto fail; |
3191 | 1329 | } | 1308 | } |
3192 | 1330 | } | 1309 | } |
3193 | @@ -1340,9 +1319,9 @@ parse_acl( | |||
3194 | 1340 | 1319 | ||
3195 | 1341 | if ( inet_pton( AF_INET6, addr, &b->a_peername_addr6 ) != 1 ) { | 1320 | if ( inet_pton( AF_INET6, addr, &b->a_peername_addr6 ) != 1 ) { |
3196 | 1342 | /* illegal address */ | 1321 | /* illegal address */ |
3200 | 1343 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1322 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3201 | 1344 | "illegal peername address \"%s\".\n", | 1323 | "illegal peername address \"%s\"", addr ); |
3202 | 1345 | fname, lineno, addr ); | 1324 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3203 | 1346 | goto fail; | 1325 | goto fail; |
3204 | 1347 | } | 1326 | } |
3205 | 1348 | 1327 | ||
3206 | @@ -1352,10 +1331,9 @@ parse_acl( | |||
3207 | 1352 | 1331 | ||
3208 | 1353 | if ( inet_pton( AF_INET6, mask, &b->a_peername_mask6 ) != 1 ) { | 1332 | if ( inet_pton( AF_INET6, mask, &b->a_peername_mask6 ) != 1 ) { |
3209 | 1354 | /* illegal mask */ | 1333 | /* illegal mask */ |
3214 | 1355 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1334 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3215 | 1356 | "illegal peername address mask " | 1335 | "illegal peername address mask \"%s\"", mask ); |
3216 | 1357 | "\"%s\".\n", | 1336 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3213 | 1358 | fname, lineno, mask ); | ||
3217 | 1359 | goto fail; | 1337 | goto fail; |
3218 | 1360 | } | 1338 | } |
3219 | 1361 | 1339 | ||
3220 | @@ -1366,10 +1344,9 @@ parse_acl( | |||
3221 | 1366 | b->a_peername_port = strtol( port, &end, 10 ); | 1344 | b->a_peername_port = strtol( port, &end, 10 ); |
3222 | 1367 | if ( end == port || end[0] != '}' ) { | 1345 | if ( end == port || end[0] != '}' ) { |
3223 | 1368 | /* illegal port */ | 1346 | /* illegal port */ |
3228 | 1369 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1347 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3229 | 1370 | "illegal peername port specification " | 1348 | "illegal peername port specification \"{%s}\"", port ); |
3230 | 1371 | "\"{%s}\".\n", | 1349 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3227 | 1372 | fname, lineno, port ); | ||
3231 | 1373 | goto fail; | 1350 | goto fail; |
3232 | 1374 | } | 1351 | } |
3233 | 1375 | } | 1352 | } |
3234 | @@ -1390,24 +1367,23 @@ parse_acl( | |||
3235 | 1390 | 1367 | ||
3236 | 1391 | default: | 1368 | default: |
3237 | 1392 | /* unknown */ | 1369 | /* unknown */ |
3241 | 1393 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1370 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3242 | 1394 | "inappropriate style \"%s\" in by clause\n", | 1371 | "inappropriate style \"%s\" in by clause", style ); |
3243 | 1395 | fname, lineno, style ); | 1372 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3244 | 1396 | goto fail; | 1373 | goto fail; |
3245 | 1397 | } | 1374 | } |
3246 | 1398 | 1375 | ||
3247 | 1399 | if ( right == NULL || right[0] == '\0' ) { | 1376 | if ( right == NULL || right[0] == '\0' ) { |
3252 | 1400 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1377 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3253 | 1401 | "missing \"=\" in (or value after) \"%s\" " | 1378 | "missing \"=\" in (or value after) \"%s\" in by clause", left ); |
3254 | 1402 | "in by clause\n", | 1379 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3251 | 1403 | fname, lineno, left ); | ||
3255 | 1404 | goto fail; | 1380 | goto fail; |
3256 | 1405 | } | 1381 | } |
3257 | 1406 | 1382 | ||
3258 | 1407 | if ( !BER_BVISNULL( &b->a_sockname_pat ) ) { | 1383 | if ( !BER_BVISNULL( &b->a_sockname_pat ) ) { |
3262 | 1408 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1384 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3263 | 1409 | "sockname pattern already specified.\n", | 1385 | "sockname pattern already specified" ); |
3264 | 1410 | fname, lineno ); | 1386 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3265 | 1411 | goto fail; | 1387 | goto fail; |
3266 | 1412 | } | 1388 | } |
3267 | 1413 | 1389 | ||
3268 | @@ -1415,10 +1391,11 @@ parse_acl( | |||
3269 | 1415 | if ( sty == ACL_STYLE_REGEX ) { | 1391 | if ( sty == ACL_STYLE_REGEX ) { |
3270 | 1416 | acl_regex_normalized_dn( right, &bv ); | 1392 | acl_regex_normalized_dn( right, &bv ); |
3271 | 1417 | if ( !ber_bvccmp( &bv, '*' ) ) { | 1393 | if ( !ber_bvccmp( &bv, '*' ) ) { |
3273 | 1418 | regtest( fname, lineno, bv.bv_val ); | 1394 | if ( regtest( c, bv.bv_val ) != 0) |
3274 | 1395 | goto fail; | ||
3275 | 1419 | } | 1396 | } |
3276 | 1420 | b->a_sockname_pat = bv; | 1397 | b->a_sockname_pat = bv; |
3278 | 1421 | 1398 | ||
3279 | 1422 | } else { | 1399 | } else { |
3280 | 1423 | ber_str2bv( right, 0, 1, &b->a_sockname_pat ); | 1400 | ber_str2bv( right, 0, 1, &b->a_sockname_pat ); |
3281 | 1424 | } | 1401 | } |
3282 | @@ -1436,11 +1413,9 @@ parse_acl( | |||
3283 | 1436 | case ACL_STYLE_EXPAND: | 1413 | case ACL_STYLE_EXPAND: |
3284 | 1437 | /* tolerated: means exact,expand */ | 1414 | /* tolerated: means exact,expand */ |
3285 | 1438 | if ( expand ) { | 1415 | if ( expand ) { |
3291 | 1439 | Debug( LDAP_DEBUG_ANY, | 1416 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3292 | 1440 | "%s: line %d: " | 1417 | "\"expand\" modifier with \"expand\" style" ); |
3293 | 1441 | "\"expand\" modifier " | 1418 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3289 | 1442 | "with \"expand\" style.\n", | ||
3290 | 1443 | fname, lineno ); | ||
3294 | 1444 | } | 1419 | } |
3295 | 1445 | sty = ACL_STYLE_BASE; | 1420 | sty = ACL_STYLE_BASE; |
3296 | 1446 | expand = 1; | 1421 | expand = 1; |
3297 | @@ -1448,24 +1423,23 @@ parse_acl( | |||
3298 | 1448 | 1423 | ||
3299 | 1449 | default: | 1424 | default: |
3300 | 1450 | /* unknown */ | 1425 | /* unknown */ |
3304 | 1451 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1426 | snprintf( c->cr_msg, sizeof( c->cr_msg), |
3305 | 1452 | "inappropriate style \"%s\" in by clause.\n", | 1427 | "inappropriate style \"%s\" in by clause", style ); |
3306 | 1453 | fname, lineno, style ); | 1428 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3307 | 1454 | goto fail; | 1429 | goto fail; |
3308 | 1455 | } | 1430 | } |
3309 | 1456 | 1431 | ||
3310 | 1457 | if ( right == NULL || right[0] == '\0' ) { | 1432 | if ( right == NULL || right[0] == '\0' ) { |
3315 | 1458 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1433 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3316 | 1459 | "missing \"=\" in (or value after) \"%s\" " | 1434 | "missing \"=\" in (or value after) \"%s\" in by clause", left ); |
3317 | 1460 | "in by clause.\n", | 1435 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3314 | 1461 | fname, lineno, left ); | ||
3318 | 1462 | goto fail; | 1436 | goto fail; |
3319 | 1463 | } | 1437 | } |
3320 | 1464 | 1438 | ||
3321 | 1465 | if ( !BER_BVISEMPTY( &b->a_domain_pat ) ) { | 1439 | if ( !BER_BVISEMPTY( &b->a_domain_pat ) ) { |
3325 | 1466 | Debug( LDAP_DEBUG_ANY, | 1440 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3326 | 1467 | "%s: line %d: domain pattern already specified.\n", | 1441 | "domain pattern already specified" ); |
3327 | 1468 | fname, lineno ); | 1442 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3328 | 1469 | goto fail; | 1443 | goto fail; |
3329 | 1470 | } | 1444 | } |
3330 | 1471 | 1445 | ||
3331 | @@ -1474,7 +1448,8 @@ parse_acl( | |||
3332 | 1474 | if ( sty == ACL_STYLE_REGEX ) { | 1448 | if ( sty == ACL_STYLE_REGEX ) { |
3333 | 1475 | acl_regex_normalized_dn( right, &bv ); | 1449 | acl_regex_normalized_dn( right, &bv ); |
3334 | 1476 | if ( !ber_bvccmp( &bv, '*' ) ) { | 1450 | if ( !ber_bvccmp( &bv, '*' ) ) { |
3336 | 1477 | regtest( fname, lineno, bv.bv_val ); | 1451 | if ( regtest( c, bv.bv_val ) != 0) |
3337 | 1452 | goto fail; | ||
3338 | 1478 | } | 1453 | } |
3339 | 1479 | b->a_domain_pat = bv; | 1454 | b->a_domain_pat = bv; |
3340 | 1480 | 1455 | ||
3341 | @@ -1495,24 +1470,23 @@ parse_acl( | |||
3342 | 1495 | 1470 | ||
3343 | 1496 | default: | 1471 | default: |
3344 | 1497 | /* unknown */ | 1472 | /* unknown */ |
3348 | 1498 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1473 | snprintf( c->cr_msg, sizeof( c->cr_msg), |
3349 | 1499 | "inappropriate style \"%s\" in by clause.\n", | 1474 | "inappropriate style \"%s\" in by clause", style ); |
3350 | 1500 | fname, lineno, style ); | 1475 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3351 | 1501 | goto fail; | 1476 | goto fail; |
3352 | 1502 | } | 1477 | } |
3353 | 1503 | 1478 | ||
3354 | 1504 | if ( right == NULL || right[0] == '\0' ) { | 1479 | if ( right == NULL || right[0] == '\0' ) { |
3359 | 1505 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1480 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3360 | 1506 | "missing \"=\" in (or value after) \"%s\" " | 1481 | "missing \"=\" in (or value after) \"%s\" in by clause", left ); |
3361 | 1507 | "in by clause.\n", | 1482 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3358 | 1508 | fname, lineno, left ); | ||
3362 | 1509 | goto fail; | 1483 | goto fail; |
3363 | 1510 | } | 1484 | } |
3364 | 1511 | 1485 | ||
3365 | 1512 | if ( !BER_BVISEMPTY( &b->a_sockurl_pat ) ) { | 1486 | if ( !BER_BVISEMPTY( &b->a_sockurl_pat ) ) { |
3369 | 1513 | Debug( LDAP_DEBUG_ANY, | 1487 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3370 | 1514 | "%s: line %d: sockurl pattern already specified.\n", | 1488 | "sockurl pattern already specified" ); |
3371 | 1515 | fname, lineno ); | 1489 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3372 | 1516 | goto fail; | 1490 | goto fail; |
3373 | 1517 | } | 1491 | } |
3374 | 1518 | 1492 | ||
3375 | @@ -1520,10 +1494,11 @@ parse_acl( | |||
3376 | 1520 | if ( sty == ACL_STYLE_REGEX ) { | 1494 | if ( sty == ACL_STYLE_REGEX ) { |
3377 | 1521 | acl_regex_normalized_dn( right, &bv ); | 1495 | acl_regex_normalized_dn( right, &bv ); |
3378 | 1522 | if ( !ber_bvccmp( &bv, '*' ) ) { | 1496 | if ( !ber_bvccmp( &bv, '*' ) ) { |
3380 | 1523 | regtest( fname, lineno, bv.bv_val ); | 1497 | if ( regtest( c, bv.bv_val ) != 0) |
3381 | 1498 | goto fail; | ||
3382 | 1524 | } | 1499 | } |
3383 | 1525 | b->a_sockurl_pat = bv; | 1500 | b->a_sockurl_pat = bv; |
3385 | 1526 | 1501 | ||
3386 | 1527 | } else { | 1502 | } else { |
3387 | 1528 | ber_str2bv( right, 0, 1, &b->a_sockurl_pat ); | 1503 | ber_str2bv( right, 0, 1, &b->a_sockurl_pat ); |
3388 | 1529 | } | 1504 | } |
3389 | @@ -1534,37 +1509,36 @@ parse_acl( | |||
3390 | 1534 | switch ( sty ) { | 1509 | switch ( sty ) { |
3391 | 1535 | /* deprecated */ | 1510 | /* deprecated */ |
3392 | 1536 | case ACL_STYLE_REGEX: | 1511 | case ACL_STYLE_REGEX: |
3395 | 1537 | Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, | 1512 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3394 | 1538 | "%s: line %d: " | ||
3396 | 1539 | "deprecated set style " | 1513 | "deprecated set style " |
3397 | 1540 | "\"regex\" in <by> clause; " | 1514 | "\"regex\" in <by> clause; " |
3400 | 1541 | "use \"expand\" instead.\n", | 1515 | "use \"expand\" instead" ); |
3401 | 1542 | fname, lineno ); | 1516 | Debug( LDAP_DEBUG_CONFIG | LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); |
3402 | 1543 | sty = ACL_STYLE_EXPAND; | 1517 | sty = ACL_STYLE_EXPAND; |
3403 | 1544 | /* FALLTHRU */ | 1518 | /* FALLTHRU */ |
3405 | 1545 | 1519 | ||
3406 | 1546 | case ACL_STYLE_BASE: | 1520 | case ACL_STYLE_BASE: |
3407 | 1547 | case ACL_STYLE_EXPAND: | 1521 | case ACL_STYLE_EXPAND: |
3408 | 1548 | break; | 1522 | break; |
3409 | 1549 | 1523 | ||
3410 | 1550 | default: | 1524 | default: |
3414 | 1551 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1525 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3415 | 1552 | "inappropriate style \"%s\" in by clause.\n", | 1526 | "inappropriate style \"%s\" in by clause", style ); |
3416 | 1553 | fname, lineno, style ); | 1527 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3417 | 1554 | goto fail; | 1528 | goto fail; |
3418 | 1555 | } | 1529 | } |
3419 | 1556 | 1530 | ||
3420 | 1557 | if ( !BER_BVISEMPTY( &b->a_set_pat ) ) { | 1531 | if ( !BER_BVISEMPTY( &b->a_set_pat ) ) { |
3424 | 1558 | Debug( LDAP_DEBUG_ANY, | 1532 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3425 | 1559 | "%s: line %d: set attribute already specified.\n", | 1533 | "set attribute already specified" ); |
3426 | 1560 | fname, lineno ); | 1534 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3427 | 1561 | goto fail; | 1535 | goto fail; |
3428 | 1562 | } | 1536 | } |
3429 | 1563 | 1537 | ||
3430 | 1564 | if ( right == NULL || *right == '\0' ) { | 1538 | if ( right == NULL || *right == '\0' ) { |
3434 | 1565 | Debug( LDAP_DEBUG_ANY, | 1539 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3435 | 1566 | "%s: line %d: no set is defined.\n", | 1540 | "no set is defined" ); |
3436 | 1567 | fname, lineno ); | 1541 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3437 | 1568 | goto fail; | 1542 | goto fail; |
3438 | 1569 | } | 1543 | } |
3439 | 1570 | 1544 | ||
3440 | @@ -1581,12 +1555,12 @@ parse_acl( | |||
3441 | 1581 | 1555 | ||
3442 | 1582 | #if 1 /* tolerate legacy "aci" <who> */ | 1556 | #if 1 /* tolerate legacy "aci" <who> */ |
3443 | 1583 | if ( strcasecmp( left, "aci" ) == 0 ) { | 1557 | if ( strcasecmp( left, "aci" ) == 0 ) { |
3445 | 1584 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1558 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3446 | 1585 | "undocumented deprecated \"aci\" directive " | 1559 | "undocumented deprecated \"aci\" directive " |
3449 | 1586 | "is superseded by \"dynacl/aci\".\n", | 1560 | "is superseded by \"dynacl/aci\"" ); |
3450 | 1587 | fname, lineno ); | 1561 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3451 | 1588 | name = "aci"; | 1562 | name = "aci"; |
3453 | 1589 | 1563 | ||
3454 | 1590 | } else | 1564 | } else |
3455 | 1591 | #endif /* tolerate legacy "aci" <who> */ | 1565 | #endif /* tolerate legacy "aci" <who> */ |
3456 | 1592 | if ( strncasecmp( left, "dynacl/", STRLENOF( "dynacl/" ) ) == 0 ) { | 1566 | if ( strncasecmp( left, "dynacl/", STRLENOF( "dynacl/" ) ) == 0 ) { |
3457 | @@ -1599,10 +1573,10 @@ parse_acl( | |||
3458 | 1599 | } | 1573 | } |
3459 | 1600 | 1574 | ||
3460 | 1601 | if ( name ) { | 1575 | if ( name ) { |
3465 | 1602 | if ( slap_dynacl_config( fname, lineno, b, name, opts, sty, right ) ) { | 1576 | if ( slap_dynacl_config( c, b, name, opts, sty, right ) ) { |
3466 | 1603 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1577 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3467 | 1604 | "unable to configure dynacl \"%s\".\n", | 1578 | "unable to configure dynacl \"%s\"", name ); |
3468 | 1605 | fname, lineno, name ); | 1579 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3469 | 1606 | goto fail; | 1580 | goto fail; |
3470 | 1607 | } | 1581 | } |
3471 | 1608 | 1582 | ||
3472 | @@ -1613,37 +1587,37 @@ parse_acl( | |||
3473 | 1613 | 1587 | ||
3474 | 1614 | if ( strcasecmp( left, "ssf" ) == 0 ) { | 1588 | if ( strcasecmp( left, "ssf" ) == 0 ) { |
3475 | 1615 | if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { | 1589 | if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { |
3479 | 1616 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1590 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3480 | 1617 | "inappropriate style \"%s\" in by clause.\n", | 1591 | "inappropriate style \"%s\" in by clause", style ); |
3481 | 1618 | fname, lineno, style ); | 1592 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3482 | 1619 | goto fail; | 1593 | goto fail; |
3483 | 1620 | } | 1594 | } |
3484 | 1621 | 1595 | ||
3485 | 1622 | if ( b->a_authz.sai_ssf ) { | 1596 | if ( b->a_authz.sai_ssf ) { |
3489 | 1623 | Debug( LDAP_DEBUG_ANY, | 1597 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3490 | 1624 | "%s: line %d: ssf attribute already specified.\n", | 1598 | "ssf attribute already specified" ); |
3491 | 1625 | fname, lineno ); | 1599 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3492 | 1626 | goto fail; | 1600 | goto fail; |
3493 | 1627 | } | 1601 | } |
3494 | 1628 | 1602 | ||
3495 | 1629 | if ( right == NULL || *right == '\0' ) { | 1603 | if ( right == NULL || *right == '\0' ) { |
3499 | 1630 | Debug( LDAP_DEBUG_ANY, | 1604 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3500 | 1631 | "%s: line %d: no ssf is defined.\n", | 1605 | "no ssf is defined" ); |
3501 | 1632 | fname, lineno ); | 1606 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3502 | 1633 | goto fail; | 1607 | goto fail; |
3503 | 1634 | } | 1608 | } |
3504 | 1635 | 1609 | ||
3505 | 1636 | if ( lutil_atou( &b->a_authz.sai_ssf, right ) != 0 ) { | 1610 | if ( lutil_atou( &b->a_authz.sai_ssf, right ) != 0 ) { |
3509 | 1637 | Debug( LDAP_DEBUG_ANY, | 1611 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3510 | 1638 | "%s: line %d: unable to parse ssf value (%s).\n", | 1612 | "unable to parse ssf value (%s)", right ); |
3511 | 1639 | fname, lineno, right ); | 1613 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3512 | 1640 | goto fail; | 1614 | goto fail; |
3513 | 1641 | } | 1615 | } |
3514 | 1642 | 1616 | ||
3515 | 1643 | if ( !b->a_authz.sai_ssf ) { | 1617 | if ( !b->a_authz.sai_ssf ) { |
3519 | 1644 | Debug( LDAP_DEBUG_ANY, | 1618 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3520 | 1645 | "%s: line %d: invalid ssf value (%s).\n", | 1619 | "invalid ssf value (%s)", right ); |
3521 | 1646 | fname, lineno, right ); | 1620 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3522 | 1647 | goto fail; | 1621 | goto fail; |
3523 | 1648 | } | 1622 | } |
3524 | 1649 | continue; | 1623 | continue; |
3525 | @@ -1651,37 +1625,37 @@ parse_acl( | |||
3526 | 1651 | 1625 | ||
3527 | 1652 | if ( strcasecmp( left, "transport_ssf" ) == 0 ) { | 1626 | if ( strcasecmp( left, "transport_ssf" ) == 0 ) { |
3528 | 1653 | if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { | 1627 | if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { |
3532 | 1654 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1628 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3533 | 1655 | "inappropriate style \"%s\" in by clause.\n", | 1629 | "inappropriate style \"%s\" in by clause", style ); |
3534 | 1656 | fname, lineno, style ); | 1630 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3535 | 1657 | goto fail; | 1631 | goto fail; |
3536 | 1658 | } | 1632 | } |
3537 | 1659 | 1633 | ||
3538 | 1660 | if ( b->a_authz.sai_transport_ssf ) { | 1634 | if ( b->a_authz.sai_transport_ssf ) { |
3542 | 1661 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1635 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3543 | 1662 | "transport_ssf attribute already specified.\n", | 1636 | "transport_ssf attribute already specified" ); |
3544 | 1663 | fname, lineno ); | 1637 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3545 | 1664 | goto fail; | 1638 | goto fail; |
3546 | 1665 | } | 1639 | } |
3547 | 1666 | 1640 | ||
3548 | 1667 | if ( right == NULL || *right == '\0' ) { | 1641 | if ( right == NULL || *right == '\0' ) { |
3552 | 1668 | Debug( LDAP_DEBUG_ANY, | 1642 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3553 | 1669 | "%s: line %d: no transport_ssf is defined.\n", | 1643 | "no transport_ssf is defined" ); |
3554 | 1670 | fname, lineno ); | 1644 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3555 | 1671 | goto fail; | 1645 | goto fail; |
3556 | 1672 | } | 1646 | } |
3557 | 1673 | 1647 | ||
3558 | 1674 | if ( lutil_atou( &b->a_authz.sai_transport_ssf, right ) != 0 ) { | 1648 | if ( lutil_atou( &b->a_authz.sai_transport_ssf, right ) != 0 ) { |
3562 | 1675 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1649 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3563 | 1676 | "unable to parse transport_ssf value (%s).\n", | 1650 | "unable to parse transport_ssf value (%s)", right ); |
3564 | 1677 | fname, lineno, right ); | 1651 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3565 | 1678 | goto fail; | 1652 | goto fail; |
3566 | 1679 | } | 1653 | } |
3567 | 1680 | 1654 | ||
3568 | 1681 | if ( !b->a_authz.sai_transport_ssf ) { | 1655 | if ( !b->a_authz.sai_transport_ssf ) { |
3572 | 1682 | Debug( LDAP_DEBUG_ANY, | 1656 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3573 | 1683 | "%s: line %d: invalid transport_ssf value (%s).\n", | 1657 | "invalid transport_ssf value (%s)", right ); |
3574 | 1684 | fname, lineno, right ); | 1658 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3575 | 1685 | goto fail; | 1659 | goto fail; |
3576 | 1686 | } | 1660 | } |
3577 | 1687 | continue; | 1661 | continue; |
3578 | @@ -1689,37 +1663,36 @@ parse_acl( | |||
3579 | 1689 | 1663 | ||
3580 | 1690 | if ( strcasecmp( left, "tls_ssf" ) == 0 ) { | 1664 | if ( strcasecmp( left, "tls_ssf" ) == 0 ) { |
3581 | 1691 | if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { | 1665 | if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { |
3585 | 1692 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1666 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3586 | 1693 | "inappropriate style \"%s\" in by clause.\n", | 1667 | "inappropriate style \"%s\" in by clause", style ); |
3587 | 1694 | fname, lineno, style ); | 1668 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3588 | 1695 | goto fail; | 1669 | goto fail; |
3589 | 1696 | } | 1670 | } |
3590 | 1697 | 1671 | ||
3591 | 1698 | if ( b->a_authz.sai_tls_ssf ) { | 1672 | if ( b->a_authz.sai_tls_ssf ) { |
3595 | 1699 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1673 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3596 | 1700 | "tls_ssf attribute already specified.\n", | 1674 | "tls_ssf attribute already specified" ); |
3594 | 1701 | fname, lineno ); | ||
3597 | 1702 | goto fail; | 1675 | goto fail; |
3598 | 1703 | } | 1676 | } |
3599 | 1704 | 1677 | ||
3600 | 1705 | if ( right == NULL || *right == '\0' ) { | 1678 | if ( right == NULL || *right == '\0' ) { |
3604 | 1706 | Debug( LDAP_DEBUG_ANY, | 1679 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3605 | 1707 | "%s: line %d: no tls_ssf is defined\n", | 1680 | "no tls_ssf is defined" ); |
3606 | 1708 | fname, lineno ); | 1681 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3607 | 1709 | goto fail; | 1682 | goto fail; |
3608 | 1710 | } | 1683 | } |
3609 | 1711 | 1684 | ||
3610 | 1712 | if ( lutil_atou( &b->a_authz.sai_tls_ssf, right ) != 0 ) { | 1685 | if ( lutil_atou( &b->a_authz.sai_tls_ssf, right ) != 0 ) { |
3614 | 1713 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1686 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3615 | 1714 | "unable to parse tls_ssf value (%s).\n", | 1687 | "unable to parse tls_ssf value (%s)", right ); |
3616 | 1715 | fname, lineno, right ); | 1688 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3617 | 1716 | goto fail; | 1689 | goto fail; |
3618 | 1717 | } | 1690 | } |
3619 | 1718 | 1691 | ||
3620 | 1719 | if ( !b->a_authz.sai_tls_ssf ) { | 1692 | if ( !b->a_authz.sai_tls_ssf ) { |
3624 | 1720 | Debug( LDAP_DEBUG_ANY, | 1693 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3625 | 1721 | "%s: line %d: invalid tls_ssf value (%s).\n", | 1694 | "invalid tls_ssf value (%s)", right ); |
3626 | 1722 | fname, lineno, right ); | 1695 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3627 | 1723 | goto fail; | 1696 | goto fail; |
3628 | 1724 | } | 1697 | } |
3629 | 1725 | continue; | 1698 | continue; |
3630 | @@ -1727,37 +1700,37 @@ parse_acl( | |||
3631 | 1727 | 1700 | ||
3632 | 1728 | if ( strcasecmp( left, "sasl_ssf" ) == 0 ) { | 1701 | if ( strcasecmp( left, "sasl_ssf" ) == 0 ) { |
3633 | 1729 | if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { | 1702 | if ( sty != ACL_STYLE_REGEX && sty != ACL_STYLE_BASE ) { |
3637 | 1730 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1703 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3638 | 1731 | "inappropriate style \"%s\" in by clause.\n", | 1704 | "inappropriate style \"%s\" in by clause", style ); |
3639 | 1732 | fname, lineno, style ); | 1705 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3640 | 1733 | goto fail; | 1706 | goto fail; |
3641 | 1734 | } | 1707 | } |
3642 | 1735 | 1708 | ||
3643 | 1736 | if ( b->a_authz.sai_sasl_ssf ) { | 1709 | if ( b->a_authz.sai_sasl_ssf ) { |
3647 | 1737 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1710 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3648 | 1738 | "sasl_ssf attribute already specified.\n", | 1711 | "sasl_ssf attribute already specified" ); |
3649 | 1739 | fname, lineno ); | 1712 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3650 | 1740 | goto fail; | 1713 | goto fail; |
3651 | 1741 | } | 1714 | } |
3652 | 1742 | 1715 | ||
3653 | 1743 | if ( right == NULL || *right == '\0' ) { | 1716 | if ( right == NULL || *right == '\0' ) { |
3657 | 1744 | Debug( LDAP_DEBUG_ANY, | 1717 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3658 | 1745 | "%s: line %d: no sasl_ssf is defined.\n", | 1718 | "no sasl_ssf is defined" ); |
3659 | 1746 | fname, lineno ); | 1719 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3660 | 1747 | goto fail; | 1720 | goto fail; |
3661 | 1748 | } | 1721 | } |
3662 | 1749 | 1722 | ||
3663 | 1750 | if ( lutil_atou( &b->a_authz.sai_sasl_ssf, right ) != 0 ) { | 1723 | if ( lutil_atou( &b->a_authz.sai_sasl_ssf, right ) != 0 ) { |
3667 | 1751 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1724 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3668 | 1752 | "unable to parse sasl_ssf value (%s).\n", | 1725 | "unable to parse sasl_ssf value (%s)", right ); |
3669 | 1753 | fname, lineno, right ); | 1726 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3670 | 1754 | goto fail; | 1727 | goto fail; |
3671 | 1755 | } | 1728 | } |
3672 | 1756 | 1729 | ||
3673 | 1757 | if ( !b->a_authz.sai_sasl_ssf ) { | 1730 | if ( !b->a_authz.sai_sasl_ssf ) { |
3677 | 1758 | Debug( LDAP_DEBUG_ANY, | 1731 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3678 | 1759 | "%s: line %d: invalid sasl_ssf value (%s).\n", | 1732 | "invalid sasl_ssf value (%s)", right ); |
3679 | 1760 | fname, lineno, right ); | 1733 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3680 | 1761 | goto fail; | 1734 | goto fail; |
3681 | 1762 | } | 1735 | } |
3682 | 1763 | continue; | 1736 | continue; |
3683 | @@ -1770,7 +1743,7 @@ parse_acl( | |||
3684 | 1770 | break; | 1743 | break; |
3685 | 1771 | } | 1744 | } |
3686 | 1772 | 1745 | ||
3688 | 1773 | if ( i == argc || ( strcasecmp( left, "stop" ) == 0 ) ) { | 1746 | if ( i == argc || ( strcasecmp( left, "stop" ) == 0 ) ) { |
3689 | 1774 | /* out of arguments or plain stop */ | 1747 | /* out of arguments or plain stop */ |
3690 | 1775 | 1748 | ||
3691 | 1776 | ACL_PRIV_ASSIGN( b->a_access_mask, ACL_PRIV_ADDITIVE ); | 1749 | ACL_PRIV_ASSIGN( b->a_access_mask, ACL_PRIV_ADDITIVE ); |
3692 | @@ -1831,9 +1804,9 @@ parse_acl( | |||
3693 | 1831 | } | 1804 | } |
3694 | 1832 | 1805 | ||
3695 | 1833 | if ( ACL_IS_INVALID( b->a_access_mask ) ) { | 1806 | if ( ACL_IS_INVALID( b->a_access_mask ) ) { |
3699 | 1834 | Debug( LDAP_DEBUG_ANY, | 1807 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3700 | 1835 | "%s: line %d: expecting <access> got \"%s\".\n", | 1808 | "expecting <access> got \"%s\"", left ); |
3701 | 1836 | fname, lineno, left ); | 1809 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3702 | 1837 | goto fail; | 1810 | goto fail; |
3703 | 1838 | } | 1811 | } |
3704 | 1839 | 1812 | ||
3705 | @@ -1862,19 +1835,18 @@ parse_acl( | |||
3706 | 1862 | b = NULL; | 1835 | b = NULL; |
3707 | 1863 | 1836 | ||
3708 | 1864 | } else { | 1837 | } else { |
3713 | 1865 | Debug( LDAP_DEBUG_ANY, | 1838 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3714 | 1866 | "%s: line %d: expecting \"to\" " | 1839 | "expecting \"to\" or \"by\" got \"%s\"", argv[i] ); |
3715 | 1867 | "or \"by\" got \"%s\"\n", | 1840 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3712 | 1868 | fname, lineno, argv[i] ); | ||
3716 | 1869 | goto fail; | 1841 | goto fail; |
3717 | 1870 | } | 1842 | } |
3718 | 1871 | } | 1843 | } |
3719 | 1872 | 1844 | ||
3720 | 1873 | /* if we have no real access clause, complain and do nothing */ | 1845 | /* if we have no real access clause, complain and do nothing */ |
3721 | 1874 | if ( a == NULL ) { | 1846 | if ( a == NULL ) { |
3725 | 1875 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1847 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3726 | 1876 | "warning: no access clause(s) specified in access line.\n", | 1848 | "warning: no access clause(s) specified in access line"); |
3727 | 1877 | fname, lineno ); | 1849 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3728 | 1878 | goto fail; | 1850 | goto fail; |
3729 | 1879 | 1851 | ||
3730 | 1880 | } else { | 1852 | } else { |
3731 | @@ -1883,53 +1855,49 @@ parse_acl( | |||
3732 | 1883 | print_acl( be, a ); | 1855 | print_acl( be, a ); |
3733 | 1884 | } | 1856 | } |
3734 | 1885 | #endif | 1857 | #endif |
3736 | 1886 | 1858 | ||
3737 | 1887 | if ( a->acl_access == NULL ) { | 1859 | if ( a->acl_access == NULL ) { |
3741 | 1888 | Debug( LDAP_DEBUG_ANY, "%s: line %d: " | 1860 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3742 | 1889 | "warning: no by clause(s) specified in access line.\n", | 1861 | "warning: no by clause(s) specified in access line" ); |
3743 | 1890 | fname, lineno ); | 1862 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
3744 | 1891 | goto fail; | 1863 | goto fail; |
3745 | 1892 | } | 1864 | } |
3746 | 1893 | 1865 | ||
3747 | 1894 | if ( be != NULL ) { | 1866 | if ( be != NULL ) { |
3748 | 1895 | if ( be->be_nsuffix == NULL ) { | 1867 | if ( be->be_nsuffix == NULL ) { |
3752 | 1896 | Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: " | 1868 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3753 | 1897 | "scope checking needs suffix before ACLs.\n", | 1869 | "warning: scope checking needs suffix before ACLs" ); |
3754 | 1898 | fname, lineno ); | 1870 | Debug( LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); |
3755 | 1899 | /* go ahead, since checking is not authoritative */ | 1871 | /* go ahead, since checking is not authoritative */ |
3756 | 1900 | } else if ( !BER_BVISNULL( &be->be_nsuffix[ 1 ] ) ) { | 1872 | } else if ( !BER_BVISNULL( &be->be_nsuffix[ 1 ] ) ) { |
3761 | 1901 | Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: " | 1873 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3762 | 1902 | "scope checking only applies to single-valued " | 1874 | "warning: scope checking only applies to single-valued suffix databases" ); |
3763 | 1903 | "suffix databases\n", | 1875 | Debug( LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); |
3760 | 1904 | fname, lineno ); | ||
3764 | 1905 | /* go ahead, since checking is not authoritative */ | 1876 | /* go ahead, since checking is not authoritative */ |
3765 | 1906 | } else { | 1877 | } else { |
3766 | 1907 | switch ( check_scope( be, a ) ) { | 1878 | switch ( check_scope( be, a ) ) { |
3767 | 1908 | case ACL_SCOPE_UNKNOWN: | 1879 | case ACL_SCOPE_UNKNOWN: |
3772 | 1909 | Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: " | 1880 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3773 | 1910 | "cannot assess the validity of the ACL scope within " | 1881 | "warning: cannot assess the validity of the ACL scope within backend naming context" ); |
3774 | 1911 | "backend naming context\n", | 1882 | Debug( LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); |
3771 | 1912 | fname, lineno ); | ||
3775 | 1913 | break; | 1883 | break; |
3776 | 1914 | 1884 | ||
3777 | 1915 | case ACL_SCOPE_WARN: | 1885 | case ACL_SCOPE_WARN: |
3781 | 1916 | Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: " | 1886 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3782 | 1917 | "ACL could be out of scope within backend naming context\n", | 1887 | "warning: ACL could be out of scope within backend naming context" ); |
3783 | 1918 | fname, lineno ); | 1888 | Debug( LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); |
3784 | 1919 | break; | 1889 | break; |
3785 | 1920 | 1890 | ||
3786 | 1921 | case ACL_SCOPE_PARTIAL: | 1891 | case ACL_SCOPE_PARTIAL: |
3791 | 1922 | Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: " | 1892 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3792 | 1923 | "ACL appears to be partially out of scope within " | 1893 | "warning: ACL appears to be partially out of scope within backend naming context" ); |
3793 | 1924 | "backend naming context\n", | 1894 | Debug( LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); |
3790 | 1925 | fname, lineno ); | ||
3794 | 1926 | break; | 1895 | break; |
3796 | 1927 | 1896 | ||
3797 | 1928 | case ACL_SCOPE_ERR: | 1897 | case ACL_SCOPE_ERR: |
3802 | 1929 | Debug( LDAP_DEBUG_ACL, "%s: line %d: warning: " | 1898 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
3803 | 1930 | "ACL appears to be out of scope within " | 1899 | "warning: ACL appears to be out of scope within backend naming context" ); |
3804 | 1931 | "backend naming context\n", | 1900 | Debug( LDAP_DEBUG_ACL, "%s: %s.\n", c->log, c->cr_msg ); |
3801 | 1932 | fname, lineno ); | ||
3805 | 1933 | break; | 1901 | break; |
3806 | 1934 | 1902 | ||
3807 | 1935 | default: | 1903 | default: |
3808 | @@ -1999,7 +1967,7 @@ accessmask2str( slap_mask_t mask, char *buf, int debug ) | |||
3809 | 1999 | } else { | 1967 | } else { |
3810 | 2000 | ptr = lutil_strcopy( ptr, "unknown" ); | 1968 | ptr = lutil_strcopy( ptr, "unknown" ); |
3811 | 2001 | } | 1969 | } |
3813 | 2002 | 1970 | ||
3814 | 2003 | if ( !debug ) { | 1971 | if ( !debug ) { |
3815 | 2004 | *ptr = '\0'; | 1972 | *ptr = '\0'; |
3816 | 2005 | return buf; | 1973 | return buf; |
3817 | @@ -2020,7 +1988,7 @@ accessmask2str( slap_mask_t mask, char *buf, int debug ) | |||
3818 | 2020 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_MANAGE) ) { | 1988 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_MANAGE) ) { |
3819 | 2021 | none = 0; | 1989 | none = 0; |
3820 | 2022 | *ptr++ = 'm'; | 1990 | *ptr++ = 'm'; |
3822 | 2023 | } | 1991 | } |
3823 | 2024 | 1992 | ||
3824 | 2025 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_WRITE) ) { | 1993 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_WRITE) ) { |
3825 | 2026 | none = 0; | 1994 | none = 0; |
3826 | @@ -2033,37 +2001,37 @@ accessmask2str( slap_mask_t mask, char *buf, int debug ) | |||
3827 | 2033 | } else if ( ACL_PRIV_ISSET(mask, ACL_PRIV_WDEL) ) { | 2001 | } else if ( ACL_PRIV_ISSET(mask, ACL_PRIV_WDEL) ) { |
3828 | 2034 | none = 0; | 2002 | none = 0; |
3829 | 2035 | *ptr++ = 'z'; | 2003 | *ptr++ = 'z'; |
3831 | 2036 | } | 2004 | } |
3832 | 2037 | 2005 | ||
3833 | 2038 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_READ) ) { | 2006 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_READ) ) { |
3834 | 2039 | none = 0; | 2007 | none = 0; |
3835 | 2040 | *ptr++ = 'r'; | 2008 | *ptr++ = 'r'; |
3837 | 2041 | } | 2009 | } |
3838 | 2042 | 2010 | ||
3839 | 2043 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_SEARCH) ) { | 2011 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_SEARCH) ) { |
3840 | 2044 | none = 0; | 2012 | none = 0; |
3841 | 2045 | *ptr++ = 's'; | 2013 | *ptr++ = 's'; |
3843 | 2046 | } | 2014 | } |
3844 | 2047 | 2015 | ||
3845 | 2048 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_COMPARE) ) { | 2016 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_COMPARE) ) { |
3846 | 2049 | none = 0; | 2017 | none = 0; |
3847 | 2050 | *ptr++ = 'c'; | 2018 | *ptr++ = 'c'; |
3849 | 2051 | } | 2019 | } |
3850 | 2052 | 2020 | ||
3851 | 2053 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_AUTH) ) { | 2021 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_AUTH) ) { |
3852 | 2054 | none = 0; | 2022 | none = 0; |
3853 | 2055 | *ptr++ = 'x'; | 2023 | *ptr++ = 'x'; |
3855 | 2056 | } | 2024 | } |
3856 | 2057 | 2025 | ||
3857 | 2058 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_DISCLOSE) ) { | 2026 | if ( ACL_PRIV_ISSET(mask, ACL_PRIV_DISCLOSE) ) { |
3858 | 2059 | none = 0; | 2027 | none = 0; |
3859 | 2060 | *ptr++ = 'd'; | 2028 | *ptr++ = 'd'; |
3861 | 2061 | } | 2029 | } |
3862 | 2062 | 2030 | ||
3863 | 2063 | if ( none && ACL_PRIV_ISSET(mask, ACL_PRIV_NONE) ) { | 2031 | if ( none && ACL_PRIV_ISSET(mask, ACL_PRIV_NONE) ) { |
3864 | 2064 | none = 0; | 2032 | none = 0; |
3865 | 2065 | *ptr++ = '0'; | 2033 | *ptr++ = '0'; |
3867 | 2066 | } | 2034 | } |
3868 | 2067 | 2035 | ||
3869 | 2068 | if ( none ) { | 2036 | if ( none ) { |
3870 | 2069 | ptr = buf; | 2037 | ptr = buf; |
3871 | @@ -2178,7 +2146,7 @@ str2accessmask( const char *str ) | |||
3872 | 2178 | } | 2146 | } |
3873 | 2179 | 2147 | ||
3874 | 2180 | static int | 2148 | static int |
3876 | 2181 | acl_usage( void ) | 2149 | acl_usage(void) |
3877 | 2182 | { | 2150 | { |
3878 | 2183 | char *access = | 2151 | char *access = |
3879 | 2184 | "<access clause> ::= access to <what> " | 2152 | "<access clause> ::= access to <what> " |
3880 | @@ -2227,7 +2195,7 @@ acl_usage( void ) | |||
3881 | 2227 | 2195 | ||
3882 | 2228 | /* | 2196 | /* |
3883 | 2229 | * Set pattern to a "normalized" DN from src. | 2197 | * Set pattern to a "normalized" DN from src. |
3885 | 2230 | * At present it simply eats the (optional) space after | 2198 | * At present, it simply eats the (optional) space after |
3886 | 2231 | * a RDN separator (,) | 2199 | * a RDN separator (,) |
3887 | 2232 | * Eventually will evolve in a more complete normalization | 2200 | * Eventually will evolve in a more complete normalization |
3888 | 2233 | */ | 2201 | */ |
3889 | @@ -2245,10 +2213,10 @@ acl_regex_normalized_dn( | |||
3890 | 2245 | for ( p = str; p && p[0]; p++ ) { | 2213 | for ( p = str; p && p[0]; p++ ) { |
3891 | 2246 | /* escape */ | 2214 | /* escape */ |
3892 | 2247 | if ( p[0] == '\\' && p[1] ) { | 2215 | if ( p[0] == '\\' && p[1] ) { |
3894 | 2248 | /* | 2216 | /* |
3895 | 2249 | * if escaping a hex pair we should | 2217 | * if escaping a hex pair we should |
3898 | 2250 | * increment p twice; however, in that | 2218 | * increment p twice; however, in that |
3899 | 2251 | * case the second hex number does | 2219 | * case the second hex number does |
3900 | 2252 | * no harm | 2220 | * no harm |
3901 | 2253 | */ | 2221 | */ |
3902 | 2254 | p++; | 2222 | p++; |
3903 | @@ -2256,7 +2224,7 @@ acl_regex_normalized_dn( | |||
3904 | 2256 | 2224 | ||
3905 | 2257 | if ( p[0] == ',' && p[1] == ' ' ) { | 2225 | if ( p[0] == ',' && p[1] == ' ' ) { |
3906 | 2258 | char *q; | 2226 | char *q; |
3908 | 2259 | 2227 | ||
3909 | 2260 | /* | 2228 | /* |
3910 | 2261 | * too much space should be an error if we are pedantic | 2229 | * too much space should be an error if we are pedantic |
3911 | 2262 | */ | 2230 | */ |
3912 | @@ -2532,7 +2500,7 @@ dnaccess2text( slap_dn_access *bdn, char *ptr, int is_realdn ) | |||
3913 | 2532 | if ( is_realdn ) { | 2500 | if ( is_realdn ) { |
3914 | 2533 | assert( ! ber_bvccmp( &bdn->a_pat, '*' ) ); | 2501 | assert( ! ber_bvccmp( &bdn->a_pat, '*' ) ); |
3915 | 2534 | } | 2502 | } |
3917 | 2535 | 2503 | ||
3918 | 2536 | ptr = acl_safe_strbvcopy( ptr, &bdn->a_pat ); | 2504 | ptr = acl_safe_strbvcopy( ptr, &bdn->a_pat ); |
3919 | 2537 | if ( bdn->a_style == ACL_STYLE_SELF && bdn->a_self_level != 0 ) { | 2505 | if ( bdn->a_style == ACL_STYLE_SELF && bdn->a_self_level != 0 ) { |
3920 | 2538 | char buf[SLAP_TEXT_BUFLEN]; | 2506 | char buf[SLAP_TEXT_BUFLEN]; |
3921 | @@ -2546,7 +2514,7 @@ dnaccess2text( slap_dn_access *bdn, char *ptr, int is_realdn ) | |||
3922 | 2546 | ptr = acl_safe_strcopy( ptr, "dn." ); | 2514 | ptr = acl_safe_strcopy( ptr, "dn." ); |
3923 | 2547 | if ( bdn->a_style == ACL_STYLE_BASE ) | 2515 | if ( bdn->a_style == ACL_STYLE_BASE ) |
3924 | 2548 | ptr = acl_safe_strcopy( ptr, style_base ); | 2516 | ptr = acl_safe_strcopy( ptr, style_base ); |
3926 | 2549 | else | 2517 | else |
3927 | 2550 | ptr = acl_safe_strcopy( ptr, style_strings[bdn->a_style] ); | 2518 | ptr = acl_safe_strcopy( ptr, style_strings[bdn->a_style] ); |
3928 | 2551 | if ( bdn->a_style == ACL_STYLE_LEVEL ) { | 2519 | if ( bdn->a_style == ACL_STYLE_LEVEL ) { |
3929 | 2552 | char buf[SLAP_TEXT_BUFLEN]; | 2520 | char buf[SLAP_TEXT_BUFLEN]; |
3930 | @@ -2668,7 +2636,7 @@ access2text( Access *b, char *ptr ) | |||
3931 | 2668 | /* Security Strength Factors */ | 2636 | /* Security Strength Factors */ |
3932 | 2669 | if ( b->a_authz.sai_ssf ) { | 2637 | if ( b->a_authz.sai_ssf ) { |
3933 | 2670 | char buf[SLAP_TEXT_BUFLEN]; | 2638 | char buf[SLAP_TEXT_BUFLEN]; |
3935 | 2671 | int n = snprintf( buf, sizeof(buf), " ssf=%u", | 2639 | int n = snprintf( buf, sizeof(buf), " ssf=%u", |
3936 | 2672 | b->a_authz.sai_ssf ); | 2640 | b->a_authz.sai_ssf ); |
3937 | 2673 | ptr = acl_safe_strncopy( ptr, buf, n ); | 2641 | ptr = acl_safe_strncopy( ptr, buf, n ); |
3938 | 2674 | } | 2642 | } |
3939 | diff --git a/servers/slapd/back-asyncmeta/map.c b/servers/slapd/back-asyncmeta/map.c | |||
3940 | index b811708..66bb8b0 100644 | |||
3941 | --- a/servers/slapd/back-asyncmeta/map.c | |||
3942 | +++ b/servers/slapd/back-asyncmeta/map.c | |||
3943 | @@ -197,16 +197,26 @@ ignore: | |||
3944 | 197 | } | 197 | } |
3945 | 198 | 198 | ||
3946 | 199 | /* DN longer than our suffix and doesn't match */ | 199 | /* DN longer than our suffix and doesn't match */ |
3948 | 200 | if ( diff > 0 && !DN_SEPARATOR(dn->bv_val[diff-1])) | 200 | if ( osuff->bv_len != 0 && diff > 0 && !DN_SEPARATOR(dn->bv_val[diff-1]) ) |
3949 | 201 | goto ignore; | 201 | goto ignore; |
3950 | 202 | 202 | ||
3951 | 203 | /* suffix is same length as ours, but doesn't match */ | 203 | /* suffix is same length as ours, but doesn't match */ |
3952 | 204 | if ( strcasecmp( osuff->bv_val, &dn->bv_val[diff] )) | 204 | if ( strcasecmp( osuff->bv_val, &dn->bv_val[diff] )) |
3953 | 205 | goto ignore; | 205 | goto ignore; |
3954 | 206 | 206 | ||
3955 | 207 | /* if remote suffix is empty, remove or add the dn separator*/ | ||
3956 | 208 | if ( nsuff->bv_len == 0 ) { | ||
3957 | 209 | diff--; | ||
3958 | 210 | } else if ( osuff->bv_len == 0 ) { | ||
3959 | 211 | diff++; | ||
3960 | 212 | } | ||
3961 | 213 | |||
3962 | 214 | |||
3963 | 207 | res->bv_len = diff + nsuff->bv_len; | 215 | res->bv_len = diff + nsuff->bv_len; |
3964 | 208 | res->bv_val = dc->op->o_tmpalloc( res->bv_len + 1, dc->memctx ); | 216 | res->bv_val = dc->op->o_tmpalloc( res->bv_len + 1, dc->memctx ); |
3965 | 209 | strncpy( res->bv_val, dn->bv_val, diff ); | 217 | strncpy( res->bv_val, dn->bv_val, diff ); |
3966 | 218 | if ( osuff->bv_len == 0 ) | ||
3967 | 219 | res->bv_val[diff-1] = ','; | ||
3968 | 210 | strcpy( &res->bv_val[diff], nsuff->bv_val ); | 220 | strcpy( &res->bv_val[diff], nsuff->bv_val ); |
3969 | 211 | 221 | ||
3970 | 212 | if (pretty.bv_val) | 222 | if (pretty.bv_val) |
3971 | diff --git a/servers/slapd/back-ldap/chain.c b/servers/slapd/back-ldap/chain.c | |||
3972 | index d6ffd1a..fece74d 100644 | |||
3973 | --- a/servers/slapd/back-ldap/chain.c | |||
3974 | +++ b/servers/slapd/back-ldap/chain.c | |||
3975 | @@ -1040,7 +1040,7 @@ ldap_chain_response( Operation *op, SlapReply *rs ) | |||
3976 | 1040 | 1040 | ||
3977 | 1041 | /* we need this to know if back-ldap returned any result */ | 1041 | /* we need this to know if back-ldap returned any result */ |
3978 | 1042 | lb.lb_lc = lc; | 1042 | lb.lb_lc = lc; |
3980 | 1043 | sc2.sc_next = sc->sc_next; | 1043 | sc2.sc_next = sc; |
3981 | 1044 | sc2.sc_private = &lb; | 1044 | sc2.sc_private = &lb; |
3982 | 1045 | sc2.sc_response = ldap_chain_cb_response; | 1045 | sc2.sc_response = ldap_chain_cb_response; |
3983 | 1046 | op->o_callback = &sc2; | 1046 | op->o_callback = &sc2; |
3984 | diff --git a/servers/slapd/back-null/null.c b/servers/slapd/back-null/null.c | |||
3985 | index 50b6fbc..c8d3292 100644 | |||
3986 | --- a/servers/slapd/back-null/null.c | |||
3987 | +++ b/servers/slapd/back-null/null.c | |||
3988 | @@ -72,8 +72,8 @@ null_back_db_open( BackendDB *be, ConfigReply *cr ) | |||
3989 | 72 | 72 | ||
3990 | 73 | if ( ni->ni_dosearch ) { | 73 | if ( ni->ni_dosearch ) { |
3991 | 74 | e = entry_alloc(); | 74 | e = entry_alloc(); |
3994 | 75 | e->e_name = be->be_suffix[0]; | 75 | ber_dupbv( &e->e_name, &be->be_suffix[0] ); |
3995 | 76 | e->e_nname = be->be_nsuffix[0]; | 76 | ber_dupbv( &e->e_nname, &be->be_nsuffix[0] ); |
3996 | 77 | 77 | ||
3997 | 78 | dnRdn( &e->e_nname, &bv[0] ); | 78 | dnRdn( &e->e_nname, &bv[0] ); |
3998 | 79 | bv[1].bv_val = strchr(bv[0].bv_val, '=') + 1; | 79 | bv[1].bv_val = strchr(bv[0].bv_val, '=') + 1; |
3999 | diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c | |||
4000 | index 4c4b925..59236c4 100644 | |||
4001 | --- a/servers/slapd/bconfig.c | |||
4002 | +++ b/servers/slapd/bconfig.c | |||
4003 | @@ -2247,7 +2247,7 @@ sortval_reject: | |||
4004 | 2247 | for ( a=c->be->be_acl; a; a = a->acl_next ) | 2247 | for ( a=c->be->be_acl; a; a = a->acl_next ) |
4005 | 2248 | i++; | 2248 | i++; |
4006 | 2249 | } | 2249 | } |
4008 | 2250 | if ( parse_acl(c->be, c->fname, c->lineno, c->argc, c->argv, i ) ) { | 2250 | if ( parse_acl( c, i ) ) { |
4009 | 2251 | if ( SLAP_CONFIG( c->be ) && !c->be->be_acl) { | 2251 | if ( SLAP_CONFIG( c->be ) && !c->be->be_acl) { |
4010 | 2252 | c->be->be_acl = defacl_parsed; | 2252 | c->be->be_acl = defacl_parsed; |
4011 | 2253 | } | 2253 | } |
4012 | @@ -2533,7 +2533,7 @@ sortval_reject: | |||
4013 | 2533 | 2533 | ||
4014 | 2534 | #ifdef LDAP_SLAPI | 2534 | #ifdef LDAP_SLAPI |
4015 | 2535 | case CFG_PLUGIN: | 2535 | case CFG_PLUGIN: |
4017 | 2536 | if(slapi_int_read_config(c->be, c->fname, c->lineno, c->argc, c->argv, c->valx) != LDAP_SUCCESS) | 2536 | if(slapi_int_read_config(c) != LDAP_SUCCESS) |
4018 | 2537 | return(1); | 2537 | return(1); |
4019 | 2538 | slapi_plugins_used++; | 2538 | slapi_plugins_used++; |
4020 | 2539 | break; | 2539 | break; |
4021 | @@ -4360,7 +4360,8 @@ config_tls_config(ConfigArgs *c) { | |||
4022 | 4360 | #endif | 4360 | #endif |
4023 | 4361 | 4361 | ||
4024 | 4362 | static CfEntryInfo * | 4362 | static CfEntryInfo * |
4026 | 4363 | config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last ) | 4363 | config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last, |
4027 | 4364 | Operation *op ) | ||
4028 | 4364 | { | 4365 | { |
4029 | 4365 | struct berval cdn; | 4366 | struct berval cdn; |
4030 | 4366 | char *c; | 4367 | char *c; |
4031 | @@ -4377,7 +4378,14 @@ config_find_base( CfEntryInfo *root, struct berval *dn, CfEntryInfo **last ) | |||
4032 | 4377 | for (;*c != ',';c--); | 4378 | for (;*c != ',';c--); |
4033 | 4378 | 4379 | ||
4034 | 4379 | while(root) { | 4380 | while(root) { |
4036 | 4380 | *last = root; | 4381 | if ( !op || access_allowed( op, root->ce_entry, |
4037 | 4382 | slap_schema.si_ad_entry, NULL, ACL_DISCLOSE, NULL ) ) { | ||
4038 | 4383 | /* | ||
4039 | 4384 | * ITS#10139: Only record the lowermost entry that the user has | ||
4040 | 4385 | * disclose access to | ||
4041 | 4386 | */ | ||
4042 | 4387 | *last = root; | ||
4043 | 4388 | } | ||
4044 | 4381 | for (--c;c>dn->bv_val && *c != ',';c--); | 4389 | for (--c;c>dn->bv_val && *c != ',';c--); |
4045 | 4382 | cdn.bv_val = c; | 4390 | cdn.bv_val = c; |
4046 | 4383 | if ( *c == ',' ) | 4391 | if ( *c == ',' ) |
4047 | @@ -5495,7 +5503,7 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs, | |||
4048 | 5495 | * Databases and Overlays to be inserted. Don't do any | 5503 | * Databases and Overlays to be inserted. Don't do any |
4049 | 5496 | * auto-renumbering if manageDSAit control is present. | 5504 | * auto-renumbering if manageDSAit control is present. |
4050 | 5497 | */ | 5505 | */ |
4052 | 5498 | ce = config_find_base( cfb->cb_root, &e->e_nname, &last ); | 5506 | ce = config_find_base( cfb->cb_root, &e->e_nname, &last, op ); |
4053 | 5499 | if ( ce ) { | 5507 | if ( ce ) { |
4054 | 5500 | if ( ( op && op->o_managedsait ) || | 5508 | if ( ( op && op->o_managedsait ) || |
4055 | 5501 | ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay && | 5509 | ( ce->ce_type != Cft_Database && ce->ce_type != Cft_Overlay && |
4056 | @@ -5516,14 +5524,14 @@ config_add_internal( CfBackInfo *cfb, Entry *e, ConfigArgs *ca, SlapReply *rs, | |||
4057 | 5516 | /* If last is NULL, the new entry is the root/suffix entry, | 5524 | /* If last is NULL, the new entry is the root/suffix entry, |
4058 | 5517 | * otherwise last should be the parent. | 5525 | * otherwise last should be the parent. |
4059 | 5518 | */ | 5526 | */ |
4062 | 5519 | if ( last && !dn_match( &last->ce_entry->e_nname, &pdn ) ) { | 5527 | if ( cfb->cb_root && ( !last || !dn_match( &last->ce_entry->e_nname, &pdn ) ) ) { |
4063 | 5520 | if ( rs ) { | 5528 | if ( last && rs ) { |
4064 | 5521 | rs->sr_matched = last->ce_entry->e_name.bv_val; | 5529 | rs->sr_matched = last->ce_entry->e_name.bv_val; |
4065 | 5522 | } | 5530 | } |
4066 | 5523 | Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: " | 5531 | Debug( LDAP_DEBUG_TRACE, "%s: config_add_internal: " |
4067 | 5524 | "DN=\"%s\" not child of DN=\"%s\"\n", | 5532 | "DN=\"%s\" not child of DN=\"%s\"\n", |
4068 | 5525 | log_prefix, e->e_name.bv_val, | 5533 | log_prefix, e->e_name.bv_val, |
4070 | 5526 | last->ce_entry->e_name.bv_val ); | 5534 | last ? last->ce_entry->e_name.bv_val : "" ); |
4071 | 5527 | return LDAP_NO_SUCH_OBJECT; | 5535 | return LDAP_NO_SUCH_OBJECT; |
4072 | 5528 | } | 5536 | } |
4073 | 5529 | 5537 | ||
4074 | @@ -6461,7 +6469,7 @@ config_back_modify( Operation *op, SlapReply *rs ) | |||
4075 | 6461 | 6469 | ||
4076 | 6462 | cfb = (CfBackInfo *)op->o_bd->be_private; | 6470 | cfb = (CfBackInfo *)op->o_bd->be_private; |
4077 | 6463 | 6471 | ||
4079 | 6464 | ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last ); | 6472 | ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last, op ); |
4080 | 6465 | if ( !ce ) { | 6473 | if ( !ce ) { |
4081 | 6466 | if ( last ) | 6474 | if ( last ) |
4082 | 6467 | rs->sr_matched = last->ce_entry->e_name.bv_val; | 6475 | rs->sr_matched = last->ce_entry->e_name.bv_val; |
4083 | @@ -6569,7 +6577,7 @@ config_back_modrdn( Operation *op, SlapReply *rs ) | |||
4084 | 6569 | 6577 | ||
4085 | 6570 | cfb = (CfBackInfo *)op->o_bd->be_private; | 6578 | cfb = (CfBackInfo *)op->o_bd->be_private; |
4086 | 6571 | 6579 | ||
4088 | 6572 | ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last ); | 6580 | ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last, op ); |
4089 | 6573 | if ( !ce ) { | 6581 | if ( !ce ) { |
4090 | 6574 | if ( last ) | 6582 | if ( last ) |
4091 | 6575 | rs->sr_matched = last->ce_entry->e_name.bv_val; | 6583 | rs->sr_matched = last->ce_entry->e_name.bv_val; |
4092 | @@ -6785,7 +6793,7 @@ config_back_delete( Operation *op, SlapReply *rs ) | |||
4093 | 6785 | 6793 | ||
4094 | 6786 | cfb = (CfBackInfo *)op->o_bd->be_private; | 6794 | cfb = (CfBackInfo *)op->o_bd->be_private; |
4095 | 6787 | 6795 | ||
4097 | 6788 | ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last ); | 6796 | ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last, op ); |
4098 | 6789 | if ( !ce ) { | 6797 | if ( !ce ) { |
4099 | 6790 | if ( last ) | 6798 | if ( last ) |
4100 | 6791 | rs->sr_matched = last->ce_entry->e_name.bv_val; | 6799 | rs->sr_matched = last->ce_entry->e_name.bv_val; |
4101 | @@ -6938,7 +6946,7 @@ config_back_search( Operation *op, SlapReply *rs ) | |||
4102 | 6938 | cfb = (CfBackInfo *)op->o_bd->be_private; | 6946 | cfb = (CfBackInfo *)op->o_bd->be_private; |
4103 | 6939 | 6947 | ||
4104 | 6940 | ldap_pvt_thread_rdwr_rlock( &cfb->cb_rwlock ); | 6948 | ldap_pvt_thread_rdwr_rlock( &cfb->cb_rwlock ); |
4106 | 6941 | ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last ); | 6949 | ce = config_find_base( cfb->cb_root, &op->o_req_ndn, &last, op ); |
4107 | 6942 | if ( !ce ) { | 6950 | if ( !ce ) { |
4108 | 6943 | if ( last ) | 6951 | if ( last ) |
4109 | 6944 | rs->sr_matched = last->ce_entry->e_name.bv_val; | 6952 | rs->sr_matched = last->ce_entry->e_name.bv_val; |
4110 | @@ -7026,7 +7034,7 @@ int config_back_entry_get( | |||
4111 | 7026 | if ( !paused ) { | 7034 | if ( !paused ) { |
4112 | 7027 | ldap_pvt_thread_rdwr_rlock( &cfb->cb_rwlock ); | 7035 | ldap_pvt_thread_rdwr_rlock( &cfb->cb_rwlock ); |
4113 | 7028 | } | 7036 | } |
4115 | 7029 | ce = config_find_base( cfb->cb_root, ndn, &last ); | 7037 | ce = config_find_base( cfb->cb_root, ndn, &last, op ); |
4116 | 7030 | if ( ce ) { | 7038 | if ( ce ) { |
4117 | 7031 | e = ce->ce_entry; | 7039 | e = ce->ce_entry; |
4118 | 7032 | if ( e ) { | 7040 | if ( e ) { |
4119 | @@ -7332,7 +7340,7 @@ config_check_schema(Operation *op, CfBackInfo *cfb) | |||
4120 | 7332 | return 0; | 7340 | return 0; |
4121 | 7333 | 7341 | ||
4122 | 7334 | /* Make sure the main schema entry exists */ | 7342 | /* Make sure the main schema entry exists */ |
4124 | 7335 | ce = config_find_base( cfb->cb_root, &schema_dn, &last ); | 7343 | ce = config_find_base( cfb->cb_root, &schema_dn, &last, op ); |
4125 | 7336 | if ( ce ) { | 7344 | if ( ce ) { |
4126 | 7337 | Attribute *a; | 7345 | Attribute *a; |
4127 | 7338 | struct berval *bv; | 7346 | struct berval *bv; |
4128 | @@ -7447,7 +7455,12 @@ config_back_db_open( BackendDB *be, ConfigReply *cr ) | |||
4129 | 7447 | */ | 7455 | */ |
4130 | 7448 | save_access = be->bd_self->be_acl; | 7456 | save_access = be->bd_self->be_acl; |
4131 | 7449 | be->bd_self->be_acl = NULL; | 7457 | be->bd_self->be_acl = NULL; |
4133 | 7450 | parse_acl(be->bd_self, "config_back_db_open", 0, 6, (char **)defacl, 0 ); | 7458 | c.be = be->bd_self; |
4134 | 7459 | c.fname = "config_back_db_open"; | ||
4135 | 7460 | c.lineno = 0; | ||
4136 | 7461 | c.argc = 6; | ||
4137 | 7462 | c.argv = (char **)defacl; | ||
4138 | 7463 | parse_acl( &c, 0 ); | ||
4139 | 7451 | defacl_parsed = be->bd_self->be_acl; | 7464 | defacl_parsed = be->bd_self->be_acl; |
4140 | 7452 | if ( save_access ) { | 7465 | if ( save_access ) { |
4141 | 7453 | be->bd_self->be_acl = save_access; | 7466 | be->bd_self->be_acl = save_access; |
4142 | @@ -8029,7 +8042,7 @@ config_tool_entry_modify( BackendDB *be, Entry *e, struct berval *text ) | |||
4143 | 8029 | BackendInfo *bi = cfb->cb_db.bd_info; | 8042 | BackendInfo *bi = cfb->cb_db.bd_info; |
4144 | 8030 | CfEntryInfo *ce, *last; | 8043 | CfEntryInfo *ce, *last; |
4145 | 8031 | 8044 | ||
4147 | 8032 | ce = config_find_base( cfb->cb_root, &e->e_nname, &last ); | 8045 | ce = config_find_base( cfb->cb_root, &e->e_nname, &last, NULL ); |
4148 | 8033 | 8046 | ||
4149 | 8034 | if ( ce && bi && bi->bi_tool_entry_modify ) | 8047 | if ( ce && bi && bi->bi_tool_entry_modify ) |
4150 | 8035 | return bi->bi_tool_entry_modify( &cfb->cb_db, e, text ); | 8048 | return bi->bi_tool_entry_modify( &cfb->cb_db, e, text ); |
4151 | @@ -8044,7 +8057,7 @@ config_tool_entry_delete( BackendDB *be, struct berval *ndn, struct berval *text | |||
4152 | 8044 | BackendInfo *bi = cfb->cb_db.bd_info; | 8057 | BackendInfo *bi = cfb->cb_db.bd_info; |
4153 | 8045 | CfEntryInfo *ce, *last; | 8058 | CfEntryInfo *ce, *last; |
4154 | 8046 | 8059 | ||
4156 | 8047 | ce = config_find_base( cfb->cb_root, ndn, &last ); | 8060 | ce = config_find_base( cfb->cb_root, ndn, &last, NULL ); |
4157 | 8048 | 8061 | ||
4158 | 8049 | if ( ce && bi && bi->bi_tool_entry_delete ) | 8062 | if ( ce && bi && bi->bi_tool_entry_delete ) |
4159 | 8050 | return bi->bi_tool_entry_delete( &cfb->cb_db, ndn, text ); | 8063 | return bi->bi_tool_entry_delete( &cfb->cb_db, ndn, text ); |
4160 | diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c | |||
4161 | index 940ca3d..beabe44 100644 | |||
4162 | --- a/servers/slapd/controls.c | |||
4163 | +++ b/servers/slapd/controls.c | |||
4164 | @@ -17,6 +17,7 @@ | |||
4165 | 17 | 17 | ||
4166 | 18 | #include <stdio.h> | 18 | #include <stdio.h> |
4167 | 19 | 19 | ||
4168 | 20 | #include <ac/ctype.h> | ||
4169 | 20 | #include <ac/string.h> | 21 | #include <ac/string.h> |
4170 | 21 | #include <ac/socket.h> | 22 | #include <ac/socket.h> |
4171 | 22 | 23 | ||
4172 | diff --git a/servers/slapd/overlays/dynlist.c b/servers/slapd/overlays/dynlist.c | |||
4173 | index 10cacf9..5c38b64 100644 | |||
4174 | --- a/servers/slapd/overlays/dynlist.c | |||
4175 | +++ b/servers/slapd/overlays/dynlist.c | |||
4176 | @@ -65,6 +65,7 @@ typedef struct dynlist_info_t { | |||
4177 | 65 | typedef struct dynlist_gen_t { | 65 | typedef struct dynlist_gen_t { |
4178 | 66 | dynlist_info_t *dlg_dli; | 66 | dynlist_info_t *dlg_dli; |
4179 | 67 | int dlg_memberOf; | 67 | int dlg_memberOf; |
4180 | 68 | int dlg_simple; | ||
4181 | 68 | } dynlist_gen_t; | 69 | } dynlist_gen_t; |
4182 | 69 | 70 | ||
4183 | 70 | #define DYNLIST_USAGE \ | 71 | #define DYNLIST_USAGE \ |
4184 | @@ -556,9 +557,8 @@ dynlist_nested_member_dg( Operation *op, SlapReply *rs ) | |||
4185 | 556 | } | 557 | } |
4186 | 557 | 558 | ||
4187 | 558 | static void | 559 | static void |
4189 | 559 | dynlist_nested_member( Operation *op, dynlist_member_t *dm, TAvlnode *subs ) | 560 | dynlist_nested_member( Operation *op, slap_overinst *on, dynlist_member_t *dm, TAvlnode *subs ) |
4190 | 560 | { | 561 | { |
4191 | 561 | slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; | ||
4192 | 562 | TAvlnode *ptr; | 562 | TAvlnode *ptr; |
4193 | 563 | dynlist_name_t *dyn; | 563 | dynlist_name_t *dyn; |
4194 | 564 | Entry *ne; | 564 | Entry *ne; |
4195 | @@ -596,12 +596,12 @@ dynlist_nested_member( Operation *op, dynlist_member_t *dm, TAvlnode *subs ) | |||
4196 | 596 | dynlist_urlmembers( op, dyn, &cb ); | 596 | dynlist_urlmembers( op, dyn, &cb ); |
4197 | 597 | } | 597 | } |
4198 | 598 | if ( dyn->dy_subs ) | 598 | if ( dyn->dy_subs ) |
4200 | 599 | dynlist_nested_member( op, dm, dyn->dy_subs ); | 599 | dynlist_nested_member( op, on, dm, dyn->dy_subs ); |
4201 | 600 | } | 600 | } |
4202 | 601 | } | 601 | } |
4203 | 602 | 602 | ||
4204 | 603 | static int | 603 | static int |
4206 | 604 | dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli, dynlist_name_t *dyn ) | 604 | dynlist_prepare_entry( Operation *op, SlapReply *rs, slap_overinst *on, dynlist_info_t *dli, dynlist_name_t *dyn ) |
4207 | 605 | { | 605 | { |
4208 | 606 | Attribute *a, *id = NULL; | 606 | Attribute *a, *id = NULL; |
4209 | 607 | slap_callback cb = { 0 }; | 607 | slap_callback cb = { 0 }; |
4210 | @@ -875,7 +875,7 @@ checkdyn: | |||
4211 | 875 | /* ensure e is modifiable */ | 875 | /* ensure e is modifiable */ |
4212 | 876 | if ( e == rs->sr_entry && !( rs->sr_flags & REP_ENTRY_MODIFIABLE ) ) { | 876 | if ( e == rs->sr_entry && !( rs->sr_flags & REP_ENTRY_MODIFIABLE ) ) { |
4213 | 877 | e = entry_dup( rs->sr_entry ); | 877 | e = entry_dup( rs->sr_entry ); |
4215 | 878 | rs_replace_entry( op, rs, (slap_overinst *)op->o_bd->bd_info, e ); | 878 | rs_replace_entry( op, rs, on, e ); |
4216 | 879 | rs->sr_flags |= REP_ENTRY_MODIFIABLE | REP_ENTRY_MUSTBEFREED; | 879 | rs->sr_flags |= REP_ENTRY_MODIFIABLE | REP_ENTRY_MUSTBEFREED; |
4217 | 880 | } | 880 | } |
4218 | 881 | if ( dyn->dy_subs ) { | 881 | if ( dyn->dy_subs ) { |
4219 | @@ -888,7 +888,7 @@ checkdyn: | |||
4220 | 888 | dm.dm_mod.sm_type = dlm->dlm_member_ad->ad_cname; | 888 | dm.dm_mod.sm_type = dlm->dlm_member_ad->ad_cname; |
4221 | 889 | dm.dm_e = e; | 889 | dm.dm_e = e; |
4222 | 890 | dm.dm_ad = dlm->dlm_member_ad; | 890 | dm.dm_ad = dlm->dlm_member_ad; |
4224 | 891 | dynlist_nested_member( op, &dm, dyn->dy_subs ); | 891 | dynlist_nested_member( op, on, &dm, dyn->dy_subs ); |
4225 | 892 | if ( dm.dm_groups ) | 892 | if ( dm.dm_groups ) |
4226 | 893 | ldap_tavl_free( dm.dm_groups, NULL ); | 893 | ldap_tavl_free( dm.dm_groups, NULL ); |
4227 | 894 | } | 894 | } |
4228 | @@ -904,7 +904,7 @@ checkdyn: | |||
4229 | 904 | } | 904 | } |
4230 | 905 | 905 | ||
4231 | 906 | if ( e != rs->sr_entry ) { | 906 | if ( e != rs->sr_entry ) { |
4233 | 907 | rs_replace_entry( op, rs, (slap_overinst *)op->o_bd->bd_info, e ); | 907 | rs_replace_entry( op, rs, on, e ); |
4234 | 908 | rs->sr_flags |= REP_ENTRY_MODIFIABLE | REP_ENTRY_MUSTBEFREED; | 908 | rs->sr_flags |= REP_ENTRY_MODIFIABLE | REP_ENTRY_MUSTBEFREED; |
4235 | 909 | } | 909 | } |
4236 | 910 | 910 | ||
4237 | @@ -1098,7 +1098,7 @@ done:; | |||
4238 | 1098 | r.sr_attrs = an; | 1098 | r.sr_attrs = an; |
4239 | 1099 | 1099 | ||
4240 | 1100 | o.o_acl_priv = ACL_COMPARE; | 1100 | o.o_acl_priv = ACL_COMPARE; |
4242 | 1101 | dynlist_prepare_entry( &o, &r, dli, NULL ); | 1101 | dynlist_prepare_entry( &o, &r, on, dli, NULL ); |
4243 | 1102 | a = attrs_find( r.sr_entry->e_attrs, op->orc_ava->aa_desc ); | 1102 | a = attrs_find( r.sr_entry->e_attrs, op->orc_ava->aa_desc ); |
4244 | 1103 | 1103 | ||
4245 | 1104 | ret = LDAP_NO_SUCH_ATTRIBUTE; | 1104 | ret = LDAP_NO_SUCH_ATTRIBUTE; |
4246 | @@ -1131,6 +1131,7 @@ release:; | |||
4247 | 1131 | #define WANT_MEMBER 2 | 1131 | #define WANT_MEMBER 2 |
4248 | 1132 | 1132 | ||
4249 | 1133 | typedef struct dynlist_search_t { | 1133 | typedef struct dynlist_search_t { |
4250 | 1134 | slap_overinst *ds_on; | ||
4251 | 1134 | TAvlnode *ds_names; | 1135 | TAvlnode *ds_names; |
4252 | 1135 | TAvlnode *ds_fnodes; | 1136 | TAvlnode *ds_fnodes; |
4253 | 1136 | dynlist_info_t *ds_dli; | 1137 | dynlist_info_t *ds_dli; |
4254 | @@ -1555,11 +1556,11 @@ dynlist_test_dynmember(Operation *op, dynlist_name_t *dyn, Entry *e) | |||
4255 | 1555 | } | 1556 | } |
4256 | 1556 | 1557 | ||
4257 | 1557 | static int | 1558 | static int |
4259 | 1558 | dynlist_test_membership(Operation *op, dynlist_name_t *dyn, Entry *e) | 1559 | dynlist_test_membership(Operation *op, slap_overinst *on, dynlist_name_t *dyn, Entry *e) |
4260 | 1559 | { | 1560 | { |
4261 | 1560 | if ( dyn->dy_staticmember ) { | 1561 | if ( dyn->dy_staticmember ) { |
4262 | 1561 | Entry *grp; | 1562 | Entry *grp; |
4264 | 1562 | if ( overlay_entry_get_ov( op, &dyn->dy_nname, NULL, NULL, 0, &grp, (slap_overinst *)op->o_bd->bd_info ) == LDAP_SUCCESS && grp ) { | 1563 | if ( overlay_entry_get_ov( op, &dyn->dy_nname, NULL, NULL, 0, &grp, on ) == LDAP_SUCCESS && grp ) { |
4265 | 1563 | Attribute *a = attr_find( grp->e_attrs, dyn->dy_staticmember ); | 1564 | Attribute *a = attr_find( grp->e_attrs, dyn->dy_staticmember ); |
4266 | 1564 | int rc; | 1565 | int rc; |
4267 | 1565 | if ( a ) { | 1566 | if ( a ) { |
4268 | @@ -1569,7 +1570,7 @@ dynlist_test_membership(Operation *op, dynlist_name_t *dyn, Entry *e) | |||
4269 | 1569 | } else { | 1570 | } else { |
4270 | 1570 | rc = LDAP_COMPARE_FALSE; | 1571 | rc = LDAP_COMPARE_FALSE; |
4271 | 1571 | } | 1572 | } |
4273 | 1572 | overlay_entry_release_ov( op, grp, 0, (slap_overinst *)op->o_bd->bd_info ); | 1573 | overlay_entry_release_ov( op, grp, 0, on ); |
4274 | 1573 | return rc; | 1574 | return rc; |
4275 | 1574 | } | 1575 | } |
4276 | 1575 | } | 1576 | } |
4277 | @@ -1591,7 +1592,7 @@ dynlist_add_memberOf(Operation *op, SlapReply *rs, dynlist_search_t *ds) | |||
4278 | 1591 | dyn = ptr->avl_data; | 1592 | dyn = ptr->avl_data; |
4279 | 1592 | for ( dlm = dyn->dy_dli->dli_dlm; dlm; dlm = dlm->dlm_next ) { | 1593 | for ( dlm = dyn->dy_dli->dli_dlm; dlm; dlm = dlm->dlm_next ) { |
4280 | 1593 | if ( dlm->dlm_memberOf_ad ) { | 1594 | if ( dlm->dlm_memberOf_ad ) { |
4282 | 1594 | if ( dynlist_test_membership( op, dyn, e ) == LDAP_COMPARE_TRUE ) { | 1595 | if ( dynlist_test_membership( op, ds->ds_on, dyn, e ) == LDAP_COMPARE_TRUE ) { |
4283 | 1595 | /* ensure e is modifiable, but do not replace | 1596 | /* ensure e is modifiable, but do not replace |
4284 | 1596 | * sr_entry yet since we have pointers into it */ | 1597 | * sr_entry yet since we have pointers into it */ |
4285 | 1597 | if ( !( rs->sr_flags & REP_ENTRY_MODIFIABLE ) && e == rs->sr_entry ) { | 1598 | if ( !( rs->sr_flags & REP_ENTRY_MODIFIABLE ) && e == rs->sr_entry ) { |
4286 | @@ -1655,7 +1656,7 @@ dynlist_search2resp( Operation *op, SlapReply *rs ) | |||
4287 | 1655 | dyn = ldap_tavl_find( ds->ds_names, &rs->sr_entry->e_nname, dynlist_avl_cmp ); | 1656 | dyn = ldap_tavl_find( ds->ds_names, &rs->sr_entry->e_nname, dynlist_avl_cmp ); |
4288 | 1656 | if ( dyn ) { | 1657 | if ( dyn ) { |
4289 | 1657 | dyn->dy_seen = 1; | 1658 | dyn->dy_seen = 1; |
4291 | 1658 | rc = dynlist_prepare_entry( op, rs, dyn->dy_dli, dyn ); | 1659 | rc = dynlist_prepare_entry( op, rs, ds->ds_on, dyn->dy_dli, dyn ); |
4292 | 1659 | } else if ( ds->ds_want ) | 1660 | } else if ( ds->ds_want ) |
4293 | 1660 | dynlist_add_memberOf( op, rs, ds ); | 1661 | dynlist_add_memberOf( op, rs, ds ); |
4294 | 1661 | } | 1662 | } |
4295 | @@ -1667,7 +1668,7 @@ dynlist_search2resp( Operation *op, SlapReply *rs ) | |||
4296 | 1667 | for ( dli = ds->ds_dli; dli; dli = dli->dli_next ) { | 1668 | for ( dli = ds->ds_dli; dli; dli = dli->dli_next ) { |
4297 | 1668 | if ( is_entry_objectclass_or_sub( rs->sr_entry, dli->dli_oc ) && | 1669 | if ( is_entry_objectclass_or_sub( rs->sr_entry, dli->dli_oc ) && |
4298 | 1669 | dynlist_check_scope( op, rs->sr_entry, dli )) | 1670 | dynlist_check_scope( op, rs->sr_entry, dli )) |
4300 | 1670 | rc = dynlist_prepare_entry( op, rs, dli, NULL ); | 1671 | rc = dynlist_prepare_entry( op, rs, ds->ds_on, dli, NULL ); |
4301 | 1671 | } | 1672 | } |
4302 | 1672 | } | 1673 | } |
4303 | 1673 | } | 1674 | } |
4304 | @@ -1677,7 +1678,7 @@ dynlist_search2resp( Operation *op, SlapReply *rs ) | |||
4305 | 1677 | } | 1678 | } |
4306 | 1678 | return rc; | 1679 | return rc; |
4307 | 1679 | } else if ( rs->sr_type == REP_RESULT && rs->sr_err == LDAP_SUCCESS ) { | 1680 | } else if ( rs->sr_type == REP_RESULT && rs->sr_err == LDAP_SUCCESS ) { |
4309 | 1680 | slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; | 1681 | slap_overinst *on = ds->ds_on; |
4310 | 1681 | TAvlnode *ptr, *skip = NULL; | 1682 | TAvlnode *ptr, *skip = NULL; |
4311 | 1682 | SlapReply r = *rs; | 1683 | SlapReply r = *rs; |
4312 | 1683 | dynlist_map_t *dlm = NULL; | 1684 | dynlist_map_t *dlm = NULL; |
4313 | @@ -1729,7 +1730,7 @@ dynlist_search2resp( Operation *op, SlapReply *rs ) | |||
4314 | 1729 | r.sr_entry == NULL ) | 1730 | r.sr_entry == NULL ) |
4315 | 1730 | goto next; | 1731 | goto next; |
4316 | 1731 | r.sr_flags = REP_ENTRY_MUSTRELEASE; | 1732 | r.sr_flags = REP_ENTRY_MUSTRELEASE; |
4318 | 1732 | dynlist_prepare_entry( op, &r, dyn->dy_dli, dyn ); | 1733 | dynlist_prepare_entry( op, &r, on, dyn->dy_dli, dyn ); |
4319 | 1733 | if ( test_filter( op, r.sr_entry, f ) == LDAP_COMPARE_TRUE ) { | 1734 | if ( test_filter( op, r.sr_entry, f ) == LDAP_COMPARE_TRUE ) { |
4320 | 1734 | r.sr_attrs = op->ors_attrs; | 1735 | r.sr_attrs = op->ors_attrs; |
4321 | 1735 | rs->sr_err = send_search_entry( op, &r ); | 1736 | rs->sr_err = send_search_entry( op, &r ); |
4322 | @@ -1895,6 +1896,8 @@ dynlist_search( Operation *op, SlapReply *rs ) | |||
4323 | 1895 | userattrs = SLAP_USERATTRS( attrflags ); | 1896 | userattrs = SLAP_USERATTRS( attrflags ); |
4324 | 1896 | } | 1897 | } |
4325 | 1897 | 1898 | ||
4326 | 1899 | if (dlg->dlg_simple) | ||
4327 | 1900 | goto simple; | ||
4328 | 1898 | /* Find all groups in scope. For group expansion | 1901 | /* Find all groups in scope. For group expansion |
4329 | 1899 | * we only need the groups within the search scope, but | 1902 | * we only need the groups within the search scope, but |
4330 | 1900 | * for memberOf populating, we need all dyngroups. | 1903 | * for memberOf populating, we need all dyngroups. |
4331 | @@ -2063,12 +2066,14 @@ dynlist_search( Operation *op, SlapReply *rs ) | |||
4332 | 2063 | dynlist_nestlink( op, ds ); | 2066 | dynlist_nestlink( op, ds ); |
4333 | 2064 | } | 2067 | } |
4334 | 2065 | } | 2068 | } |
4335 | 2069 | simple: | ||
4336 | 2066 | 2070 | ||
4337 | 2067 | if ( dlg->dlg_dli || ds->ds_names != NULL ) { | 2071 | if ( dlg->dlg_dli || ds->ds_names != NULL ) { |
4338 | 2068 | sc->sc_response = dynlist_search2resp; | 2072 | sc->sc_response = dynlist_search2resp; |
4339 | 2069 | sc->sc_cleanup = dynlist_search_cleanup; | 2073 | sc->sc_cleanup = dynlist_search_cleanup; |
4340 | 2070 | sc->sc_next = op->o_callback; | 2074 | sc->sc_next = op->o_callback; |
4341 | 2071 | op->o_callback = sc; | 2075 | op->o_callback = sc; |
4342 | 2076 | ds->ds_on = on; | ||
4343 | 2072 | 2077 | ||
4344 | 2073 | /* dynamic lists need this */ | 2078 | /* dynamic lists need this */ |
4345 | 2074 | ds->ds_dli = dlg->dlg_dli; | 2079 | ds->ds_dli = dlg->dlg_dli; |
4346 | @@ -2145,6 +2150,13 @@ static ConfigTable dlcfg[] = { | |||
4347 | 2145 | 3, 3, 0, ARG_MAGIC|DL_ATTRPAIR_COMPAT, dl_cfgen, | 2150 | 3, 3, 0, ARG_MAGIC|DL_ATTRPAIR_COMPAT, dl_cfgen, |
4348 | 2146 | NULL, NULL, NULL }, | 2151 | NULL, NULL, NULL }, |
4349 | 2147 | #endif | 2152 | #endif |
4350 | 2153 | { "dynlist-simple", NULL, 0, 0, 0, ARG_OFFSET|ARG_ON_OFF, | ||
4351 | 2154 | (void *)offsetof(dynlist_gen_t, dlg_simple), | ||
4352 | 2155 | "( OLcfgOvAt:8.2 NAME 'olcDynListSimple' " | ||
4353 | 2156 | "DESC 'Simple mode - disable features added since 2.4.' " | ||
4354 | 2157 | "EQUALITY booleanMatch " | ||
4355 | 2158 | "SYNTAX OMsBoolean SINGLE-VALUE )", | ||
4356 | 2159 | NULL, NULL }, | ||
4357 | 2148 | { NULL, NULL, 0, 0, 0, ARG_IGNORED } | 2160 | { NULL, NULL, 0, 0, 0, ARG_IGNORED } |
4358 | 2149 | }; | 2161 | }; |
4359 | 2150 | 2162 | ||
4360 | @@ -2153,7 +2165,7 @@ static ConfigOCs dlocs[] = { | |||
4361 | 2153 | "NAME ( 'olcDynListConfig' 'olcDynamicList' ) " | 2165 | "NAME ( 'olcDynListConfig' 'olcDynamicList' ) " |
4362 | 2154 | "DESC 'Dynamic list configuration' " | 2166 | "DESC 'Dynamic list configuration' " |
4363 | 2155 | "SUP olcOverlayConfig " | 2167 | "SUP olcOverlayConfig " |
4365 | 2156 | "MAY olcDynListAttrSet )", | 2168 | "MAY ( olcDynListAttrSet $ olcDynListSimple ) )", |
4366 | 2157 | Cft_Overlay, dlcfg, NULL, NULL }, | 2169 | Cft_Overlay, dlcfg, NULL, NULL }, |
4367 | 2158 | { NULL, 0, NULL } | 2170 | { NULL, 0, NULL } |
4368 | 2159 | }; | 2171 | }; |
4369 | @@ -2740,10 +2752,13 @@ dynlist_db_init( | |||
4370 | 2740 | slap_overinst *on = (slap_overinst *)be->bd_info; | 2752 | slap_overinst *on = (slap_overinst *)be->bd_info; |
4371 | 2741 | dynlist_gen_t *dlg; | 2753 | dynlist_gen_t *dlg; |
4372 | 2742 | 2754 | ||
4374 | 2743 | dlg = (dynlist_gen_t *)ch_malloc( sizeof( *dlg )); | 2755 | if ( SLAP_ISGLOBALOVERLAY( be ) ) { |
4375 | 2756 | Debug( LDAP_DEBUG_ANY, "dynlist cannot be used as global overlay.\n" ); | ||
4376 | 2757 | return 1; | ||
4377 | 2758 | } | ||
4378 | 2759 | |||
4379 | 2760 | dlg = (dynlist_gen_t *)ch_calloc( 1, sizeof( *dlg )); | ||
4380 | 2744 | on->on_bi.bi_private = dlg; | 2761 | on->on_bi.bi_private = dlg; |
4381 | 2745 | dlg->dlg_dli = NULL; | ||
4382 | 2746 | dlg->dlg_memberOf = 0; | ||
4383 | 2747 | 2762 | ||
4384 | 2748 | return 0; | 2763 | return 0; |
4385 | 2749 | } | 2764 | } |
4386 | diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h | |||
4387 | index 106a371..c1364a9 100644 | |||
4388 | --- a/servers/slapd/proto-slap.h | |||
4389 | +++ b/servers/slapd/proto-slap.h | |||
4390 | @@ -100,9 +100,7 @@ LDAP_SLAPD_F (int) acl_string_expand LDAP_P(( | |||
4391 | 100 | */ | 100 | */ |
4392 | 101 | LDAP_SLAPD_V (LDAP_CONST char *) style_strings[]; | 101 | LDAP_SLAPD_V (LDAP_CONST char *) style_strings[]; |
4393 | 102 | 102 | ||
4397 | 103 | LDAP_SLAPD_F (int) parse_acl LDAP_P(( Backend *be, | 103 | LDAP_SLAPD_F (int) parse_acl LDAP_P(( struct config_args_s *ca, int pos )); |
4395 | 104 | const char *fname, int lineno, | ||
4396 | 105 | int argc, char **argv, int pos )); | ||
4398 | 106 | 104 | ||
4399 | 107 | LDAP_SLAPD_F (char *) access2str LDAP_P(( slap_access_t access )); | 105 | LDAP_SLAPD_F (char *) access2str LDAP_P(( slap_access_t access )); |
4400 | 108 | LDAP_SLAPD_F (slap_access_t) str2access LDAP_P(( const char *str )); | 106 | LDAP_SLAPD_F (slap_access_t) str2access LDAP_P(( const char *str )); |
4401 | diff --git a/servers/slapd/slap-config.h b/servers/slapd/slap-config.h | |||
4402 | index 3252fd7..5682204 100644 | |||
4403 | --- a/servers/slapd/slap-config.h | |||
4404 | +++ b/servers/slapd/slap-config.h | |||
4405 | @@ -196,31 +196,31 @@ typedef struct config_args_s { | |||
4406 | 196 | #define value_ndn values.v_dn.vdn_ndn | 196 | #define value_ndn values.v_dn.vdn_ndn |
4407 | 197 | #define value_ad values.v_ad | 197 | #define value_ad values.v_ad |
4408 | 198 | 198 | ||
4426 | 199 | int config_fp_parse_line(ConfigArgs *c); | 199 | LDAP_SLAPD_F (int) config_fp_parse_line(ConfigArgs *c); |
4427 | 200 | 200 | ||
4428 | 201 | int config_register_schema(ConfigTable *ct, ConfigOCs *co); | 201 | LDAP_SLAPD_F (int) config_register_schema(ConfigTable *ct, ConfigOCs *co); |
4429 | 202 | int config_del_vals(ConfigTable *cf, ConfigArgs *c); | 202 | LDAP_SLAPD_F (int) config_del_vals(ConfigTable *cf, ConfigArgs *c); |
4430 | 203 | int config_get_vals(ConfigTable *ct, ConfigArgs *c); | 203 | LDAP_SLAPD_F (int) config_get_vals(ConfigTable *ct, ConfigArgs *c); |
4431 | 204 | int config_add_vals(ConfigTable *ct, ConfigArgs *c); | 204 | LDAP_SLAPD_F (int) config_add_vals(ConfigTable *ct, ConfigArgs *c); |
4432 | 205 | 205 | ||
4433 | 206 | int config_push_cleanup(ConfigArgs *c, ConfigDriver *cleanup); | 206 | LDAP_SLAPD_F (int) config_push_cleanup(ConfigArgs *c, ConfigDriver *cleanup); |
4434 | 207 | int config_run_cleanup(ConfigArgs *c); | 207 | LDAP_SLAPD_F (int) config_run_cleanup(ConfigArgs *c); |
4435 | 208 | 208 | ||
4436 | 209 | void init_config_argv( ConfigArgs *c ); | 209 | LDAP_SLAPD_F (void) init_config_argv( ConfigArgs *c ); |
4437 | 210 | int init_config_attrs(ConfigTable *ct); | 210 | LDAP_SLAPD_F (int) init_config_attrs(ConfigTable *ct); |
4438 | 211 | int init_config_ocs( ConfigOCs *ocs ); | 211 | LDAP_SLAPD_F (int) init_config_ocs( ConfigOCs *ocs ); |
4439 | 212 | void config_parse_ldif( ConfigArgs *c ); | 212 | LDAP_SLAPD_F (void) config_parse_ldif( ConfigArgs *c ); |
4440 | 213 | int config_parse_vals(ConfigTable *ct, ConfigArgs *c, int valx); | 213 | LDAP_SLAPD_F (int) config_parse_vals(ConfigTable *ct, ConfigArgs *c, int valx); |
4441 | 214 | int config_parse_add(ConfigTable *ct, ConfigArgs *c, int valx); | 214 | LDAP_SLAPD_F (int) config_parse_add(ConfigTable *ct, ConfigArgs *c, int valx); |
4442 | 215 | int read_config_file(const char *fname, int depth, ConfigArgs *cf, | 215 | LDAP_SLAPD_F (int) read_config_file(const char *fname, int depth, ConfigArgs *cf, |
4443 | 216 | ConfigTable *cft ); | 216 | ConfigTable *cft ); |
4444 | 217 | 217 | ||
4447 | 218 | ConfigTable * config_find_keyword(ConfigTable *ct, ConfigArgs *c); | 218 | LDAP_SLAPD_F (ConfigTable *) config_find_keyword(ConfigTable *ct, ConfigArgs *c); |
4448 | 219 | Entry * config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent, | 219 | LDAP_SLAPD_F (Entry *) config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent, |
4449 | 220 | ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra ); | 220 | ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra ); |
4450 | 221 | 221 | ||
4453 | 222 | Listener *config_check_my_url(const char *url, LDAPURLDesc *lud); | 222 | LDAP_SLAPD_F (Listener *) config_check_my_url(const char *url, LDAPURLDesc *lud); |
4454 | 223 | int config_shadow( ConfigArgs *c, slap_mask_t flag ); | 223 | LDAP_SLAPD_F (int) config_shadow( ConfigArgs *c, slap_mask_t flag ); |
4455 | 224 | #define config_slurp_shadow(c) config_shadow((c), SLAP_DBFLAG_SLURP_SHADOW) | 224 | #define config_slurp_shadow(c) config_shadow((c), SLAP_DBFLAG_SLURP_SHADOW) |
4456 | 225 | #define config_sync_shadow(c) config_shadow((c), SLAP_DBFLAG_SYNC_SHADOW) | 225 | #define config_sync_shadow(c) config_shadow((c), SLAP_DBFLAG_SYNC_SHADOW) |
4457 | 226 | 226 | ||
4458 | @@ -231,7 +231,7 @@ int config_shadow( ConfigArgs *c, slap_mask_t flag ); | |||
4459 | 231 | #define SLAP_X_ORDERED_FMT "{%d}" | 231 | #define SLAP_X_ORDERED_FMT "{%d}" |
4460 | 232 | 232 | ||
4461 | 233 | LDAP_SLAPD_V (slap_verbmasks *) slap_ldap_response_code; | 233 | LDAP_SLAPD_V (slap_verbmasks *) slap_ldap_response_code; |
4463 | 234 | extern int slap_ldap_response_code_register( struct berval *bv, int err ); | 234 | LDAP_SLAPD_F (int) slap_ldap_response_code_register( struct berval *bv, int err ); |
4464 | 235 | 235 | ||
4465 | 236 | LDAP_SLAPD_V (ConfigTable) olcDatabaseDummy[]; | 236 | LDAP_SLAPD_V (ConfigTable) olcDatabaseDummy[]; |
4466 | 237 | 237 | ||
4467 | diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h | |||
4468 | index 5cf2f46..605a80f 100644 | |||
4469 | --- a/servers/slapd/slap.h | |||
4470 | +++ b/servers/slapd/slap.h | |||
4471 | @@ -1319,12 +1319,15 @@ typedef struct AuthorizationInformation { | |||
4472 | 1319 | slap_ssf_t sai_sasl_ssf; /* SASL SSF */ | 1319 | slap_ssf_t sai_sasl_ssf; /* SASL SSF */ |
4473 | 1320 | } AuthorizationInformation; | 1320 | } AuthorizationInformation; |
4474 | 1321 | 1321 | ||
4475 | 1322 | typedef struct config_args_s ConfigArgs; /* slap-config.h */ | ||
4476 | 1323 | typedef struct config_reply_s ConfigReply; /* slap-config.h */ | ||
4477 | 1324 | |||
4478 | 1322 | #ifdef SLAP_DYNACL | 1325 | #ifdef SLAP_DYNACL |
4479 | 1323 | 1326 | ||
4480 | 1324 | /* | 1327 | /* |
4481 | 1325 | * "dynamic" ACL infrastructure (for ACIs and more) | 1328 | * "dynamic" ACL infrastructure (for ACIs and more) |
4482 | 1326 | */ | 1329 | */ |
4484 | 1327 | typedef int (slap_dynacl_parse) LDAP_P(( const char *fname, int lineno, | 1330 | typedef int (slap_dynacl_parse) LDAP_P(( ConfigArgs *ca, |
4485 | 1328 | const char *opts, slap_style_t, const char *, void **privp )); | 1331 | const char *opts, slap_style_t, const char *, void **privp )); |
4486 | 1329 | typedef int (slap_dynacl_unparse) LDAP_P(( void *priv, struct berval *bv )); | 1332 | typedef int (slap_dynacl_unparse) LDAP_P(( void *priv, struct berval *bv )); |
4487 | 1330 | typedef int (slap_dynacl_mask) LDAP_P(( | 1333 | typedef int (slap_dynacl_mask) LDAP_P(( |
4488 | @@ -2019,7 +2022,6 @@ typedef int (BI_config) LDAP_P((BackendInfo *bi, | |||
4489 | 2019 | const char *fname, int lineno, | 2022 | const char *fname, int lineno, |
4490 | 2020 | int argc, char **argv)); | 2023 | int argc, char **argv)); |
4491 | 2021 | 2024 | ||
4492 | 2022 | typedef struct config_reply_s ConfigReply; /* slap-config.h */ | ||
4493 | 2023 | typedef int (BI_db_func) LDAP_P((Backend *bd, ConfigReply *cr)); | 2025 | typedef int (BI_db_func) LDAP_P((Backend *bd, ConfigReply *cr)); |
4494 | 2024 | typedef BI_db_func BI_db_init; | 2026 | typedef BI_db_func BI_db_init; |
4495 | 2025 | typedef BI_db_func BI_db_open; | 2027 | typedef BI_db_func BI_db_open; |
4496 | diff --git a/servers/slapd/slapi/Makefile.in b/servers/slapd/slapi/Makefile.in | |||
4497 | index 0e46f78..32ade0c 100644 | |||
4498 | --- a/servers/slapd/slapi/Makefile.in | |||
4499 | +++ b/servers/slapd/slapi/Makefile.in | |||
4500 | @@ -19,9 +19,6 @@ LIBRARY = libslapi.la | |||
4501 | 19 | #all-common: $(LIBRARY) $(PROGRAMS) | 19 | #all-common: $(LIBRARY) $(PROGRAMS) |
4502 | 20 | # @touch plugin.c slapi_pblock.c slapi_utils.c slapi_ops.c slapi_ext.c | 20 | # @touch plugin.c slapi_pblock.c slapi_utils.c slapi_ops.c slapi_ext.c |
4503 | 21 | 21 | ||
4504 | 22 | NT_SRCS = nt_err.c | ||
4505 | 23 | NT_OBJS = nt_err.lo | ||
4506 | 24 | |||
4507 | 25 | LIB_DEFS = -DSLAPI_LIBRARY | 22 | LIB_DEFS = -DSLAPI_LIBRARY |
4508 | 26 | 23 | ||
4509 | 27 | SRCS= plugin.c slapi_pblock.c slapi_utils.c printmsg.c slapi_ops.c slapi_dn.c slapi_ext.c slapi_overlay.c \ | 24 | SRCS= plugin.c slapi_pblock.c slapi_utils.c printmsg.c slapi_ops.c slapi_dn.c slapi_ext.c slapi_overlay.c \ |
4510 | @@ -31,12 +28,15 @@ OBJS= plugin.lo slapi_pblock.lo slapi_utils.lo printmsg.lo slapi_ops.lo slapi_d | |||
4511 | 31 | 28 | ||
4512 | 32 | XSRCS= version.c | 29 | XSRCS= version.c |
4513 | 33 | 30 | ||
4516 | 34 | LDAP_INCDIR= ../../../include -I.. -I. | 31 | LDAP_INCDIR= ../../../include -I.. -I. |
4517 | 35 | LDAP_LIBDIR= ../../../libraries | 32 | LDAP_LIBDIR= ../../../libraries |
4518 | 33 | |||
4519 | 34 | shared_LDAP_LIBS = $(LDAP_LIBLDAP_LA) $(LDAP_LIBLBER_LA) | ||
4520 | 36 | 35 | ||
4521 | 37 | XLIBS = $(LIBRARY) | 36 | XLIBS = $(LIBRARY) |
4522 | 38 | XXLIBS = | 37 | XXLIBS = |
4524 | 39 | NT_LINK_LIBS = $(AC_LIBS) | 38 | MOD_LIBS = $(MODULES_LIBS) |
4525 | 39 | NT_LINK_LIBS = $(AC_LIBS) -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) | ||
4526 | 40 | 40 | ||
4527 | 41 | XINCPATH = -I$(srcdir)/.. -I$(srcdir) | 41 | XINCPATH = -I$(srcdir)/.. -I$(srcdir) |
4528 | 42 | XDEFS = $(MODULES_CPPFLAGS) | 42 | XDEFS = $(MODULES_CPPFLAGS) |
4529 | diff --git a/servers/slapd/slapi/plugin.c b/servers/slapd/slapi/plugin.c | |||
4530 | index de8c60d..ca5dbea 100644 | |||
4531 | --- a/servers/slapd/slapi/plugin.c | |||
4532 | +++ b/servers/slapd/slapi/plugin.c | |||
4533 | @@ -36,7 +36,7 @@ | |||
4534 | 36 | #include <ltdl.h> | 36 | #include <ltdl.h> |
4535 | 37 | 37 | ||
4536 | 38 | static int slapi_int_load_plugin( Slapi_PBlock *, const char *, const char *, int, | 38 | static int slapi_int_load_plugin( Slapi_PBlock *, const char *, const char *, int, |
4538 | 39 | SLAPI_FUNC *, lt_dlhandle * ); | 39 | SLAPI_FUNC *, lt_dlhandle *, ConfigArgs *c ); |
4539 | 40 | 40 | ||
4540 | 41 | /* pointer to link list of extended objects */ | 41 | /* pointer to link list of extended objects */ |
4541 | 42 | static ExtendedOp *pGExtendedOps = NULL; | 42 | static ExtendedOp *pGExtendedOps = NULL; |
4542 | @@ -68,15 +68,15 @@ static Slapi_PBlock * | |||
4543 | 68 | plugin_pblock_new( | 68 | plugin_pblock_new( |
4544 | 69 | int type, | 69 | int type, |
4545 | 70 | int argc, | 70 | int argc, |
4547 | 71 | char *argv[] ) | 71 | ConfigArgs *c ) |
4548 | 72 | { | 72 | { |
4549 | 73 | Slapi_PBlock *pPlugin = NULL; | 73 | Slapi_PBlock *pPlugin = NULL; |
4550 | 74 | Slapi_PluginDesc *pPluginDesc = NULL; | 74 | Slapi_PluginDesc *pPluginDesc = NULL; |
4551 | 75 | lt_dlhandle hdLoadHandle; | 75 | lt_dlhandle hdLoadHandle; |
4552 | 76 | int rc; | 76 | int rc; |
4553 | 77 | char **av2 = NULL, **ppPluginArgv; | 77 | char **av2 = NULL, **ppPluginArgv; |
4556 | 78 | char *path = argv[2]; | 78 | char *path = c->argv[2]; |
4557 | 79 | char *initfunc = argv[3]; | 79 | char *initfunc = c->argv[3]; |
4558 | 80 | 80 | ||
4559 | 81 | pPlugin = slapi_pblock_new(); | 81 | pPlugin = slapi_pblock_new(); |
4560 | 82 | if ( pPlugin == NULL ) { | 82 | if ( pPlugin == NULL ) { |
4561 | @@ -87,7 +87,7 @@ plugin_pblock_new( | |||
4562 | 87 | slapi_pblock_set( pPlugin, SLAPI_PLUGIN_TYPE, (void *)&type ); | 87 | slapi_pblock_set( pPlugin, SLAPI_PLUGIN_TYPE, (void *)&type ); |
4563 | 88 | slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGC, (void *)&argc ); | 88 | slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGC, (void *)&argc ); |
4564 | 89 | 89 | ||
4566 | 90 | av2 = ldap_charray_dup( argv ); | 90 | av2 = ldap_charray_dup( c->argv ); |
4567 | 91 | if ( av2 == NULL ) { | 91 | if ( av2 == NULL ) { |
4568 | 92 | rc = LDAP_NO_MEMORY; | 92 | rc = LDAP_NO_MEMORY; |
4569 | 93 | goto done; | 93 | goto done; |
4570 | @@ -102,7 +102,7 @@ plugin_pblock_new( | |||
4571 | 102 | slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGV, (void *)ppPluginArgv ); | 102 | slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGV, (void *)ppPluginArgv ); |
4572 | 103 | slapi_pblock_set( pPlugin, SLAPI_X_CONFIG_ARGV, (void *)av2 ); | 103 | slapi_pblock_set( pPlugin, SLAPI_X_CONFIG_ARGV, (void *)av2 ); |
4573 | 104 | 104 | ||
4575 | 105 | rc = slapi_int_load_plugin( pPlugin, path, initfunc, 1, NULL, &hdLoadHandle ); | 105 | rc = slapi_int_load_plugin( pPlugin, path, initfunc, 1, NULL, &hdLoadHandle, c ); |
4576 | 106 | if ( rc != 0 ) { | 106 | if ( rc != 0 ) { |
4577 | 107 | goto done; | 107 | goto done; |
4578 | 108 | } | 108 | } |
4579 | @@ -556,7 +556,8 @@ slapi_int_load_plugin( | |||
4580 | 556 | const char *initfunc, | 556 | const char *initfunc, |
4581 | 557 | int doInit, | 557 | int doInit, |
4582 | 558 | SLAPI_FUNC *pInitFunc, | 558 | SLAPI_FUNC *pInitFunc, |
4584 | 559 | lt_dlhandle *pLdHandle ) | 559 | lt_dlhandle *pLdHandle, |
4585 | 560 | ConfigArgs *c ) | ||
4586 | 560 | { | 561 | { |
4587 | 561 | int rc = LDAP_SUCCESS; | 562 | int rc = LDAP_SUCCESS; |
4588 | 562 | SLAPI_FUNC fpInitFunc = NULL; | 563 | SLAPI_FUNC fpInitFunc = NULL; |
4589 | @@ -570,15 +571,17 @@ slapi_int_load_plugin( | |||
4590 | 570 | /* load in the module */ | 571 | /* load in the module */ |
4591 | 571 | *pLdHandle = lt_dlopen( path ); | 572 | *pLdHandle = lt_dlopen( path ); |
4592 | 572 | if ( *pLdHandle == NULL ) { | 573 | if ( *pLdHandle == NULL ) { |
4594 | 573 | fprintf( stderr, "failed to load plugin %s: %s\n", | 574 | snprintf( c->cr_msg, sizeof( c->cr_msg ), "failed to load plugin %s: %s", |
4595 | 574 | path, lt_dlerror() ); | 575 | path, lt_dlerror() ); |
4596 | 576 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
4597 | 575 | return LDAP_LOCAL_ERROR; | 577 | return LDAP_LOCAL_ERROR; |
4598 | 576 | } | 578 | } |
4599 | 577 | 579 | ||
4600 | 578 | fpInitFunc = (SLAPI_FUNC)lt_dlsym( *pLdHandle, initfunc ); | 580 | fpInitFunc = (SLAPI_FUNC)lt_dlsym( *pLdHandle, initfunc ); |
4601 | 579 | if ( fpInitFunc == NULL ) { | 581 | if ( fpInitFunc == NULL ) { |
4603 | 580 | fprintf( stderr, "failed to find symbol %s in plugin %s: %s\n", | 582 | snprintf( c->cr_msg, sizeof( c->cr_msg ), "failed to find symbol %s in plugin %s: %s", |
4604 | 581 | initfunc, path, lt_dlerror() ); | 583 | initfunc, path, lt_dlerror() ); |
4605 | 584 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
4606 | 582 | lt_dlclose( *pLdHandle ); | 585 | lt_dlclose( *pLdHandle ); |
4607 | 583 | return LDAP_LOCAL_ERROR; | 586 | return LDAP_LOCAL_ERROR; |
4608 | 584 | } | 587 | } |
4609 | @@ -643,50 +646,46 @@ slapi_int_call_plugins( | |||
4610 | 643 | 646 | ||
4611 | 644 | int | 647 | int |
4612 | 645 | slapi_int_read_config( | 648 | slapi_int_read_config( |
4619 | 646 | Backend *be, | 649 | struct config_args_s *c ) |
4614 | 647 | const char *fname, | ||
4615 | 648 | int lineno, | ||
4616 | 649 | int argc, | ||
4617 | 650 | char **argv, | ||
4618 | 651 | int index ) | ||
4620 | 652 | { | 650 | { |
4621 | 653 | int iType = -1; | 651 | int iType = -1; |
4622 | 654 | int numPluginArgc = 0; | 652 | int numPluginArgc = 0; |
4623 | 655 | 653 | ||
4627 | 656 | if ( argc < 4 ) { | 654 | if ( c->argc < 4 ) { |
4628 | 657 | fprintf( stderr, | 655 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
4629 | 658 | "%s: line %d: missing arguments " | 656 | "missing arguments " |
4630 | 659 | "in \"plugin <plugin_type> <lib_path> " | 657 | "in \"plugin <plugin_type> <lib_path> " |
4633 | 660 | "<init_function> [<arguments>]\" line\n", | 658 | "<init_function> [<arguments>]\" line" ); |
4634 | 661 | fname, lineno ); | 659 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); |
4635 | 662 | return 1; | 660 | return 1; |
4636 | 663 | } | 661 | } |
4637 | 664 | 662 | ||
4638 | 665 | /* automatically instantiate overlay if necessary */ | 663 | /* automatically instantiate overlay if necessary */ |
4644 | 666 | if ( !slapi_over_is_inst( be ) ) { | 664 | if ( !slapi_over_is_inst( c->be ) ) { |
4645 | 667 | ConfigReply cr = { 0 }; | 665 | if ( slapi_over_config( c->be, &c->reply ) != 0 ) { |
4646 | 668 | if ( slapi_over_config( be, &cr ) != 0 ) { | 666 | Debug( LDAP_DEBUG_ANY, "%s: " |
4647 | 669 | fprintf( stderr, "Failed to instantiate SLAPI overlay: " | 667 | "Failed to instantiate SLAPI overlay: " |
4648 | 670 | "err=%d msg=\"%s\"\n", cr.err, cr.msg ); | 668 | "err=%d msg=\"%s\"\n", c->log, c->reply.err, c->reply.msg ); |
4649 | 671 | return -1; | 669 | return -1; |
4650 | 672 | } | 670 | } |
4651 | 673 | } | 671 | } |
4652 | 674 | 672 | ||
4654 | 675 | if ( strcasecmp( argv[1], "preoperation" ) == 0 ) { | 673 | if ( strcasecmp( c->argv[1], "preoperation" ) == 0 ) { |
4655 | 676 | iType = SLAPI_PLUGIN_PREOPERATION; | 674 | iType = SLAPI_PLUGIN_PREOPERATION; |
4657 | 677 | } else if ( strcasecmp( argv[1], "postoperation" ) == 0 ) { | 675 | } else if ( strcasecmp( c->argv[1], "postoperation" ) == 0 ) { |
4658 | 678 | iType = SLAPI_PLUGIN_POSTOPERATION; | 676 | iType = SLAPI_PLUGIN_POSTOPERATION; |
4660 | 679 | } else if ( strcasecmp( argv[1], "extendedop" ) == 0 ) { | 677 | } else if ( strcasecmp( c->argv[1], "extendedop" ) == 0 ) { |
4661 | 680 | iType = SLAPI_PLUGIN_EXTENDEDOP; | 678 | iType = SLAPI_PLUGIN_EXTENDEDOP; |
4663 | 681 | } else if ( strcasecmp( argv[1], "object" ) == 0 ) { | 679 | } else if ( strcasecmp( c->argv[1], "object" ) == 0 ) { |
4664 | 682 | iType = SLAPI_PLUGIN_OBJECT; | 680 | iType = SLAPI_PLUGIN_OBJECT; |
4665 | 683 | } else { | 681 | } else { |
4668 | 684 | fprintf( stderr, "%s: line %d: invalid plugin type \"%s\".\n", | 682 | snprintf( c->cr_msg, sizeof( c->cr_msg ), |
4669 | 685 | fname, lineno, argv[1] ); | 683 | "invalid plugin type \"%s\"", c->argv[1] ); |
4670 | 684 | Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->cr_msg ); | ||
4671 | 686 | return 1; | 685 | return 1; |
4672 | 687 | } | 686 | } |
4673 | 688 | 687 | ||
4675 | 689 | numPluginArgc = argc - 4; | 688 | numPluginArgc = c->argc - 4; |
4676 | 690 | 689 | ||
4677 | 691 | if ( iType == SLAPI_PLUGIN_PREOPERATION || | 690 | if ( iType == SLAPI_PLUGIN_PREOPERATION || |
4678 | 692 | iType == SLAPI_PLUGIN_EXTENDEDOP || | 691 | iType == SLAPI_PLUGIN_EXTENDEDOP || |
4679 | @@ -695,23 +694,23 @@ slapi_int_read_config( | |||
4680 | 695 | int rc; | 694 | int rc; |
4681 | 696 | Slapi_PBlock *pPlugin; | 695 | Slapi_PBlock *pPlugin; |
4682 | 697 | 696 | ||
4684 | 698 | pPlugin = plugin_pblock_new( iType, numPluginArgc, argv ); | 697 | pPlugin = plugin_pblock_new( iType, numPluginArgc, c->argv ); |
4685 | 699 | if (pPlugin == NULL) { | 698 | if (pPlugin == NULL) { |
4686 | 700 | return 1; | 699 | return 1; |
4687 | 701 | } | 700 | } |
4688 | 702 | 701 | ||
4689 | 703 | if (iType == SLAPI_PLUGIN_EXTENDEDOP) { | 702 | if (iType == SLAPI_PLUGIN_EXTENDEDOP) { |
4691 | 704 | rc = slapi_int_register_extop(be, &pGExtendedOps, pPlugin); | 703 | rc = slapi_int_register_extop(c->be, &pGExtendedOps, pPlugin); |
4692 | 705 | if ( rc != LDAP_SUCCESS ) { | 704 | if ( rc != LDAP_SUCCESS ) { |
4693 | 706 | slapi_pblock_destroy( pPlugin ); | 705 | slapi_pblock_destroy( pPlugin ); |
4694 | 707 | return 1; | 706 | return 1; |
4695 | 708 | } | 707 | } |
4696 | 709 | } | 708 | } |
4697 | 710 | 709 | ||
4699 | 711 | rc = slapi_int_register_plugin_index( be, pPlugin, index ); | 710 | rc = slapi_int_register_plugin_index( c->be, pPlugin, c->valx ); |
4700 | 712 | if ( rc != LDAP_SUCCESS ) { | 711 | if ( rc != LDAP_SUCCESS ) { |
4701 | 713 | if ( iType == SLAPI_PLUGIN_EXTENDEDOP ) { | 712 | if ( iType == SLAPI_PLUGIN_EXTENDEDOP ) { |
4703 | 714 | slapi_int_unregister_extop( be, &pGExtendedOps, pPlugin ); | 713 | slapi_int_unregister_extop( c->be, &pGExtendedOps, pPlugin ); |
4704 | 715 | } | 714 | } |
4705 | 716 | slapi_pblock_destroy( pPlugin ); | 715 | slapi_pblock_destroy( pPlugin ); |
4706 | 717 | return 1; | 716 | return 1; |
4707 | diff --git a/servers/slapd/slapi/printmsg.c b/servers/slapd/slapi/printmsg.c | |||
4708 | index 15b6004..5251846 100644 | |||
4709 | --- a/servers/slapd/slapi/printmsg.c | |||
4710 | +++ b/servers/slapd/slapi/printmsg.c | |||
4711 | @@ -32,6 +32,10 @@ | |||
4712 | 32 | #include <slap.h> | 32 | #include <slap.h> |
4713 | 33 | #include <slapi.h> | 33 | #include <slapi.h> |
4714 | 34 | 34 | ||
4715 | 35 | #ifdef _WIN32 | ||
4716 | 36 | #include <io.h> | ||
4717 | 37 | #endif | ||
4718 | 38 | |||
4719 | 35 | #include <ldap_pvt_thread.h> | 39 | #include <ldap_pvt_thread.h> |
4720 | 36 | 40 | ||
4721 | 37 | /* Single threads access to routine */ | 41 | /* Single threads access to routine */ |
4722 | @@ -60,18 +64,30 @@ slapi_int_log_error( | |||
4723 | 60 | 64 | ||
4724 | 61 | /* for now, we log all severities */ | 65 | /* for now, we log all severities */ |
4725 | 62 | if ( level <= slapi_log_level ) { | 66 | if ( level <= slapi_log_level ) { |
4726 | 67 | #ifdef _WIN32 | ||
4727 | 68 | intptr_t fhandle; | ||
4728 | 69 | #endif | ||
4729 | 63 | fp = fopen( slapi_log_file, "a" ); | 70 | fp = fopen( slapi_log_file, "a" ); |
4730 | 64 | if ( fp == NULL) { | 71 | if ( fp == NULL) { |
4731 | 65 | rc = -1; | 72 | rc = -1; |
4732 | 66 | goto done; | 73 | goto done; |
4733 | 67 | } | 74 | } |
4734 | 68 | 75 | ||
4735 | 76 | #ifdef _WIN32 | ||
4736 | 77 | fhandle = _get_osfhandle( fileno( fp )); | ||
4737 | 78 | #endif | ||
4738 | 69 | /* | 79 | /* |
4739 | 70 | * FIXME: could block | 80 | * FIXME: could block |
4740 | 71 | */ | 81 | */ |
4741 | 82 | #ifdef _WIN32 | ||
4742 | 83 | while ( LockFile( fhandle, 0, 0, UINT_MAX, UINT_MAX ) == 0 ) { | ||
4743 | 84 | /* DO NOTHING */ ; | ||
4744 | 85 | } | ||
4745 | 86 | #else | ||
4746 | 72 | while ( lockf( fileno( fp ), F_LOCK, 0 ) != 0 ) { | 87 | while ( lockf( fileno( fp ), F_LOCK, 0 ) != 0 ) { |
4747 | 73 | /* DO NOTHING */ ; | 88 | /* DO NOTHING */ ; |
4748 | 74 | } | 89 | } |
4749 | 90 | #endif | ||
4750 | 75 | 91 | ||
4751 | 76 | time( ¤tTime ); | 92 | time( ¤tTime ); |
4752 | 77 | ltm = localtime( ¤tTime ); | 93 | ltm = localtime( ¤tTime ); |
4753 | @@ -85,7 +101,11 @@ slapi_int_log_error( | |||
4754 | 85 | } | 101 | } |
4755 | 86 | fflush( fp ); | 102 | fflush( fp ); |
4756 | 87 | 103 | ||
4757 | 104 | #ifdef _WIN32 | ||
4758 | 105 | UnlockFile( fhandle, 0, 0, UINT_MAX, UINT_MAX ); | ||
4759 | 106 | #else | ||
4760 | 88 | lockf( fileno( fp ), F_ULOCK, 0 ); | 107 | lockf( fileno( fp ), F_ULOCK, 0 ); |
4761 | 108 | #endif | ||
4762 | 89 | 109 | ||
4763 | 90 | fclose( fp ); | 110 | fclose( fp ); |
4764 | 91 | 111 | ||
4765 | diff --git a/servers/slapd/slapi/proto-slapi.h b/servers/slapd/slapi/proto-slapi.h | |||
4766 | index 9d52510..e9eb76b 100644 | |||
4767 | --- a/servers/slapd/slapi/proto-slapi.h | |||
4768 | +++ b/servers/slapd/slapi/proto-slapi.h | |||
4769 | @@ -72,8 +72,7 @@ LDAP_SLAPI_F (int) slapi_int_register_extop LDAP_P((Backend *pBE, ExtendedOp **o | |||
4770 | 72 | LDAP_SLAPI_F (int) slapi_int_get_extop_plugin LDAP_P((struct berval *reqoid, SLAPI_FUNC *pFuncAddr )); | 72 | LDAP_SLAPI_F (int) slapi_int_get_extop_plugin LDAP_P((struct berval *reqoid, SLAPI_FUNC *pFuncAddr )); |
4771 | 73 | LDAP_SLAPI_F (struct berval *) slapi_int_get_supported_extop LDAP_P(( int )); | 73 | LDAP_SLAPI_F (struct berval *) slapi_int_get_supported_extop LDAP_P(( int )); |
4772 | 74 | LDAP_SLAPI_F (int) slapi_int_unregister_plugins LDAP_P((Backend *be, int index)); | 74 | LDAP_SLAPI_F (int) slapi_int_unregister_plugins LDAP_P((Backend *be, int index)); |
4775 | 75 | LDAP_SLAPI_F (int) slapi_int_read_config LDAP_P((Backend *be, const char *fname, int lineno, | 75 | LDAP_SLAPI_F (int) slapi_int_read_config LDAP_P(( struct config_args_s *c )); |
4774 | 76 | int argc, char **argv, int index )); | ||
4776 | 77 | LDAP_SLAPI_F (void) slapi_int_plugin_unparse LDAP_P((Backend *be, BerVarray *out )); | 76 | LDAP_SLAPI_F (void) slapi_int_plugin_unparse LDAP_P((Backend *be, BerVarray *out )); |
4777 | 78 | LDAP_SLAPI_F (int) slapi_int_initialize LDAP_P((void)); | 77 | LDAP_SLAPI_F (int) slapi_int_initialize LDAP_P((void)); |
4778 | 79 | 78 | ||
4779 | diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c | |||
4780 | index 6c1cecf..c459122 100644 | |||
4781 | --- a/servers/slapd/slapi/slapi_utils.c | |||
4782 | +++ b/servers/slapd/slapi/slapi_utils.c | |||
4783 | @@ -31,7 +31,11 @@ | |||
4784 | 31 | #include <slap.h> | 31 | #include <slap.h> |
4785 | 32 | #include <slapi.h> | 32 | #include <slapi.h> |
4786 | 33 | 33 | ||
4787 | 34 | #ifdef _WIN32 | ||
4788 | 35 | #include <winsock.h> | ||
4789 | 36 | #else | ||
4790 | 34 | #include <netdb.h> | 37 | #include <netdb.h> |
4791 | 38 | #endif | ||
4792 | 35 | 39 | ||
4793 | 36 | #ifdef LDAP_SLAPI | 40 | #ifdef LDAP_SLAPI |
4794 | 37 | 41 | ||
4795 | @@ -1971,6 +1975,8 @@ slapi_timer_current_time( void ) | |||
4796 | 1971 | */ | 1975 | */ |
4797 | 1972 | #else /* _WIN32 */ | 1976 | #else /* _WIN32 */ |
4798 | 1973 | LARGE_INTEGER now; | 1977 | LARGE_INTEGER now; |
4799 | 1978 | static LARGE_INTEGER base_time, performance_freq; | ||
4800 | 1979 | static int performance_counter_present; | ||
4801 | 1974 | 1980 | ||
4802 | 1975 | if ( first_time ) { | 1981 | if ( first_time ) { |
4803 | 1976 | first_time = 0; | 1982 | first_time = 0; |
4804 | diff --git a/servers/slapd/slappasswd.c b/servers/slapd/slappasswd.c | |||
4805 | index 9c2adef..e384364 100644 | |||
4806 | --- a/servers/slapd/slappasswd.c | |||
4807 | +++ b/servers/slapd/slappasswd.c | |||
4808 | @@ -250,11 +250,16 @@ slappasswd( int argc, char *argv[] ) | |||
4809 | 250 | if( newpw == NULL ) { | 250 | if( newpw == NULL ) { |
4810 | 251 | /* prompt for new password */ | 251 | /* prompt for new password */ |
4811 | 252 | char *cknewpw; | 252 | char *cknewpw; |
4813 | 253 | newpw = ch_strdup(getpassphrase("New password: ")); | 253 | newpw = getpassphrase("New password: "); |
4814 | 254 | if ( newpw == NULL ) { /* Allow EOF to exit. */ | ||
4815 | 255 | rc = EXIT_FAILURE; | ||
4816 | 256 | goto destroy; | ||
4817 | 257 | } | ||
4818 | 258 | newpw = ch_strdup(newpw); | ||
4819 | 254 | cknewpw = getpassphrase("Re-enter new password: "); | 259 | cknewpw = getpassphrase("Re-enter new password: "); |
4823 | 255 | 260 | if( cknewpw == NULL || strcmp( newpw, cknewpw )) { | |
4824 | 256 | if( strcmp( newpw, cknewpw )) { | 261 | fprintf( stderr, |
4825 | 257 | fprintf( stderr, "Password values do not match\n" ); | 262 | "Password values do not match\n" ); |
4826 | 258 | rc = EXIT_FAILURE; | 263 | rc = EXIT_FAILURE; |
4827 | 259 | goto destroy; | 264 | goto destroy; |
4828 | 260 | } | 265 | } |
4829 | diff --git a/tests/progs/slapd-tester.c b/tests/progs/slapd-tester.c | |||
4830 | index 7ad88b8..8f9656e 100644 | |||
4831 | --- a/tests/progs/slapd-tester.c | |||
4832 | +++ b/tests/progs/slapd-tester.c | |||
4833 | @@ -406,6 +406,9 @@ main( int argc, char **argv ) | |||
4834 | 406 | 406 | ||
4835 | 407 | if ( pw_ask ) { | 407 | if ( pw_ask ) { |
4836 | 408 | passwd = getpassphrase( _("Enter LDAP Password: ") ); | 408 | passwd = getpassphrase( _("Enter LDAP Password: ") ); |
4837 | 409 | if ( passwd == NULL ) { /* Allow EOF to exit. */ | ||
4838 | 410 | exit( EXIT_FAILURE ); | ||
4839 | 411 | } | ||
4840 | 409 | 412 | ||
4841 | 410 | } else if ( pw_file ) { | 413 | } else if ( pw_file ) { |
4842 | 411 | struct berval pw; | 414 | struct berval pw; |
LGTM, +1, presuming the autopkgtests pass.
I like the more detailed changelog personally, and if it saves some thinking time not to have to filter it, then that's a bonus.
I skimmed briefly through the upstream diff, nothing caught my eye. A healthy chunk of it is debug messaging, which is a good sign. There's an `mplay` command being added although that appears just for analysis/debugging (I can't tell if it gets installed but am guessing no.) The remainder does indeed look like bugfixes.