perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From go...@apache.org
Subject svn commit: r384596 - in /perl/modperl/trunk: ./ src/modules/perl/ t/api/ t/htdocs/TestAPI__add_config/ t/response/TestAPI/ xs/Apache2/Access/ xs/Apache2/CmdParms/ xs/Apache2/RequestUtil/ xs/maps/ xs/tables/current/ModPerl/
Date Thu, 09 Mar 2006 20:16:28 GMT
Author: gozer
Date: Thu Mar  9 12:16:26 2006
New Revision: 384596

URL: http://svn.apache.org/viewcvs?rev=384596&view=rev
Log:
Added support for httpd-2.2's new override_opts in Apache2::Access.
Calls to add_config() now accept an override_opts value as the 4th
argument.

Submitted-By: Torsten Foertsch <torsten.foertsch@gmx.net>
Reviewed-By: Gozer

Added:
    perl/modperl/trunk/t/api/add_config.t
    perl/modperl/trunk/t/htdocs/TestAPI__add_config/
    perl/modperl/trunk/t/htdocs/TestAPI__add_config/htaccess
    perl/modperl/trunk/t/response/TestAPI/add_config.pm
Modified:
    perl/modperl/trunk/Changes
    perl/modperl/trunk/src/modules/perl/modperl_apache_compat.h
    perl/modperl/trunk/src/modules/perl/modperl_config.c
    perl/modperl/trunk/src/modules/perl/modperl_config.h
    perl/modperl/trunk/xs/Apache2/Access/Apache2__Access.h
    perl/modperl/trunk/xs/Apache2/CmdParms/Apache2__CmdParms.h
    perl/modperl/trunk/xs/Apache2/RequestUtil/Apache2__RequestUtil.h
    perl/modperl/trunk/xs/maps/apache2_structures.map
    perl/modperl/trunk/xs/maps/modperl_functions.map
    perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm

Modified: perl/modperl/trunk/Changes
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/Changes?rev=384596&r1=384595&r2=384596&view=diff
==============================================================================
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Thu Mar  9 12:16:26 2006
@@ -12,6 +12,10 @@
 
 =item 2.0.3-dev
 
+Added support for httpd-2.2's new override_opts in Apache2::Access.
+Calls to add_config() now accept an override_opts value as the 4th
+argument. [Torsten Foertsch <torsten.foertsch@gmx.net>, Gozer]
+
 Fix 'PerlSwitches +inherit' that got broken somewhere along
 the way to 2.0. You can also use 'PerlOptions +InheritSwitches'
 for the same result. [Gozer]

Modified: perl/modperl/trunk/src/modules/perl/modperl_apache_compat.h
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_apache_compat.h?rev=384596&r1=384595&r2=384596&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_apache_compat.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_apache_compat.h Thu Mar  9 12:16:26 2006
@@ -40,4 +40,15 @@
 #define ap_http_scheme(r) ap_http_method(r)
 #endif
 
+#if AP_SERVER_MAJORVERSION_NUMBER>2 || AP_SERVER_MINORVERSION_NUMBER>=2
+#define MP_HTTPD_HAS_OVERRIDE_OPTS
+#endif
+
+#define MP_HTTPD_OVERRIDE_OPTS_UNSET (-1)
+#define MP_HTTPD_OVERRIDE_OPTS_DEFAULT (OPT_UNSET | \
+                                        OPT_ALL | \
+                                        OPT_INCNOEXEC | \
+                                        OPT_SYM_OWNER | \
+                                        OPT_MULTI)
+
 #endif /* MODPERL_APACHE_COMPAT_H */

Modified: perl/modperl/trunk/src/modules/perl/modperl_config.c
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_config.c?rev=384596&r1=384595&r2=384596&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_config.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_config.c Thu Mar  9 12:16:26 2006
@@ -498,6 +498,7 @@
                                   apr_pool_t *ptmp,
                                   int override,
                                   char *path,
+                                  int override_options,
                                   ap_conf_vector_t *conf,
                                   SV *lines)
 {
@@ -513,6 +514,14 @@
     parms.override = override;
     parms.path = path;
     parms.pool = p;
+#ifdef MP_HTTPD_HAS_OVERRIDE_OPTS
+    if (override_options == MP_HTTPD_OVERRIDE_OPTS_UNSET) {
+        parms.override_opts = MP_HTTPD_OVERRIDE_OPTS_DEFAULT;
+    }
+    else {
+        parms.override_opts = override_options;
+    }
+#endif
 
     if (ptmp) {
         parms.temp_pool = ptmp;
@@ -559,6 +568,11 @@
                                  parms->temp_pool,
                                  parms->override, 
                                  parms->path,
+#ifdef MP_HTTPD_HAS_OVERRIDE_OPTS
+                                 parms->override_opts,
+#else
+                                 MP_HTTPD_OVERRIDE_OPTS_UNSET,
+#endif
                                  parms->context,
                                  lines);
 }
@@ -570,6 +584,7 @@
     apr_pool_t *p = s->process->pconf;
 
     return modperl_config_insert(aTHX_ s, p, NULL, override, NULL,
+                                 MP_HTTPD_OVERRIDE_OPTS_UNSET,
                                  s->lookup_defaults, lines);
 }
 
@@ -577,20 +592,24 @@
                                           request_rec *r,
                                           SV *lines,
                                           int override,
-                                          char *path)
+                                          char *path,
+                                          int override_options)
 {
     const char *errmsg;
     ap_conf_vector_t *dconf = ap_create_per_dir_config(r->pool);
 
-    /* The path argument of "/" is only required to be non-NULL
-       and "/" is as good a default as anything else */
     if (!path) {
+        /* pass a non-NULL path if nothing else given and for compatibility */
         path = "/";
     }
+    else if (!*path) {
+        /* an empty string says a NULL pointer should be used here */
+        path = NULL;
+    }
 
     errmsg = modperl_config_insert(aTHX_
                                    r->server, r->pool, r->pool,
-                                   override, path,
+                                   override, path, override_options,
                                    dconf, lines);
 
     if (errmsg) {

Modified: perl/modperl/trunk/src/modules/perl/modperl_config.h
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_config.h?rev=384596&r1=384595&r2=384596&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_config.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_config.h Thu Mar  9 12:16:26 2006
@@ -131,6 +131,7 @@
                                   apr_pool_t *ptmp,
                                   int override,
                                   char *path,
+                                  int override_options,
                                   ap_conf_vector_t *conf,
                                   SV *lines);
 
@@ -143,7 +144,8 @@
                                           request_rec *r,
                                           SV *lines,
                                           int override,
-                                          char *path);
+                                          char *path,
+                                          int override_options);
 
 int modperl_config_is_perl_option_enabled(pTHX_ request_rec *r,
                                           server_rec *s, const char *name);

Added: perl/modperl/trunk/t/api/add_config.t
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/api/add_config.t?rev=384596&view=auto
==============================================================================
--- perl/modperl/trunk/t/api/add_config.t (added)
+++ perl/modperl/trunk/t/api/add_config.t Thu Mar  9 12:16:26 2006
@@ -0,0 +1,13 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::TestRequest qw(GET_BODY_ASSERT);
+use Apache::Test;
+use Apache::TestUtil;
+
+my $module = 'TestAPI::add_config';
+my $url    = Apache::TestRequest::module2url($module);
+
+t_debug("connecting to $url");
+print GET_BODY_ASSERT $url;
+

Added: perl/modperl/trunk/t/htdocs/TestAPI__add_config/htaccess
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/htdocs/TestAPI__add_config/htaccess?rev=384596&view=auto
==============================================================================
--- perl/modperl/trunk/t/htdocs/TestAPI__add_config/htaccess (added)
+++ perl/modperl/trunk/t/htdocs/TestAPI__add_config/htaccess Thu Mar  9 12:16:26 2006
@@ -0,0 +1 @@
+TestAddConfig Htaccess

Added: perl/modperl/trunk/t/response/TestAPI/add_config.pm
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/response/TestAPI/add_config.pm?rev=384596&view=auto
==============================================================================
--- perl/modperl/trunk/t/response/TestAPI/add_config.pm (added)
+++ perl/modperl/trunk/t/response/TestAPI/add_config.pm Thu Mar  9 12:16:26 2006
@@ -0,0 +1,122 @@
+package TestAPI::add_config;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache2::Access ();
+use Apache2::CmdParms ();
+use Apache2::RequestUtil ();
+use Apache2::Directive ();
+use Apache2::ServerUtil ();
+use base qw(Apache2::Module);
+
+use Apache::Test;
+use Apache::TestUtil;
+
+use Apache2::Const -compile => qw(
+    OK
+    DECLINED
+    :options
+);
+
+use constant KEY        => "TestAddConfig";
+use constant APACHE22   => have_min_apache_version('2.2.0');
+
+my @directives = (
+    {
+        name        => KEY,
+        cmd_data    => 'cmd_data',
+        errmsg      => 'errmsg',
+    },
+);
+
+Apache2::Module::add(__PACKAGE__, \@directives);
+
+sub TestAddConfig {
+    my ($self, $parms, $args) = @_;
+    my $srv_cfg = $self->get_config($parms->server);
+    $srv_cfg->{override_opts} = $parms->override_opts();
+}
+
+sub map2storage {
+    my $r = shift;
+
+    my $o = APACHE22 ? '=All,SymLinksIfOwnerMatch' : '';
+
+    eval {
+        $r->add_config(['AllowOverride All Options'.$o]);
+    };
+    $r->pnotes(add_config1 => "$@");
+
+    eval {
+        $r->add_config(['Options ExecCGI'], -1, '/', 0);
+    };
+    $r->pnotes(add_config2 => "$@");
+
+    eval {
+        my $directory = join '/', ('', $r->document_root,
+                                   'TestAPI__add_config');
+        $r->add_config(["<Directory $directory>",
+                      'AllowOverride All Options'.$o,
+                      '</Directory>'
+                      ], -1, '');
+    };
+    $r->pnotes(add_config4 => "$@");
+
+    return Apache2::Const::DECLINED;
+}
+
+sub fixup {
+    my ($r) = @_;
+
+    eval {
+        $r->add_config(['Options ExecCGI'], -1, '/',
+                       Apache2::Const::OPT_EXECCGI);
+    };
+    $r->pnotes(add_config3 => "$@");
+
+    return Apache2::Const::DECLINED;
+}
+
+sub handler : method {
+    my ($self, $r) = @_;
+    my $cf = $self->get_config($r->server);
+
+    plan $r, tests => 7;
+
+    ok t_cmp $r->pnotes('add_config1'), qr/.+\n/;
+    ok t_cmp $r->pnotes('add_config2'), (APACHE22 ? qr/.+\n/ : '');
+    ok t_cmp $r->pnotes('add_config3'), '';
+    ok t_cmp $r->pnotes('add_config4'), '';
+
+    my $default_opts = 0;
+    unless (APACHE22) {
+        $default_opts = Apache2::Const::OPT_UNSET |
+                        Apache2::Const::OPT_INCNOEXEC |
+                        Apache2::Const::OPT_MULTI;
+    }
+   
+    my $expect = $default_opts | Apache2::Const::OPT_ALL 
+                               | Apache2::Const::OPT_SYM_OWNER;
+
+    ok t_cmp $cf->{override_opts}, $expect;
+    ok t_cmp $r->allow_override_opts, $expect;
+    ok t_cmp $r->allow_options, Apache2::Const::OPT_EXECCGI;
+
+    return Apache2::Const::OK;
+}
+
+1;
+__END__
+
+# APACHE_TEST_CONFIG_ORDER 950
+<NoAutoConfig>
+    <VirtualHost TestAPI::add_config>
+        PerlModule TestAPI::add_config
+        AccessFileName htaccess
+        SetHandler modperl
+        PerlResponseHandler TestAPI::add_config
+        PerlMapToStorageHandler TestAPI::add_config::map2storage
+        PerlFixupHandler TestAPI::add_config::fixup
+    </VirtualHost>
+</NoAutoConfig>

Modified: perl/modperl/trunk/xs/Apache2/Access/Apache2__Access.h
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/xs/Apache2/Access/Apache2__Access.h?rev=384596&r1=384595&r2=384596&view=diff
==============================================================================
--- perl/modperl/trunk/xs/Apache2/Access/Apache2__Access.h (original)
+++ perl/modperl/trunk/xs/Apache2/Access/Apache2__Access.h Thu Mar  9 12:16:26 2006
@@ -80,8 +80,8 @@
     errmsg =
         modperl_config_insert_request(aTHX_ r,
                                       newRV_noinc((SV*)config),
-                                      OR_AUTHCFG,
-                                      NULL);
+                                      OR_AUTHCFG, NULL, 
+                                      MP_HTTPD_OVERRIDE_OPTS_UNSET);
 
     if (errmsg) {
         Perl_warn(aTHX_ "Can't change %s to '%s'\n", directive, val);
@@ -140,4 +140,16 @@
             PUSHs(&PL_sv_undef);
         }
     });
+}
+
+static MP_INLINE
+int mpxs_Apache2__RequestRec_allow_override_opts(pTHX_ request_rec *r)
+{
+#ifdef MP_HTTPD_HAS_OVERRIDE_OPTS
+    core_dir_config *cfg = ap_get_module_config(r->per_dir_config, 
+                                                &core_module);
+    return cfg->override_opts;
+#else
+    return MP_HTTPD_OVERRIDE_OPTS_DEFAULT;
+#endif
 }

Modified: perl/modperl/trunk/xs/Apache2/CmdParms/Apache2__CmdParms.h
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/xs/Apache2/CmdParms/Apache2__CmdParms.h?rev=384596&r1=384595&r2=384596&view=diff
==============================================================================
--- perl/modperl/trunk/xs/Apache2/CmdParms/Apache2__CmdParms.h (original)
+++ perl/modperl/trunk/xs/Apache2/CmdParms/Apache2__CmdParms.h Thu Mar  9 12:16:26 2006
@@ -35,3 +35,13 @@
         Perl_croak(aTHX_ "$parms->add_config() has failed: %s", errmsg);
     }
 }
+
+static MP_INLINE
+int mpxs_Apache2__CmdParms_override_opts(pTHX_ cmd_parms *parms)
+{
+#ifdef MP_HTTPD_HAS_OVERRIDE_OPTS
+    return parms->override_opts;
+#else
+    return MP_HTTPD_OVERRIDE_OPTS_DEFAULT;
+#endif
+}

Modified: perl/modperl/trunk/xs/Apache2/RequestUtil/Apache2__RequestUtil.h
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/xs/Apache2/RequestUtil/Apache2__RequestUtil.h?rev=384596&r1=384595&r2=384596&view=diff
==============================================================================
--- perl/modperl/trunk/xs/Apache2/RequestUtil/Apache2__RequestUtil.h (original)
+++ perl/modperl/trunk/xs/Apache2/RequestUtil/Apache2__RequestUtil.h Thu Mar  9 12:16:26 2006
@@ -303,10 +303,12 @@
 
 static MP_INLINE
 void mpxs_Apache2__RequestRec_add_config(pTHX_ request_rec *r, SV *lines,
-                                         int override, char *path)
+                                         int override, char *path,
+                                         int override_options)
 {
     const char *errmsg = modperl_config_insert_request(aTHX_ r, lines,
-                                                       override, path);
+                                                       override, path,
+                                                       override_options);
     if (errmsg) {
         Perl_croak(aTHX_ "$r->add_config() has failed: %s", errmsg);
     }

Modified: perl/modperl/trunk/xs/maps/apache2_structures.map
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/xs/maps/apache2_structures.map?rev=384596&r1=384595&r2=384596&view=diff
==============================================================================
--- perl/modperl/trunk/xs/maps/apache2_structures.map (original)
+++ perl/modperl/trunk/xs/maps/apache2_structures.map Thu Mar  9 12:16:26 2006
@@ -246,6 +246,7 @@
 <  cmd
 <  context
 !  err_directive
+-  override_opts
 </cmd_parms>
 
 !<ap_mgmt_item_t>

Modified: perl/modperl/trunk/xs/maps/modperl_functions.map
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/xs/maps/modperl_functions.map?rev=384596&r1=384595&r2=384596&view=diff
==============================================================================
--- perl/modperl/trunk/xs/maps/modperl_functions.map (original)
+++ perl/modperl/trunk/xs/maps/modperl_functions.map Thu Mar  9 12:16:26 2006
@@ -30,7 +30,7 @@
  mpxs_Apache2__RequestRec_location
  mpxs_Apache2__RequestRec_as_string
  mpxs_Apache2__RequestRec_pnotes | | r, key=Nullsv, val=Nullsv
- mpxs_Apache2__RequestRec_add_config | | r, lines, override=OR_AUTHCFG, path=NULL
+ mpxs_Apache2__RequestRec_add_config | | r, lines, override=OR_AUTHCFG, path=NULL, override_options=MP_HTTPD_OVERRIDE_OPTS_UNSET
  mpxs_Apache2__RequestRec_document_root | | r, new_root=Nullsv
  mpxs_Apache2__RequestRec_child_terminate
 
@@ -152,6 +152,10 @@
  ap_method_is_limited
  mpxs_Apache2__CmdParms_info
  mpxs_Apache2__CmdParms_add_config
+ mpxs_Apache2__CmdParms_override_opts
 
 MODULE=Apache2::MPM    PACKAGE=Apache2::MPM   BOOT=1
  mpxs_Apache2__MPM_query
+
+MODULE=Apache2::Access   PACKAGE=guess
+ mpxs_Apache2__RequestRec_allow_override_opts

Modified: perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm?rev=384596&r1=384595&r2=384596&view=diff
==============================================================================
--- perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm (original)
+++ perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm Thu Mar  9 12:16:26 2006
@@ -1371,6 +1371,10 @@
         'name' => 'path'
       },
       {
+        'type' => 'int',
+        'name' => 'override_options'
+      },
+      {
         'type' => 'ap_conf_vector_t *',
         'name' => 'conf'
       },
@@ -1421,6 +1425,10 @@
       {
         'type' => 'char *',
         'name' => 'path'
+      },
+      {
+        'type' => 'int',
+        'name' => 'override_options'
       }
     ]
   },
@@ -6109,6 +6117,20 @@
     ]
   },
   {
+    'return_type' => 'int',
+    'name' => 'mpxs_Apache2__CmdParms_override_opts',
+    'args' => [
+      {
+        'type' => 'PerlInterpreter *',
+        'name' => 'my_perl'
+      },
+      {
+        'type' => 'cmd_parms *',
+        'name' => 'parms'
+      }
+    ]
+  },
+  {
     'return_type' => 'void',
     'name' => 'mpxs_Apache2__Connection_add_input_filter',
     'args' => [
@@ -6644,6 +6666,10 @@
       {
         'type' => 'char *',
         'name' => 'path'
+      },
+      {
+        'type' => 'int',
+        'name' => 'override_options'
       }
     ]
   },
@@ -6680,6 +6706,20 @@
       {
         'type' => 'SV *',
         'name' => 'callback'
+      }
+    ]
+  },
+  {
+    'return_type' => 'int',
+    'name' => 'mpxs_Apache2__RequestRec_allow_override_opts',
+    'args' => [
+      {
+        'type' => 'PerlInterpreter *',
+        'name' => 'my_perl'
+      },
+     {
+        'type' => 'request_rec *',
+        'name' => 'r'
       }
     ]
   },



Mime
View raw message