|
|
Author: jhorwitz
Date: Fri Sep 19 10:17:20 2008
New Revision: 432
Modified:
mod_parrot/branches/hll-modules/include/modparrot_config.h
mod_parrot/branches/hll-modules/lib/ModParrot/HLL/pir.pir
mod_parrot/branches/hll-modules/src/mod_parrot.c
mod_parrot/branches/hll-modules/src/module.c
mod_parrot/branches/hll-modules/src/nci.c
mod_parrot/branches/hll-modules/t/conf/extra.conf.in
Log:
convert the following PIR layer metahandlers to new model:
* response
* authen
* access
* authz
this was enough to allow existing tests to pass.
Modified: mod_parrot/branches/hll-modules/include/modparrot_config.h
==============================================================================
--- mod_parrot/branches/hll-modules/include/modparrot_config.h (original)
+++ mod_parrot/branches/hll-modules/include/modparrot_config.h Fri Sep 19
10:17:20 2008
@@ -228,5 +228,8 @@
/* handlers for HLL apache modules */
int modparrot_meta_response_handler(request_rec *);
+int modparrot_meta_authen_handler(request_rec *);
+int modparrot_meta_authz_handler(request_rec *);
+int modparrot_meta_access_handler(request_rec *);
#endif /* _MODPARROT_CONFIG_H */
Modified: mod_parrot/branches/hll-modules/lib/ModParrot/HLL/pir.pir
==============================================================================
--- mod_parrot/branches/hll-modules/lib/ModParrot/HLL/pir.pir (original)
+++ mod_parrot/branches/hll-modules/lib/ModParrot/HLL/pir.pir Fri Sep 19
10:17:20 2008
@@ -14,28 +14,154 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+.sub __onload :anon :load
+ load_bytecode 'languages/perl6/perl6.pbc'
+ load_bytecode 'Apache/Module.pbc'
+ load_bytecode 'ModParrot/Constants.pbc'
+
+ # register apache directives
+ .local pmc add_module, cmds
+
+ load_bytecode 'Apache/Module.pbc'
+
+ cmds = new 'ResizablePMCArray'
+
+ $P0 = new_cmd('ParrotHandler', 'TAKE1', 'cmd_parrothandler', 'OR_AUTHCFG',
'usage: ParrotHandler handler-name')
+ cmds.push($P0)
+ $P0 = new_cmd('ParrotResponseHandler', 'TAKE1', 'cmd_parrothandler',
'OR_AUTHCFG', 'usage: ParrotResponseHandler handler-name')
+ cmds.push($P0)
+ $P0 = new_cmd('ParrotAuthenHandler', 'TAKE1', 'cmd_parrotauthenhandler',
'OR_AUTHCFG', 'usage: ParrotAuthenHandler handler-name')
+ cmds.push($P0)
+ $P0 = new_cmd('ParrotAuthzHandler', 'TAKE1', 'cmd_parrotauthzhandler',
'OR_AUTHCFG', 'usage: ParrotAuthzHandler handler-name')
+ cmds.push($P0)
+ $P0 = new_cmd('ParrotAccessHandler', 'TAKE1', 'cmd_parrotaccesshandler',
'OR_AUTHCFG', 'usage: ParrotAccessHandler handler-name')
+ cmds.push($P0)
+
+ add_module = get_hll_global [ 'Apache'; 'Module' ], 'add'
+ $P1 = add_module("modparrot_pir_module", "PIR", cmds)
+.end
+
+.sub new_cmd
+ .param string name
+ .param string how
+ .param string func
+ .param string override
+ .param string errmsg
+ .local pmc ap_const
+ .local pmc cmd
+
+ ap_const = get_root_global ['Apache'; 'Constants'], 'ap_constants'
+
+ cmd = new 'Hash'
+ $P0 = new 'String'
+ $P0 = name
+ cmd['name'] = $P0
+ $P0 = new 'Integer'
+ $P0 = ap_const[how]
+ cmd['args_how'] = $P0
+ $P0 = get_hll_global [ 'ModParrot'; 'HLL'; 'PIR' ], func
+ cmd['func'] = $P0
+ $P0 = new 'Integer'
+ $P0 = ap_const['OR_AUTHCFG']
+ cmd['req_override'] = $P0
+ $P0 = new 'String'
+ $P0 = errmsg
+ cmd['errmsg'] = $P0
+
+ .return(cmd)
+.end
+
.namespace [ 'ModParrot'; 'HLL'; 'PIR' ]
+.sub server_create
+ $P0 = new 'Hash'
+ .return($P0)
+.end
+
+.sub dir_create
+ $P0 = new 'Hash'
+ .return($P0)
+.end
+
+# XXX implement merging
+
+#.sub server_merge
+#.end
+
+#.sub dir_merge
+#.end
+
+.sub cmd_parrothandler
+ .param pmc dircfg
+ .param pmc args
+
+ $S0 = args[0]
+ dircfg['response_handler'] = $S0
+.end
+
+.sub cmd_parrotauthenhandler
+ .param pmc dircfg
+ .param pmc args
+
+ $S0 = args[0]
+ dircfg['authen_handler'] = $S0
+.end
+
+.sub cmd_parrotauthzhandler
+ .param pmc dircfg
+ .param pmc args
+
+ $S0 = args[0]
+ dircfg['authz_handler'] = $S0
+.end
+
+.sub cmd_parrotaccesshandler
+ .param pmc dircfg
+ .param pmc args
+
+ $S0 = args[0]
+ dircfg['access_handler'] = $S0
+.end
+
.sub load
.param string path
load_bytecode path
.end
-#.sub config
-
# response handler
-.sub handler
+.sub response_handler
.param pmc ctx
- .param string handler_name
- .local pmc r
- .local pmc handler
+ .local pmc r, handler, cfg, dircfg, get_config, ap_const
.local int status
+ ap_const = get_root_global ['Apache'; 'Constants'], 'ap_constants'
+
# get the request_rec object
r = ctx.'request_rec'()
+ # get configs
+ get_config = get_hll_global ['Apache'; 'Module'], 'get_config'
+ cfg = get_config('modparrot_pir_module')
+ $P0 = r.'per_dir_config'()
+ dircfg = get_config('modparrot_pir_module', $P0)
+
+ # decline if we have no config in this section
+ unless null dircfg goto get_handler
+ status = ap_const['DECLINED']
+ .return(status)
+
+ get_handler:
+ # decline if we have no handler in this section
+ $S0 = dircfg['response_handler']
+ if $S0 goto run_handler
+ status = ap_const['DECLINED']
+ .return(status)
+
+ run_handler:
+ # set our default content type
+ r.'content_type'('text/html')
# find the handler sub and call it
- find_global handler, handler_name, 'handler'
+ find_global handler, $S0, 'handler'
status = handler(r)
# return status code
@@ -45,16 +171,35 @@
# authen handler
.sub authen_handler
.param pmc ctx
- .param string handler_name
- .local pmc r
- .local pmc handler
+ .local pmc r, handler, cfg, dircfg, get_config, ap_const
.local int status
+ ap_const = get_root_global ['Apache'; 'Constants'], 'ap_constants'
+
# get the request_rec object
r = ctx.'request_rec'()
+ # get configs
+ get_config = get_hll_global ['Apache'; 'Module'], 'get_config'
+ cfg = get_config('modparrot_pir_module')
+ $P0 = r.'per_dir_config'()
+ dircfg = get_config('modparrot_pir_module', $P0)
+
+ # decline if we have no config in this section
+ unless null dircfg goto get_handler
+ status = ap_const['DECLINED']
+ .return(status)
+
+ get_handler:
+ # decline if we have no handler in this section
+ $S0 = dircfg['authen_handler']
+ if $S0 goto run_handler
+ status = ap_const['DECLINED']
+ .return(status)
+
+ run_handler:
# find the handler sub and call it
- find_global handler, handler_name, 'handler'
+ find_global handler, $S0, 'handler'
status = handler(r)
# return status code
@@ -64,16 +209,35 @@
# authz handler
.sub authz_handler
.param pmc ctx
- .param string handler_name
- .local pmc r
- .local pmc handler
+ .local pmc r, handler, cfg, dircfg, get_config, ap_const
.local int status
+ ap_const = get_root_global ['Apache'; 'Constants'], 'ap_constants'
+
# get the request_rec object
r = ctx.'request_rec'()
+ # get configs
+ get_config = get_hll_global ['Apache'; 'Module'], 'get_config'
+ cfg = get_config('modparrot_pir_module')
+ $P0 = r.'per_dir_config'()
+ dircfg = get_config('modparrot_pir_module', $P0)
+
+ # decline if we have no config in this section
+ unless null dircfg goto get_handler
+ status = ap_const['DECLINED']
+ .return(status)
+
+ get_handler:
+ # decline if we have no handler in this section
+ $S0 = dircfg['authz_handler']
+ if $S0 goto run_handler
+ status = ap_const['DECLINED']
+ .return(status)
+
+ run_handler:
# find the handler sub and call it
- find_global handler, handler_name, 'handler'
+ find_global handler, $S0, 'handler'
status = handler(r)
# return status code
@@ -83,16 +247,35 @@
# access handler
.sub access_handler
.param pmc ctx
- .param string handler_name
- .local pmc r
- .local pmc handler
+ .local pmc r, handler, cfg, dircfg, get_config, ap_const
.local int status
+ ap_const = get_root_global ['Apache'; 'Constants'], 'ap_constants'
+
# get the request_rec object
r = ctx.'request_rec'()
+ # get configs
+ get_config = get_hll_global ['Apache'; 'Module'], 'get_config'
+ cfg = get_config('modparrot_pir_module')
+ $P0 = r.'per_dir_config'()
+ dircfg = get_config('modparrot_pir_module', $P0)
+
+ # decline if we have no config in this section
+ unless null dircfg goto get_handler
+ status = ap_const['DECLINED']
+ .return(status)
+
+ get_handler:
+ # decline if we have no handler in this section
+ $S0 = dircfg['access_handler']
+ if $S0 goto run_handler
+ status = ap_const['DECLINED']
+ .return(status)
+
+ run_handler:
# find the handler sub and call it
- find_global handler, handler_name, 'handler'
+ find_global handler, $S0, 'handler'
status = handler(r)
# return status code
Modified: mod_parrot/branches/hll-modules/src/mod_parrot.c
==============================================================================
--- mod_parrot/branches/hll-modules/src/mod_parrot.c (original)
+++ mod_parrot/branches/hll-modules/src/mod_parrot.c Fri Sep 19 10:17:20 2008
@@ -280,7 +280,6 @@
/* clean up */
release_ctx(ctxp);
- /* we only do setup, no output */
return DECLINED;
}
@@ -896,34 +895,6 @@
"set the Parrot header parser handler"
),
AP_INIT_TAKE1(
- "ParrotHandler",
- modparrot_cmd_handler,
- NULL,
- OR_AUTHCFG,
- "set the Parrot response handler"
- ),
- AP_INIT_TAKE1(
- "ParrotAccessHandler",
- modparrot_cmd_access_handler,
- NULL,
- OR_AUTHCFG,
- "set the Parrot access handler"
- ),
- AP_INIT_TAKE1(
- "ParrotAuthenHandler",
- modparrot_cmd_authen_handler,
- NULL,
- OR_AUTHCFG,
- "set the Parrot authentication handler"
- ),
- AP_INIT_TAKE1(
- "ParrotAuthzHandler",
- modparrot_cmd_authz_handler,
- NULL,
- OR_AUTHCFG,
- "set the Parrot authorization handler"
- ),
- AP_INIT_TAKE1(
"ParrotTypeHandler",
modparrot_cmd_type_handler,
NULL,
Modified: mod_parrot/branches/hll-modules/src/module.c
==============================================================================
--- mod_parrot/branches/hll-modules/src/module.c (original)
+++ mod_parrot/branches/hll-modules/src/module.c Fri Sep 19 10:17:20 2008
@@ -88,7 +88,17 @@
static void register_meta_hooks(apr_pool_t *p)
{
- ap_hook_handler(modparrot_meta_response_handler, NULL, NULL,
APR_HOOK_MIDDLE);
+ /* XXX does this also work for Apache >= 2.3 */
+ static const char *aszSucc[] = { "mod_auth.c", NULL };
+
+ ap_hook_check_user_id(modparrot_meta_authen_handler, NULL, NULL,
+ APR_HOOK_MIDDLE);
+ ap_hook_access_checker(modparrot_meta_access_handler, NULL, NULL,
+ APR_HOOK_MIDDLE);
+ ap_hook_auth_checker(modparrot_meta_authz_handler, NULL, aszSucc,
+ APR_HOOK_MIDDLE);
+ ap_hook_handler(modparrot_meta_response_handler, NULL, NULL,
+ APR_HOOK_MIDDLE);
}
/* this is very leaky */
Modified: mod_parrot/branches/hll-modules/src/nci.c
==============================================================================
--- mod_parrot/branches/hll-modules/src/nci.c (original)
+++ mod_parrot/branches/hll-modules/src/nci.c Fri Sep 19 10:17:20 2008
@@ -231,8 +231,11 @@
cfg = ap_get_module_config(ctxp->s->module_config, modp);
}
- /* return the PMC cfg inside the modparrot_module_config struct */
- return(cfg->cfg);
+ /* return the PMC cfg inside the modparrot_module_config struct. if we
+ * have no directives in the section, we'll have no dircfg, so we should
+ * return PMCNULL.
+ */
+ return cfg ? cfg->cfg : PMCNULL;
}
#define SET_DIRCFG_INFO(x) if (update) { ctxp->dircfg->x = handler_info; } \
Modified: mod_parrot/branches/hll-modules/t/conf/extra.conf.in
==============================================================================
--- mod_parrot/branches/hll-modules/t/conf/extra.conf.in (original)
+++ mod_parrot/branches/hll-modules/t/conf/extra.conf.in Fri Sep 19
10:17:20 2008
@@ -4,6 +4,7 @@
ParrotIncludePath @ServerRoot@/../lib
ParrotInit @ServerRoot@/../lib/mod_parrot.pbc
+ParrotLoadImmediate @ServerRoot@/../lib/ModParrot/HLL/pir.pbc
ParrotLoad @ServerRoot@/lib/handlers.pbc
# enable for test debugging
|
|