]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/config.c
ec574b626ca821aa0f5be0d2926adfa447ac9a78
[openldap] / servers / slapd / back-ldap / config.c
1 /* config.c - ldap backend configuration file routine */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7 /* This is an altered version */
8 /*
9  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
10  * 
11  * Permission is granted to anyone to use this software for any purpose
12  * on any computer system, and to alter it and redistribute it, subject
13  * to the following restrictions:
14  * 
15  * 1. The author is not responsible for the consequences of use of this
16  *    software, no matter how awful, even if they arise from flaws in it.
17  * 
18  * 2. The origin of this software must not be misrepresented, either by
19  *    explicit claim or by omission.  Since few users ever read sources,
20  *    credits should appear in the documentation.
21  * 
22  * 3. Altered versions must be plainly marked as such, and must not be
23  *    misrepresented as being the original software.  Since few users
24  *    ever read sources, credits should appear in the documentation.
25  * 
26  * 4. This notice may not be removed or altered.
27  *
28  *
29  *
30  * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
31  * 
32  * This software is being modified by Pierangelo Masarati.
33  * The previously reported conditions apply to the modified code as well.
34  * Changes in the original code are highlighted where required.
35  * Credits for the original code go to the author, Howard Chu.
36  */
37
38 #include "portable.h"
39
40 #include <stdio.h>
41
42 #include <ac/string.h>
43 #include <ac/socket.h>
44
45 #include "slap.h"
46 #include "back-ldap.h"
47 #include "lutil.h"
48
49 static SLAP_EXTOP_MAIN_FN ldap_back_exop_whoami;
50
51 int
52 ldap_back_db_config(
53     BackendDB   *be,
54     const char  *fname,
55     int         lineno,
56     int         argc,
57     char        **argv
58 )
59 {
60         struct ldapinfo *li = (struct ldapinfo *) be->be_private;
61
62         if ( li == NULL ) {
63                 fprintf( stderr, "%s: line %d: ldap backend info is null!\n",
64                     fname, lineno );
65                 return( 1 );
66         }
67
68         /* server address to query (depricated, use "uri" directive) */
69         if ( strcasecmp( argv[0], "server" ) == 0 ) {
70                 if (argc != 2) {
71                         fprintf( stderr,
72         "%s: line %d: missing address in \"server <address>\" line\n",
73                             fname, lineno );
74                         return( 1 );
75                 }
76                 if (li->url != NULL)
77                         ch_free(li->url);
78                 li->url = ch_calloc(strlen(argv[1]) + 9, sizeof(char));
79                 if (li->url != NULL) {
80                         strcpy(li->url, "ldap://");
81                         strcat(li->url, argv[1]);
82                         strcat(li->url, "/");
83                 }
84
85         /* URI of server to query (preferred over "server" directive) */
86         } else if ( strcasecmp( argv[0], "uri" ) == 0 ) {
87                 if (argc != 2) {
88                         fprintf( stderr,
89         "%s: line %d: missing address in \"uri <address>\" line\n",
90                             fname, lineno );
91                         return( 1 );
92                 }
93                 if (li->url != NULL)
94                         ch_free(li->url);
95                 li->url = ch_strdup(argv[1]);
96
97         /* name to use for ldap_back_group */
98         } else if ( strcasecmp( argv[0], "binddn" ) == 0 ) {
99                 if (argc != 2) {
100                         fprintf( stderr,
101         "%s: line %d: missing name in \"binddn <name>\" line\n",
102                             fname, lineno );
103                         return( 1 );
104                 }
105                 ber_str2bv( argv[1], 0, 1, &li->binddn );
106
107         /* password to use for ldap_back_group */
108         } else if ( strcasecmp( argv[0], "bindpw" ) == 0 ) {
109                 if (argc != 2) {
110                         fprintf( stderr,
111         "%s: line %d: missing password in \"bindpw <password>\" line\n",
112                             fname, lineno );
113                         return( 1 );
114                 }
115                 ber_str2bv( argv[1], 0, 1, &li->bindpw );
116         
117         /* save bind creds for referral rebinds? */
118         } else if ( strcasecmp( argv[0], "rebind-as-user" ) == 0 ) {
119                 if (argc != 1) {
120                         fprintf( stderr,
121         "%s: line %d: rebind-as-user takes no arguments\n",
122                             fname, lineno );
123                         return( 1 );
124                 }
125                 li->savecred = 1;
126         
127         /* intercept exop_who_am_i? */
128         } else if ( strcasecmp( argv[0], "proxy-whoami" ) == 0 ) {
129                 if (argc != 1) {
130                         fprintf( stderr,
131         "%s: line %d: proxy-whoami takes no arguments\n",
132                             fname, lineno );
133                         return( 1 );
134                 }
135                 load_extop( (struct berval *)&slap_EXOP_WHOAMI,
136                         0, ldap_back_exop_whoami );
137         
138         /* dn massaging */
139         } else if ( strcasecmp( argv[0], "suffixmassage" ) == 0 ) {
140                 BackendDB *tmp_be;
141                 struct berval bvnc, nvnc, pvnc, brnc, nrnc, prnc;
142 #ifdef ENABLE_REWRITE
143                 int rc;
144 #endif /* ENABLE_REWRITE */
145                 
146                 /*
147                  * syntax:
148                  * 
149                  *      suffixmassage <suffix> <massaged suffix>
150                  *
151                  * the <suffix> field must be defined as a valid suffix
152                  * (or suffixAlias?) for the current database;
153                  * the <massaged suffix> shouldn't have already been
154                  * defined as a valid suffix or suffixAlias for the 
155                  * current server
156                  */
157                 if ( argc != 3 ) {
158                         fprintf( stderr, "%s: line %d: syntax is"
159                                        " \"suffixMassage <suffix>"
160                                        " <massaged suffix>\"\n",
161                                 fname, lineno );
162                         return( 1 );
163                 }
164                 
165                 ber_str2bv( argv[1], 0, 0, &bvnc );
166                 if ( dnPrettyNormal( NULL, &bvnc, &pvnc, &nvnc, NULL ) != LDAP_SUCCESS ) {
167                         fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n",
168                                 fname, lineno, bvnc.bv_val );
169                         return( 1 );
170                 }
171                 tmp_be = select_backend( &nvnc, 0, 0 );
172                 if ( tmp_be != NULL && tmp_be != be ) {
173                         fprintf( stderr, "%s: line %d: suffix already in use"
174                                        " by another backend in"
175                                        " \"suffixMassage <suffix>"
176                                        " <massaged suffix>\"\n",
177                                 fname, lineno );
178                         free( nvnc.bv_val );
179                         free( pvnc.bv_val );
180                         return( 1 );
181                 }
182
183                 ber_str2bv( argv[2], 0, 0, &brnc );
184                 if ( dnPrettyNormal( NULL, &brnc, &prnc, &nrnc, NULL ) != LDAP_SUCCESS ) {
185                         fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n",
186                                 fname, lineno, brnc.bv_val );
187                         free( nvnc.bv_val );
188                         free( pvnc.bv_val );
189                         return( 1 );
190                 }
191
192 #if 0
193                 tmp_be = select_backend( &nrnc, 0, 0 );
194                 if ( tmp_be != NULL ) {
195                         fprintf( stderr, "%s: line %d: massaged suffix"
196                                        " already in use by another backend in" 
197                                        " \"suffixMassage <suffix>"
198                                        " <massaged suffix>\"\n",
199                                 fname, lineno );
200                         free( nvnc.bv_val );
201                         free( pvnc.bv_val );
202                         free( nrnc.bv_val );
203                         free( prnc.bv_val );
204                         return( 1 );
205                 }
206 #endif
207
208 #ifdef ENABLE_REWRITE
209                 /*
210                  * The suffix massaging is emulated by means of the
211                  * rewrite capabilities
212                  * FIXME: no extra rewrite capabilities should be added
213                  * to the database
214                  */
215                 rc = suffix_massage_config( li->rwmap.rwm_rw,
216                                 &pvnc, &nvnc, &prnc, &nrnc );
217                 free( nvnc.bv_val );
218                 free( pvnc.bv_val );
219                 free( nrnc.bv_val );
220                 free( prnc.bv_val );
221
222                 return( rc );
223
224 #else /* !ENABLE_REWRITE */
225                 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &pvnc );
226                 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &nvnc );
227                 
228                 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &prnc );
229                 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &nrnc );
230 #endif /* !ENABLE_REWRITE */
231
232         /* rewrite stuff ... */
233         } else if ( strncasecmp( argv[0], "rewrite", 7 ) == 0 ) {
234 #ifdef ENABLE_REWRITE
235                 return rewrite_parse( li->rwmap.rwm_rw,
236                                 fname, lineno, argc, argv );
237
238 #else /* !ENABLE_REWRITE */
239                 fprintf( stderr, "%s: line %d: rewrite capabilities "
240                                 "are not enabled\n", fname, lineno );
241 #endif /* !ENABLE_REWRITE */
242                 
243         /* objectclass/attribute mapping */
244         } else if ( strcasecmp( argv[0], "map" ) == 0 ) {
245                 return ldap_back_map_config( &li->rwmap.rwm_oc,
246                                 &li->rwmap.rwm_at,
247                                 fname, lineno, argc, argv );
248
249         /* anything else */
250         } else {
251                 fprintf( stderr, "%s: line %d: unknown directive \"%s\" "
252                         "in ldap database definition (ignored)\n",
253                     fname, lineno, argv[0] );
254         }
255         return 0;
256 }
257
258 int
259 ldap_back_map_config(
260                 struct ldapmap  *oc_map,
261                 struct ldapmap  *at_map,
262                 const char      *fname,
263                 int             lineno,
264                 int             argc,
265                 char            **argv )
266 {
267         struct ldapmap          *map;
268         struct ldapmapping      *mapping;
269         char                    *src, *dst;
270         int                     is_oc = 0;
271
272         if ( argc < 3 || argc > 4 ) {
273                 fprintf( stderr,
274         "%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
275                         fname, lineno );
276                 return 1;
277         }
278
279         if ( strcasecmp( argv[1], "objectclass" ) == 0 ) {
280                 map = oc_map;
281                 is_oc = 1;
282
283         } else if ( strcasecmp( argv[1], "attribute" ) == 0 ) {
284                 map = at_map;
285
286         } else {
287                 fprintf( stderr, "%s: line %d: syntax is "
288                         "\"map {objectclass | attribute} [<local> | *] "
289                         "{<foreign> | *}\"\n",
290                         fname, lineno );
291                 return 1;
292         }
293
294         if ( strcmp( argv[2], "*" ) == 0 ) {
295                 if ( argc < 4 || strcmp( argv[3], "*" ) == 0 ) {
296                         map->drop_missing = ( argc < 4 );
297                         return 0;
298                 }
299                 src = dst = argv[3];
300
301         } else if ( argc < 4 ) {
302                 src = "";
303                 dst = argv[2];
304
305         } else {
306                 src = argv[2];
307                 dst = ( strcmp( argv[3], "*" ) == 0 ? src : argv[3] );
308         }
309
310         if ( ( map == at_map )
311                         && ( strcasecmp( src, "objectclass" ) == 0
312                         || strcasecmp( dst, "objectclass" ) == 0 ) )
313         {
314                 fprintf( stderr,
315                         "%s: line %d: objectclass attribute cannot be mapped\n",
316                         fname, lineno );
317         }
318
319         mapping = (struct ldapmapping *)ch_calloc( 2,
320                 sizeof(struct ldapmapping) );
321         if ( mapping == NULL ) {
322                 fprintf( stderr,
323                         "%s: line %d: out of memory\n",
324                         fname, lineno );
325                 return 1;
326         }
327         ber_str2bv( src, 0, 1, &mapping->src );
328         ber_str2bv( dst, 0, 1, &mapping->dst );
329         mapping[1].src = mapping->dst;
330         mapping[1].dst = mapping->src;
331
332         /*
333          * schema check
334          */
335         if ( is_oc ) {
336                 if ( src[0] != '\0' ) {
337                         if ( oc_bvfind( &mapping->src ) == NULL ) {
338                                 fprintf( stderr,
339         "%s: line %d: warning, source objectClass '%s' "
340         "should be defined in schema\n",
341                                         fname, lineno, src );
342
343                                 /*
344                                  * FIXME: this should become an err
345                                  */
346                         }
347                 }
348
349                 if ( oc_bvfind( &mapping->dst ) == NULL ) {
350                         fprintf( stderr,
351         "%s: line %d: warning, destination objectClass '%s' "
352         "is not defined in schema\n",
353                                 fname, lineno, dst );
354                 }
355         } else {
356                 int                     rc;
357                 const char              *text = NULL;
358                 AttributeDescription    *ad = NULL;
359
360                 if ( src[0] != '\0' ) {
361                         rc = slap_bv2ad( &mapping->src, &ad, &text );
362                         if ( rc != LDAP_SUCCESS ) {
363                                 fprintf( stderr,
364         "%s: line %d: warning, source attributeType '%s' "
365         "should be defined in schema\n",
366                                         fname, lineno, src );
367
368                                 /*
369                                  * FIXME: this should become an err
370                                  */
371                         }
372
373                         ad = NULL;
374                 }
375
376                 rc = slap_bv2ad( &mapping->dst, &ad, &text );
377                 if ( rc != LDAP_SUCCESS ) {
378                         fprintf( stderr,
379         "%s: line %d: warning, destination attributeType '%s' "
380         "is not defined in schema\n",
381                                 fname, lineno, dst );
382                 }
383         }
384
385         if ( (src[0] != '\0' && avl_find( map->map, (caddr_t)mapping, mapping_cmp ) != NULL)
386                         || avl_find( map->remap, (caddr_t)&mapping[1], mapping_cmp ) != NULL)
387         {
388                 fprintf( stderr,
389                         "%s: line %d: duplicate mapping found (ignored)\n",
390                         fname, lineno );
391                 /* FIXME: free stuff */
392                 goto error_return;
393         }
394
395         if ( src[0] != '\0' ) {
396                 avl_insert( &map->map, (caddr_t)mapping,
397                                         mapping_cmp, mapping_dup );
398         }
399         avl_insert( &map->remap, (caddr_t)&mapping[1],
400                                 mapping_cmp, mapping_dup );
401
402         return 0;
403
404 error_return:;
405         if ( mapping ) {
406                 ch_free( mapping->src.bv_val );
407                 ch_free( mapping->dst.bv_val );
408                 ch_free( mapping );
409         }
410
411         return 1;
412 }
413
414 static int
415 ldap_back_exop_whoami(
416         Operation *op,
417         SlapReply *rs )
418 {
419         struct berval *bv = NULL;
420
421         if ( op->oq_extended.rs_reqdata != NULL ) {
422                 /* no request data should be provided */
423                 rs->sr_text = "no request data expected";
424                 return rs->sr_err = LDAP_PROTOCOL_ERROR;
425         }
426
427         rs->sr_err = backend_check_restrictions( op, rs, 
428                         (struct berval *)&slap_EXOP_WHOAMI );
429         if( rs->sr_err != LDAP_SUCCESS ) return rs->sr_err;
430
431         /* if auth'd by back-ldap and request is proxied, forward it */
432         if ( op->o_conn->c_authz_backend && !strcmp(op->o_conn->c_authz_backend->be_type, "ldap" ) && !dn_match(&op->o_ndn, &op->o_conn->c_ndn)) {
433                 struct ldapconn *lc;
434
435                 LDAPControl c, *ctrls[2] = {NULL, NULL};
436                 LDAPMessage *res;
437                 Operation op2 = *op;
438                 ber_int_t msgid;
439
440                 ctrls[0] = &c;
441                 op2.o_ndn = op->o_conn->c_ndn;
442                 lc = ldap_back_getconn(&op2, rs);
443                 if (!lc || !ldap_back_dobind( lc, op, rs )) {
444                         return -1;
445                 }
446                 c.ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
447                 c.ldctl_iscritical = 1;
448                 c.ldctl_value.bv_val = ch_malloc(op->o_ndn.bv_len+4);
449                 c.ldctl_value.bv_len = op->o_ndn.bv_len + 3;
450                 strcpy(c.ldctl_value.bv_val, "dn:");
451                 strcpy(c.ldctl_value.bv_val+3, op->o_ndn.bv_val);
452
453                 rs->sr_err = ldap_whoami(lc->ld, ctrls, NULL, &msgid);
454                 if (rs->sr_err == LDAP_SUCCESS) {
455                         if (ldap_result(lc->ld, msgid, 1, NULL, &res) == -1) {
456                                 ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER,
457                                         &rs->sr_err);
458                         } else {
459                                 rs->sr_err = ldap_parse_whoami(lc->ld, res, &bv);
460                                 ldap_msgfree(res);
461                         }
462                 }
463                 ch_free(c.ldctl_value.bv_val);
464                 if (rs->sr_err != LDAP_SUCCESS) {
465                         rs->sr_err = ldap_back_map_result(rs);
466                 }
467         } else {
468         /* else just do the same as before */
469                 bv = (struct berval *) ch_malloc( sizeof(struct berval) );
470                 if( op->o_dn.bv_len ) {
471                         bv->bv_len = op->o_dn.bv_len + sizeof("dn:")-1;
472                         bv->bv_val = ch_malloc( bv->bv_len + 1 );
473                         AC_MEMCPY( bv->bv_val, "dn:", sizeof("dn:")-1 );
474                         AC_MEMCPY( &bv->bv_val[sizeof("dn:")-1], op->o_dn.bv_val,
475                                 op->o_dn.bv_len );
476                         bv->bv_val[bv->bv_len] = '\0';
477                 } else {
478                         bv->bv_len = 0;
479                         bv->bv_val = NULL;
480                 }
481         }
482
483         rs->sr_rspdata = bv;
484         return rs->sr_err;
485 }
486
487
488 #ifdef ENABLE_REWRITE
489 static char *
490 suffix_massage_regexize( const char *s )
491 {
492         char *res, *ptr;
493         const char *p, *r;
494         int i;
495
496         for ( i = 0, p = s; 
497                         ( r = strchr( p, ',' ) ) != NULL; 
498                         p = r + 1, i++ )
499                 ;
500
501         res = ch_calloc( sizeof( char ), strlen( s ) + 4 + 4*i + 1 );
502
503         ptr = lutil_strcopy( res, "(.*)" );
504         for ( i = 0, p = s;
505                         ( r = strchr( p, ',' ) ) != NULL;
506                         p = r + 1 , i++ ) {
507                 ptr = lutil_strncopy( ptr, p, r - p + 1 );
508                 ptr = lutil_strcopy( ptr, "[ ]?" );
509
510                 if ( r[ 1 ] == ' ' ) {
511                         r++;
512                 }
513         }
514         lutil_strcopy( ptr, p );
515
516         return res;
517 }
518
519 static char *
520 suffix_massage_patternize( const char *s )
521 {
522         ber_len_t       len;
523         char            *res;
524
525         len = strlen( s );
526
527         res = ch_calloc( sizeof( char ), len + sizeof( "%1" ) );
528         if ( res == NULL ) {
529                 return NULL;
530         }
531
532         strcpy( res, "%1" );
533         strcpy( res + sizeof( "%1" ) - 1, s );
534
535         return res;
536 }
537
538 int
539 suffix_massage_config( 
540                 struct rewrite_info *info,
541                 struct berval *pvnc,
542                 struct berval *nvnc,
543                 struct berval *prnc,
544                 struct berval *nrnc
545 )
546 {
547         char *rargv[ 5 ];
548         int line = 0;
549
550         rargv[ 0 ] = "rewriteEngine";
551         rargv[ 1 ] = "on";
552         rargv[ 2 ] = NULL;
553         rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
554
555         rargv[ 0 ] = "rewriteContext";
556         rargv[ 1 ] = "default";
557         rargv[ 2 ] = NULL;
558         rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
559
560         rargv[ 0 ] = "rewriteRule";
561         rargv[ 1 ] = suffix_massage_regexize( pvnc->bv_val );
562         rargv[ 2 ] = suffix_massage_patternize( prnc->bv_val );
563         rargv[ 3 ] = ":";
564         rargv[ 4 ] = NULL;
565         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
566         ch_free( rargv[ 1 ] );
567         ch_free( rargv[ 2 ] );
568         
569         rargv[ 0 ] = "rewriteContext";
570         rargv[ 1 ] = "searchResult";
571         rargv[ 2 ] = NULL;
572         rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
573         
574         rargv[ 0 ] = "rewriteRule";
575         rargv[ 1 ] = suffix_massage_regexize( prnc->bv_val );
576         rargv[ 2 ] = suffix_massage_patternize( pvnc->bv_val );
577         rargv[ 3 ] = ":";
578         rargv[ 4 ] = NULL;
579         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
580         ch_free( rargv[ 1 ] );
581         ch_free( rargv[ 2 ] );
582
583 #if 0
584         /*
585          * FIXME: this is no longer required since now we map filters
586          * based on the parsed filter structure, so we can deal directly
587          * with attribute types and values.  The rewriteContext 
588          * "searchFilter" now refers to the value of attrbutes
589          * with DN syntax.
590          */
591
592         /*
593          * the filter should be rewritten as
594          * 
595          * rewriteRule
596          *      "(.*)member=([^)]+),o=Foo Bar,[ ]?c=US(.*)"
597          *      "%1member=%2,dc=example,dc=com%3"
598          *
599          * where "o=Foo Bar, c=US" is the virtual naming context,
600          * and "dc=example, dc=com" is the real naming context
601          */
602         rargv[ 0 ] = "rewriteContext";
603         rargv[ 1 ] = "searchFilter";
604         rargv[ 2 ] = NULL;
605         rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
606
607 #if 1 /* rewrite filters */
608         {
609                 /*
610                  * Note: this is far more optimistic than desirable:
611                  * for any AVA value ending with the virtual naming
612                  * context the terminal part will be replaced by the
613                  * real naming context; a better solution would be to
614                  * walk the filter looking for DN-valued attributes,
615                  * and only rewrite those that require rewriting
616                  */
617                 char    vbuf_[BUFSIZ], *vbuf = vbuf_,
618                         rbuf_[BUFSIZ], *rbuf = rbuf_;
619                 int     len;
620
621                 len = snprintf( vbuf, sizeof( vbuf_ ), 
622                                 "(.*)%s\\)(.*)", nvnc->bv_val );
623                 if ( len == -1 ) {
624                         /* 
625                          * traditional behavior: snprintf returns -1 
626                          * if buffer is insufficient
627                          */
628                         return -1;
629
630                 } else if ( len >= (int)sizeof( vbuf_ ) ) {
631                         /* 
632                          * C99: snprintf returns the required size 
633                          */
634                         vbuf = ch_malloc( len + 1 );
635                         len = snprintf( vbuf, len,
636                                         "(.*)%s\\)(.*)", nvnc->bv_val );
637                         assert( len > 0 );
638                 }
639
640                 len = snprintf( rbuf, sizeof( rbuf_ ), "%%1%s)%%2", 
641                                 nrnc->bv_val );
642                 if ( len == -1 ) {
643                         return -1;
644
645                 } else if ( len >= (int)sizeof( rbuf_ ) ) {
646                         rbuf = ch_malloc( len + 1 );
647                         len = snprintf( rbuf, sizeof( rbuf_ ), "%%1%s)%%2", 
648                                         nrnc->bv_val );
649                         assert( len > 0 );
650                 }
651                 
652                 rargv[ 0 ] = "rewriteRule";
653                 rargv[ 1 ] = vbuf;
654                 rargv[ 2 ] = rbuf;
655                 rargv[ 3 ] = ":";
656                 rargv[ 4 ] = NULL;
657                 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
658
659                 if ( vbuf != vbuf_ ) {
660                         ch_free( vbuf );
661                 }
662
663                 if ( rbuf != rbuf_ ) {
664                         ch_free( rbuf );
665                 }
666         }
667 #endif /* rewrite filters */
668 #endif
669
670 #if 0 /*  "matched" is not normalized */
671         rargv[ 0 ] = "rewriteContext";
672         rargv[ 1 ] = "matchedDn";
673         rargv[ 2 ] = "alias";
674         rargv[ 3 ] = "searchResult";
675         rargv[ 4 ] = NULL;
676         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
677 #else /* normalize "matched" */
678
679         rargv[ 0 ] = "rewriteContext";
680         rargv[ 1 ] = "matchedDN";
681         rargv[ 2 ] = "alias";
682         rargv[ 3 ] = "searchResult";
683         rargv[ 4 ] = NULL;
684         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
685
686         rargv[ 0 ] = "rewriteContext";
687         rargv[ 1 ] = "searchAttrDN";
688         rargv[ 2 ] = "alias";
689         rargv[ 3 ] = "searchResult";
690         rargv[ 4 ] = NULL;
691         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
692
693 #if 0
694         rargv[ 0 ] = "rewriteRule";
695         rargv[ 1 ] = suffix_massage_regexize( prnc->bv_val );
696         rargv[ 2 ] = suffix_massage_patternize( nvnc->bv_val );
697         rargv[ 3 ] = ":";
698         rargv[ 4 ] = NULL;
699         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
700         ch_free( rargv[ 1 ] );
701         ch_free( rargv[ 2 ] );
702 #endif /* 0 */
703 #endif /* normalize "matched" */
704
705         return 0;
706 }
707 #endif /* ENABLE_REWRITE */