]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/config.c
c82b410c1fd062b0ae7a369bf50aa77578e210de
[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, ldap_back_exop_whoami );
136         
137         /* dn massaging */
138         } else if ( strcasecmp( argv[0], "suffixmassage" ) == 0 ) {
139                 BackendDB *tmp_be;
140                 struct berval bvnc, nvnc, pvnc, brnc, nrnc, prnc;
141 #ifdef ENABLE_REWRITE
142                 int rc;
143 #endif /* ENABLE_REWRITE */
144                 
145                 /*
146                  * syntax:
147                  * 
148                  *      suffixmassage <suffix> <massaged suffix>
149                  *
150                  * the <suffix> field must be defined as a valid suffix
151                  * (or suffixAlias?) for the current database;
152                  * the <massaged suffix> shouldn't have already been
153                  * defined as a valid suffix or suffixAlias for the 
154                  * current server
155                  */
156                 if ( argc != 3 ) {
157                         fprintf( stderr, "%s: line %d: syntax is"
158                                        " \"suffixMassage <suffix>"
159                                        " <massaged suffix>\"\n",
160                                 fname, lineno );
161                         return( 1 );
162                 }
163                 
164                 ber_str2bv( argv[1], 0, 0, &bvnc );
165                 if ( dnPrettyNormal( NULL, &bvnc, &pvnc, &nvnc, NULL ) != LDAP_SUCCESS ) {
166                         fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n",
167                                 fname, lineno, bvnc.bv_val );
168                         return( 1 );
169                 }
170                 tmp_be = select_backend( &nvnc, 0, 0 );
171                 if ( tmp_be != NULL && tmp_be != be ) {
172                         fprintf( stderr, "%s: line %d: suffix already in use"
173                                        " by another backend in"
174                                        " \"suffixMassage <suffix>"
175                                        " <massaged suffix>\"\n",
176                                 fname, lineno );
177                         free( nvnc.bv_val );
178                         free( pvnc.bv_val );
179                         return( 1 );
180                 }
181
182                 ber_str2bv( argv[2], 0, 0, &brnc );
183                 if ( dnPrettyNormal( NULL, &brnc, &prnc, &nrnc, NULL ) != LDAP_SUCCESS ) {
184                         fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n",
185                                 fname, lineno, brnc.bv_val );
186                         free( nvnc.bv_val );
187                         free( pvnc.bv_val );
188                         return( 1 );
189                 }
190
191 #if 0
192                 tmp_be = select_backend( &nrnc, 0, 0 );
193                 if ( tmp_be != NULL ) {
194                         fprintf( stderr, "%s: line %d: massaged suffix"
195                                        " already in use by another backend in" 
196                                        " \"suffixMassage <suffix>"
197                                        " <massaged suffix>\"\n",
198                                 fname, lineno );
199                         free( nvnc.bv_val );
200                         free( pvnc.bv_val );
201                         free( nrnc.bv_val );
202                         free( prnc.bv_val );
203                         return( 1 );
204                 }
205 #endif
206
207 #ifdef ENABLE_REWRITE
208                 /*
209                  * The suffix massaging is emulated by means of the
210                  * rewrite capabilities
211                  * FIXME: no extra rewrite capabilities should be added
212                  * to the database
213                  */
214                 rc = suffix_massage_config( li->rwmap.rwm_rw,
215                                 &pvnc, &nvnc, &prnc, &nrnc );
216                 free( nvnc.bv_val );
217                 free( pvnc.bv_val );
218                 free( nrnc.bv_val );
219                 free( prnc.bv_val );
220
221                 return( rc );
222
223 #else /* !ENABLE_REWRITE */
224                 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &pvnc );
225                 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &nvnc );
226                 
227                 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &prnc );
228                 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &nrnc );
229 #endif /* !ENABLE_REWRITE */
230
231         /* rewrite stuff ... */
232         } else if ( strncasecmp( argv[0], "rewrite", 7 ) == 0 ) {
233 #ifdef ENABLE_REWRITE
234                 return rewrite_parse( li->rwmap.rwm_rw,
235                                 fname, lineno, argc, argv );
236
237 #else /* !ENABLE_REWRITE */
238                 fprintf( stderr, "%s: line %d: rewrite capabilities "
239                                 "are not enabled\n", fname, lineno );
240 #endif /* !ENABLE_REWRITE */
241                 
242         /* objectclass/attribute mapping */
243         } else if ( strcasecmp( argv[0], "map" ) == 0 ) {
244                 return ldap_back_map_config( &li->rwmap.rwm_oc,
245                                 &li->rwmap.rwm_at,
246                                 fname, lineno, argc, argv );
247
248         /* anything else */
249         } else {
250                 fprintf( stderr, "%s: line %d: unknown directive \"%s\" "
251                         "in ldap database definition (ignored)\n",
252                     fname, lineno, argv[0] );
253         }
254         return 0;
255 }
256
257 int
258 ldap_back_map_config(
259                 struct ldapmap  *oc_map,
260                 struct ldapmap  *at_map,
261                 const char      *fname,
262                 int             lineno,
263                 int             argc,
264                 char            **argv )
265 {
266         struct ldapmap          *map;
267         struct ldapmapping      *mapping;
268         char                    *src, *dst;
269         int                     is_oc = 0;
270
271         if ( argc < 3 || argc > 4 ) {
272                 fprintf( stderr,
273         "%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
274                         fname, lineno );
275                 return 1;
276         }
277
278         if ( strcasecmp( argv[1], "objectclass" ) == 0 ) {
279                 map = oc_map;
280                 is_oc = 1;
281
282         } else if ( strcasecmp( argv[1], "attribute" ) == 0 ) {
283                 map = at_map;
284
285         } else {
286                 fprintf( stderr, "%s: line %d: syntax is "
287                         "\"map {objectclass | attribute} [<local> | *] "
288                         "{<foreign> | *}\"\n",
289                         fname, lineno );
290                 return 1;
291         }
292
293         if ( strcmp( argv[2], "*" ) == 0 ) {
294                 if ( argc < 4 || strcmp( argv[3], "*" ) == 0 ) {
295                         map->drop_missing = ( argc < 4 );
296                         return 0;
297                 }
298                 src = dst = argv[3];
299
300         } else if ( argc < 4 ) {
301                 src = "";
302                 dst = argv[2];
303
304         } else {
305                 src = argv[2];
306                 dst = ( strcmp( argv[3], "*" ) == 0 ? src : argv[3] );
307         }
308
309         if ( ( map == at_map )
310                         && ( strcasecmp( src, "objectclass" ) == 0
311                         || strcasecmp( dst, "objectclass" ) == 0 ) )
312         {
313                 fprintf( stderr,
314                         "%s: line %d: objectclass attribute cannot be mapped\n",
315                         fname, lineno );
316         }
317
318         mapping = (struct ldapmapping *)ch_calloc( 2,
319                 sizeof(struct ldapmapping) );
320         if ( mapping == NULL ) {
321                 fprintf( stderr,
322                         "%s: line %d: out of memory\n",
323                         fname, lineno );
324                 return 1;
325         }
326         ber_str2bv( src, 0, 1, &mapping->src );
327         ber_str2bv( dst, 0, 1, &mapping->dst );
328         mapping[1].src = mapping->dst;
329         mapping[1].dst = mapping->src;
330
331         /*
332          * schema check
333          */
334         if ( is_oc ) {
335                 if ( src[0] != '\0' ) {
336                         if ( oc_bvfind( &mapping->src ) == NULL ) {
337                                 fprintf( stderr,
338         "%s: line %d: warning, source objectClass '%s' "
339         "should be defined in schema\n",
340                                         fname, lineno, src );
341
342                                 /*
343                                  * FIXME: this should become an err
344                                  */
345                         }
346                 }
347
348                 if ( oc_bvfind( &mapping->dst ) == NULL ) {
349                         fprintf( stderr,
350         "%s: line %d: warning, destination objectClass '%s' "
351         "is not defined in schema\n",
352                                 fname, lineno, dst );
353                 }
354         } else {
355                 int                     rc;
356                 const char              *text = NULL;
357                 AttributeDescription    *ad = NULL;
358
359                 if ( src[0] != '\0' ) {
360                         rc = slap_bv2ad( &mapping->src, &ad, &text );
361                         if ( rc != LDAP_SUCCESS ) {
362                                 fprintf( stderr,
363         "%s: line %d: warning, source attributeType '%s' "
364         "should be defined in schema\n",
365                                         fname, lineno, src );
366
367                                 /*
368                                  * FIXME: this should become an err
369                                  */
370                         }
371
372                         ad = NULL;
373                 }
374
375                 rc = slap_bv2ad( &mapping->dst, &ad, &text );
376                 if ( rc != LDAP_SUCCESS ) {
377                         fprintf( stderr,
378         "%s: line %d: warning, destination attributeType '%s' "
379         "is not defined in schema\n",
380                                 fname, lineno, dst );
381                 }
382         }
383
384         if ( (src[0] != '\0' && avl_find( map->map, (caddr_t)mapping, mapping_cmp ) != NULL)
385                         || avl_find( map->remap, (caddr_t)&mapping[1], mapping_cmp ) != NULL)
386         {
387                 fprintf( stderr,
388                         "%s: line %d: duplicate mapping found (ignored)\n",
389                         fname, lineno );
390                 /* FIXME: free stuff */
391                 goto error_return;
392         }
393
394         if ( src[0] != '\0' ) {
395                 avl_insert( &map->map, (caddr_t)mapping,
396                                         mapping_cmp, mapping_dup );
397         }
398         avl_insert( &map->remap, (caddr_t)&mapping[1],
399                                 mapping_cmp, mapping_dup );
400
401         return 0;
402
403 error_return:;
404         if ( mapping ) {
405                 ch_free( mapping->src.bv_val );
406                 ch_free( mapping->dst.bv_val );
407                 ch_free( mapping );
408         }
409
410         return 1;
411 }
412
413 static int
414 ldap_back_exop_whoami(
415         Operation *op,
416         SlapReply *rs )
417 {
418         struct berval *bv = NULL;
419
420         if ( op->oq_extended.rs_reqdata != NULL ) {
421                 /* no request data should be provided */
422                 rs->sr_text = "no request data expected";
423                 return rs->sr_err = LDAP_PROTOCOL_ERROR;
424         }
425
426         rs->sr_err = backend_check_restrictions( op, rs, 
427                         (struct berval *)&slap_EXOP_WHOAMI );
428         if( rs->sr_err != LDAP_SUCCESS ) return rs->sr_err;
429
430         /* if auth'd by back-ldap and request is proxied, forward it */
431         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)) {
432                 struct ldapconn *lc;
433
434                 LDAPControl c, *ctrls[2] = {NULL, NULL};
435                 LDAPMessage *res;
436                 Operation op2 = *op;
437                 ber_int_t msgid;
438
439                 ctrls[0] = &c;
440                 op2.o_ndn = op->o_conn->c_ndn;
441                 lc = ldap_back_getconn(&op2, rs);
442                 if (!lc || !ldap_back_dobind( lc, op, rs )) {
443                         return -1;
444                 }
445                 c.ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
446                 c.ldctl_iscritical = 1;
447                 c.ldctl_value.bv_val = ch_malloc(op->o_ndn.bv_len+4);
448                 c.ldctl_value.bv_len = op->o_ndn.bv_len + 3;
449                 strcpy(c.ldctl_value.bv_val, "dn:");
450                 strcpy(c.ldctl_value.bv_val+3, op->o_ndn.bv_val);
451
452                 rs->sr_err = ldap_whoami(lc->ld, ctrls, NULL, &msgid);
453                 if (rs->sr_err == LDAP_SUCCESS) {
454                         if (ldap_result(lc->ld, msgid, 1, NULL, &res) == -1) {
455                                 ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER,
456                                         &rs->sr_err);
457                         } else {
458                                 rs->sr_err = ldap_parse_whoami(lc->ld, res, &bv);
459                                 ldap_msgfree(res);
460                         }
461                 }
462                 ch_free(c.ldctl_value.bv_val);
463                 if (rs->sr_err != LDAP_SUCCESS) {
464                         rs->sr_err = ldap_back_map_result(rs);
465                 }
466         } else {
467         /* else just do the same as before */
468                 bv = (struct berval *) ch_malloc( sizeof(struct berval) );
469                 if( op->o_dn.bv_len ) {
470                         bv->bv_len = op->o_dn.bv_len + sizeof("dn:")-1;
471                         bv->bv_val = ch_malloc( bv->bv_len + 1 );
472                         AC_MEMCPY( bv->bv_val, "dn:", sizeof("dn:")-1 );
473                         AC_MEMCPY( &bv->bv_val[sizeof("dn:")-1], op->o_dn.bv_val,
474                                 op->o_dn.bv_len );
475                         bv->bv_val[bv->bv_len] = '\0';
476                 } else {
477                         bv->bv_len = 0;
478                         bv->bv_val = NULL;
479                 }
480         }
481
482         rs->sr_rspdata = bv;
483         return rs->sr_err;
484 }
485
486
487 #ifdef ENABLE_REWRITE
488 static char *
489 suffix_massage_regexize( const char *s )
490 {
491         char *res, *ptr;
492         const char *p, *r;
493         int i;
494
495         for ( i = 0, p = s; 
496                         ( r = strchr( p, ',' ) ) != NULL; 
497                         p = r + 1, i++ )
498                 ;
499
500         res = ch_calloc( sizeof( char ), strlen( s ) + 4 + 4*i + 1 );
501
502         ptr = lutil_strcopy( res, "(.*)" );
503         for ( i = 0, p = s;
504                         ( r = strchr( p, ',' ) ) != NULL;
505                         p = r + 1 , i++ ) {
506                 ptr = lutil_strncopy( ptr, p, r - p + 1 );
507                 ptr = lutil_strcopy( ptr, "[ ]?" );
508
509                 if ( r[ 1 ] == ' ' ) {
510                         r++;
511                 }
512         }
513         lutil_strcopy( ptr, p );
514
515         return res;
516 }
517
518 static char *
519 suffix_massage_patternize( const char *s )
520 {
521         ber_len_t       len;
522         char            *res;
523
524         len = strlen( s );
525
526         res = ch_calloc( sizeof( char ), len + sizeof( "%1" ) );
527         if ( res == NULL ) {
528                 return NULL;
529         }
530
531         strcpy( res, "%1" );
532         strcpy( res + sizeof( "%1" ) - 1, s );
533
534         return res;
535 }
536
537 int
538 suffix_massage_config( 
539                 struct rewrite_info *info,
540                 struct berval *pvnc,
541                 struct berval *nvnc,
542                 struct berval *prnc,
543                 struct berval *nrnc
544 )
545 {
546         char *rargv[ 5 ];
547         int line = 0;
548
549         rargv[ 0 ] = "rewriteEngine";
550         rargv[ 1 ] = "on";
551         rargv[ 2 ] = NULL;
552         rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
553
554         rargv[ 0 ] = "rewriteContext";
555         rargv[ 1 ] = "default";
556         rargv[ 2 ] = NULL;
557         rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
558
559         rargv[ 0 ] = "rewriteRule";
560         rargv[ 1 ] = suffix_massage_regexize( pvnc->bv_val );
561         rargv[ 2 ] = suffix_massage_patternize( prnc->bv_val );
562         rargv[ 3 ] = ":";
563         rargv[ 4 ] = NULL;
564         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
565         ch_free( rargv[ 1 ] );
566         ch_free( rargv[ 2 ] );
567         
568         rargv[ 0 ] = "rewriteContext";
569         rargv[ 1 ] = "searchResult";
570         rargv[ 2 ] = NULL;
571         rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
572         
573         rargv[ 0 ] = "rewriteRule";
574         rargv[ 1 ] = suffix_massage_regexize( prnc->bv_val );
575         rargv[ 2 ] = suffix_massage_patternize( pvnc->bv_val );
576         rargv[ 3 ] = ":";
577         rargv[ 4 ] = NULL;
578         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
579         ch_free( rargv[ 1 ] );
580         ch_free( rargv[ 2 ] );
581
582 #if 0
583         /*
584          * FIXME: this is no longer required since now we map filters
585          * based on the parsed filter structure, so we can deal directly
586          * with attribute types and values.  The rewriteContext 
587          * "searchFilter" now refers to the value of attrbutes
588          * with DN syntax.
589          */
590
591         /*
592          * the filter should be rewritten as
593          * 
594          * rewriteRule
595          *      "(.*)member=([^)]+),o=Foo Bar,[ ]?c=US(.*)"
596          *      "%1member=%2,dc=example,dc=com%3"
597          *
598          * where "o=Foo Bar, c=US" is the virtual naming context,
599          * and "dc=example, dc=com" is the real naming context
600          */
601         rargv[ 0 ] = "rewriteContext";
602         rargv[ 1 ] = "searchFilter";
603         rargv[ 2 ] = NULL;
604         rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
605
606 #if 1 /* rewrite filters */
607         {
608                 /*
609                  * Note: this is far more optimistic than desirable:
610                  * for any AVA value ending with the virtual naming
611                  * context the terminal part will be replaced by the
612                  * real naming context; a better solution would be to
613                  * walk the filter looking for DN-valued attributes,
614                  * and only rewrite those that require rewriting
615                  */
616                 char    vbuf_[BUFSIZ], *vbuf = vbuf_,
617                         rbuf_[BUFSIZ], *rbuf = rbuf_;
618                 int     len;
619
620                 len = snprintf( vbuf, sizeof( vbuf_ ), 
621                                 "(.*)%s\\)(.*)", nvnc->bv_val );
622                 if ( len == -1 ) {
623                         /* 
624                          * traditional behavior: snprintf returns -1 
625                          * if buffer is insufficient
626                          */
627                         return -1;
628
629                 } else if ( len >= (int)sizeof( vbuf_ ) ) {
630                         /* 
631                          * C99: snprintf returns the required size 
632                          */
633                         vbuf = ch_malloc( len + 1 );
634                         len = snprintf( vbuf, len,
635                                         "(.*)%s\\)(.*)", nvnc->bv_val );
636                         assert( len > 0 );
637                 }
638
639                 len = snprintf( rbuf, sizeof( rbuf_ ), "%%1%s)%%2", 
640                                 nrnc->bv_val );
641                 if ( len == -1 ) {
642                         return -1;
643
644                 } else if ( len >= (int)sizeof( rbuf_ ) ) {
645                         rbuf = ch_malloc( len + 1 );
646                         len = snprintf( rbuf, sizeof( rbuf_ ), "%%1%s)%%2", 
647                                         nrnc->bv_val );
648                         assert( len > 0 );
649                 }
650                 
651                 rargv[ 0 ] = "rewriteRule";
652                 rargv[ 1 ] = vbuf;
653                 rargv[ 2 ] = rbuf;
654                 rargv[ 3 ] = ":";
655                 rargv[ 4 ] = NULL;
656                 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
657
658                 if ( vbuf != vbuf_ ) {
659                         ch_free( vbuf );
660                 }
661
662                 if ( rbuf != rbuf_ ) {
663                         ch_free( rbuf );
664                 }
665         }
666 #endif /* rewrite filters */
667 #endif
668
669 #if 0 /*  "matched" is not normalized */
670         rargv[ 0 ] = "rewriteContext";
671         rargv[ 1 ] = "matchedDn";
672         rargv[ 2 ] = "alias";
673         rargv[ 3 ] = "searchResult";
674         rargv[ 4 ] = NULL;
675         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
676 #else /* normalize "matched" */
677
678         rargv[ 0 ] = "rewriteContext";
679         rargv[ 1 ] = "matchedDN";
680         rargv[ 2 ] = "alias";
681         rargv[ 3 ] = "searchResult";
682         rargv[ 4 ] = NULL;
683         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
684
685         rargv[ 0 ] = "rewriteContext";
686         rargv[ 1 ] = "searchAttrDN";
687         rargv[ 2 ] = "alias";
688         rargv[ 3 ] = "searchResult";
689         rargv[ 4 ] = NULL;
690         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
691
692 #if 0
693         rargv[ 0 ] = "rewriteRule";
694         rargv[ 1 ] = suffix_massage_regexize( prnc->bv_val );
695         rargv[ 2 ] = suffix_massage_patternize( nvnc->bv_val );
696         rargv[ 3 ] = ":";
697         rargv[ 4 ] = NULL;
698         rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
699         ch_free( rargv[ 1 ] );
700         ch_free( rargv[ 2 ] );
701 #endif /* 0 */
702 #endif /* normalize "matched" */
703
704         return 0;
705 }
706 #endif /* ENABLE_REWRITE */