From: Pierangelo Masarati Date: Thu, 12 Feb 2009 23:00:47 +0000 (+0000) Subject: rewrite info should always be set (ITS#5940) X-Git-Tag: ACLCHECK_0~831 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d1b415e6beb3688183d3357a2376d4d46a3b7146;p=openldap rewrite info should always be set (ITS#5940) --- diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index 66844b388e..070d4b3f70 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -1947,6 +1947,53 @@ slap_rewrite_unparse( BerVarray in, BerVarray *out ) *out = bva; } +static int +rwm_bva_rewrite_add( + struct ldaprwmap *rwmap, + const char *argv[] ) +{ + char *line; + struct berval bv; + + line = ldap_charray2str( argv, "\" \"" ); + if ( line != NULL ) { + int len = strlen( argv[ 0 ] ); + + ber_str2bv( line, 0, 0, &bv ); + AC_MEMCPY( &bv.bv_val[ len ], &bv.bv_val[ len + 1 ], + bv.bv_len - ( len + 1 ) ); + bv.bv_val[ bv.bv_len - 1 ] = '"'; + ber_bvarray_add( &rwmap->rwm_bva_rewrite, &bv ); + } + + return 0; +} + +static int +rwm_info_init( struct ldaprwmap *rwmap ) +{ + char *rargv[ 3 ]; + + rwmap->rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT ); + if ( rwmap->rwm_rw == NULL ) { + return -1; + } + + /* this rewriteContext by default must be null; + * rules can be added if required */ + rargv[ 0 ] = "rewriteContext"; + rargv[ 1 ] = "searchFilter"; + rargv[ 2 ] = NULL; + rewrite_parse( rwmap->rwm_rw, "", 1, 2, rargv ); + + rargv[ 0 ] = "rewriteContext"; + rargv[ 1 ] = "default"; + rargv[ 2 ] = NULL; + rewrite_parse( rwmap->rwm_rw, "", 2, 2, rargv ); + + return 0; +} + static int rwm_cf_gen( ConfigArgs *c ) { @@ -2023,6 +2070,8 @@ rwm_cf_gen( ConfigArgs *c ) ber_bvarray_free( rwmap->rwm_bva_rewrite ); rwmap->rwm_bva_rewrite = NULL; + + rc = rwm_info_init( rwmap ); } break; @@ -2085,19 +2134,7 @@ rwm_cf_gen( ConfigArgs *c ) return 1; } else { - char *line; - struct berval bv; - - line = ldap_charray2str( &c->argv[ idx0 ], "\" \"" ); - if ( line != NULL ) { - int len = strlen( c->argv[ idx0 ] ); - - ber_str2bv( line, 0, 0, &bv ); - AC_MEMCPY( &bv.bv_val[ len ], &bv.bv_val[ len + 1 ], - bv.bv_len - ( len + 1 ) ); - bv.bv_val[ bv.bv_len - 1 ] = '"'; - ber_bvarray_add( &rwmap->rwm_bva_rewrite, &bv ); - } + rwm_bva_rewrite_add( rwmap, &c->argv[ idx0 ] ); } break; @@ -2155,28 +2192,11 @@ rwm_db_init( { slap_overinst *on = (slap_overinst *) be->bd_info; struct ldaprwmap *rwmap; - char *rargv[ 3 ]; int rc = 0; rwmap = (struct ldaprwmap *)ch_calloc( 1, sizeof( struct ldaprwmap ) ); - rwmap->rwm_rw = rewrite_info_init( REWRITE_MODE_USE_DEFAULT ); - if ( rwmap->rwm_rw == NULL ) { - rc = -1; - goto error_return; - } - - /* this rewriteContext by default must be null; - * rules can be added if required */ - rargv[ 0 ] = "rewriteContext"; - rargv[ 1 ] = "searchFilter"; - rargv[ 2 ] = NULL; - rewrite_parse( rwmap->rwm_rw, "", 1, 2, rargv ); - - rargv[ 0 ] = "rewriteContext"; - rargv[ 1 ] = "default"; - rargv[ 2 ] = NULL; - rewrite_parse( rwmap->rwm_rw, "", 2, 2, rargv ); + rc = rwm_info_init( rwmap ); error_return:; on->on_bi.bi_private = (void *)rwmap;