On 2012-06-26 13:14, oh...@cox.net wrote:

---- Sorin Manolache <sor...@gmail.com> wrote:
On 2012-06-26 03:49, oh...@cox.net wrote:

Hi,

I have my small prototype module, which I implemented starting with the 
mod_headers.c source, working.  The changes that I did to the original source 
were to add some code in the insert_filter hook to inject an additional header 
into the request.

That seems to work ok with a "vanilla" Apache configuration.

I want to be able to make my modified module work together with another module, provided 
by Oracle (the Oracle Access Manager webgate, aka "webgate").

However, after I add the directives into the Apache httpd.conf to enable the 
webgate, it appears that, on incoming requests, the webgate processing occurs, 
but my code in the modified mod_headers module is not called at all :(!!


Here's the last part of my modified mod_headers.c:

static void register_hooks(apr_pool_t *p)
{
      printf("mod_headers-jl V0.13 - use LIBCURL instead of OAM ASDK-process 
response from callCurl\n");
      printf("In register_hooks\n");
      ap_register_output_filter("FIXUP_HEADERS_OUT", ap_headers_output_filter,
                                NULL, AP_FTYPE_CONTENT_SET);
      ap_register_output_filter("FIXUP_HEADERS_ERR", ap_headers_error_filter,
                                NULL, AP_FTYPE_CONTENT_SET);
      ap_hook_pre_config(header_pre_config,NULL,NULL,APR_HOOK_MIDDLE);
      ap_hook_post_config(header_post_config,NULL,NULL,APR_HOOK_MIDDLE);
      ap_hook_insert_filter(ap_headers_insert_output_filter, NULL, NULL, 
APR_HOOK_LAST);
      ap_hook_insert_error_filter(ap_headers_insert_error_filter,
                                  NULL, NULL, APR_HOOK_LAST);
      ap_hook_fixups(ap_headers_fixup, NULL, NULL, APR_HOOK_LAST);
      ap_hook_post_read_request(ap_headers_early, NULL, NULL, APR_HOOK_FIRST);
}

module AP_MODULE_DECLARE_DATA headers_module =
{
      STANDARD20_MODULE_STUFF,
      create_headers_dir_config,  /* dir config creater */
      merge_headers_config,       /* dir merger --- default is to override */
      NULL,                       /* server config */
      NULL,                       /* merge server configs */
      headers_cmds,               /* command apr_table_t */
      register_hooks              /* register hooks */
};


The code I added is in the "ap_headers_insert_output_filter()" function.


I did an "export SHOW_HOOKS=1" and ran the Apache, and I see this for the 
modified mod_headers:

Registering hooks for mod_headers.c
mod_headers-jl V0.13 - use LIBCURL instead of OAM ASDK-process response from 
callCurl
In register_hooks
    Hooked pre_config
    Hooked post_config
    Hooked insert_filter
    Hooked insert_error_filter
    Hooked fixups
    Hooked post_read_request


And for webgate, I see:

Registering hooks for apache2entry_web_gate.cpp
    Hooked post_config
    Hooked handler
    Hooked check_user_id
    Hooked auth_checker


I thought that the handler functions are called almost last part of the 
processing (content generation), and my code is hooked to insert_filter, which 
I thought occurs earlier than content generation, so shouldn't my code get 
processed BEFORE Apache attempts to process the webgate functions?

How can I get my code to process before the webgate does?


insert_filter is run between the fixups and the handler hooks.

Try to identify who is producing the variables that you need, in which
phase they are available at the earliest. Then identify which part of
web_gate hijacks the processing such that your code is not executed
anymore. I suppose it is one of web_gate's auth_checker or
check_user_id. If it was the web_gate handler then your code would have
run before.

Sorin


Hi Sorin,

I posted a later msg that I've been trying do something along the lines that 
you said:

"I've been doing more testing, and it appears that the insert_filter hook (the
"ap_headers_insert_output_filter()" function) is the only place where I can put
my code where it has access to the variables that it needs to do the processing
that I'm doing.

The problem is that if that other Oracle module is enabled in the Apache, it
runs before my code, and I can't get the insert_filter hook (my function) to get
processed before the Oracle module "

The SSL variables are set in the fixups hook by mod_ssl. The fixups hook is run _after_ check_user_id and auth_checker. So you cannot rely on mod_ssl to populate the environment with the variables. I guess you'll have to get those variables yourself, before Oracle's check_user_id and auth_checker hooks.

Sorin

Reply via email to