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