Commit 6e0d483f authored by Howard Chu's avatar Howard Chu
Browse files

Backward compatibility - treat unknown directives as perlModuleConfig's

parent 1c59810a
......@@ -48,7 +48,7 @@ perl_back_db_destroy(
{
PerlBackend *pb = be->be_private;
ch_free( pb->pb_module_name.bv_val );
ch_free( pb->pb_module_name );
ber_bvarray_free( pb->pb_module_path );
ber_bvarray_free( pb->pb_module_config );
......
......@@ -34,7 +34,7 @@ static ConfigTable perlcfg[] = {
"EQUALITY caseExactMatch "
"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
{ "perlModulePath", "path", 2, 2, 0,
ARG_STRING|ARG_MAGIC|PERL_PATH, perl_cf,
ARG_MAGIC|PERL_PATH, perl_cf,
"( OLcfgDbAt:11.2 NAME 'olcPerlModulePath' "
"DESC 'Perl module path' "
"EQUALITY caseExactMatch "
......@@ -45,7 +45,7 @@ static ConfigTable perlcfg[] = {
"DESC 'Filter search results before returning to client' "
"SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
{ "perlModuleConfig", "args", 2, 0, 0,
ARG_STRING|ARG_MAGIC|PERL_CONFIG, perl_cf,
ARG_MAGIC|PERL_CONFIG, perl_cf,
"( OLcfgDbAt:11.4 NAME 'olcPerlModuleConfig' "
"DESC 'Perl module config directives' "
"EQUALITY caseExactMatch "
......@@ -55,7 +55,7 @@ static ConfigTable perlcfg[] = {
static ConfigOCs perlocs[] = {
{ "( OLcfgDbOc:11.1 "
"NAME 'olcPerlConfig' "
"NAME 'olcDbPerlConfig' "
"DESC 'Perl DB configuration' "
"SUP olcDatabaseConfig "
"MUST ( olcPerlModulePath $ olcPerlModule ) "
......@@ -64,11 +64,48 @@ static ConfigOCs perlocs[] = {
{ NULL }
};
static ConfigOCs ovperlocs[] = {
{ "( OLcfgDbOc:11.2 "
"NAME 'olcovPerlConfig' "
"DESC 'Perl overlay configuration' "
"SUP olcOverlayConfig "
"MUST ( olcPerlModulePath $ olcPerlModule ) "
"MAY ( olcPerlFilterSearchResults $ olcPerlModuleConfig ) )",
Cft_Overlay, perlcfg, NULL, NULL },
{ NULL }
};
/**********************************************************
*
* Config
*
**********************************************************/
int
perl_back_db_config(
BackendDB *be,
const char *fname,
int lineno,
int argc,
char **argv
)
{
int rc = config_generic_wrapper( be, fname, lineno, argc, argv );
/* backward compatibility: map unknown directives to perlModuleConfig */
if ( rc == SLAP_CONF_UNKNOWN ) {
char **av = ch_malloc( (argc+2) * sizeof(char *));
int i;
av[0] = "perlModuleConfig";
av++;
for ( i=0; i<argc; i++ )
av[i] = argv[i];
av[i] = NULL;
av--;
rc = config_generic_wrapper( be, fname, lineno, argc+1, av );
ch_free( av );
}
return rc;
}
static int
perl_cf(
ConfigArgs *c
......@@ -85,9 +122,9 @@ perl_cf(
if ( c->op == SLAP_CONFIG_EMIT ) {
switch( c-> type ) {
case PERL_MODULE:
if ( bv.bv_len < 1 )
if ( !pb->pb_module_name )
return 1;
value_add_one( &c->rvalue_vals, &pb->pb_module_name );
c->value_string = ch_strdup( pb->pb_module_name );
break;
case PERL_PATH:
if ( !pb->pb_module_path )
......@@ -107,8 +144,8 @@ perl_cf(
*/
switch( c-> type ) {
case PERL_MODULE:
ch_free( pb->pb_module_name.bv_val );
BER_BVZERO( &pb->pb_module_name );
ch_free( pb->pb_module_name );
pb->pb_module_name = NULL;
break;
case PERL_PATH:
if ( c->valx < 0 ) {
......@@ -168,7 +205,7 @@ perl_cf(
pb->pb_obj_ref = newSVsv(POPs);
PUTBACK; FREETMPS; LEAVE ;
ber_str2bv( c->argv[1], 0, 1, &pb->pb_module_name );
pb->pb_module_name = ch_strdup( c->argv[1] );
}
break;
......
......@@ -45,7 +45,7 @@ perl_back_initialize(
bi->bi_destroy = 0;
bi->bi_db_init = perl_back_db_init;
bi->bi_db_config = 0;
bi->bi_db_config = perl_back_db_config;
bi->bi_db_open = perl_back_db_open;
bi->bi_db_close = 0;
bi->bi_db_destroy = perl_back_db_destroy;
......
......@@ -67,7 +67,7 @@ extern PerlInterpreter *PERL_INTERPRETER;
typedef struct perl_backend_instance {
struct berval pb_module_name;
char *pb_module_name;
BerVarray pb_module_path;
BerVarray pb_module_config;
SV *pb_obj_ref;
......
......@@ -27,6 +27,7 @@ extern BI_close perl_back_close;
extern BI_db_init perl_back_db_init;
extern BI_db_open perl_back_db_open;
extern BI_db_destroy perl_back_db_destroy;
extern BI_db_config perl_back_db_config;
extern BI_op_bind perl_back_bind;
extern BI_op_search perl_back_search;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment