2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1999-2006 The OpenLDAP Foundation.
5 * Portions Copyright 2001-2003 Pierangelo Masarati.
6 * Portions Copyright 1999-2003 Howard Chu.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in the file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by the Howard Chu for inclusion
19 * in OpenLDAP Software and subsequently enhanced by Pierangelo
27 #include <ac/string.h>
28 #include <ac/socket.h>
32 #include "../back-ldap/back-ldap.h"
33 #undef ldap_debug /* silence a warning in ldap-int.h */
34 #include "../../../libraries/libldap/ldap-int.h"
35 #include "back-meta.h"
41 struct ldapmapping *mapping;
47 mt = ch_calloc( sizeof( metatarget_t ), 1 );
49 mt->mt_rwmap.rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT );
50 if ( mt->mt_rwmap.rwm_rw == NULL ) {
57 * the filter rewrite as a string must be disabled
58 * by default; it can be re-enabled by adding rules;
59 * this creates an empty rewriteContext
61 rargv[ 0 ] = "rewriteContext";
62 rargv[ 1 ] = "searchFilter";
64 rewrite_parse( mt->mt_rwmap.rwm_rw, "<suffix massage>", 1, 2, rargv );
66 rargv[ 0 ] = "rewriteContext";
67 rargv[ 1 ] = "default";
69 rewrite_parse( mt->mt_rwmap.rwm_rw, "<suffix massage>", 1, 2, rargv );
71 ldap_back_map_init( &mt->mt_rwmap.rwm_at, &mapping );
73 ldap_pvt_thread_mutex_init( &mt->mt_uri_mutex );
75 mt->mt_idassert_mode = LDAP_BACK_IDASSERT_LEGACY;
76 mt->mt_idassert_authmethod = LDAP_AUTH_NONE;
77 mt->mt_idassert_tls = SB_TLS_DEFAULT;
79 /* by default, use proxyAuthz control on each operation */
80 mt->mt_idassert_flags = LDAP_BACK_AUTH_PRESCRIPTIVE;
88 check_true_false( char *str )
90 if ( strcasecmp( str, "true" ) == 0 || strcasecmp( str, "yes" ) == 0 ) {
94 if ( strcasecmp( str, "false" ) == 0 || strcasecmp( str, "no" ) == 0 ) {
111 metainfo_t *mi = ( metainfo_t * )be->be_private;
113 assert( mi != NULL );
115 /* URI of server to query */
116 if ( strcasecmp( argv[ 0 ], "uri" ) == 0 ) {
117 int i = mi->mi_ntargets;
120 #endif /* uncomment if uri MUST be a branch of suffix */
121 LDAPURLDesc *ludp, *tmpludp;
130 Debug( LDAP_DEBUG_ANY,
131 "%s: line %d: missing URI "
132 "in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
140 Debug( LDAP_DEBUG_ANY,
141 "%s: line %d: too many args "
142 "in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
147 if ( be->be_nsuffix == NULL ) {
148 Debug( LDAP_DEBUG_ANY,
149 "%s: line %d: the suffix must be defined before any target.\n",
156 mi->mi_targets = ( metatarget_t ** )ch_realloc( mi->mi_targets,
157 sizeof( metatarget_t * ) * mi->mi_ntargets );
158 if ( mi->mi_targets == NULL ) {
159 Debug( LDAP_DEBUG_ANY,
160 "%s: line %d: out of memory while storing server name"
161 " in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
166 if ( meta_back_new_target( &mi->mi_targets[ i ] ) != 0 ) {
167 Debug( LDAP_DEBUG_ANY,
168 "%s: line %d: unable to init server"
169 " in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
174 mt = mi->mi_targets[ i ];
176 mt->mt_rebind_f = mi->mi_rebind_f;
177 mt->mt_urllist_f = mi->mi_urllist_f;
178 mt->mt_urllist_p = mt;
180 mt->mt_nretries = mi->mi_nretries;
181 mt->mt_quarantine = mi->mi_quarantine;
182 if ( META_BACK_QUARANTINE( mi ) ) {
183 ldap_pvt_thread_mutex_init( &mt->mt_quarantine_mutex );
185 mt->mt_flags = mi->mi_flags;
186 mt->mt_version = mi->mi_version;
187 mt->mt_network_timeout = mi->mi_network_timeout;
188 mt->mt_bind_timeout = mi->mi_bind_timeout;
189 for ( c = 0; c < LDAP_BACK_OP_LAST; c++ ) {
190 mt->mt_timeout[ c ] = mi->mi_timeout[ c ];
196 if ( ldap_url_parselist_ext( &ludp, argv[ 1 ], "\t",
197 LDAP_PVT_URL_PARSE_NONE ) != LDAP_SUCCESS )
199 Debug( LDAP_DEBUG_ANY,
200 "%s: line %d: unable to parse URI"
201 " in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
207 * uri MUST have the <dn> part!
209 if ( ludp->lud_dn == NULL ) {
210 Debug( LDAP_DEBUG_ANY,
211 "%s: line %d: missing <naming context> "
212 " in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
216 } else if ( ludp->lud_dn[ 0 ] == '\0' ) {
219 for ( j = 0; !BER_BVISNULL( &be->be_nsuffix[ j ] ); j++ ) {
220 if ( BER_BVISEMPTY( &be->be_nsuffix[ j ] ) ) {
225 if ( BER_BVISNULL( &be->be_nsuffix[ j ] ) ) {
226 Debug( LDAP_DEBUG_ANY,
227 "%s: line %d: missing <naming context> "
228 " in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
235 * copies and stores uri and suffix
237 ber_str2bv( ludp->lud_dn, 0, 0, &dn );
238 rc = dnPrettyNormal( NULL, &dn, &mt->mt_psuffix,
239 &mt->mt_nsuffix, NULL );
240 if( rc != LDAP_SUCCESS ) {
241 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
242 "target \"%s\" DN is invalid\n",
243 fname, lineno, argv[ 1 ] );
247 ludp->lud_dn[ 0 ] = '\0';
249 switch ( ludp->lud_scope ) {
250 case LDAP_SCOPE_DEFAULT:
251 mt->mt_scope = LDAP_SCOPE_SUBTREE;
254 case LDAP_SCOPE_SUBTREE:
255 case LDAP_SCOPE_SUBORDINATE:
256 mt->mt_scope = ludp->lud_scope;
260 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
261 "invalid scope for target \"%s\"\n",
262 fname, lineno, argv[ 1 ] );
266 /* check all, to apply the scope check on the first one */
267 for ( tmpludp = ludp; tmpludp; tmpludp = tmpludp->lud_next ) {
268 if ( tmpludp->lud_dn != NULL && tmpludp->lud_dn[ 0 ] != '\0' ) {
269 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
270 "multiple URIs must have "
278 mt->mt_uri = ldap_url_list2urls( ludp );
279 ldap_free_urllist( ludp );
280 if ( mt->mt_uri == NULL) {
281 Debug( LDAP_DEBUG_ANY, "%s: line %d: no memory?\n",
287 * uri MUST be a branch of suffix!
289 #if 0 /* too strict a constraint */
290 if ( select_backend( &mt->mt_nsuffix, 0, 0 ) != be ) {
291 Debug( LDAP_DEBUG_ANY,
292 "%s: line %d: <naming context> of URI does not refer to current backend"
293 " in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
299 * uri MUST be a branch of a suffix!
301 if ( select_backend( &mt->mt_nsuffix, 0, 0 ) == NULL ) {
302 Debug( LDAP_DEBUG_ANY,
303 "%s: line %d: <naming context> of URI does not resolve to a backend"
304 " in \"uri <protocol>://<server>[:port]/<naming context>\" line\n",
310 /* subtree-exclude */
311 } else if ( strcasecmp( argv[ 0 ], "subtree-exclude" ) == 0 ) {
312 int i = mi->mi_ntargets - 1;
313 struct berval dn, ndn;
316 Debug( LDAP_DEBUG_ANY,
317 "%s: line %d: need \"uri\" directive first\n",
324 Debug( LDAP_DEBUG_ANY,
325 "%s: line %d: missing DN in \"subtree-exclude <DN>\" line\n",
333 Debug( LDAP_DEBUG_ANY,
334 "%s: line %d: too many args in \"subtree-exclude <DN>\" line\n",
339 ber_str2bv( argv[ 1 ], 0, 0, &dn );
340 if ( dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL )
343 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
344 "subtree-exclude DN=\"%s\" is invalid\n",
345 fname, lineno, argv[ 1 ] );
349 if ( !dnIsSuffix( &ndn, &mi->mi_targets[ i ]->mt_nsuffix ) ) {
350 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
351 "subtree-exclude DN=\"%s\" "
352 "must be subtree of target\n",
353 fname, lineno, argv[ 1 ] );
354 ber_memfree( ndn.bv_val );
358 if ( mi->mi_targets[ i ]->mt_subtree_exclude != NULL ) {
361 for ( j = 0; !BER_BVISNULL( &mi->mi_targets[ i ]->mt_subtree_exclude[ j ] ); j++ )
363 if ( dnIsSuffix( &mi->mi_targets[ i ]->mt_subtree_exclude[ j ], &ndn ) ) {
364 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
365 "subtree-exclude DN=\"%s\" "
366 "is suffix of another subtree-exclude\n",
367 fname, lineno, argv[ 1 ] );
368 /* reject, because it might be superior
369 * to more than one subtree-exclude */
370 ber_memfree( ndn.bv_val );
373 } else if ( dnIsSuffix( &ndn, &mi->mi_targets[ i ]->mt_subtree_exclude[ j ] ) ) {
374 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
375 "another subtree-exclude is suffix of "
376 "subtree-exclude DN=\"%s\"\n",
377 fname, lineno, argv[ 1 ] );
378 ber_memfree( ndn.bv_val );
384 ber_bvarray_add( &mi->mi_targets[ i ]->mt_subtree_exclude, &ndn );
386 /* default target directive */
387 } else if ( strcasecmp( argv[ 0 ], "default-target" ) == 0 ) {
388 int i = mi->mi_ntargets - 1;
392 Debug( LDAP_DEBUG_ANY,
393 "%s: line %d: \"default-target\" alone need be"
394 " inside a \"uri\" directive\n",
398 mi->mi_defaulttarget = i;
401 if ( strcasecmp( argv[ 1 ], "none" ) == 0 ) {
403 Debug( LDAP_DEBUG_ANY,
404 "%s: line %d: \"default-target none\""
405 " should go before uri definitions\n",
408 mi->mi_defaulttarget = META_DEFAULT_TARGET_NONE;
412 if ( lutil_atoi( &mi->mi_defaulttarget, argv[ 1 ] ) != 0
413 || mi->mi_defaulttarget < 0
414 || mi->mi_defaulttarget >= i - 1 )
416 Debug( LDAP_DEBUG_ANY,
417 "%s: line %d: illegal target number %d\n",
418 fname, lineno, mi->mi_defaulttarget );
424 /* ttl of dn cache */
425 } else if ( strcasecmp( argv[ 0 ], "dncache-ttl" ) == 0 ) {
427 Debug( LDAP_DEBUG_ANY,
428 "%s: line %d: missing ttl in \"dncache-ttl <ttl>\" line\n",
433 if ( strcasecmp( argv[ 1 ], "forever" ) == 0 ) {
434 mi->mi_cache.ttl = META_DNCACHE_FOREVER;
436 } else if ( strcasecmp( argv[ 1 ], "disabled" ) == 0 ) {
437 mi->mi_cache.ttl = META_DNCACHE_DISABLED;
442 if ( lutil_parse_time( argv[ 1 ], &t ) != 0 ) {
443 Debug( LDAP_DEBUG_ANY,
444 "%s: line %d: unable to parse ttl \"%s\" in \"dncache-ttl <ttl>\" line\n",
445 fname, lineno, argv[ 1 ] );
448 mi->mi_cache.ttl = (time_t)t;
451 /* network timeout when connecting to ldap servers */
452 } else if ( strcasecmp( argv[ 0 ], "network-timeout" ) == 0 ) {
454 time_t *tp = mi->mi_ntargets ?
455 &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_network_timeout
456 : &mi->mi_network_timeout;
459 Debug( LDAP_DEBUG_ANY,
460 "%s: line %d: missing network timeout in \"network-timeout <seconds>\" line\n",
465 if ( lutil_parse_time( argv[ 1 ], &t ) ) {
466 Debug( LDAP_DEBUG_ANY,
467 "%s: line %d: unable to parse timeout \"%s\" in \"network-timeout <seconds>\" line\n",
468 fname, lineno, argv[ 1 ] );
475 /* idle timeout when connecting to ldap servers */
476 } else if ( strcasecmp( argv[ 0 ], "idle-timeout" ) == 0 ) {
481 Debug( LDAP_DEBUG_ANY,
482 "%s: line %d: missing timeout value in \"idle-timeout <seconds>\" line\n",
488 Debug( LDAP_DEBUG_ANY,
489 "%s: line %d: extra cruft after timeout value in \"idle-timeout <seconds>\" line\n",
494 if ( lutil_parse_time( argv[ 1 ], &t ) ) {
495 Debug( LDAP_DEBUG_ANY,
496 "%s: line %d: unable to parse timeout \"%s\" in \"idle-timeout <seconds>\" line\n",
497 fname, lineno, argv[ 1 ] );
502 mi->mi_idle_timeout = (time_t)t;
505 } else if ( strcasecmp( argv[ 0 ], "conn-ttl" ) == 0 ) {
510 Debug( LDAP_DEBUG_ANY,
511 "%s: line %d: missing ttl value in \"conn-ttl <seconds>\" line\n",
517 Debug( LDAP_DEBUG_ANY,
518 "%s: line %d: extra cruft after ttl value in \"conn-ttl <seconds>\" line\n",
523 if ( lutil_parse_time( argv[ 1 ], &t ) ) {
524 Debug( LDAP_DEBUG_ANY,
525 "%s: line %d: unable to parse ttl \"%s\" in \"conn-ttl <seconds>\" line\n",
526 fname, lineno, argv[ 1 ] );
531 mi->mi_conn_ttl = (time_t)t;
533 /* bind timeout when connecting to ldap servers */
534 } else if ( strcasecmp( argv[ 0 ], "bind-timeout" ) == 0 ) {
536 struct timeval *tp = mi->mi_ntargets ?
537 &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_bind_timeout
538 : &mi->mi_bind_timeout;
542 Debug( LDAP_DEBUG_ANY,
543 "%s: line %d: missing timeout value in \"bind-timeout <microseconds>\" line\n",
549 Debug( LDAP_DEBUG_ANY,
550 "%s: line %d: extra cruft after timeout value in \"bind-timeout <microseconds>\" line\n",
555 if ( lutil_atoul( &t, argv[ 1 ] ) != 0 ) {
556 Debug( LDAP_DEBUG_ANY,
557 "%s: line %d: unable to parse timeout \"%s\" in \"bind-timeout <microseconds>\" line\n",
558 fname, lineno, argv[ 1 ] );
563 tp->tv_sec = t/1000000;
564 tp->tv_usec = t%1000000;
566 /* name to use for meta_back_group */
567 } else if ( strcasecmp( argv[ 0 ], "acl-authcDN" ) == 0
568 || strcasecmp( argv[ 0 ], "binddn" ) == 0 )
570 int i = mi->mi_ntargets - 1;
574 Debug( LDAP_DEBUG_ANY,
575 "%s: line %d: need \"uri\" directive first\n",
581 Debug( LDAP_DEBUG_ANY,
582 "%s: line %d: missing name in \"binddn <name>\" line\n",
587 if ( strcasecmp( argv[ 0 ], "binddn" ) == 0 ) {
588 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
589 "\"binddn\" statement is deprecated; "
590 "use \"acl-authcDN\" instead\n",
592 /* FIXME: some day we'll need to throw an error */
595 ber_str2bv( argv[ 1 ], 0, 0, &dn );
596 if ( dnNormalize( 0, NULL, NULL, &dn, &mi->mi_targets[ i ]->mt_binddn,
597 NULL ) != LDAP_SUCCESS )
599 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
600 "bind DN '%s' is invalid\n",
601 fname, lineno, argv[ 1 ] );
605 /* password to use for meta_back_group */
606 } else if ( strcasecmp( argv[ 0 ], "acl-passwd" ) == 0
607 || strcasecmp( argv[ 0 ], "bindpw" ) == 0 )
609 int i = mi->mi_ntargets - 1;
612 Debug( LDAP_DEBUG_ANY,
613 "%s: line %d: need \"uri\" directive first\n",
619 Debug( LDAP_DEBUG_ANY,
620 "%s: line %d: missing password in \"bindpw <password>\" line\n",
625 if ( strcasecmp( argv[ 0 ], "bindpw" ) == 0 ) {
626 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
627 "\"bindpw\" statement is deprecated; "
628 "use \"acl-passwd\" instead\n",
630 /* FIXME: some day we'll need to throw an error */
633 ber_str2bv( argv[ 1 ], 0L, 1, &mi->mi_targets[ i ]->mt_bindpw );
635 /* save bind creds for referral rebinds? */
636 } else if ( strcasecmp( argv[ 0 ], "rebind-as-user" ) == 0 ) {
638 Debug( LDAP_DEBUG_ANY,
639 "%s: line %d: \"rebind-as-user {NO|yes}\" takes 1 argument.\n",
645 Debug( LDAP_DEBUG_ANY,
646 "%s: line %d: deprecated use of \"rebind-as-user {FALSE|true}\" with no arguments.\n",
648 mi->mi_flags |= LDAP_BACK_F_SAVECRED;
651 switch ( check_true_false( argv[ 1 ] ) ) {
653 mi->mi_flags &= ~LDAP_BACK_F_SAVECRED;
657 mi->mi_flags |= LDAP_BACK_F_SAVECRED;
661 Debug( LDAP_DEBUG_ANY,
662 "%s: line %d: \"rebind-as-user {FALSE|true}\" unknown argument \"%s\".\n",
663 fname, lineno, argv[ 1 ] );
668 } else if ( strcasecmp( argv[ 0 ], "chase-referrals" ) == 0 ) {
669 unsigned *flagsp = mi->mi_ntargets ?
670 &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_flags
674 Debug( LDAP_DEBUG_ANY,
675 "%s: line %d: \"chase-referrals {TRUE|false}\" needs 1 argument.\n",
680 /* this is the default; we add it because the default might change... */
681 switch ( check_true_false( argv[ 1 ] ) ) {
683 *flagsp |= LDAP_BACK_F_CHASE_REFERRALS;
687 *flagsp &= ~LDAP_BACK_F_CHASE_REFERRALS;
691 Debug( LDAP_DEBUG_ANY,
692 "%s: line %d: \"chase-referrals {TRUE|false}\": unknown argument \"%s\".\n",
693 fname, lineno, argv[ 1 ] );
697 } else if ( strcasecmp( argv[ 0 ], "tls" ) == 0 ) {
698 unsigned *flagsp = mi->mi_ntargets ?
699 &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_flags
703 Debug( LDAP_DEBUG_ANY,
704 "%s: line %d: \"tls <what>\" needs 1 argument.\n",
710 if ( strcasecmp( argv[ 1 ], "start" ) == 0 ) {
711 *flagsp |= ( LDAP_BACK_F_USE_TLS | LDAP_BACK_F_TLS_CRITICAL );
714 } else if ( strcasecmp( argv[ 1 ], "try-start" ) == 0 ) {
715 *flagsp &= ~LDAP_BACK_F_TLS_CRITICAL;
716 *flagsp |= LDAP_BACK_F_USE_TLS;
718 /* propagate start tls */
719 } else if ( strcasecmp( argv[ 1 ], "propagate" ) == 0 ) {
720 *flagsp |= ( LDAP_BACK_F_PROPAGATE_TLS | LDAP_BACK_F_TLS_CRITICAL );
723 } else if ( strcasecmp( argv[ 1 ], "try-propagate" ) == 0 ) {
724 *flagsp &= ~LDAP_BACK_F_TLS_CRITICAL;
725 *flagsp |= LDAP_BACK_F_PROPAGATE_TLS;
728 Debug( LDAP_DEBUG_ANY,
729 "%s: line %d: \"tls <what>\": unknown argument \"%s\".\n",
730 fname, lineno, argv[ 1 ] );
734 } else if ( strcasecmp( argv[ 0 ], "t-f-support" ) == 0 ) {
735 unsigned *flagsp = mi->mi_ntargets ?
736 &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_flags
740 Debug( LDAP_DEBUG_ANY,
741 "%s: line %d: \"t-f-support {FALSE|true|discover}\" needs 1 argument.\n",
746 switch ( check_true_false( argv[ 1 ] ) ) {
748 *flagsp &= ~LDAP_BACK_F_T_F_MASK2;
752 *flagsp |= LDAP_BACK_F_T_F;
756 if ( strcasecmp( argv[ 1 ], "discover" ) == 0 ) {
757 *flagsp |= LDAP_BACK_F_T_F_DISCOVER;
760 Debug( LDAP_DEBUG_ANY,
761 "%s: line %d: unknown value \"%s\" for \"t-f-support {no|yes|discover}\".\n",
762 fname, lineno, argv[ 1 ] );
769 } else if ( strcasecmp( argv[ 0 ], "onerr" ) == 0 ) {
771 Debug( LDAP_DEBUG_ANY,
772 "%s: line %d: \"onerr {CONTINUE|stop}\" takes 1 argument\n",
777 if ( strcasecmp( argv[ 1 ], "continue" ) == 0 ) {
778 mi->mi_flags &= ~META_BACK_F_ONERR_STOP;
780 } else if ( strcasecmp( argv[ 1 ], "stop" ) == 0 ) {
781 mi->mi_flags |= META_BACK_F_ONERR_STOP;
784 Debug( LDAP_DEBUG_ANY,
785 "%s: line %d: \"onerr {CONTINUE|stop}\": invalid arg \"%s\".\n",
786 fname, lineno, argv[ 1 ] );
791 } else if ( strcasecmp( argv[ 0 ], "pseudoroot-bind-defer" ) == 0
792 || strcasecmp( argv[ 0 ], "root-bind-defer" ) == 0 )
795 Debug( LDAP_DEBUG_ANY,
796 "%s: line %d: \"[pseudo]root-bind-defer {FALSE|true}\" takes 1 argument\n",
801 switch ( check_true_false( argv[ 1 ] ) ) {
803 mi->mi_flags &= ~META_BACK_F_DEFER_ROOTDN_BIND;
807 mi->mi_flags |= META_BACK_F_DEFER_ROOTDN_BIND;
811 Debug( LDAP_DEBUG_ANY,
812 "%s: line %d: \"[pseudo]root-bind-defer {FALSE|true}\": invalid arg \"%s\".\n",
813 fname, lineno, argv[ 1 ] );
818 } else if ( strcasecmp( argv[ 0 ], "single-conn" ) == 0 ) {
820 Debug( LDAP_DEBUG_ANY,
821 "%s: line %d: \"single-conn {FALSE|true}\" takes 1 argument\n",
826 if ( mi->mi_ntargets > 0 ) {
827 Debug( LDAP_DEBUG_ANY,
828 "%s: line %d: \"single-conn\" must appear before target definitions\n",
833 switch ( check_true_false( argv[ 1 ] ) ) {
835 mi->mi_flags &= ~LDAP_BACK_F_SINGLECONN;
839 mi->mi_flags |= LDAP_BACK_F_SINGLECONN;
843 Debug( LDAP_DEBUG_ANY,
844 "%s: line %d: \"single-conn {FALSE|true}\": invalid arg \"%s\".\n",
845 fname, lineno, argv[ 1 ] );
849 } else if ( strcasecmp( argv[ 0 ], "cancel" ) == 0 ) {
851 unsigned *flagsp = mi->mi_ntargets ?
852 &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_flags
856 Debug( LDAP_DEBUG_ANY,
857 "%s: line %d: \"cancel {abandon|ignore|exop}\" takes 1 argument\n",
862 if ( strcasecmp( argv[ 1 ], "abandon" ) == 0 ) {
863 flag = LDAP_BACK_F_CANCEL_ABANDON;
865 } else if ( strcasecmp( argv[ 1 ], "ignore" ) == 0 ) {
866 flag = LDAP_BACK_F_CANCEL_IGNORE;
868 } else if ( strcasecmp( argv[ 1 ], "exop" ) == 0 ) {
869 flag = LDAP_BACK_F_CANCEL_EXOP;
871 } else if ( strcasecmp( argv[ 1 ], "exop-discover" ) == 0 ) {
872 flag = LDAP_BACK_F_CANCEL_EXOP_DISCOVER;
875 Debug( LDAP_DEBUG_ANY,
876 "%s: line %d: \"cancel {abandon|ignore|exop[-discover]}\": unknown mode \"%s\" \n",
877 fname, lineno, argv[ 1 ] );
881 *flagsp &= ~LDAP_BACK_F_CANCEL_MASK2;
884 } else if ( strcasecmp( argv[ 0 ], "timeout" ) == 0 ) {
886 time_t *tv = mi->mi_ntargets ?
887 mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_timeout
892 Debug( LDAP_DEBUG_ANY,
893 "%s: line %d: \"timeout [{add|delete|modify|modrdn}=]<val> [...]\" takes at least 1 argument\n",
898 for ( c = 1; c < argc; c++ ) {
902 sep = strchr( argv[ c ], '=' );
904 size_t len = sep - argv[ c ];
906 if ( strncasecmp( argv[ c ], "add", len ) == 0 ) {
907 t = &tv[ LDAP_BACK_OP_ADD ];
908 } else if ( strncasecmp( argv[ c ], "delete", len ) == 0 ) {
909 t = &tv[ LDAP_BACK_OP_DELETE ];
910 } else if ( strncasecmp( argv[ c ], "modify", len ) == 0 ) {
911 t = &tv[ LDAP_BACK_OP_MODIFY ];
912 } else if ( strncasecmp( argv[ c ], "modrdn", len ) == 0 ) {
913 t = &tv[ LDAP_BACK_OP_MODRDN ];
915 char buf[ SLAP_TEXT_BUFLEN ];
916 snprintf( buf, sizeof( buf ),
917 "unknown operation \"%s\" for timeout #%d",
919 Debug( LDAP_DEBUG_ANY,
920 "%s: line %d: %s.\n",
921 fname, lineno, buf );
930 if ( lutil_parse_time( sep, &val ) != 0 ) {
931 Debug( LDAP_DEBUG_ANY,
932 "%s: line %d: unable to parse value \"%s\" for timeout.\n",
933 fname, lineno, sep );
943 for ( i = 0; i < LDAP_BACK_OP_LAST; i++ ) {
944 tv[ i ] = (time_t)val;
949 /* name to use as pseudo-root dn */
950 } else if ( strcasecmp( argv[ 0 ], "pseudorootdn" ) == 0 ) {
951 int i = mi->mi_ntargets - 1;
954 Debug( LDAP_DEBUG_ANY,
955 "%s: line %d: need \"uri\" directive first\n",
961 Debug( LDAP_DEBUG_ANY,
962 "%s: line %d: missing name in \"pseudorootdn <name>\" line\n",
971 idassert-bind bindmethod=simple
972 binddn=<pseudorootdn>
973 credentials=<pseudorootpw>
975 flags=non-prescriptive
976 idassert-authzFrom "dn:<rootdn>"
978 * so that only when authc'd as <rootdn> the proxying occurs
979 * rebinding as the <pseudorootdn> without proxyAuthz.
982 Debug( LDAP_DEBUG_ANY,
983 "%s: line %d: \"pseudorootdn\", \"pseudorootpw\" are no longer supported; "
984 "use \"idassert-bind\" and \"idassert-authzFrom\" instead.\n",
988 char binddn[ SLAP_TEXT_BUFLEN ];
994 "flags=non-prescriptive",
1000 if ( BER_BVISNULL( &be->be_rootndn ) ) {
1001 Debug( LDAP_DEBUG_ANY, "%s: line %d: \"pseudorootpw\": \"rootdn\" must be defined first.\n",
1006 if ( snprintf( binddn, sizeof( binddn ), "binddn=%s", argv[ 1 ] ) >= sizeof( binddn ) ) {
1007 Debug( LDAP_DEBUG_ANY, "%s: line %d: \"pseudorootdn\" too long.\n",
1011 cargv[ 2 ] = binddn;
1013 rc = slap_idassert_parse_cf( fname, lineno, cargc, cargv, &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_idassert );
1017 if ( mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_idassert_authz != NULL ) {
1018 Debug( LDAP_DEBUG_ANY, "%s: line %d: \"idassert-authzFrom\" already defined (discarded).\n",
1020 ber_bvarray_free( mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_idassert_authz );
1021 mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_idassert_authz = NULL;
1024 assert( !BER_BVISNULL( &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_idassert_authcDN ) );
1026 bv.bv_len = STRLENOF( "dn:" ) + be->be_rootndn.bv_len;
1027 bv.bv_val = ber_memalloc( bv.bv_len + 1 );
1028 AC_MEMCPY( bv.bv_val, "dn:", STRLENOF( "dn:" ) );
1029 AC_MEMCPY( &bv.bv_val[ STRLENOF( "dn:" ) ], be->be_rootndn.bv_val, be->be_rootndn.bv_len + 1 );
1031 ber_bvarray_add( &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_idassert_authz, &bv );
1037 /* password to use as pseudo-root */
1038 } else if ( strcasecmp( argv[ 0 ], "pseudorootpw" ) == 0 ) {
1039 int i = mi->mi_ntargets - 1;
1042 Debug( LDAP_DEBUG_ANY,
1043 "%s: line %d: need \"uri\" directive first\n",
1049 Debug( LDAP_DEBUG_ANY,
1050 "%s: line %d: missing password in \"pseudorootpw <password>\" line\n",
1055 Debug( LDAP_DEBUG_ANY,
1056 "%s: line %d: \"pseudorootdn\", \"pseudorootpw\" are no longer supported; "
1057 "use \"idassert-bind\" and \"idassert-authzFrom\" instead.\n",
1060 if ( BER_BVISNULL( &mi->mi_targets[ i ]->mt_idassert_authcDN ) ) {
1061 Debug( LDAP_DEBUG_ANY, "%s: line %d: \"pseudorootpw\": \"pseudorootdn\" must be defined first.\n",
1066 if ( !BER_BVISNULL( &mi->mi_targets[ i ]->mt_idassert_passwd ) ) {
1067 memset( mi->mi_targets[ i ]->mt_idassert_passwd.bv_val, 0,
1068 mi->mi_targets[ i ]->mt_idassert_passwd.bv_len );
1069 ber_memfree( mi->mi_targets[ i ]->mt_idassert_passwd.bv_val );
1071 ber_str2bv( argv[ 1 ], 0, 1, &mi->mi_targets[ i ]->mt_idassert_passwd );
1074 } else if ( strcasecmp( argv[ 0 ], "idassert-bind" ) == 0 ) {
1075 if ( mi->mi_ntargets == 0 ) {
1076 Debug( LDAP_DEBUG_ANY,
1077 "%s: line %d: \"idassert-bind\" "
1078 "must appear inside a target specification.\n",
1083 return slap_idassert_parse_cf( fname, lineno, argc, argv, &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_idassert );
1085 /* idassert-authzFrom */
1086 } else if ( strcasecmp( argv[ 0 ], "idassert-authzFrom" ) == 0 ) {
1087 if ( mi->mi_ntargets == 0 ) {
1088 Debug( LDAP_DEBUG_ANY,
1089 "%s: line %d: \"idassert-bind\" "
1090 "must appear inside a target specification.\n",
1100 Debug( LDAP_DEBUG_ANY,
1101 "%s: line %d: missing <id> in \"idassert-authzFrom <id>\".\n",
1106 Debug( LDAP_DEBUG_ANY,
1107 "%s: line %d: extra cruft after <id> in \"idassert-authzFrom <id>\".\n",
1112 return slap_idassert_authzfrom_parse_cf( fname, lineno, argv[ 1 ], &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_idassert );
1115 } else if ( strcasecmp( argv[ 0 ], "quarantine" ) == 0 ) {
1116 char buf[ SLAP_TEXT_BUFLEN ] = { '\0' };
1117 slap_retry_info_t *ri = mi->mi_ntargets ?
1118 &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_quarantine
1119 : &mi->mi_quarantine;
1121 if ( ( mi->mi_ntargets == 0 && META_BACK_QUARANTINE( mi ) )
1122 || ( mi->mi_ntargets > 0 && META_BACK_TGT_QUARANTINE( mi->mi_targets[ mi->mi_ntargets - 1 ] ) ) )
1124 Debug( LDAP_DEBUG_ANY,
1125 "%s: line %d: quarantine already defined.\n",
1135 Debug( LDAP_DEBUG_ANY,
1136 "%s: line %d: missing arg in \"quarantine <pattern list>\".\n",
1141 Debug( LDAP_DEBUG_ANY,
1142 "%s: line %d: extra cruft after \"quarantine <pattern list>\".\n",
1147 if ( ri != &mi->mi_quarantine ) {
1148 ri->ri_interval = NULL;
1152 if ( mi->mi_ntargets > 0 && !META_BACK_QUARANTINE( mi ) ) {
1153 ldap_pvt_thread_mutex_init( &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_quarantine_mutex );
1156 if ( slap_retry_info_parse( argv[ 1 ], ri, buf, sizeof( buf ) ) ) {
1157 Debug( LDAP_DEBUG_ANY,
1158 "%s line %d: %s.\n",
1159 fname, lineno, buf );
1164 } else if ( strcasecmp( argv[ 0 ], "suffixmassage" ) == 0 ) {
1166 int i = mi->mi_ntargets - 1, rc;
1167 struct berval dn, nvnc, pvnc, nrnc, prnc;
1170 Debug( LDAP_DEBUG_ANY,
1171 "%s: line %d: need \"uri\" directive first\n",
1179 * suffixmassage <suffix> <massaged suffix>
1181 * the <suffix> field must be defined as a valid suffix
1182 * (or suffixAlias?) for the current database;
1183 * the <massaged suffix> shouldn't have already been
1184 * defined as a valid suffix or suffixAlias for the
1188 Debug( LDAP_DEBUG_ANY,
1189 "%s: line %d: syntax is \"suffixMassage <suffix> <massaged suffix>\"\n",
1194 ber_str2bv( argv[ 1 ], 0, 0, &dn );
1195 if ( dnPrettyNormal( NULL, &dn, &pvnc, &nvnc, NULL ) != LDAP_SUCCESS ) {
1196 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1197 "suffix '%s' is invalid\n",
1198 fname, lineno, argv[ 1 ] );
1202 tmp_be = select_backend( &nvnc, 0, 0 );
1203 if ( tmp_be != NULL && tmp_be != be ) {
1204 Debug( LDAP_DEBUG_ANY,
1205 "%s: line %d: suffix already in use by another backend in"
1206 " \"suffixMassage <suffix> <massaged suffix>\"\n",
1208 free( pvnc.bv_val );
1209 free( nvnc.bv_val );
1213 ber_str2bv( argv[ 2 ], 0, 0, &dn );
1214 if ( dnPrettyNormal( NULL, &dn, &prnc, &nrnc, NULL ) != LDAP_SUCCESS ) {
1215 Debug( LDAP_DEBUG_ANY, "%s: line %d: "
1216 "massaged suffix '%s' is invalid\n",
1217 fname, lineno, argv[ 2 ] );
1218 free( pvnc.bv_val );
1219 free( nvnc.bv_val );
1224 tmp_be = select_backend( &nrnc, 0, 0 );
1225 if ( tmp_be != NULL ) {
1226 Debug( LDAP_DEBUG_ANY,
1227 "%s: line %d: massaged suffix already in use by another backend in"
1228 " \"suffixMassage <suffix> <massaged suffix>\"\n",
1230 free( pvnc.bv_val );
1231 free( nvnc.bv_val );
1232 free( prnc.bv_val );
1233 free( nrnc.bv_val );
1239 * The suffix massaging is emulated by means of the
1240 * rewrite capabilities
1241 * FIXME: no extra rewrite capabilities should be added
1244 rc = suffix_massage_config( mi->mi_targets[ i ]->mt_rwmap.rwm_rw,
1245 &pvnc, &nvnc, &prnc, &nrnc );
1247 free( pvnc.bv_val );
1248 free( nvnc.bv_val );
1249 free( prnc.bv_val );
1250 free( nrnc.bv_val );
1254 /* rewrite stuff ... */
1255 } else if ( strncasecmp( argv[ 0 ], "rewrite", 7 ) == 0 ) {
1256 int i = mi->mi_ntargets - 1;
1259 Debug( LDAP_DEBUG_ANY, "%s: line %d: \"rewrite\" "
1260 "statement outside target definition.\n",
1265 return rewrite_parse( mi->mi_targets[ i ]->mt_rwmap.rwm_rw,
1266 fname, lineno, argc, argv );
1268 /* objectclass/attribute mapping */
1269 } else if ( strcasecmp( argv[ 0 ], "map" ) == 0 ) {
1270 int i = mi->mi_ntargets - 1;
1273 Debug( LDAP_DEBUG_ANY,
1274 "%s: line %d: need \"uri\" directive first\n",
1279 return ldap_back_map_config( &mi->mi_targets[ i ]->mt_rwmap.rwm_oc,
1280 &mi->mi_targets[ i ]->mt_rwmap.rwm_at,
1281 fname, lineno, argc, argv );
1283 } else if ( strcasecmp( argv[ 0 ], "nretries" ) == 0 ) {
1284 int i = mi->mi_ntargets - 1;
1285 int nretries = META_RETRY_UNDEFINED;
1288 Debug( LDAP_DEBUG_ANY,
1289 "%s: line %d: need value in \"nretries <value>\"\n",
1294 if ( strcasecmp( argv[ 1 ], "forever" ) == 0 ) {
1295 nretries = META_RETRY_FOREVER;
1297 } else if ( strcasecmp( argv[ 1 ], "never" ) == 0 ) {
1298 nretries = META_RETRY_NEVER;
1301 if ( lutil_atoi( &nretries, argv[ 1 ] ) != 0 ) {
1302 Debug( LDAP_DEBUG_ANY,
1303 "%s: line %d: unable to parse value \"%s\" in \"nretries <value>\"\n",
1304 fname, lineno, argv[ 1 ] );
1310 mi->mi_nretries = nretries;
1313 mi->mi_targets[ i ]->mt_nretries = nretries;
1316 } else if ( strcasecmp( argv[ 0 ], "protocol-version" ) == 0 ) {
1317 int *version = mi->mi_ntargets ?
1318 &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_version
1322 Debug( LDAP_DEBUG_ANY,
1323 "%s: line %d: need value in \"protocol-version <version>\"\n",
1328 if ( lutil_atoi( version, argv[ 1 ] ) != 0 ) {
1329 Debug( LDAP_DEBUG_ANY,
1330 "%s: line %d: unable to parse version \"%s\" in \"protocol-version <version>\"\n",
1331 fname, lineno, argv[ 1 ] );
1335 if ( *version != 0 && ( *version < LDAP_VERSION_MIN || *version > LDAP_VERSION_MAX ) ) {
1336 Debug( LDAP_DEBUG_ANY,
1337 "%s: line %d: unsupported version \"%s\" in \"protocol-version <version>\"\n",
1338 fname, lineno, argv[ 1 ] );
1344 return SLAP_CONF_UNKNOWN;
1350 ldap_back_map_config(
1351 struct ldapmap *oc_map,
1352 struct ldapmap *at_map,
1358 struct ldapmap *map;
1359 struct ldapmapping *mapping;
1363 if ( argc < 3 || argc > 4 ) {
1364 Debug( LDAP_DEBUG_ANY,
1365 "%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
1370 if ( strcasecmp( argv[ 1 ], "objectclass" ) == 0 ) {
1374 } else if ( strcasecmp( argv[ 1 ], "attribute" ) == 0 ) {
1378 Debug( LDAP_DEBUG_ANY, "%s: line %d: syntax is "
1379 "\"map {objectclass | attribute} [<local> | *] "
1380 "{<foreign> | *}\"\n",
1385 if ( strcmp( argv[ 2 ], "*" ) == 0 ) {
1386 if ( argc < 4 || strcmp( argv[ 3 ], "*" ) == 0 ) {
1387 map->drop_missing = ( argc < 4 );
1390 src = dst = argv[ 3 ];
1392 } else if ( argc < 4 ) {
1398 dst = ( strcmp( argv[ 3 ], "*" ) == 0 ? src : argv[ 3 ] );
1401 if ( ( map == at_map )
1402 && ( strcasecmp( src, "objectclass" ) == 0
1403 || strcasecmp( dst, "objectclass" ) == 0 ) )
1405 Debug( LDAP_DEBUG_ANY,
1406 "%s: line %d: objectclass attribute cannot be mapped\n",
1410 mapping = (struct ldapmapping *)ch_calloc( 2,
1411 sizeof(struct ldapmapping) );
1412 if ( mapping == NULL ) {
1413 Debug( LDAP_DEBUG_ANY,
1414 "%s: line %d: out of memory\n",
1418 ber_str2bv( src, 0, 1, &mapping[ 0 ].src );
1419 ber_str2bv( dst, 0, 1, &mapping[ 0 ].dst );
1420 mapping[ 1 ].src = mapping[ 0 ].dst;
1421 mapping[ 1 ].dst = mapping[ 0 ].src;
1427 if ( src[ 0 ] != '\0' ) {
1428 if ( oc_bvfind( &mapping[ 0 ].src ) == NULL ) {
1429 Debug( LDAP_DEBUG_ANY,
1430 "%s: line %d: warning, source objectClass '%s' "
1431 "should be defined in schema\n",
1432 fname, lineno, src );
1435 * FIXME: this should become an err
1441 if ( oc_bvfind( &mapping[ 0 ].dst ) == NULL ) {
1442 Debug( LDAP_DEBUG_ANY,
1443 "%s: line %d: warning, destination objectClass '%s' "
1444 "is not defined in schema\n",
1445 fname, lineno, dst );
1449 const char *text = NULL;
1450 AttributeDescription *ad = NULL;
1452 if ( src[ 0 ] != '\0' ) {
1453 rc = slap_bv2ad( &mapping[ 0 ].src, &ad, &text );
1454 if ( rc != LDAP_SUCCESS ) {
1455 Debug( LDAP_DEBUG_ANY,
1456 "%s: line %d: warning, source attributeType '%s' "
1457 "should be defined in schema\n",
1458 fname, lineno, src );
1461 * FIXME: this should become an err
1464 * we create a fake "proxied" ad
1468 rc = slap_bv2undef_ad( &mapping[ 0 ].src,
1469 &ad, &text, SLAP_AD_PROXIED );
1470 if ( rc != LDAP_SUCCESS ) {
1471 char buf[ SLAP_TEXT_BUFLEN ];
1473 snprintf( buf, sizeof( buf ),
1474 "source attributeType \"%s\": %d (%s)",
1475 src, rc, text ? text : "" );
1476 Debug( LDAP_DEBUG_ANY,
1477 "%s: line %d: %s\n",
1478 fname, lineno, buf );
1486 rc = slap_bv2ad( &mapping[ 0 ].dst, &ad, &text );
1487 if ( rc != LDAP_SUCCESS ) {
1488 Debug( LDAP_DEBUG_ANY,
1489 "%s: line %d: warning, destination attributeType '%s' "
1490 "is not defined in schema\n",
1491 fname, lineno, dst );
1494 * we create a fake "proxied" ad
1498 rc = slap_bv2undef_ad( &mapping[ 0 ].dst,
1499 &ad, &text, SLAP_AD_PROXIED );
1500 if ( rc != LDAP_SUCCESS ) {
1501 char buf[ SLAP_TEXT_BUFLEN ];
1503 snprintf( buf, sizeof( buf ),
1504 "source attributeType \"%s\": %d (%s)\n",
1505 dst, rc, text ? text : "" );
1506 Debug( LDAP_DEBUG_ANY,
1507 "%s: line %d: %s\n",
1508 fname, lineno, buf );
1514 if ( (src[ 0 ] != '\0' && avl_find( map->map, (caddr_t)&mapping[ 0 ], mapping_cmp ) != NULL)
1515 || avl_find( map->remap, (caddr_t)&mapping[ 1 ], mapping_cmp ) != NULL)
1517 Debug( LDAP_DEBUG_ANY,
1518 "%s: line %d: duplicate mapping found.\n",
1523 if ( src[ 0 ] != '\0' ) {
1524 avl_insert( &map->map, (caddr_t)&mapping[ 0 ],
1525 mapping_cmp, mapping_dup );
1527 avl_insert( &map->remap, (caddr_t)&mapping[ 1 ],
1528 mapping_cmp, mapping_dup );
1534 ch_free( mapping[ 0 ].src.bv_val );
1535 ch_free( mapping[ 0 ].dst.bv_val );
1543 #ifdef ENABLE_REWRITE
1545 suffix_massage_regexize( const char *s )
1551 if ( s[ 0 ] == '\0' ) {
1552 return ch_strdup( "^(.+)$" );
1556 ( r = strchr( p, ',' ) ) != NULL;
1560 res = ch_calloc( sizeof( char ),
1562 + STRLENOF( "((.+),)?" )
1563 + STRLENOF( "[ ]?" ) * i
1564 + STRLENOF( "$" ) + 1 );
1566 ptr = lutil_strcopy( res, "((.+),)?" );
1568 ( r = strchr( p, ',' ) ) != NULL;
1570 ptr = lutil_strncopy( ptr, p, r - p + 1 );
1571 ptr = lutil_strcopy( ptr, "[ ]?" );
1573 if ( r[ 1 ] == ' ' ) {
1577 ptr = lutil_strcopy( ptr, p );
1586 suffix_massage_patternize( const char *s, const char *p )
1593 if ( s[ 0 ] == '\0' ) {
1597 res = ch_calloc( sizeof( char ), len + STRLENOF( "%1" ) + 1 );
1598 if ( res == NULL ) {
1602 ptr = lutil_strcopy( res, ( p[ 0 ] == '\0' ? "%2" : "%1" ) );
1603 if ( s[ 0 ] == '\0' ) {
1607 lutil_strcopy( ptr, p );
1613 suffix_massage_config(
1614 struct rewrite_info *info,
1615 struct berval *pvnc,
1616 struct berval *nvnc,
1617 struct berval *prnc,
1624 rargv[ 0 ] = "rewriteEngine";
1627 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
1629 rargv[ 0 ] = "rewriteContext";
1630 rargv[ 1 ] = "default";
1632 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
1634 rargv[ 0 ] = "rewriteRule";
1635 rargv[ 1 ] = suffix_massage_regexize( pvnc->bv_val );
1636 rargv[ 2 ] = suffix_massage_patternize( pvnc->bv_val, prnc->bv_val );
1639 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
1640 ch_free( rargv[ 1 ] );
1641 ch_free( rargv[ 2 ] );
1643 if ( BER_BVISEMPTY( pvnc ) ) {
1644 rargv[ 0 ] = "rewriteRule";
1646 rargv[ 2 ] = prnc->bv_val;
1649 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
1652 rargv[ 0 ] = "rewriteContext";
1653 rargv[ 1 ] = "searchEntryDN";
1655 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
1657 rargv[ 0 ] = "rewriteRule";
1658 rargv[ 1 ] = suffix_massage_regexize( prnc->bv_val );
1659 rargv[ 2 ] = suffix_massage_patternize( prnc->bv_val, pvnc->bv_val );
1662 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
1663 ch_free( rargv[ 1 ] );
1664 ch_free( rargv[ 2 ] );
1666 if ( BER_BVISEMPTY( prnc ) ) {
1667 rargv[ 0 ] = "rewriteRule";
1669 rargv[ 2 ] = pvnc->bv_val;
1672 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
1675 /* backward compatibility */
1676 rargv[ 0 ] = "rewriteContext";
1677 rargv[ 1 ] = "searchResult";
1678 rargv[ 2 ] = "alias";
1679 rargv[ 3 ] = "searchEntryDN";
1681 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
1683 rargv[ 0 ] = "rewriteContext";
1684 rargv[ 1 ] = "matchedDN";
1685 rargv[ 2 ] = "alias";
1686 rargv[ 3 ] = "searchEntryDN";
1688 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
1690 rargv[ 0 ] = "rewriteContext";
1691 rargv[ 1 ] = "searchAttrDN";
1692 rargv[ 2 ] = "alias";
1693 rargv[ 3 ] = "searchEntryDN";
1695 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
1697 /* NOTE: this corresponds to #undef'ining RWM_REFERRAL_REWRITE;
1698 * see servers/slapd/overlays/rwm.h for details */
1699 rargv[ 0 ] = "rewriteContext";
1700 rargv[ 1 ] = "referralAttrDN";
1702 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
1704 rargv[ 0 ] = "rewriteContext";
1705 rargv[ 1 ] = "referralDN";
1707 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
1711 #endif /* ENABLE_REWRITE */