]> git.sur5r.net Git - openldap/commitdiff
Backward compatibility - treat unknown directives as perlModuleConfig's
authorHoward Chu <hyc@openldap.org>
Fri, 4 Feb 2011 17:07:35 +0000 (17:07 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 4 Feb 2011 17:07:35 +0000 (17:07 +0000)
servers/slapd/back-perl/close.c
servers/slapd/back-perl/config.c
servers/slapd/back-perl/init.c
servers/slapd/back-perl/perl_back.h
servers/slapd/back-perl/proto-perl.h

index 893834b760b75b0a3d4a4d8eaece8833c9a780a1..6e16a04daf7a8a7234d29b4894ad0b7fc36a4823 100644 (file)
@@ -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 );
 
index e8489b68698611ac389b4b716696350590a4bd59..a8b98a394337319b54735310144f1ca6abcab75f 100644 (file)
@@ -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;
 
index f4acb87e3ed2e12a49bb545d3bb2f15adde430da..bb0d16f2e4849b97940abbc51fcb5ddbb5234211 100644 (file)
@@ -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;
index 538d41f901bdffff133b57ab537527e6b572e1a5..b76c20b7a9e5ded9b6a89426149abae2bfe40841 100644 (file)
@@ -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;
index f0582d8958866d67c584d2045de811f52bc5100a..0fd9f0be71f4d2f2d8949c08d632bdf9db9fc7ea 100644 (file)
@@ -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;