Re: The Apache docs readPost causing SIGSEGV

2015-05-18 Thread Joe Lewis
Please check how you are creating the formData[i].key and format[i].value
fields.  If you are using the POST data in the structure, it is not NULL
terminated.  You have to do your own NULL termination, or (when it reads
out of bounds) you get a SIGSEGV.  Unless you are lucky and have NULL
characters in your own module.

I don't like using the apr_pstrdup, I use the apr_pstrndup form because I
have complete control of size, and I make it one character bigger, and add
a NULL termination to the string JUST to make sure.  I had enough SIGSEGV's
in my life to call it a best practice to make sure the character is there.

Joe

On Mon, May 18, 2015 at 1:45 PM, Vitaliy Kaplenko  wrote:

> Hi,
> I am developing a module for Apache that requires parsing form data. As
> example I have used "Retrieve variables from POST form data" from
> http://httpd.apache.org/docs/2.4/developer/modguide.html#snippets.
>
> When I try to retrieve variables from Post data, in the example
> row: ap_rprintf(r, "%s = %s\n", formData[i].key, formData[i].value);
>
> I got:Program received signal SIGSEGV, Segmentation fault.strlen () at
> ../sysdeps/x86_64/strlen.S:106106 movdqu (%rax), %xmm12
>
> Is there any way to pass it?Thanks!


Re: A web based terminal emulator as an Apache module?

2015-01-09 Thread Joe Lewis
Here is a good example thread :

http://grokbase.com/t/apache/modules-dev/11bp9bhxr5/basic-example-shared-memory-code

On Fri, Jan 9, 2015 at 10:35 AM, Joe Lewis  wrote:

> It is definitely possible to share information - see the apr_shm_*
> functions (or check the history on this list for shared memory).  Eash POST
> request is considered a separate event, and is processed as such, which
> means there is no state in the protocol itself (there is when you add HTTP
> headers into the mix, such as "cookies").
>
> For what you are trying to do - I'd simply assume it's stateless, and
> design any modules to utilize shared memory.
>
> Joe
>
> On Fri, Jan 9, 2015 at 9:30 AM, Sean Neeley 
> wrote:
>
>> I'm trying to determine if it is plausible to build an apache module for a
>> web based terminal emulator.  I would be borrowing some of the code from
>> the ShellInaBox project:
>> https://code.google.com/p/shellinabox/
>> The code uses openpty() to create a new process operating in a pseudo-tty.
>> The apache module would have to pass keyboard and display information back
>> and forth from the client browser to the pseudo-tty in the module.
>>
>> It seems like with the pre-fork mpm, I cannot guarantee that the ajax POST
>> requests will make it to the same module instance each time.  Are modules
>> stateless?  Is it possible to share the pseudo-tty and hashmaps keeping
>> session information across all instances of my module?  Or is there
>> anything that can be added to the POST request to guarantee that it goes
>> to
>> a specific module instance?
>>
>> Thanks for the help.
>>
>> - Sean
>>
>
>


Re: A web based terminal emulator as an Apache module?

2015-01-09 Thread Joe Lewis
It is definitely possible to share information - see the apr_shm_*
functions (or check the history on this list for shared memory).  Eash POST
request is considered a separate event, and is processed as such, which
means there is no state in the protocol itself (there is when you add HTTP
headers into the mix, such as "cookies").

For what you are trying to do - I'd simply assume it's stateless, and
design any modules to utilize shared memory.

Joe

On Fri, Jan 9, 2015 at 9:30 AM, Sean Neeley 
wrote:

> I'm trying to determine if it is plausible to build an apache module for a
> web based terminal emulator.  I would be borrowing some of the code from
> the ShellInaBox project:
> https://code.google.com/p/shellinabox/
> The code uses openpty() to create a new process operating in a pseudo-tty.
> The apache module would have to pass keyboard and display information back
> and forth from the client browser to the pseudo-tty in the module.
>
> It seems like with the pre-fork mpm, I cannot guarantee that the ajax POST
> requests will make it to the same module instance each time.  Are modules
> stateless?  Is it possible to share the pseudo-tty and hashmaps keeping
> session information across all instances of my module?  Or is there
> anything that can be added to the POST request to guarantee that it goes to
> a specific module instance?
>
> Thanks for the help.
>
> - Sean
>


Re: debugging ssl packet drop

2014-10-18 Thread Joe Lewis
Another possible list thst would be good would be the HTTPD development list. 
You may need the author of mod_ssl. 


Thanks, 
Joe Lewis


 Original message 
From: Pon Umapathy Kailash S  
Date: 10/18/2014  4:28 AM  (GMT-07:00) 
To: modules-dev@httpd.apache.org 
Subject: Re: debugging ssl packet drop 

Hi,
I resent the mail since I didn't receive a copy of my first mail and
I am subscribed to this list as well.

In any case, I am not asking for help to debug any network issues here
(if you read the content of my mail). There's an issue with a SSL
packet being sent from IE10 browsers in the context of the websocket
protocol (over ssl) and I have been working on the steps you mention
further down in your email.
My original mail was to see if I can get help regarding specific
breakpoints in the code flow of the apache server/ssl module flow to
check where the packet was being dropped.

However, I'll take your suggestion that this probably needs to go to
the openssl mailing list. Thank you.

Regards,
Umapathy

On Fri, Oct 17, 2014 at 9:31 PM, Joe Lewis  wrote:
> Your first message was delivered less than 24 hours ago - most of us are
> not paid by the Apache modules developers list, meaning we are stricly
> volunteer, and 24 hours might not be enough time.  I would suggest
> patience, especially while asking questions on the fringes of this lists
> expertise.  Most people here are module developers, not SSL debuggers or
> TCP experts.  I actually thought your original e-mail should have gone to
> an openssl mailing list instead of an Apache modules list.
>
> I won't support tracking down something like network errors without access
> and a consultation fee - it's an ugly rabbit hole that not many actually
> want to go down, especially me.
>
> I will simply suggest using Wireshark at multiple points (e.g. on the same
> LAN as the client, and on the same LAN as the server) just to ensure that a
> firewall, netscaler, or any other device between the client and the server
> isn't your problem.  You claim an error code of 101 (network reset).  Are
> you seeing TCP resets in your packet capture (remember, I'm not going to
> support or help beyond this - the question is to get you to think about
> what you are actually seeing in your packet capture).  Did you decrypt your
> SSL-encrypted packet capture just to ensure you are seeing things
> properly?  Are you sure you haven't custom-configured timeouts for Apache?
>  ipfw/iptables/etc on the server (tcpdump of *nix will help)?
>
> Remember, it sounds like you are asking for help for things on the fringes
> of most people's expertise here.  Be patient.
>
> Joe
>
> On Fri, Oct 17, 2014 at 9:22 AM, Pon Umapathy Kailash S <
> pon.umapa...@gmail.com> wrote:
>
>> Resending since it doesn't seem to have been delivered.
>>
>> On Thu, Oct 16, 2014 at 11:26 AM, Pon Umapathy Kailash S
>>  wrote:
>> > Hi,
>> >  I am facing the an issue where a SSL packet from IE10 doesn't reach
>> > the client processing thread for a particular connection(more details
>> > below).  Can you please provide me pointers on where to look/add more
>> > debug logs in the code to figure out what's happening? We use mpm
>> > worker threads.
>> >
>> > I have added support for websockets in a customised manner(as required
>> > for our application) inside apache. At a high level, it's done as
>> > follows:
>> >
>> > - the initial GET request with 101 code is handled by a handler hook
>> > function which computes the required security keys and sends back the
>> > response. Also, the socket on which the request came in is not
>> > closed(by maintaining a list and patching some parts of the apache
>> > code to not close if a socket is present in this list).
>> >
>> > - the child thread which processes this connection will relinquish the
>> > connection after the keep-alive timeout , which is ok since all we
>> > need is for the server to send messages to the client, with one
>> > exception.
>> >
>> > - At this point, the socket is recognised as a websocket client which
>> > is not yet authenticated(since from browsers we cannot set custom
>> > headers with the initial websocket connection request).
>> >
>> > - Authentication is done by the client sending the cookie as the
>> > 1st(and only) message on this connection to the server within the
>> > keep-alive timeout period(at which point the cookie is authenticated
>> > and the socket is marked as a valid, authenticated subscriber).
>> > (* there are other functions/timers to take care 

Re: debugging ssl packet drop

2014-10-17 Thread Joe Lewis
Your first message was delivered less than 24 hours ago - most of us are
not paid by the Apache modules developers list, meaning we are stricly
volunteer, and 24 hours might not be enough time.  I would suggest
patience, especially while asking questions on the fringes of this lists
expertise.  Most people here are module developers, not SSL debuggers or
TCP experts.  I actually thought your original e-mail should have gone to
an openssl mailing list instead of an Apache modules list.

I won't support tracking down something like network errors without access
and a consultation fee - it's an ugly rabbit hole that not many actually
want to go down, especially me.

I will simply suggest using Wireshark at multiple points (e.g. on the same
LAN as the client, and on the same LAN as the server) just to ensure that a
firewall, netscaler, or any other device between the client and the server
isn't your problem.  You claim an error code of 101 (network reset).  Are
you seeing TCP resets in your packet capture (remember, I'm not going to
support or help beyond this - the question is to get you to think about
what you are actually seeing in your packet capture).  Did you decrypt your
SSL-encrypted packet capture just to ensure you are seeing things
properly?  Are you sure you haven't custom-configured timeouts for Apache?
 ipfw/iptables/etc on the server (tcpdump of *nix will help)?

Remember, it sounds like you are asking for help for things on the fringes
of most people's expertise here.  Be patient.

Joe

On Fri, Oct 17, 2014 at 9:22 AM, Pon Umapathy Kailash S <
pon.umapa...@gmail.com> wrote:

> Resending since it doesn't seem to have been delivered.
>
> On Thu, Oct 16, 2014 at 11:26 AM, Pon Umapathy Kailash S
>  wrote:
> > Hi,
> >  I am facing the an issue where a SSL packet from IE10 doesn't reach
> > the client processing thread for a particular connection(more details
> > below).  Can you please provide me pointers on where to look/add more
> > debug logs in the code to figure out what's happening? We use mpm
> > worker threads.
> >
> > I have added support for websockets in a customised manner(as required
> > for our application) inside apache. At a high level, it's done as
> > follows:
> >
> > - the initial GET request with 101 code is handled by a handler hook
> > function which computes the required security keys and sends back the
> > response. Also, the socket on which the request came in is not
> > closed(by maintaining a list and patching some parts of the apache
> > code to not close if a socket is present in this list).
> >
> > - the child thread which processes this connection will relinquish the
> > connection after the keep-alive timeout , which is ok since all we
> > need is for the server to send messages to the client, with one
> > exception.
> >
> > - At this point, the socket is recognised as a websocket client which
> > is not yet authenticated(since from browsers we cannot set custom
> > headers with the initial websocket connection request).
> >
> > - Authentication is done by the client sending the cookie as the
> > 1st(and only) message on this connection to the server within the
> > keep-alive timeout period(at which point the cookie is authenticated
> > and the socket is marked as a valid, authenticated subscriber).
> > (* there are other functions/timers to take care of stale, unauth
> > connections etc)
> >
> > This works fine in all browsers with support for websockets with the
> > following exceptions:
> >
> > IE10 over ssl(https/wss) and IE11 over ssl on 32-bit client machines.
> >
> > Doing a packet capture, we could figure out that the initial
> > connection goes through fine and when the cookie is sent from the
> > client, it reaches the server(and there's a tcp ack received at the
> > client for this packet). However, the client processing this
> > connection doesn't seem to receive this packet(this is well within the
> > keep alive interval and the client thread is still actively processing
> > that connection).
> >
> > Can you please let me know at which points in the code flow it might
> > be useful to add debugging info to see where this is getting dropped?
> >
> > Regards,
> > Umapathy
>


Re: handler pass to php

2014-10-14 Thread Joe Lewis
I'd consider having your handler fire off a subrequest.  The book should
cover this topic, but you can also look in the source for some examples (or
google "ap_run_sub_req" and review the results).  You just want the php
handler set for it.

Joe

On Tue, Oct 14, 2014 at 3:41 PM, Jeremy Thompson  wrote:

> Hello all,
> We have written a handler for apache that talks to our point of sales
> software.  At this point the POS software renders a lot of the html itself
> and sends it back through apache.  We would however, like to be able to
> integrate PHP to offload some of this work.  The problem right now is that
> once the handler catches the request it renders and sends its through never
> reaching PHP.  This is the same whether or not PHP is built as a fcgi or
> apache2handler.  I'm pretty sure the problem is that our handler is not
> passing any info forward.  Its taking the request sending it to our
> software
> and returning the rendered page.  Would the apache modules book cover this
> or are there any examples of playing nice with the other plugins?  Thanks.
>
> ~Jeremy
>
>
>
>
>


Re: Tear down of module on server stop

2013-06-07 Thread Joe Lewis


On 06/07/2013 09:52 AM, Sean Beck wrote:

All I really need a pool for is so I have something to pass as a parameter.

I see here that
apr_pool_cleanup_register actually takes two functions as parameters.
The one I would want is plain_cleanup, right? If I understand pools
correctly, pools are destroyed/cleaned up when the server shuts down.


Not all pools are created equally.  A temporary pool may be cleaned up 
earlier.  A request pool may be cleaned up when the request is 
complete.  Check your cart-before-the-horse logic.  If you create a 
temporary pool, expect it to be cleaned up when you destroy it.  The 
pool associated with the post_config hook will be cleaned up on 
shutdown.  I'll repeat myself again : use the one provided by the 
post_config hook.


Joe


Re: Tear down of module on server stop

2013-06-07 Thread Joe Lewis


On 06/07/2013 09:29 AM, Sean Beck wrote:

Currently when I create the connections I don't use a pool for anything.
I'm using the fusemq-c library. I did notice that libstomp uses a pool
though.


If the memory allocation isn't done through the apr_* routines, I'm not 
sure what pool to use.  The one provided in the post_config should be 
the closest to what you need because it will be called when HTTPD does 
shut down gracefully.


Joe


Re: Tear down of module on server stop

2013-06-07 Thread Joe Lewis

On 06/07/2013 09:23 AM, Sean Beck wrote:

Should I give it ptemp as the pool? Or should I create a new one in
post_config()?


When you set up your ActiveMQ connections, you will be using a pool to 
allocate the memory used.  Use that pool.  Otherwise, your cleanup and 
your config for the connection management will happen at different times.


Joe



Re: Tear down of module on server stop

2013-06-07 Thread Joe Lewis


On 06/07/2013 08:59 AM, Sean Beck wrote:

You guys are awesome.
So it should only run once then? Also for tear down of the stuff is there a
different hook that I could load?


It still runs twice.  Tear down should be registering a pool clean up 
function, and using that.





Re: Tear down of module on server stop

2013-06-07 Thread Joe Lewis

On 06/07/2013 09:09 AM, Sean Beck wrote:

OK good to know.

Would I use apr_pool_cleanup_register in register hooks?


I'd suggest setting up your ActiveMQ connection in post_config, and then 
calling apr_pool_cleanup_register() when you set it up.  That way, your 
cleanup function will be called when the pool associated with your 
ActiveMQ data is going away.


You can do that all in a handler function, too, but the lifetime of the 
ActiveMQ connection will be a lot shorter.


Joe


Re: Tear down of module on server stop

2013-06-07 Thread Joe Lewis


On 06/07/2013 08:19 AM, Sean Beck wrote:

I'm looking through and example I found
hereand
it says this about the method used by post_config():
This routine is called to perform any module-specific fixing of header
fields, et cetera. It is invoked just before any content-handler.
That makes it seem like this is called every time a connection is made.
That isn't what I want. I want to do set up only once for as long as the
server is running. Would pre_config() be more suitable for that?

Thanks



Sounds like it's the wrong description.  From http_config.h :

/**
 * Run the post_config function for each module
 * @param pconf The config pool
 * @param plog The logging streams pool
 * @param ptemp The temporary pool
 * @param s The list of server_recs
 * @return OK or DECLINED on success anything else is a error
 */
AP_DECLARE_HOOK(int,post_config,(apr_pool_t *pconf,apr_pool_t *plog,
 apr_pool_t *ptemp,server_rec *s))


The post_config hook should happen when the child loads, and won't be 
associated with a specific request.  It happens after the config is 
loaded when HTTPD starts, potentially twice because of the way HTTPD 
loads.  Once done and HTTPD starts serving requests, it shouldn't be 
called again in that processes lifetime.


Joe
--
http://www.silverhawk.net/


Re: Tear down of module on server stop

2013-06-06 Thread Joe Lewis


On 06/06/2013 04:13 PM, Sean Beck wrote:

So in the post_config hook I set up the connections then register a clean
up function to terminate the connections?


Yes.  It's the one place that, if you are calling apr_palloc/etc, you 
have the direct pool that will be called when things do get cleaned up 
for what is in the pool, and immediately before the memory is freed up 
on a graceful exit.


Joe


Re: Tear down of module on server stop

2013-06-06 Thread Joe Lewis

On 06/06/2013 03:27 PM, Sean Beck wrote:

Would I register the pool clean up function in the module struct?


On Thu, Jun 6, 2013 at 3:16 PM, Joe Lewis  wrote:


On 06/06/2013 03:14 PM, Sean Beck wrote:


Where does the tear down happen when httpd is stopped? I have some code
for
sending messages to ActiveMQ in my module and I would like to only make a
connection on startup rather than every time someone connects, but then I
need to destroy the connection when the server stops.

Also, register_hooks is called when the server starts, correct? I am
thinking I would put the code for connecting to ActiveMQ in there.

Thanks!



Register a pool clean up function with the pool for the server record.
  That should be called when the pool is removed.

Joe



Try doing this in the post_config hook, which is probably where you set 
the connections up.


Joe


Re: Tear down of module on server stop

2013-06-06 Thread Joe Lewis

On 06/06/2013 03:14 PM, Sean Beck wrote:

Where does the tear down happen when httpd is stopped? I have some code for
sending messages to ActiveMQ in my module and I would like to only make a
connection on startup rather than every time someone connects, but then I
need to destroy the connection when the server stops.

Also, register_hooks is called when the server starts, correct? I am
thinking I would put the code for connecting to ActiveMQ in there.

Thanks!



Register a pool clean up function with the pool for the server record.  
That should be called when the pool is removed.


Joe


Re: Issue in using php5_module module.

2013-05-28 Thread Joe Lewis

On 05/28/2013 08:38 AM, Sindhi Sindhi wrote:

[SNIP]

With these changes, when I start httpd.exe and try to launch a simple php
file shown above, from the browser, the first time I see that my filter
module gets the correct php data from php file in the buckets. But when I
try to open the same php file second time, I see that there are some extra
strings appended to the original php file contents and sent to my filter
module in the buckets. So in my filter when I read php data from the bucket
I get the php data and some additional strings appended to the php data
like below -

"Hello from PHP
6.26%20(KHTML,%20like%20Gecko)%20Version/6.0%20Mobile/10A5355d
%20Safari/8536.25 HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101
Firefox/22.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5 "

Any help is highly appreciated.

Thanks.



Are you sure it's a problem with the php5_module and not your filter?  I 
only ask because the php5_module has been installed in numerous 
locations throughout the world, with custom modules (including an output 
filter of mine that wraps the page into a template), without issue.  I 
had run into a similar problem eons ago (I believe about 10 years or 
so).  In fact, I have one question that (if you answer honestly) will 
probably tell you where your problem is.


Are you NULL-terminating all of your strings when you set them up at the 
beginning of the transaction?  If you say "yes", please send copies of 
code.  If you say "no", please fix and try again.  When I ran into that 
problem so long ago, I was mistakenly working under the assumption that 
the strings being passed around were NULL-terminated, which is not 
always the case.


Joe
--
http://www.silverhawk.net/


Re: Apache C++ equivalent of javax.servlet.Filter

2013-05-03 Thread Joe Lewis


On 05/03/2013 01:53 AM, Sindhi Sindhi wrote:

I'm so sorry, I searched, and found that request_rec has the below members -
char *args;
char *unparsed_uri;
apr_uri_t parsed_uri;

Which of the below members will have the exact URI that is passed from
the browser?



unparsed_uri will have what you are looking for.  parsed_uri will be a 
post-processing, so it may or may not be the same.

Joe




Re: Using APR based C++ classes in Apache2 module

2013-05-01 Thread Joe Lewis

On 05/01/2013 06:21 AM, Somostetoi Kilato wrote:

Hallo,

I have a small web page generator library, written in C++ and I am
rewriting it to use APR. More, I would like to create an Apache2 module
which will use this generator. But I have no idea how to integrate it into
Apache2.

Maybe somebody is so kind to guide me in this process and he/she can
provide me some examples. Thank you in advance.

Best regards,
SK

If you have the Apache HTTP server source code, there are a number of 
examples.  If you don't have access, I'd suggest procuring a copy of 
Nick Kew's book about writing HTTPD modules for Apache.


If you cannot afford a book you can always use the documentation for 
getting started (virtually any popular search engine would be able to 
guide you to some things, for example, typing in "apache module example 
c++").


Hopefully, this will help.  If you have specific questions that you 
cannot find answers to in the history of this list, we'd love to help.


Thanks,
Joe


Re: Looking for suggestions: email clients

2013-04-15 Thread Joe Lewis

On Apr 14, 2013, at 5:36 PM, Tom Roth  wrote:

> My web app needs to service email clients as well as browsers.  Since the 
> only messages
> I expect to process are small (SMS) and machine generated I'm looking for 
> solutions
> short of installing a smtpd server and connecting it via scripts to the 
> Apache server.
> 
> At first glance I thought I could scavenge the protocol handler from 
> mod_smtpd but it's
> apparently not well maintained and the source isn't where it was purported to 
> be.  Is
> there an smtp protocol module you would recommend?  Any cleaner solutions 
> than the
> "brute-force" approach outlined above?  Hey, thanks in advance!  ;-)
>   - Tom

Tom;

I'm unaware of any up-to-date SMTP modules for Apache.  That's not saying it 
cannot be done, but I think most people using SMTP will set up a separate SMTP 
server (e.g. Postfix or Exim).  You'd get more mileage out of a separate 
software service than you would reinventing the wheel.  I do not know of any 
open-source SMS service handler that doesn't require an SMS service gateway or 
cellular service of some sort, so you may not find what you are looking for in 
that regard.  Hope you find what you are looking for!

Joe

smime.p7s
Description: S/MIME cryptographic signature


Re: state management in handlers

2013-03-06 Thread Joe Lewis
Probably not, because you will have to cater to the MPM - e.g. use shared
memory if a subsequent request comes into a different process.

I'd suggest using shared memory (there are apr routines to do that), and
that should guarantee that state will be shared between different threads
or processes.

Joe


On Wed, Mar 6, 2013 at 5:59 PM, Nce Rt  wrote:

> Is there a sample code to store and retrieve the state in a custom
> handler's local session?


Re: Private mod and mod_jk

2012-11-08 Thread Joe Lewis

On 11/08/2012 05:11 AM, easyboy wrote:

I am new to the apache mods. I just writing up a new mod with content handler
to set cookies in request http header. I was able to load this mod.

I need this mod process the request header before mod_jk.


I'd suggest mod_proxy_ajp instead of mod_jk - the proxy API is much 
easier to get a request into and alter content, and it is the future of 
Apache-Jakarta connections.


Joe


Re: Modules Communicating

2012-08-22 Thread Joe Lewis

On 08/22/2012 01:31 AM, Adi Selitzky wrote:

Hi!
I am writing my own module that handles all incoming requests. In some cases, I 
want this request to be handled by mod_python which I installed. In these 
cases, my module should change the requested file extension to .py, which is 
configured to be handled by mod_python.

AddHandler mod_python .py

I have tow questions:
1. How can I set the modules order, so my module will handle the request first, 
change its url, and then mod_python will handle it?
2. Which field in the request_rec I should change so it will take effect? I 
tried to change the URL key in subprocess_env table, but the request was not 
handled by mod_python.

apr_table_set(r->subprocess_env, "URL", strUriWithPyAtTheEnd);

Thanks

Perhaps you should simply use an early hook (e.g. 
"ap_hook_translate_name" should work if you are already using the 
translate hook) and set r->handler to "mod_python", regardless of the 
extension?


Joe
--
http://www.silverhawk.net/


Re: best way to return the content of a file

2012-08-19 Thread Joe Lewis
Yes. Every virtual host should be able to have a separate configuration,
hence different configs. The server_rec structure points to the virtual
host. There are ways to get the global settings from the global server_rec,
do some searches.on the list archives and you will find that if its what
you needed.

Joe
--
Http://www.silverhawk.net/
On Aug 19, 2012 3:49 AM, "nik600"  wrote:

> On Sat, Aug 18, 2012 at 7:18 PM, nik600  wrote:
> > On Sat, Aug 18, 2012 at 6:32 PM, Eric Covener  wrote:
> >>> i'm enabling my module with a Location directive:
> >>>
> >>> 
> >>> SetHandler kcache
> >>> 
> >>>
> >>> and i want to control the execution of the module with an initial
> check:
> >>>
> >>> if (!r->handler || strcmp(r->handler, "kcache")) return (DECLINED);
> >>>
> >>> but r->handler is null if the hook is called in ap_hook_translate_name
> >>> state, so how can i check this condition?
> >>
> >> You can't check that condition early.  You should implement a
> >> directive to enable your module in these early phases.
> >
> > i've done that, and i've set the configuration per-directory, but it
> > seems that is have every time the same value, even if called from
> > different locations:
> >
> > static const command_reckcache_directives[] =
> > {
> > AP_INIT_TAKE1("KcacheEnabled", kcache_set_enabled, NULL,
> > ACCESS_CONF, "KcacheEnabled must have Off or On value"),
> > AP_INIT_TAKE1("KcachePath", kcache_set_path, NULL, ACCESS_CONF,
> > "KcachePath must contain the path"),
> > { NULL }
> > };
> >
> >
> > static void register_hooks(apr_pool_t* pool)
> > {
> >
> > /*
> > * imposto i valori di default
> > */
> > config.enabled=FALSE;
> > config.path="/var/www";
> >
> > static const char *succ[] = {"mod_proxy.c","mod_alias.c", NULL};
> > ap_hook_translate_name(kcache_handler, NULL, succ, APR_HOOK_MIDDLE);
> > }
> > module AP_MODULE_DECLARE_DATA kcache_module = {
> > STANDARD20_MODULE_STUFF,
> > NULL,
> > NULL,
> > NULL,
> > NULL,
> > kcache_directives,
> > register_hooks
> > };
> >
> > then i have:
> > in the global config
> > 
> >KcacheEnabled Off
> > 
> > and in a specific vhost:
> > 
> > KcacheEnabled On
> > KcachePath /var/www/data
> >  
> >
> > finally i've added in my handler:
> >
> > static int kcache_handler(request_rec* r)
> > {
> > apr_status_t s;
> >
> > ap_log_rerror(APLOG_MARK, APLOG_DEBUG,s,r,"KcacheEnabled =
> %i",config.enabled);
> > ap_log_rerror(APLOG_MARK, APLOG_DEBUG,s,r,"KcachePath =
> %s",config.path);
> > if(!config.enabled){
> > ap_log_rerror(APLOG_MARK, APLOG_NOTICE,s,r,"KcacheEnabled =
> Off,
> > exiting from kcache");
> > return DECLINED;
> >
> > }
> > ...
> > ...
> >
> > but looking at logs it seems that KcacheEnabled is always On.
> >
> > Is my approach correct?
> >
> > Thanks
> >
> >
> >
> >
> > --
> > /*/
> > nik600
> > http://www.kumbe.it
>
> Ok, i was missing the create_dir_conf and merge_dir_conf handlers.
>
> One more thing (i hope the last :-) ) when the documentation talk
> about  server configuration handler/merge it is intended by vhost?
>
> Thanks
> --
> /*/
> nik600
> http://www.kumbe.it
>


Re: endless loop in my module

2012-07-26 Thread Joe Lewis

On 07/25/2012 11:10 PM, Abitfarago Cini wrote:

Hi,

I need in my Apache 2 module an endless loop what starts after the module
was loaded. Where should I put it?
Are you trying to prevent Apache from doing's it's job?  Why would you 
want an endless loop?  What is the ultimate objective?


I'd not put an endless loop anywhere directly in a module.  If you have 
to use one, please fork another process off, and use that process to 
enter into an endless loop, then simply communicate with that process 
via a socket.  Adding an endless loop into an apache module has the 
potential to bring apache to it's knees.


Joe
--
http://www.silverhawk.net/


Re: "Best practices" or recommendations for logging from a module?

2012-07-01 Thread Joe Lewis

On 07/01/2012 05:28 PM, oh...@cox.net wrote:

 Joe Lewis  wrote:
   

On 07/01/2012 01:53 PM, oh...@cox.net wrote:
 

 Joe Lewis   wrote:

   

On 07/01/2012 12:55 PM, oh...@cox.net wrote:

 

 oh...@cox.net wrote:


   

 oh...@cox.net wrote:


 

 Joe Lewiswrote:


   

Jim, you could use the log_error funtion all the time. Log_perror javits
logging associated with a pool, and log_rerror is for requests. If
possible, use log_rerror, because it puts the up address, etc into the logs.

Joe
On Jul 1, 2012 10:56 AM,wrote:



 

Joe,

Thanks!

Jim


   

Hi,

Oh, oh :(.

I'm using:

ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,);

all over the place, and even though I have only one LogLevel in the httpd;conf, at the 
top level, set to "debug", I don't see those messages.

The only ones I see are the ones that use APLOG_NOTICE.

Why is this?  I thought that with LogLevel set to debug, that I should see all 
level msgs output using ap_log_error?

Thanks,
Jim



 

Hi,

I think that I've found out why I'm not seeing those log messages.  Apparently, 
if the server parameter is NULL, only APLOG_NOTICE message appear except for 
during startup.

So, I have use a server for that parameter, e.g. r->server, BUT, in some cases, 
e.g., in a function like the response callback for libcurl, where the signature is 
pre-defined, and where there is no request_rec or server_rec among the parameters, 
how can I get ap_log_error to output anything (other than APLOG_NOTICE) messages?

Thanks,
Jim


   

Again, if you have access to a request_rec structure, I'd use
ap_log_rerror.  Otherwise, use ap_log_perror.  Those have a better
consistency with logging, e.g. :

ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, requestrec, "uri = %s",r->uri);
ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, pool, "creating config");

Joe

 

Hi,

I think that I'm not explaining the problem that I have very clearly :(...

Per earlier thread, I'm using libcurl to make an HTTP GET request from my 
module.

In order that my module can access the response to that GET request, I had to 
use a write callback function tha allows curl to t make the response available 
to my code.

   

That does explain things.  Using libcurl in a situation like that
before, I ended up using the callback function data as a structure, and
you could (in theory) slap the same request_rec pointers into that
structure so that you also had them in the call back.

Aside from that, you are correct, if you don't have access to the
request_rec/pool_t structures, ap_log_error works the best, but
r->server won't work, either.

Are you using virtual hosts?  If so, did you check all of the logs?
using r->server might behave differently and end up logging messages
into a different log file if you have virtual hosts.

Joe
 


Hi,

I was thinking about something similar to what you suggested, but I think that, 
for now, I'll just use APLOG_NOTICE for the ap_log_error() calls inside the 
callback.  These would mainly be for debugging anyway.

Thanks,
Jim
   


Just a suggestion, then.

I'd suggest leaving those calls in, and surround them with #ifdef 
directives.  Then, rather than "removing" them when you finish the 
product, you simply remove a #define listed at the top and those calls 
don't get compiled in.  Makes it easier to also compile a debug-specific 
version, too.


Joe
--
http://www.silverhawk.net/


Re: "Best practices" or recommendations for logging from a module?

2012-07-01 Thread Joe Lewis

On 07/01/2012 01:53 PM, oh...@cox.net wrote:

 Joe Lewis  wrote:
   

On 07/01/2012 12:55 PM, oh...@cox.net wrote:
 

 oh...@cox.net wrote:

   

 oh...@cox.net wrote:

 

 Joe Lewis   wrote:

   

Jim, you could use the log_error funtion all the time. Log_perror javits
logging associated with a pool, and log_rerror is for requests. If
possible, use log_rerror, because it puts the up address, etc into the logs.

Joe
On Jul 1, 2012 10:56 AM,   wrote:


 

Joe,

Thanks!

Jim

   

Hi,

Oh, oh :(.

I'm using:

ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,);

all over the place, and even though I have only one LogLevel in the httpd;conf, at the 
top level, set to "debug", I don't see those messages.

The only ones I see are the ones that use APLOG_NOTICE.

Why is this?  I thought that with LogLevel set to debug, that I should see all 
level msgs output using ap_log_error?

Thanks,
Jim


 

Hi,

I think that I've found out why I'm not seeing those log messages.  Apparently, 
if the server parameter is NULL, only APLOG_NOTICE message appear except for 
during startup.

So, I have use a server for that parameter, e.g. r->server, BUT, in some cases, 
e.g., in a function like the response callback for libcurl, where the signature is 
pre-defined, and where there is no request_rec or server_rec among the parameters, 
how can I get ap_log_error to output anything (other than APLOG_NOTICE) messages?

Thanks,
Jim

   

Again, if you have access to a request_rec structure, I'd use
ap_log_rerror.  Otherwise, use ap_log_perror.  Those have a better
consistency with logging, e.g. :

ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, requestrec, "uri = %s",r->uri);
ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, pool, "creating config");

Joe
 


Hi,

I think that I'm not explaining the problem that I have very clearly :(...

Per earlier thread, I'm using libcurl to make an HTTP GET request from my 
module.

In order that my module can access the response to that GET request, I had to 
use a write callback function tha allows curl to t make the response available 
to my code.
   


That does explain things.  Using libcurl in a situation like that 
before, I ended up using the callback function data as a structure, and 
you could (in theory) slap the same request_rec pointers into that 
structure so that you also had them in the call back.


Aside from that, you are correct, if you don't have access to the 
request_rec/pool_t structures, ap_log_error works the best, but 
r->server won't work, either.


Are you using virtual hosts?  If so, did you check all of the logs?  
using r->server might behave differently and end up logging messages 
into a different log file if you have virtual hosts.


Joe


Re: "Best practices" or recommendations for logging from a module?

2012-07-01 Thread Joe Lewis

On 07/01/2012 12:55 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:
   

 oh...@cox.net wrote:
 

 Joe Lewis  wrote:
   

Jim, you could use the log_error funtion all the time. Log_perror javits
logging associated with a pool, and log_rerror is for requests. If
possible, use log_rerror, because it puts the up address, etc into the logs.

Joe
On Jul 1, 2012 10:56 AM,  wrote:

 


Joe,

Thanks!

Jim
   


Hi,

Oh, oh :(.

I'm using:

ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,);

all over the place, and even though I have only one LogLevel in the httpd;conf, at the 
top level, set to "debug", I don't see those messages.

The only ones I see are the ones that use APLOG_NOTICE.

Why is this?  I thought that with LogLevel set to debug, that I should see all 
level msgs output using ap_log_error?

Thanks,
Jim

 


Hi,

I think that I've found out why I'm not seeing those log messages.  Apparently, 
if the server parameter is NULL, only APLOG_NOTICE message appear except for 
during startup.

So, I have use a server for that parameter, e.g. r->server, BUT, in some cases, 
e.g., in a function like the response callback for libcurl, where the signature is 
pre-defined, and where there is no request_rec or server_rec among the parameters, 
how can I get ap_log_error to output anything (other than APLOG_NOTICE) messages?

Thanks,
Jim
   
Again, if you have access to a request_rec structure, I'd use 
ap_log_rerror.  Otherwise, use ap_log_perror.  Those have a better 
consistency with logging, e.g. :


ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, requestrec, "uri = %s",r->uri);
ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, pool, "creating config");

Joe


Re: "Best practices" or recommendations for logging from a module?

2012-07-01 Thread Joe Lewis
Jim, you could use the log_error funtion all the time. Log_perror javits
logging associated with a pool, and log_rerror is for requests. If
possible, use log_rerror, because it puts the up address, etc into the logs.

Joe
On Jul 1, 2012 10:56 AM,  wrote:

>
>  oh...@cox.net wrote:
> > Hi,
> >
> > I'm working on my 1st module, and everything seems to be working so far.
>  At this point, since it's a first module, and I've been doing lots of
> debugging, mostly running Apache in single process mode (-k start -X), I've
> only been using printf to output various things.
> >
> > I am somewhat loath to remove some of the printf output, esp. since my
> module is still pretty raw (though working), but I'm starting to look into
> how I can switch from using printf to whatever is "normally" used for
> logging output from Apache modules.
> >
> > Given that I don't want to completely remove the ability to output the
> debug output, is there a best practice for logging from an Apache module?
>  Is it just to use the apr logging calls, and set the level to debug?
> >
> > Thanks,
> > Jim
> >
> >
> >
> >
>
>
> Hi,
>
> Also, I guess that, other than the functions take different parameters, I
> don't quite "get" why there are 4(?) different log functions
> (apr_log_error(), apr_log_rerror(), etc.).  Can I just use one of them all
> the time, e.g., apr_log_error()?
>
> Jim
>


Re: Anyone have some example code doing simple HTTP GET request from within a module?

2012-06-23 Thread Joe Lewis
Jim, that might be the way to go. Mod_proxy and the subrequests pass the
data back to the browser via an output filter. I believe you just want to
see the data and not pass it back to the client.  Libcurl should do exactly
what you need.

Joe
--
http://www.silverhawk.net/
On Jun 23, 2012 4:51 AM,  wrote:

>
>  Sorin Manolache  wrote:
> > On 2012-06-23 04:47, oh...@cox.net wrote:
> > > Hi,
> > >
> > > Per earlier threads on this list, I've been working on an Apache
> module.  For the time being, I'm kind of stuck because of the problems that
> I've run into with trying to integrate my module with a 3rd party library,
> so just for my module, which is mainly a proof-of-concept, I'd like to have
> my module do an HTTP GET request.
> > >
> > > So, I was wondering if anyone has some simple example code for doing
> that from within a module, maybe using libcurl, or just natively using
> sockets?
> > >
> > > I'm trying to do this myself, and I've been looking at using libcurl,
> but most of the examples that I've seen use the "easy" setup, so if someone
> has something like that that can be shared, it'd be a big help.
>  Conversely, if I figure it out, I'll post some working snippets here :)...
> > >
> > I'll say the same thing as Ben, try with apache, either mod_proxy or
> > ap_run_sub_request. That if you make one outgoing request per incoming
> > request. If you want several outgoing requests, in parallel preferably,
> > per incoming request, then go with some 3rd-party library.
> >
> > I have some in-house C++ wrappers for libcurl (curl_multi_* + timeouts +
> > client pools), but they are not straightforward to use, a lot of setup
> > is involved, and they are not thoroughly tested.
> >
> > S
>
> Sorin and Ben,
>
> I'll take a look at mod_proxy.c later, but, FYI, I just tried the
> following:
>
> - I added the following to my tweaked mod_headers.c:
>
> #include "curl/curl.h"
> .
> .
> .
> void callCurl() {
>  CURL *curl;
>  CURLcode res;
>
>  curl = curl_easy_init();
>  if(curl) {
>curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com";);
>res = curl_easy_perform(curl);
>
>/* always cleanup */
>curl_easy_cleanup(curl);
>  }
>  return;
> }
>
> - I compiled with apxs, with no additonal -L or -l
>
> - I added a call to callCurl() in my code where I knew it'd get called.
>
> - In my httpd.conf, I added in front of the LoadModule for mod_headers:
>
> LoadFile /usr/lib64/libcurl.so.3.0.0
>
>
> Then I started Apache in single process (-k start -X), and it started, and
> then I tested, and it worked!!
>
> For this prototype, I'll try to see if I can get this to the point that I
> confirm what I'm doing, then I'll go back and look at mod_proxy.c to maybe
> do native HTTP GET.
>
> Thanks,
> Jim
>


Re: Deleting only bucket in brigade

2012-06-22 Thread Joe Lewis

On 06/22/2012 12:17 PM, Jodi Bosa wrote:

excellent - that worked!

 ...
 tmpBucket = APR_BUCKET_NEXT(b);
 newBucket = apr_bucket_immortal_create("", (apr_size_t )0, bucketAlloc);
 APR_BUCKET_INSERT_BEFORE(tmpBucket, newBucket);
 apr_bucket_delete(b);
 ...


But I'm surprised I haven't seen this in other modules - am I that unique
in deleting an entire bucket??


You're not the only one who removes buckets.  I delete buckets in one of 
my output filters.  If you need the filters to still be called with an 
empty brigade, the create/insert/delete technique should guarante it's 
not an empty brigade, even though there is no data.


My thoughts are that if a brigade is empty, why pass it on?  You can't 
really parse much data when there is none to be parsed.  Hence, I think 
they get dropped if the brigade is empty by default, but am not 100% 
sure on that.


Joe
--
http://www.silverhawk.net/


Re: Deleting only bucket in brigade

2012-06-22 Thread Joe Lewis

On 6/22/12 9:52 AM, Jodi Bosa wrote:

What do you do in an input filter when you need to remove the only bucket
in the bucket brigade?

The following results in the filter not being called with any of the
subsequent bucket brigades:

 apr_bucket_delete(b);


The following hangs:

 b->length = 0;


In other words, my input filter gets called multiple times (once for each
line (AP_MODE_READLINE)) with a new bucket brigade each time.  For one of
these I want to delete the bucket but it is the only bucket in the brigade.

Can you simply create a new bucket (apr_bucket_alloc_create), insert it 
before the bucket you wish to delete, then delete the old bucket?


Joe
--
http://www.silverhawk.net/


Re: Followup to earlier thread about "How to compiling/link/use Apache module that uses shared library?"

2012-06-22 Thread Joe Lewis

On 6/22/12 9:35 AM, oh...@cox.net wrote:

 oh...@cox.net wrote:

Hi,

Now that I've gotten by earlier problems with the module I'm working on (see thread 
"Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that 
uses shared library?"), I am trying to get my module to work with the stuff in that 
libobaccess.so.  This .so is part of Oracle's Access Server SDK (ASDK).

The problem I'm running into now is that there's an initialization call in the 
library that I need to make, ObConfig_initialize() that is suppose to 
initialize the SDK environment, but when I call that (it takes either NULL or a 
const * char as parameter), it's blowing up (Apache aborts).

I *think* that the problem is that the libobaccess.so is actually C++, with a 
bunch of wrapper-type C functions to wrap the C++ functions, i.e., so my module 
(which is C) calls a function, and inside obaccess.so the function calls a C++ 
function)., and it's probably blowing up because the Oracle code doesn't know 
anything about Pool memory, but rather uses C++ new, etc.

Here's a gdb backtrace showing this:

In callAccessGate()...


In callAccessGate(): About to set handler...

In callAccessGate(): returned from set handler


In callAccessGate(): About to call ObConfig_initialize()...

Program received signal SIGABRT, Aborted.
[Switching to Thread 182897612000 (LWP 15573)]
0x00351432e26d in raise () from /lib64/tls/libc.so.6
(gdb) bt full
#0 0x00351432e26d in raise () from /lib64/tls/libc.so.6
No symbol table info available.
#1 0x00351432fa6e in abort () from /lib64/tls/libc.so.6
No symbol table info available.
#2 0x00351a7b1148 in __gnu_cxx::__verbose_terminate_handler () from 
/lib64/libstdc++.so.6
No symbol table info available.
#3 0x00351a7af176 in __cxa_call_unexpected () from /lib64/libstdc++.so.6
No symbol table info available.
#4 0x00351a7af1a3 in std::terminate () from /lib64/libstdc++.so.6
No symbol table info available.
#5 0x00351a7af2a3 in __cxa_throw () from /lib64/libstdc++.so.6
No symbol table info available.
#6 0x002a97898a05 in ObThreadInitNLS () from 
/apps/netpoint/lib64/libobaccess.so
No symbol table info available.
#7 0x002a97898f75 in SetGlobalInTLS () from 
/apps/netpoint/lib64/libobaccess.so
No symbol table info available.
#8 0x002a9789913f in GetGlobalFromTLS () from 
/apps/netpoint/lib64/libobaccess.so
No symbol table info available.
#9 0x002a97899edc in NLS::NLS () from /apps/netpoint/lib64/libobaccess.so
No symbol table info available.
#10 0x002a9773f1b1 in ObConfig::initialize () from 
/apps/netpoint/lib64/libobaccess.so
No symbol table info available.
#11 0x002a976ee55d in ObConfig_initialize () from 
/apps/netpoint/lib64/libobaccess.so
---Type  to continue, or q  to quit---
No symbol table info available.
#12 0x002a97b94266 in callAccessGate (
PEM=0x706850 
"MIICrTCCAhagAwIBAgICECUwDQYJKoZIhvcNAQEEBQAwgZMxCzAJBgNVBAYTAlVT\nMQswCQYDVQQIEwJWQTEPMA0GA1UEBxMGT0FLVE9OMRMwEQYDVQQKEwpKTFNpbXBs\nZUNBMRIwEAYDVQQLEwlKTERlbW8gQ0ExGzAZBgNVBAMTEkpMU2ltcGxlQ0EgRGVt\nbyBDQ"...,
url=0x2a97b956b0 "//apache1/certprotected/index.html") at mod_headers.c:847
res = Variable "res" is not available.
(gdb)

So, my code calls ObConfig_initialize() then it appears that that calls 
ObConfig_initialize() which is presumably a C++ function.

In general, is there any way to handle this problem/situation if it's memory 
allocation (inside libobaccess.so) related?

Thanks,
Jim

Sorry.  I meant to say:

"So, my code calls ObConfig_initialize() then it appears that that calls
ObConfig::initialize() which is presumably a C++ function. "

Jim


I believe you are correct - the previous stack traces (exception 
handling) is a C++ thing.  The real problem you have is that it's using 
malloc() and free(), and I don't think you can manipulate that.  You may 
have to contact Oracle to see if there are functions to override their 
use of malloc and free.  If there's not a way to override, you have one 
option - on post_config, spin off a separate process that you 
communicate with via socket/IPC.


Joe
--
http://www.silverhawk.net/


Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-22 Thread Joe Lewis

On 6/22/12 6:16 AM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Rainer Jung  wrote:

On 22.06.2012 06:10, Joe Lewis wrote:

On 6/21/12 10:02 PM, oh...@cox.net wrote:

 Joe Lewis   wrote:

On 6/21/12 9:39 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewiswrote:

On 6/21/12 7:32 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewis wrote:

On 6/21/12 6:46 PM, oh...@cox.net wrote:

 Joe Lewis  wrote:

On 6/21/12 5:49 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolache   wrote:

And I forgot to say: run gdb in some sort of environment
where you see
your current source code line and a couple of surrounding
lines. You
could achieve this with the "list" command, but I prefer
running gdb in
emacs and let emacs do the nice listing of source code in
a different panel.

S

Here's the function from my source.  It's the original
from mod_headers.c, plus my printf:


static int header_post_config(apr_pool_t *pconf,
apr_pool_t *plog,
apr_pool_t *ptemp,
server_rec *s)
{
  printf("In header_post_config\n");
  header_ssl_lookup =
APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
  return OK;
}

Jim

Hi,

I was able to get the segfault to go away.  Here's what I
had to do:

- Created /etc/ld.so.conf.d/my.conf, and added the
directory where my libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments

After that, Apache appears to start ok, without segfault :)!!

Thanks for all of the great help, esp. the suggestion about
checking "ldconfig -p".  I still don't understand why, but
I'm just glad that I can get past this piece so now I can
debug my module :)...

Later,
Jim

I'm just glad this list is as good as it is!

FYI, the ldconfig is the dynamic linker control, and those
/etc/ld.so.conf.d files provide additional search
directories for the
linker to check in when loading a library.

Joe
--
http://www.silverhawk.net/

Hi,

Sorry to report, but my earlier report was a "false positive"
:)...

I forgot that the mod_headers.c that I was doing the earlier
testing with had all references to the libobaccess.so removed
:(!!

So, I'm still stuck with basically the same problem, now,
working with my "full" code, with the calls in it:

- If I compile with -L and -l, Apache segfaults when it starts

- If I compile without -L and -l, then I get "undefined
symbol" errors when I try to start Apache, e.g.:

[root@apachemodule build-mod_headers]#
/apps/httpd/bin/apachectl -k start -X
httpd: Syntax error on line 84 of
/apps/httpd/conf/httpd.conf: Cannot load
/apps/httpd/modules/mod_headers.so into server:
/apps/httpd/modules/mod_headers.so: undefined symbol:
ObResource_isProtected

That "ObResource_isProtected" should be a symbol in
libobaccess.so, and in fact, if I do "nm --dynamic", I get:

[root@apachemodule build-mod_headers]# nm --dynamic
/apps/netpoint/lib64/libobaccess.so | grep
"ObResource_isProtected"
000a6d80 T ObResource_isProtected
[root@apachemodule build-mod_headers]#


I'm *assuming* that the reason for the "undefined symbol"
error is that libobaccess.so is actually not being loaded,
but then when I try to load libobaccess.so, either via -L and
-l in the apxs, or using LoadFile in httpd.conf, I get the
segfault (same gdb info, BTW).

Catch-22?

Sorry for the false alarm :(!!

Jim



Not a catch-22.  The -L and -l specify linker options when
assembling
the code.  The ldconfig is a run-time thing.  If you are
getting the
stderr messages, you are making it all the way into your
library.  I'd
suggest commenting out the following line and see if you get
farther :

header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);

That should tell you if the problem is the ssl_var_lookup.

Joe
--
http://www.silverhawk.net/

Hi,

Thanks for the suggestion.  I just tried what you suggested,
and got a segfault when I started Apache with the modified module.

Jim



Hi,

As a reminder, here's the gdb with the library loaded:


(gdb) b header_post_config
Function "header_post_config" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (header_post_config) pending.
(gdb) run -d /apps/httpd/ -f /apps/httpd/conf/httpd.conf
Starting program: /apps/httpd/bin/httpd -d /apps/httpd/
-f /apps/httpd/conf/httpd.conf
[Thread debugging using libthread_db enabled]
[New Thread 182897610272 (LWP 11317)]
Breakpoint 2 at 0x2a9751ea90: file mod_headers.c, line 1121.
Pending breakpoint "header_post_config" resolved
mod_headers-jl V0.09 - start calling OAM API
In register_hooks
In create_headers_dir_config
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In p

Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Joe Lewis

On 6/21/12 10:02 PM, oh...@cox.net wrote:

 Joe Lewis  wrote:

On 6/21/12 9:39 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewis   wrote:

On 6/21/12 7:32 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewiswrote:

On 6/21/12 6:46 PM, oh...@cox.net wrote:

 Joe Lewis wrote:

On 6/21/12 5:49 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolache  wrote:

And I forgot to say: run gdb in some sort of environment where you see
your current source code line and a couple of surrounding lines. You
could achieve this with the "list" command, but I prefer running gdb in
emacs and let emacs do the nice listing of source code in a different panel.

S

Here's the function from my source.  It's the original from mod_headers.c, plus 
my printf:


static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
   apr_pool_t *ptemp, server_rec *s)
{
 printf("In header_post_config\n");
 header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
 return OK;
}

Jim

Hi,

I was able to get the segfault to go away.  Here's what I had to do:

- Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments

After that, Apache appears to start ok, without segfault :)!!

Thanks for all of the great help, esp. the suggestion about checking "ldconfig 
-p".  I still don't understand why, but I'm just glad that I can get past this piece 
so now I can debug my module :)...

Later,
Jim

I'm just glad this list is as good as it is!

FYI, the ldconfig is the dynamic linker control, and those
/etc/ld.so.conf.d files provide additional search directories for the
linker to check in when loading a library.

Joe
--
http://www.silverhawk.net/

Hi,

Sorry to report, but my earlier report was a "false positive" :)...

I forgot that the mod_headers.c that I was doing the earlier testing with had 
all references to the libobaccess.so removed :(!!

So, I'm still stuck with basically the same problem, now, working with my 
"full" code, with the calls in it:

- If I compile with -L and -l, Apache segfaults when it starts

- If I compile without -L and -l, then I get "undefined symbol" errors when I 
try to start Apache, e.g.:

[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start -X
httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: Cannot load 
/apps/httpd/modules/mod_headers.so into server: 
/apps/httpd/modules/mod_headers.so: undefined symbol: ObResource_isProtected

That "ObResource_isProtected" should be a symbol in libobaccess.so, and in fact, if I do 
"nm --dynamic", I get:

[root@apachemodule build-mod_headers]# nm --dynamic /apps/netpoint/lib64/libobaccess.so | 
grep "ObResource_isProtected"
000a6d80 T ObResource_isProtected
[root@apachemodule build-mod_headers]#


I'm *assuming* that the reason for the "undefined symbol" error is that 
libobaccess.so is actually not being loaded, but then when I try to load libobaccess.so, 
either via -L and -l in the apxs, or using LoadFile in httpd.conf, I get the segfault 
(same gdb info, BTW).

Catch-22?

Sorry for the false alarm :(!!

Jim



Not a catch-22.  The -L and -l specify linker options when assembling
the code.  The ldconfig is a run-time thing.  If you are getting the
stderr messages, you are making it all the way into your library.  I'd
suggest commenting out the following line and see if you get farther :

header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);

That should tell you if the problem is the ssl_var_lookup.

Joe
--
http://www.silverhawk.net/

Hi,

Thanks for the suggestion.  I just tried what you suggested, and got a segfault 
when I started Apache with the modified module.

Jim



Hi,

As a reminder, here's the gdb with the library loaded:


(gdb) b header_post_config
Function "header_post_config" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (header_post_config) pending.
(gdb) run -d /apps/httpd/ -f /apps/httpd/conf/httpd.conf
Starting program: /apps/httpd/bin/httpd -d /apps/httpd/ -f 
/apps/httpd/conf/httpd.conf
[Thread debugging using libthread_db enabled]
[New Thread 182897610272 (LWP 11317)]
Breakpoint 2 at 0x2a9751ea90: file mod_headers.c, line 1121.
Pending breakpoint "header_post_config" resolved
mod_headers-jl V0.09 - start calling OAM API
In register_hooks
In create_headers_dir_config
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In p

Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Joe Lewis

On 6/21/12 9:39 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewis  wrote:

On 6/21/12 7:32 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewis   wrote:

On 6/21/12 6:46 PM, oh...@cox.net wrote:

 Joe Lewiswrote:

On 6/21/12 5:49 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolache wrote:

And I forgot to say: run gdb in some sort of environment where you see
your current source code line and a couple of surrounding lines. You
could achieve this with the "list" command, but I prefer running gdb in
emacs and let emacs do the nice listing of source code in a different panel.

S

Here's the function from my source.  It's the original from mod_headers.c, plus 
my printf:


static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
  apr_pool_t *ptemp, server_rec *s)
{
printf("In header_post_config\n");
header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
return OK;
}

Jim

Hi,

I was able to get the segfault to go away.  Here's what I had to do:

- Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments

After that, Apache appears to start ok, without segfault :)!!

Thanks for all of the great help, esp. the suggestion about checking "ldconfig 
-p".  I still don't understand why, but I'm just glad that I can get past this piece 
so now I can debug my module :)...

Later,
Jim

I'm just glad this list is as good as it is!

FYI, the ldconfig is the dynamic linker control, and those
/etc/ld.so.conf.d files provide additional search directories for the
linker to check in when loading a library.

Joe
--
http://www.silverhawk.net/

Hi,

Sorry to report, but my earlier report was a "false positive" :)...

I forgot that the mod_headers.c that I was doing the earlier testing with had 
all references to the libobaccess.so removed :(!!

So, I'm still stuck with basically the same problem, now, working with my 
"full" code, with the calls in it:

- If I compile with -L and -l, Apache segfaults when it starts

- If I compile without -L and -l, then I get "undefined symbol" errors when I 
try to start Apache, e.g.:

[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start -X
httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: Cannot load 
/apps/httpd/modules/mod_headers.so into server: 
/apps/httpd/modules/mod_headers.so: undefined symbol: ObResource_isProtected

That "ObResource_isProtected" should be a symbol in libobaccess.so, and in fact, if I do 
"nm --dynamic", I get:

[root@apachemodule build-mod_headers]# nm --dynamic /apps/netpoint/lib64/libobaccess.so | 
grep "ObResource_isProtected"
000a6d80 T ObResource_isProtected
[root@apachemodule build-mod_headers]#


I'm *assuming* that the reason for the "undefined symbol" error is that 
libobaccess.so is actually not being loaded, but then when I try to load libobaccess.so, 
either via -L and -l in the apxs, or using LoadFile in httpd.conf, I get the segfault 
(same gdb info, BTW).

Catch-22?

Sorry for the false alarm :(!!

Jim



Not a catch-22.  The -L and -l specify linker options when assembling
the code.  The ldconfig is a run-time thing.  If you are getting the
stderr messages, you are making it all the way into your library.  I'd
suggest commenting out the following line and see if you get farther :

header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);

That should tell you if the problem is the ssl_var_lookup.

Joe
--
http://www.silverhawk.net/

Hi,

Thanks for the suggestion.  I just tried what you suggested, and got a segfault 
when I started Apache with the modified module.

Jim



Hi,

As a reminder, here's the gdb with the library loaded:


(gdb) b header_post_config
Function "header_post_config" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (header_post_config) pending.
(gdb) run -d /apps/httpd/ -f /apps/httpd/conf/httpd.conf
Starting program: /apps/httpd/bin/httpd -d /apps/httpd/ -f 
/apps/httpd/conf/httpd.conf
[Thread debugging using libthread_db enabled]
[New Thread 182897610272 (LWP 11317)]
Breakpoint 2 at 0x2a9751ea90: file mod_headers.c, line 1121.
Pending breakpoint "header_post_config" resolved
mod_headers-jl V0.09 - start calling OAM API
In register_hooks
In create_headers_dir_config
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
[Switching to Thread 182897610272 (LWP 11317)]

Breakpoi

Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Joe Lewis

On 6/21/12 7:32 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Joe Lewis  wrote:

On 6/21/12 6:46 PM, oh...@cox.net wrote:

 Joe Lewis   wrote:

On 6/21/12 5:49 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolachewrote:

And I forgot to say: run gdb in some sort of environment where you see
your current source code line and a couple of surrounding lines. You
could achieve this with the "list" command, but I prefer running gdb in
emacs and let emacs do the nice listing of source code in a different panel.

S

Here's the function from my source.  It's the original from mod_headers.c, plus 
my printf:


static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
 apr_pool_t *ptemp, server_rec *s)
{
   printf("In header_post_config\n");
   header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
   return OK;
}

Jim

Hi,

I was able to get the segfault to go away.  Here's what I had to do:

- Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments

After that, Apache appears to start ok, without segfault :)!!

Thanks for all of the great help, esp. the suggestion about checking "ldconfig 
-p".  I still don't understand why, but I'm just glad that I can get past this piece 
so now I can debug my module :)...

Later,
Jim

I'm just glad this list is as good as it is!

FYI, the ldconfig is the dynamic linker control, and those
/etc/ld.so.conf.d files provide additional search directories for the
linker to check in when loading a library.

Joe
--
http://www.silverhawk.net/

Hi,

Sorry to report, but my earlier report was a "false positive" :)...

I forgot that the mod_headers.c that I was doing the earlier testing with had 
all references to the libobaccess.so removed :(!!

So, I'm still stuck with basically the same problem, now, working with my 
"full" code, with the calls in it:

- If I compile with -L and -l, Apache segfaults when it starts

- If I compile without -L and -l, then I get "undefined symbol" errors when I 
try to start Apache, e.g.:

[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start -X
httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: Cannot load 
/apps/httpd/modules/mod_headers.so into server: 
/apps/httpd/modules/mod_headers.so: undefined symbol: ObResource_isProtected

That "ObResource_isProtected" should be a symbol in libobaccess.so, and in fact, if I do 
"nm --dynamic", I get:

[root@apachemodule build-mod_headers]# nm --dynamic /apps/netpoint/lib64/libobaccess.so | 
grep "ObResource_isProtected"
000a6d80 T ObResource_isProtected
[root@apachemodule build-mod_headers]#


I'm *assuming* that the reason for the "undefined symbol" error is that 
libobaccess.so is actually not being loaded, but then when I try to load libobaccess.so, 
either via -L and -l in the apxs, or using LoadFile in httpd.conf, I get the segfault 
(same gdb info, BTW).

Catch-22?

Sorry for the false alarm :(!!

Jim



Not a catch-22.  The -L and -l specify linker options when assembling
the code.  The ldconfig is a run-time thing.  If you are getting the
stderr messages, you are making it all the way into your library.  I'd
suggest commenting out the following line and see if you get farther :

header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);

That should tell you if the problem is the ssl_var_lookup.

Joe
--
http://www.silverhawk.net/


Hi,

Thanks for the suggestion.  I just tried what you suggested, and got a segfault 
when I started Apache with the modified module.

Jim



Hi,

As a reminder, here's the gdb with the library loaded:


(gdb) b header_post_config
Function "header_post_config" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (header_post_config) pending.
(gdb) run -d /apps/httpd/ -f /apps/httpd/conf/httpd.conf
Starting program: /apps/httpd/bin/httpd -d /apps/httpd/ -f 
/apps/httpd/conf/httpd.conf
[Thread debugging using libthread_db enabled]
[New Thread 182897610272 (LWP 11317)]
Breakpoint 2 at 0x2a9751ea90: file mod_headers.c, line 1121.
Pending breakpoint "header_post_config" resolved
mod_headers-jl V0.09 - start calling OAM API
In register_hooks
In create_headers_dir_config
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
[Switching to Thread 182897610272 (LWP 11317)]

Breakpoint 2, header_post_config (pconf=0x573138, plog=0x5a52c8, 
ptemp=0x5a72d8, s=0x59d3a8) at mod_headers.c:1121
1121printf(&q

Re: UNSOLVED was Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Joe Lewis

On 6/21/12 6:46 PM, oh...@cox.net wrote:

 Joe Lewis  wrote:

On 6/21/12 5:49 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolache   wrote:

And I forgot to say: run gdb in some sort of environment where you see
your current source code line and a couple of surrounding lines. You
could achieve this with the "list" command, but I prefer running gdb in
emacs and let emacs do the nice listing of source code in a different panel.

S

Here's the function from my source.  It's the original from mod_headers.c, plus 
my printf:


static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
  printf("In header_post_config\n");
  header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
  return OK;
}

Jim

Hi,

I was able to get the segfault to go away.  Here's what I had to do:

- Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments

After that, Apache appears to start ok, without segfault :)!!

Thanks for all of the great help, esp. the suggestion about checking "ldconfig 
-p".  I still don't understand why, but I'm just glad that I can get past this piece 
so now I can debug my module :)...

Later,
Jim

I'm just glad this list is as good as it is!

FYI, the ldconfig is the dynamic linker control, and those
/etc/ld.so.conf.d files provide additional search directories for the
linker to check in when loading a library.

Joe
--
http://www.silverhawk.net/


Hi,

Sorry to report, but my earlier report was a "false positive" :)...

I forgot that the mod_headers.c that I was doing the earlier testing with had 
all references to the libobaccess.so removed :(!!

So, I'm still stuck with basically the same problem, now, working with my 
"full" code, with the calls in it:

- If I compile with -L and -l, Apache segfaults when it starts

- If I compile without -L and -l, then I get "undefined symbol" errors when I 
try to start Apache, e.g.:

[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start -X
httpd: Syntax error on line 84 of /apps/httpd/conf/httpd.conf: Cannot load 
/apps/httpd/modules/mod_headers.so into server: 
/apps/httpd/modules/mod_headers.so: undefined symbol: ObResource_isProtected

That "ObResource_isProtected" should be a symbol in libobaccess.so, and in fact, if I do 
"nm --dynamic", I get:

[root@apachemodule build-mod_headers]# nm --dynamic /apps/netpoint/lib64/libobaccess.so | 
grep "ObResource_isProtected"
000a6d80 T ObResource_isProtected
[root@apachemodule build-mod_headers]#


I'm *assuming* that the reason for the "undefined symbol" error is that 
libobaccess.so is actually not being loaded, but then when I try to load libobaccess.so, 
either via -L and -l in the apxs, or using LoadFile in httpd.conf, I get the segfault 
(same gdb info, BTW).

Catch-22?

Sorry for the false alarm :(!!

Jim


Not a catch-22.  The -L and -l specify linker options when assembling 
the code.  The ldconfig is a run-time thing.  If you are getting the 
stderr messages, you are making it all the way into your library.  I'd 
suggest commenting out the following line and see if you get farther :


header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);

That should tell you if the problem is the ssl_var_lookup.

Joe
--
http://www.silverhawk.net/


Re: SOLVED was Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Joe Lewis

On 6/21/12 5:49 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolache  wrote:

And I forgot to say: run gdb in some sort of environment where you see
your current source code line and a couple of surrounding lines. You
could achieve this with the "list" command, but I prefer running gdb in
emacs and let emacs do the nice listing of source code in a different panel.

S


Here's the function from my source.  It's the original from mod_headers.c, plus 
my printf:


static int header_post_config(apr_pool_t *pconf, apr_pool_t *plog,
   apr_pool_t *ptemp, server_rec *s)
{
 printf("In header_post_config\n");
 header_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
 return OK;
}

Jim


Hi,

I was able to get the segfault to go away.  Here's what I had to do:

- Created /etc/ld.so.conf.d/my.conf, and added the directory where my 
libobaccess.so was
- Run 'ldconfig' to activate.
- In the apxs command, DON'T include the -L and -l arguments

After that, Apache appears to start ok, without segfault :)!!

Thanks for all of the great help, esp. the suggestion about checking "ldconfig 
-p".  I still don't understand why, but I'm just glad that I can get past this piece 
so now I can debug my module :)...

Later,
Jim

I'm just glad this list is as good as it is!

FYI, the ldconfig is the dynamic linker control, and those 
/etc/ld.so.conf.d files provide additional search directories for the 
linker to check in when loading a library.


Joe
--
http://www.silverhawk.net/


Re: How to compiling/link/use Apache module that uses shared library?

2012-06-21 Thread Joe Lewis

On 6/21/12 1:40 PM, oh...@cox.net wrote:

 oh...@cox.net wrote:

 Sorin Manolache  wrote:

On 2012-06-21 19:47, oh...@cox.net wrote:


I've tried using "-l" pointing directly to the .so, libobaccess.so, but when I 
do that, it says it can't find the .so:

[root@apachemodule build-mod_headers]# ./compile-mod-headers.sh
/apps/httpd/build/libtool --silent --mode=compile gcc -prefer-pic   -DLINUX=2 
-D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/apps/httpd/include  
-I/apps/httpd/include   -I/apps/httpd/include   -c -o mod_headers.lo 
mod_headers.c&&  touch mod_headers.slo
/apps/httpd/build/libtool --silent --mode=link gcc -o mod_headers.la  
-l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so -rpath 
/apps/httpd/modules -module -avoid-versionmod_headers.lo
/usr/bin/ld: cannot find 
-l/apps/netpoint/AccessServerSDK/oblix/lib/libobaccess.so
collect2: ld returned 1 exit status
apxs:Error: Command failed with rc=65536

Try -lobaccess

S


Sorin,

I was able to get Apache to start, kind of, using the apxs I posted, but adding 
LoadFile directives to the Apache httpd.conf, to load libobaccess.so.

Now, when I run "apachectl -t", it says "OK", but when I try to actually start 
Apache, I get a segfault (see below).  The thing is, I have a bunch of printfs in almost every 
function in mod_headers.c, so I could see what functions are being called, and it looks like the 
segfault is occurring even before it gets to any of the code parts that I've tweaked (vs. original 
mod_headers.c):


[root@apachemodule build-mod_headers]# /apps/httpd/bin/apachectl -k start -X
mod_headers-jl V0.09 - start calling OAM API
In register_hooks
In create_headers_dir_config
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
In header_post_config

I tried running strace, and got (the ending of the strace):


In register_hooks
In create_headers_dir_config
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
In create_headers_dir_config
In header_cmd
In header_inout_cmd
In parse_format_tag
In parse_misc_string
In header_post_config
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x432cc0, [], SA_RESTORER, 0x351432e300}, {SIG_DFL}, 8) = 0
wait4(-1, [{WIFSIGNALED(s)&&  WTERMSIG(s) == SIGSEGV}], 0, NULL) = 11711
fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x2a983bf000
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2528, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x2a983c
read(3, "# Locale name alias data base.\n#"..., 4096) = 2528
read(3, "", 4096)   = 0
close(3)= 0
munmap(0x2a983c, 4096)  = 0
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT 
(No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT 
(No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No 
such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT 
(No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No 
such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such 
file or directory)
write(2, "/apps/httpd/bin/apachectl: l"..., 
83/apps/httpd/bin/apachectl: line 78: 11711 Segmentation fault  $HTTPD $ARGV
) = 83
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
wait4(-1, 0x7fbfffed64, WNOHANG, NULL)  = -1 ECHILD (No child processes)
rt_sigreturn(0x)= 0
rt_sigaction(SIGINT, {SIG_DFL}, {0x432cc0, [], SA_RESTORER, 0x351432e300}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
read(255, "\nexit $ERROR\n\n", 3420)= 14
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
exit_group(139) = ?


I'll try to do the apxs with -lobccess and post back...

Jim


Hi,

It looks like just including the .so in the apxs command is enough to cause the 
segfault, even if I remove all references to the functions in the .so from my 
module code.

Is there something else I need to do when using my module that uses "external" 
.so files?

Jim


You may need to ensure the .so is in your ldconfig paths.  If you do an 
"ldconfig -p" and grep for your module, it should show up.  
Additionally, on your compile, split your -l/-L into two parts :


-L/apps/netpoi

Re: Determining mimetype of document

2012-06-08 Thread Joe Lewis

On 06/08/2012 03:23 PM, Joshua Marantz wrote:

In understand any module *can* set content-type late: I'm just wondering if
that happens with any frequency.  E.g.when I googled for how to set
content-type in Apache, I got references to AddType and some hacks using
mod_rewrite, both of which would run upstream of my filter.  My main
concern is mod_headers since it runs downstream.


It shouldn't happen very often at all unless you are using third party 
modules.




RE firefox sniffing content-type:  does that imply that if there is an
explicit mimetype it will ignore it and determine XHTML vs HTML via
sniffing, I suppose, for DOCTYPE?  Do you have a link to that bit of news?
  That certainly complicates things.


Unfortunately, I don't.  We made the "discovery" when we were setting up 
a Firefox-vs-Chrome test a few months ago (it was a corporate practical 
joke), and ended up chalking it up to programmer error.  Right now, I'm 
not even remembering what the exact header when we ran into the 
problem.  Firefox worked, Chrome didn't and we thought it was a problem 
in Chrome - but ultimately found we were submitting a bad header and 
Firefox ignored it.  When we used the right header, Chrome was working, too.


Joe




-Josh

On Fri, Jun 8, 2012 at 5:16 PM, Joe Lewis  wrote:


On 06/08/2012 03:07 PM, Joshua Marantz wrote:


Hi,

I'm trying to figure out whether my filter, which currently runs upstream
of mod_headers, is likely to see the correct mimetype
in request->content_type.

In particular, we need to know whether browsers will interpret the content
as XHTML or HTML, which is determined by the mimetype.  Do people
typically
set the mimetype using mod_headers, or is that typically set using AddType
or some other mechanism?


It's usually set by the content generator.  However, you have to keep in
mind that any module may modify that value (any output filter may, too) up
until the AP_FTYPE_CONTENT_SET (runs after the AP_FTYPE_RESOURCE output
filters).

Additionally, please keep in mind that Firefox has begun the old I.E. hack
of sniffing the content and ignoring the Content-Type header if it can
figure it out, so you will have to be aware that content_type is not
indicative at any stage of what the browser is going to do.

Joe
--
http://www.silverhawk.net/



Joe
--
http://www.silverhawk.net/


Re: Determining mimetype of document

2012-06-08 Thread Joe Lewis

On 06/08/2012 03:07 PM, Joshua Marantz wrote:

Hi,

I'm trying to figure out whether my filter, which currently runs upstream
of mod_headers, is likely to see the correct mimetype
in request->content_type.

In particular, we need to know whether browsers will interpret the content
as XHTML or HTML, which is determined by the mimetype.  Do people typically
set the mimetype using mod_headers, or is that typically set using AddType
or some other mechanism?


It's usually set by the content generator.  However, you have to keep in 
mind that any module may modify that value (any output filter may, too) 
up until the AP_FTYPE_CONTENT_SET (runs after the AP_FTYPE_RESOURCE 
output filters).


Additionally, please keep in mind that Firefox has begun the old I.E. 
hack of sniffing the content and ignoring the Content-Type header if it 
can figure it out, so you will have to be aware that content_type is not 
indicative at any stage of what the browser is going to do.


Joe
--
http://www.silverhawk.net/


Re: Module: Mod_Dialup (ap_mpm_register_timed_callback)

2012-06-01 Thread Joe Lewis

On 6/1/12 2:36 AM, Pöchtrager, Bernhard wrote:

ap_die should, in theory.  Is your request handler adding in an EOS
bucket (end of socket) ?  Is anything calling the brigade functions in your

code?

No my request handler doesn't add an EOS bucket and I don't call the

brigade function.

Today I tried to take the mod_dialup without the file (I deleted every part

with the file). I mean I use all brigade functions, I append an EOS bucket and I
call the original dialup_send_pulse().

I modified the dialup_callback in this way:

apr_thread_mutex_lock(db->r->invoke_mtx);
get_data(db->r); //I added this line of code to send the response. (This

is a stupid idea, but in my mind it should work) (Or should I send the
response as a bucket?)

status = dialup_send_pulse(db); //the status I get is done...

Even with this code I have the same problem...

I am working with keepalive requests. Is it possible that this isn't working

with keepalive requests?

It is definitely a possibility.  What happens if you replace the get_data
(probably the culprit to what you are doing) with the code from mod_dialup?
Does it work as expected?  If so, make the get_data() function behave a little
more like the mod_dialup code, doing what you want it to do.

Joe

My first problem with mod_dialup is that I can't read the file. Strangely enough 
the value of r->finfo.filetype is 0.
I changed the code and send only the EOS bucket. I receive a file (with 0 bytes 
and I can save it), but I have the same problem.
Every second request is loading the whole time.
I think I didn't make any mistake.
In my mind either keepalive isn't supported or mod_dialup doesn't work (it's 
experimental...).

Bernhard
Oh.. No.. The problem is definitly the keepalive. I turned keepalive off and 
everything works fine.
Thanks for your help



I'm responding with this to the list so that it can be recorded for 
future searches.  Bernard, thank you for being willing to dig in and do 
some research, and I'm glad you have located a work around!


Joe


Re: mod_filter Chaining and Duplicate Buckets.

2012-05-30 Thread Joe Lewis

On 05/29/2012 09:41 AM, Zaid B. Amireh wrote:

Hello,

I have a content filter module that is operating in a proxy environment, the 
module parses HTML and XML documents and changes quite a bit of content.

The issue I'm facing is handling gzip'ed content, I tried the following 
mod_filter config

===
FilterDeclare inflate
FilterDeclare mymodule
FilterDeclare deflate

FilterProvider inflate INFLATE resp=Content-Encoding $gzip
FilterProvider mymodule mymodule-filter resp=Content-Type $text/html
FilterProvider deflate DEFLATE resp=Content-Encoding $gzip

FilterTrace inflate 1
FilterTrace deflate 1
FilterTrace mymodule 1

FilterChain inflate mymodule deflate
===

What is happening is that my module is receiving duplicate buckets, here is a 
snippet from the log

===
mod_filter.c(117): inflate
mod_filter.c(122): inflate: type: TRANSIENT, length: 1202
mod_filter.c(117): inflate
mod_filter.c(122): inflate: type: FLUSH, length: 0
mod_filter.c(117): mymodule
mod_filter.c(122): mymodule: type: HEAP, length: 3746
mod_filter.c(122): mymodule: type: FLUSH, length: 0
mod_filter.c(117): inflate
mod_filter.c(122): inflate: type: TRANSIENT, length: 1400
mod_filter.c(117): inflate
mod_filter.c(122): inflate: type: TRANSIENT, length: 1520
mod_filter.c(117): mymodule
mod_filter.c(122): mymodule: type: HEAP, length: 3746
mod_filter.c(122): mymodule: type: FLUSH, length: 0
mod_filter.c(122): mymodule: type: HEAP, length: 8096
...

.
mod_deflate.c(1113): Zlib: Inflated 9637 to 41199 : URL /
mod_filter.c(117): mymodule
mod_filter.c(122): mymodule: type: HEAP, length: 3746
mod_filter.c(122): mymodule: type: FLUSH, length: 0
mod_filter.c(122): mymodule: type: HEAP, length: 8096
mod_filter.c(122): mymodule: type: HEAP, length: 3829
mod_filter.c(122): mymodule: type: FLUSH, length: 0
mod_filter.c(122): mymodule: type: HEAP, length: 5008
mod_filter.c(122): mymodule: type: FLUSH, length: 0
mod_filter.c(122): mymodule: type: HEAP, length: 5412
mod_filter.c(122): mymodule: type: FLUSH, length: 0
mod_filter.c(122): mymodule: type: HEAP, length: 6947
mod_filter.c(122): mymodule: type: FLUSH, length: 0
mod_filter.c(122): mymodule: type: HEAP, length: 8096
mod_filter.c(122): mymodule: type: HEAP, length: 65
mod_filter.c(122): mymodule: type: EOS, length: 0
mod_filter.c(117): deflate
mod_filter.c(122): deflate: type: TRANSIENT, length: 198242
===

The first bucket of size 3746 was received 7 times by the module, the second 
bucket of 8096 was received 6 times and so on.

I'm really stumped as to what is causing this behavior, any ideas?


Could it be that you are intercepting the subrequest and seeing the 
content from that in your filter?  I am not sure how mod_proxy works 
(I've not actually looked at the code), but odds are that it is creating 
a sub request, which will also have filters in it, and that is what you 
are also seeing.


Joe


virtually yours
Zaid


Re: AW: Module: Mod_Dialup (ap_mpm_register_timed_callback)

2012-05-25 Thread Joe Lewis



On 05/25/2012 02:58 AM, Pöchtrager, Bernhard wrote:

-Ursprüngliche Nachricht-
Von: Joe Lewis [mailto:jle...@silverhawk.net] Im Auftrag von Joe Lewis
Gesendet: Donnerstag, 24. Mai 2012 18:06
An: modules-dev@httpd.apache.org
Cc: Pöchtrager, Bernhard
Betreff: Re: Module: Mod_Dialup (ap_mpm_register_timed_callback)

On 05/24/2012 03:26 AM, Pöchtrager, Bernhard wrote:

I created two files. One file with a strace of a successful request and one

with a strace of an unsuccessful request.

The first significant differences between these two requests are following

lines.

4171<... futex resumed>   ) = -1 EAGAIN (Resource temporarily

unavailable)

4170<... futex resumed>   ) = -1 EAGAIN (Resource temporarily

unavailable)

4169<... futex resumed>   ) = -1 EAGAIN (Resource temporarily

unavailable)

4168<... futex resumed>   ) = -1 EAGAIN (Resource temporarily

unavailable)

4167<... futex resumed>   ) = -1 EAGAIN (Resource temporarily

unavailable)

4166<... futex resumed>   ) = -1 EAGAIN (Resource temporarily

unavailable)

4164<... futex resumed>   ) = -1 EAGAIN (Resource temporarily

unavailable)

4171  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4170  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4169  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4168  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4167  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4166  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4164  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL

Well I think that the first request didn't finish correctly. But what can I do?
Do you have any ideas?

Bernhard

"futex", based on "mutexes", are locking mechanisms and are used to
prevent work from being done while something else is working (e.g. on data
to prevent corruption).  I am unfamiliar with
ap_mpm_register_timed_callback, so I pulled up the apache source to see
what it is doing.  Apparently, the source has a comment in include/httpd.h
about it :

/** Mutex protect callbacks registered with
ap_mpm_register_timed_callback
   * from being run before the original handler finishes running
   */

Looking at the trace and seeing the comment indicates that the original
handler has not completed.  In fact, if you look at the source file
modules/test/mod_dialup.c, it has an example but it uses the
apr_thread_mutex_lock and apr_thread_mutex_unlock functions in the call
back that is registered, and it re-registers the call back if it needs to check
again (e.g. if it still has data to send back to the client), but it still 
unlocks the
mutex.

Have you checked to ensure your handler has exited?

Joe

The code of my Handler exits with SUSPENDED. If the Handler doesn't complete 
the Callback wouldn't get called.
Maybe I have to change the state of the handler, but how can I do this? Do you 
have any ideas to close the handler?

Here is my actual-Code of the Callback.
Static void callback(void* data) {
  request_rec* prr = (request_rec*) data;
  apr_thread_mutex_lock(prr->invoke_mtx);
  get_data(prr);//here I get my data. It's like the handler I 
used for a synchronous connection
  apr_thread_mutex_unlock(prr->invoke_mtx);
  ap_finalize_request_protocol(prr);
  ap_process_request_after_handler(prr);
  prr->status=HTTP_OK;
  ap_die(DONE, prr);
}

The handler is:
static int async_handler(request_rec* prr)
{
 ap_mpm_register_timed_callback(apr_time_from_msec(1000),callback,prr);
 return SUSPENDED;
}


Question - the mod_dialup.c handler is generating content, but yours is 
not.  How are you generating a response?  Basically, the mod_dialup.c 
handler is sending the contents of a file (including the EOS bucket 
which is supposed to cause the connection to close), and returning 
SUSPENDED, which then triggers in the dialup_callback to either 
re-suspend, or process the request depending on the dialup_send_pulse 
result.


Curiosity - is the previous connection still open when you get to the 
second request that is failing?


Joe



Re: Module: Mod_Dialup (ap_mpm_register_timed_callback)

2012-05-24 Thread Joe Lewis

On 05/24/2012 03:26 AM, Pöchtrager, Bernhard wrote:


I created two files. One file with a strace of a successful request and one 
with a strace of an unsuccessful request.
The first significant differences between these two requests are following 
lines.

4171<... futex resumed>  ) = -1 EAGAIN (Resource temporarily 
unavailable)
4170<... futex resumed>  ) = -1 EAGAIN (Resource temporarily 
unavailable)
4169<... futex resumed>  ) = -1 EAGAIN (Resource temporarily 
unavailable)
4168<... futex resumed>  ) = -1 EAGAIN (Resource temporarily 
unavailable)
4167<... futex resumed>  ) = -1 EAGAIN (Resource temporarily 
unavailable)
4166<... futex resumed>  ) = -1 EAGAIN (Resource temporarily 
unavailable)
4164<... futex resumed>  ) = -1 EAGAIN (Resource temporarily 
unavailable)
4171  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4170  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4169  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4168  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4167  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4166  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL
4164  futex(0x1eda654, FUTEX_WAIT_PRIVATE, 42, NULL

Well I think that the first request didn't finish correctly. But what can I do?
Do you have any ideas?

Bernhard


"futex", based on "mutexes", are locking mechanisms and are used to 
prevent work from being done while something else is working (e.g. on 
data to prevent corruption).  I am unfamiliar with 
ap_mpm_register_timed_callback, so I pulled up the apache source to see 
what it is doing.  Apparently, the source has a comment in 
include/httpd.h about it :


/** Mutex protect callbacks registered with ap_mpm_register_timed_callback
 * from being run before the original handler finishes running
 */

Looking at the trace and seeing the comment indicates that the original 
handler has not completed.  In fact, if you look at the source file 
modules/test/mod_dialup.c, it has an example but it uses the 
apr_thread_mutex_lock and apr_thread_mutex_unlock functions in the call 
back that is registered, and it re-registers the call back if it needs 
to check again (e.g. if it still has data to send back to the client), 
but it still unlocks the mutex.


Have you checked to ensure your handler has exited?

Joe


Re: Module: Mod_Dialup (ap_mpm_register_timed_callback)

2012-05-22 Thread Joe Lewis



On 05/22/2012 12:27 AM, Pöchtrager, Bernhard wrote:

Hello

I am trying to work with asynchronous requests.
With synchronous requests everything WORKS fine.
I write it like mod_dialup.c.
The result is that every second request is unsuccessful (The Browser is loading 
the whole time).

Bernhard;

Do you mean that the connection just appears to be loading?  Does it 
timeout?  Or does the page successfully load?


Do you see error messages?  Are you logging anything to help debug 
this?  Can you share things like - what you are trying to accomplish, 
code, etc?


Joe




Re: one question about HTTP response header "Content-Length"

2012-03-15 Thread Joe Lewis

On 3/16/12 12:54 AM, Rui Hu wrote:

Sorry I didn't describe my question accurately. I want to modify
"Cache-Control" depending on "Content-Length" and "Content-Type", and
"Content-Type" depending on r->uri. Therefore I must get those two fields
and set that one field.

Any suggestion?


An output filter is probably where you want to be.  There are plenty of 
examples from previous posts (search the archives) if you want to know 
how to use one.


Joe
--
http://www.silverhawk.net/



Re: one question about HTTP response header "Content-Length"

2012-03-15 Thread Joe Lewis

On 3/16/12 12:31 AM, Rui Hu wrote:

I have another question. I found that not every request's response header
has field of "Content-Length", is it normal?


That depends on what "normal" is.  You are probably looking at what the 
content generators have provided, and the generators don't always set 
that.  You might find that cgi's may or may not have the header.  There 
are other modules hooking into things that alter the content even more, 
e.g. chunking and gzipping to name some examples of content being 
altered, and therefor, the headers having to be altered.


If what you want is the served content length header, you might even 
consider hooking in a logging hook that provides the setting.



Additionally, can I modify HTTP response header in output filter of
AP_FTYPE_PROTOCOL type?
Probably.  I would only modify that if you were using an output filter 
(e.g. compression, again).


Joe
--
http://www.silverhawk.net/


Re: one question about HTTP response header "Content-Length"

2012-03-15 Thread Joe Lewis
Fix UPS runs before other hooks. Output filters run after content
generation. If you can be the last output filter, you should have that
value in the headers out table.

Joe
--
Http://www.silverhawk.net/
On Mar 15, 2012 9:22 PM, "Rui Hu"  wrote:

> hi,
>
> I have a private module which want to get the ultimate value of
> "Content-Length" , and I hook this module in fixups. However, result shows
> that "Content-Length" is NULL when I get it.
>
> Which process should I hook if I want to get Content-Length's ultimate
> value? Any suggestion?
>
> Many thanks!
>
> Vic
>
> --
> Best regards,
>
> Rui Hu
>
> 
> State Key Laboratory of Networking & Switching Technology
> Beijing University of Posts and Telecommunications(BUPT)
> MSN: tchrb...@gmail.com
>
> -
>


Re: How to read PHP session in module

2012-03-04 Thread Joe Lewis
If you search Google for "php basic auth", you should get some results.
Take a look, there should even be some tutorials.
On Mar 4, 2012 7:54 PM, "yokota"  wrote:

> Thank you for your resonses, Joe and Ray.
>
> Joe,
> >Php hooks into that, too, and can do basic auth.
> Could you tell me more in detail?
>
> Ray,
> I didn't know about "apache_note". Thank you for good information.
> I can control PHP application under /app1/. So I can use "apache_note"
> when a user access /app1/ .
> But when a user access /app2/, I can not control under /app2/ and
> exactly at this time, I need to know whether a user is already logged in
> /app1/.
>
>
> Best regards,
> Sakuko
>
>
> (2012/03/03 3:43), Ray Morris wrote:
>
>> Do you control the PHP application? "notes" are a mechanism for
>> modules to share data, and PHP can set a note which can then
>> be read by the new Apache module.
>>
>> http://php.net/manual/en/**function.apache-note.php
>>
>
>


Re: How to read PHP session in module

2012-03-02 Thread Joe Lewis
Php hooks into that, too, and can do basic auth. Look into that instead. It
would be easier to implement, less complex. And just as functional.

Joe
On Mar 1, 2012 10:48 PM, "yokota"  wrote:

> Thanks for the response, Joe.
>
> My private module is for authentication.
> I will be happy if I can read PHP session
> before user authentication.
>
> If a loginOK flag of an applicationA is
> in PHP session, the user pass throug my module.
> If not, the user need to be authenticated.
>
> But probably, it will be difficult as you say.
>
>
>
> Thank you,
> Sakuko
>
>
> (2012/03/02 10:27), Joe Lewis wrote:
>
>> Use a php module? Seriously, you'll have to find out where the session
>> files are kept, and read the appropriate one. Parsing may be more
>> primitive, because you aren't using php. It's the cost of reinventing the
>> wheel.
>>
>> Joe
>> On Mar 1, 2012 6:02 PM, "yokota"  wrote:
>>
>>  Hello,
>>>
>>> I want to read PHP session in my private module.
>>> PHP session id is in PHPSESSID cookie but
>>> I want to read the contents of PHP session in my module.
>>>
>>> Please let me know if you have any suggestions.
>>> Thank you in advance.
>>>
>>> Yokota Sakuko
>>>
>>>
>


Re: How to read PHP session in module

2012-03-01 Thread Joe Lewis
Use a php module? Seriously, you'll have to find out where the session
files are kept, and read the appropriate one. Parsing may be more
primitive, because you aren't using php. It's the cost of reinventing the
wheel.

Joe
On Mar 1, 2012 6:02 PM, "yokota"  wrote:

> Hello,
>
> I want to read PHP session in my private module.
> PHP session id is in PHPSESSID cookie but
> I want to read the contents of PHP session in my module.
>
> Please let me know if you have any suggestions.
> Thank you in advance.
>
> Yokota Sakuko
>


Re: Intercepting HTTP 301/302 redirects

2012-03-01 Thread Joe Lewis

Congrats!  Welcome to the world of filters!


On 03/01/2012 09:37 AM, Swaminathan Bhaskar wrote:

Ahh - Finally, I was able to get it working. Thanks for the pointer.

Here is the code snippet:

#include
#include
#include
#include
#include
#include

#define MY_FILTER_NAME "myfilter"

static void insert_myfilter(request_rec *req)
{
 ap_add_output_filter(MY_FILTER_NAME, NULL, req, req->connection);

 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, req->server, "mod_myfilter:
inserted myfilter");
}

static int my_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
{
 if (f->r->status_line != NULL) {
 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, f->r->server,
"mod_myfilter: status = %d, status-line = %s", f->r->status,
f->r->status_line);
 }
 else {
 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, f->r->server,
"mod_myfilter: status = %d", f->r->status);
 }

 ap_pass_brigade(f->next, bb);

 return APR_SUCCESS;
}

static void my_filter_hooks(apr_pool_t *pool)
{
 ap_register_output_filter(MY_FILTER_NAME, my_output_filter, NULL,
AP_FTYPE_RESOURCE);

 ap_hook_insert_filter(insert_myfilter, NULL, NULL, APR_HOOK_LAST);

 ap_hook_insert_error_filter(insert_myfilter, NULL, NULL, APR_HOOK_LAST);

 fprintf(stderr, "mod_myfilter: registered my_output_filter\n");
}

module AP_MODULE_DECLARE_DATA myfilter_module = {
 STANDARD20_MODULE_STUFF,
 NULL,
 NULL,
 NULL,
 NULL,
 NULL,
 my_filter_hooks
};

Rgds
Bhaskar


Re: Intercepting HTTP 301/302 redirects

2012-03-01 Thread Joe Lewis

On 02/29/2012 07:46 PM, Swaminathan Bhaskar wrote:

Thanks for the quick response Joe. Just to make sure, here is what I did:



SetOutputFilter myfilter



and the code

#include 
#include 
#include 
#include 
#include 

#define MY_FILTER_NAME "myfilter"

static int my_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
{
fprintf(stderr, "mod_myfilter: status = %d, status-line = %s\n", 
f->r->status, f->r->status_line);


ap_pass_brigade(f->next, bb);

return APR_SUCCESS;
}

static void my_filter_hooks(apr_pool_t *pool)
{
ap_register_output_filter(MY_FILTER_NAME, my_output_filter, NULL, 
AP_FTYPE_RESOURCE);


fprintf(stderr, "mod_myfilter: registered my_output_filter\n");
}

module AP_MODULE_DECLARE_DATA myfilter_module = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
NULL,
my_filter_hooks
};

I setup an intentional redirect for testing

Redirect 301 /red.htm http://localhost/green.htm

When I try http://localhost/, should I not see the output from myfilter ?


Maybe.  Remember, errors don't go through the same outputs as regular 
responses.  If you want to filter the results of anything outside of the 
standard 2xx HTTP responses, you have to insert an error filter as well, 
hence my reference to ap_hook_insert_error_filter().  As an example 
(borrowed from some of my source and modified for yours) :


static void insert_my_output_error_filter(request_rec *r) {
  ap_add_output_filter(MY_FILTER_NAME,NULL,r,r->connection);
}

static void my_filter_hooks(apr_pool_t *p) {
  ap_hook_insert_error_filter(insert_my_output_error_filter, NULL, 
NULL, APR_HOOK_LAST);
  
ap_register_output_filter(MY_FILTER_NAME,my_output_filter,NULL,AP_FTYPE_RESOURCE);

};

Again, output filters and errors do not coincide.  If you want to catch 
both, you have to hook both.  (Same thing for r->headers_out and 
r->err_headers_out - r->headers_out won't make it into r->err_headers_out).


Joe
--
http://www.silverhawk.net


Re: Intercepting HTTP 301/302 redirects

2012-02-29 Thread Joe Lewis

On 02/29/2012 06:01 PM, Swaminathan Bhaskar wrote:

Hi

Is there anyway to intercept HTTP 301/302 redirects ? I tried 
registering a very simple output filter (AP_FTYPE_RESOURCE) and the 
filter function did not get a callback. I would assume all output goes 
through the filter chain


Rgds
Bhaskar


Did you hook the ap_hook_insert_error_filter function?  For errors, you 
need that one.


Joe
--
http://www.silverhawk.net/


Re: Input Filters -- not seeing anything

2012-01-16 Thread Joe Lewis

On 01/16/2012 02:21 PM, Pranesh Vadhirajan wrote:

Thanks for the response, Joe.  Are the ap_*log lines to be used in lieu of
the fprintfs that I have?   Or do those actually display errors during
compilation of my code through apxs?

Thanks,
Pranesh


You would be simply logging a message through apache's defaults.  I 
usually suggest this kind of "logging" vs. fprintf's, since fprintf's 
might not go where you expect.


Joe


Re: Input Filters -- not seeing anything

2012-01-16 Thread Joe Lewis

I think he meant on your include line :

#include "apr_buckets.h"
#include "util_filter.h

stat



On 01/16/2012 09:37 AM, Pranesh Vadhirajan wrote:

I believe it's a header that is included in the Apache build, so I would
think it doesn't have that issue.

Thanks,
Pranesh

-Original Message-
From: Arturo 'Buanzo' Busleiman [mailto:bua...@buanzo.com.ar]
Sent: Monday, January 16, 2012 11:18 AM
To: modules-dev@httpd.apache.org
Subject: Re: Input Filters -- not seeing anything

Is util_filter.h lacking a closing " in the #include ?


On 1/16/12, Pranesh Vadhirajan  wrote:

Hello,

I'm very new to developing Input Filters with Apache. I have written an
input filter to read the request body content and print it to my error

log.

I have two print statements in my filtering function (one to let me know
that my filter code has been called and the other to print the request
content).  Yet, I'm not seeing anything happening (nothing is getting
printed to my log).  I have tried different things but I'm not able to

make

anything work, so I've attached the code below hoping to get some insight

on

why my filter doesn't seem to work.  I am building the module using apxs

and

I have a LoadModule directive in the httpd.conf file to load my module.

I'm

new to the filter API and I'm totally out of ideas at this point as to why
this is not working.


#include "httpd.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_config.h"
#include "http_protocol.h"
#include "http_main.h"
#include "http_log.h"
#include "http_request.h"
#include "util_script.h"
#include "http_connection.h"
#include
#include
#include
#include
#include
#include
#include "uvds_metrics_sessions.h"

#include "apr.h"
#include "apr_lib.h"
#include "apr_general.h"
#include "apr_strings.h"
#include "ap_config.h"
#include "apr_buckets.h"
#include "util_filter.h

static apr_status_t req_body_filter_in(ap_filter_t *f, apr_bucket_brigade
*b, ap_input_mode_t mode, apr_size_t *readbytes)
{
 const char *str;
 int length;
 apr_bucket *e;

 fprintf(stderr,"reached this point\n");

 ap_get_brigade(f->next, b, mode, APR_BLOCK_READ,1);

 e = APR_BRIGADE_FIRST(b);

 if (e->type == NULL) {
 return APR_SUCCESS;
 }

 apr_bucket_read(e,&str, (apr_size_t*)&length, APR_NONBLOCK_READ);
 fprintf(stderr,"req body: %s\n",str);

 return APR_SUCCESS;
}

static void my_register_hooks (apr_pool_t *p) {
 ap_hook_insert_filter(req_body_filter_in, NULL , NULL ,
APR_HOOK_MIDDLE) ;
 //ap_register_input_filter("get_request_body" , req_body_filter_in

,

NULL , AP_FTYPE_RESOURCE) ;

}

module AP_MODULE_DECLARE_DATA my_module =
{
 STANDARD20_MODULE_STUFF,
 NULL,   /* Per-Directory
Configuration */
 NULL,   /* Directory

Config

Merger */
 NULL,   /* Per-Server
Configuration */
 NULL,   /* Server Config
Merger */
 NULL,   /* Command Table
(Directives) */
 my_register_hooks/*

Registering

Hooks */

};




Re: A few questions on Input Filters

2012-01-13 Thread Joe Lewis

On 01/13/2012 09:24 AM, Martin Townsend wrote:

Thanks Joe for the info, my input filter is now behaving itself again.
I've not seen any FLUSH buckets yet so I doubt I will as we are 
running the bare minimum of modules.  I'll let you know if I do though.
One last question, when I don't see the EOS bucket should I return a 
certain APR_ error code to say the POST request hasn't finished yet. 
I'm currently return APR_OK and this seems to work.


Cheers,
Martin.


Leave it as OK.  If you return a different APR_ error, it could cause 
the entire request to hang.


By returning OK, you are simply stating that your function has finished 
what it was passed, and all is well.


Joe
--
www.silverhawk.net


Re: please provide module for apache

2012-01-01 Thread Joe Lewis
If you compiled your own Apache properly, you should already have them. If
someone else compiled your Apache, you should contact them. Thus list is
forwriting your own modules.

Joe
On Dec 31, 2011 5:47 PM, "phijo joseph"  wrote:

>sir
>
> please provide modules for svn
>
> dav_module
> dav_svn_module
> authz_svn_module
> thanks and regards
>
> phijo


Re: I need some idea about one unusual module with threaded communication :

2011-08-22 Thread Joe Lewis
On Sun, Aug 21, 2011 at 8:57 AM, milad rezai  wrote:

> How can I communicate between different thread (one thread per client)?
>
> Problem : I need to develop a module with persistent connections, I have
> two
> kind of clients : one of them persistently sends data on connection and
> another must use and get from first kind of connections and place on his
> socket for feeding his client?
>

Consider using shared memory - or shm.  Using a search engine and "apache
module shared memory example" gives a previous thread on this list :

http://marc.info/?l=apache-modules&m=113977658131259

In it, Nick gives a pointer to look at the util_ldap source.



> Now how can I handle this type of module? Is Apache module development
> platform enough for writing this?
>

The examples will show you that there are components to the API that can be
used (for portability).

Hopefully, this will help.

Joe


Re: "?" symbol in the URL for ProxyPass

2011-08-19 Thread Joe Lewis
On Fri, 2011-08-19 at 06:44 -0700, Denys wrote:

> Hi Sorin -
> 
> Thank you for your answer. I understand what you mean but this is not a
> query string, this is a part of URL. The specified URL do not have query
> parameters.


If you are directing to a URL with a question mark, you are redirecting
to a page that has a QUERY_STRING (everything after that question mark
is the query string).

Joe Lewis
-- 
http://www.silverhawk.net/


Re: centOS apache module Vs. ubuntu apache module

2011-08-19 Thread Joe Lewis
On Fri, 2011-08-19 at 17:17 +0800, david jone wrote:

> First, very thanks for members of the modules-dev's mailist for detailed
> reply.
> Maybe I should locate the problem within more smaller within more limited
> range.


Note also, that a module compiled in a 64 bit environment will not work
in a 32 bit environment.

Usually, if you want a CentOS module, compile it on CentOS.  The moment
you start playing with the same binaries on different distributions, you
also encounter library versions (as noted by Ray).  The only ways around
this are not suggested (e.g. static linking, yada, yada, yada).

The beautiful thing about Apache 2.2.x or 2.0.x is that modules compiled
properly should not have to be re-complied for a minor version change
(e.g. 2.0.63 to 2.0.64).  However, that still leaves other packages that
may contribute to version mismatches.

Again, remember that when the ELF format is wrong, the system loading
the dynamic library can't read the library (e.g. your .so is corrupt or
wrong bit-ness).

Joe Lewis
-- 
http://www.silverhawk.net/


Re: Module distribution

2011-08-10 Thread Joe Lewis
On Wed, Aug 10, 2011 at 9:55 AM, Jason Funk  wrote:

> Hello,
>
> What is the best way to package Apache modules for distribution? Do I need
> to build binaries for each platform linux 32/64, *bsd 32/64, windows...
> etc? I'm not going to be able to distribute the source.
>
> Any tips on the smoothest way or best practices?
>
> Jason
>


If you can't distribute the source, you have to distribute the binaries.
 You can do this in multiple ways (e.g. tarballs for *BSD or *nix platforms
[different tarballs], rpm's for Linux, and DLL's for Windows), but only if
you want to have to support those platforms.  Frankly, it's really up to
what you want to end up supporting, what effort you want to go through to
get it there.

Joe
--
http://www.silverhawk.net/


Re: Module External Configuration

2011-06-21 Thread Joe Lewis
On Tue, 2011-06-21 at 16:26 -0500, Jason Funk wrote:

> One last question about shared memory...
> 
> I have my configuration now being loaded successfully into a shared memory
> segment.. now my problem is that someone could change the config so that the
> resulting structure wouldn't fit in the shared memory segment. Is it
> possible to in the child replace my current shared memory segment with a
> bigger one? I tried destroy()ing and then create()ing but that resulted in a
> segfault. Should it have worked? Is there a different way?
> 
> Jason


segfaults are good indicators of pointers pointing to the wrong things.
It will work if you do it right.  Is your pointer to the shared memory
in shared memory?  Or do the clients have their own pointer that might
change if the data in shm changes location?

You might have to shm the pointer to a separate shm segment, and then
after reading in a new config, change the shm pointer to point to the
new one and destroy the old config.  Don't touch the pointer aside from
changing where it points to.

Joe Lewis
-- 
http://www.silverhawk.net/


Re: adding and editing response headers in conf

2011-06-16 Thread Joe Lewis
On Thu, 2011-06-16 at 18:57 +0200, Sorin Manolache wrote:

> On Thu, Jun 16, 2011 at 18:41, Joe Lewis  wrote:
> > On Thu, 2011-06-16 at 12:32 -0400, Shawn Ligocki wrote:
> >
> >> On Thu, Jun 16, 2011 at 11:57 AM, Joe Lewis  wrote:
> >>
> >> > On Thu, 2011-06-16 at 17:46 +0200, Sorin Manolache wrote:
> >> >
> >> > >
> >> > > Can I get this response just by changing the configuration of apache?
> >> > >
> >> > > "Header edit cookie_name(.*)domain=[^;]+(.*)
> >> > > cookie_name$1domain=.domain.net$2" does not help as it only moves the
> >> > > cookie from one domain to the other and I want it copied, not moved.
> >> >
> >> >
> >> > That is really how it should be.  A second header of the same name isn't
> >> > really allowed in the specification.
> >>
> >>
> >> I believe the HTTP spec does allow multiple Set-Cookie HTTP headers:
> >>
> >> From RFC 2616, Section
> >> 4.2<http://greenbytes.de/tech/webdav/rfc2616.html#rfc.section.4.2.p.5>
> >> :
> >>
> >> Multiple message-header fields with the same field-name *may* be present in
> >> > a message if and only if the entire field-value for that header field is
> >> > defined as a comma-separated list [i.e., #(values)]. It *must* be 
> >> > possible
> >> > to combine the multiple header fields into one "field-name: field-value"
> >> > pair, without changing the semantics of the message, by appending each
> >> > subsequent field-value to the first, each separated by a comma. The 
> >> > order in
> >> > which header fields with the same field-name are received is therefore
> >> > significant to the interpretation of the combined field value, and thus a
> >> > proxy *must not* change the order of these field values when a message is
> >> > forwarded.
> >
> >
> > Sorin, there is your answer.  Set the header to a single value
> > containing both cookies.  Thanks, Shawn!
> 
> Thanks, I've tried, but it does not work.
> 
> First, Firefox seems to simply ignore the second cookie. I do
> "Set-Cookie: a=1,b=2" and I see only a=1 in my cookie collection.
> 
> Second, there's the problem with "expires". Typically its syntax is
> "Mon, 15-Aug-2011 10:00:00 GMT", i.e. it contains a comma. So I think
> that Set-Cookie does not satisfy the condition "It *must* be possible
> to combine the multiple header fields into one "field-name:
> field-value" pair, without changing the semantics of the message"
> 
> Sorin


That's the Netscape spec, and a lot of browsers (Firefox by nature is in
this category due to it's ancestry) choose to implement that.  If the
comma doesn't work, you might have to resort to the javascript or the
location bounce to get the second header.

The problem with the native C approaches to adding a second header is
that it uses the apr_table_* functions, which overwrite what is in there
when a "new" one is set.

Joe
-- 
Director - Systems Administration
http://www.silverhawk.net/


Re: adding and editing response headers in conf

2011-06-16 Thread Joe Lewis
On Thu, 2011-06-16 at 12:32 -0400, Shawn Ligocki wrote:

> On Thu, Jun 16, 2011 at 11:57 AM, Joe Lewis  wrote:
> 
> > On Thu, 2011-06-16 at 17:46 +0200, Sorin Manolache wrote:
> >
> > > 
> > > Can I get this response just by changing the configuration of apache?
> > >
> > > "Header edit cookie_name(.*)domain=[^;]+(.*)
> > > cookie_name$1domain=.domain.net$2" does not help as it only moves the
> > > cookie from one domain to the other and I want it copied, not moved.
> >
> >
> > That is really how it should be.  A second header of the same name isn't
> > really allowed in the specification.
> 
> 
> I believe the HTTP spec does allow multiple Set-Cookie HTTP headers:
> 
> From RFC 2616, Section
> 4.2<http://greenbytes.de/tech/webdav/rfc2616.html#rfc.section.4.2.p.5>
> :
> 
> Multiple message-header fields with the same field-name *may* be present in
> > a message if and only if the entire field-value for that header field is
> > defined as a comma-separated list [i.e., #(values)]. It *must* be possible
> > to combine the multiple header fields into one "field-name: field-value"
> > pair, without changing the semantics of the message, by appending each
> > subsequent field-value to the first, each separated by a comma. The order in
> > which header fields with the same field-name are received is therefore
> > significant to the interpretation of the combined field value, and thus a
> > proxy *must not* change the order of these field values when a message is
> > forwarded.


Sorin, there is your answer.  Set the header to a single value
containing both cookies.  Thanks, Shawn!

Joe
-- 
Director - Systems Administration
http://www.silverhawk.net/


Re: Kill a request nicely

2011-06-15 Thread Joe Lewis
On Wed, 2011-06-15 at 13:11 -0500, Jason Funk wrote:


> 
> User Makes Request- > Web Server processes and generates output -> My
> module analyzes ouput determines whether it should be passed back to the
> user or not.



Sounds like you have the right one, an output filter.  However, should
it really just delete the content it is checking for, rather than to try
and force an error response to the browser?  Or are you trying to end
with a 403 forbidden?

There should be output filters that can change things BEFORE the headers
are sent (see 
AP_FTYPE_RESOURCE).  PHP is one of those that behave this way.  Remember
though, that sending a bucket brigade on to the next filter may result
in the headings being sent.

If you use an output filter, loop through the buckets (don't flatten
them) to ensure everything is okay, before passing to the next filter.
If not, you can create a new bucket brigade and send that on.

Joe Lewis
-- 
Director - Systems Administration
http://www.silverhawk.net/


Re: [mod_rewrite] Convert POST to GET

2010-06-16 Thread Joe Lewis

henryccsf wrote:

Hi,

Due to our backend implentation limitation, I need to convert POST request
to GET in our proxy server running apache2.2. I read that mod_rewrite can't
do it alone since POST variables are not accessible. I have looked at
apache2::POST200 and doesn't understand how it can apply to solve my
problem.

Does anyone here have experience handling this kind of situation?

Thanks in advance! 
  


I would have "solved" that trouble by creating a content generator 
module, read the POST data, and create a sub request (could be a proxy 
request). One thing you will need to be aware of is the GET data will 
have to be limited. It's one of the reasons why POST came into existence.


Joe
--
Joe Lewis


Re: Doing a subrequest with ap_run_sub_req

2010-05-06 Thread Joe Lewis
On May 6, 2010, at 4:22 PM, Some Guy wrote:

> What we want to do is create the subrequest (or maybe just a request)
> without any previous request_rec* object.  At least that is what I figured
> markus meant when he said "build a request completely free".  From the APIs,
> this does not seem possible, and using libCurl may be the better solution.

Question:  when is the code being called?  On an incoming request?  Or is this 
something you are trying to do with a pool clean up?  Or init?  Since this is 
an apache module, it will have some sort of a hook, most can work (e.g. filters 
will still have a request).

So, if you don't have a request_rec structure anywhere because you are using 
the sub_request to log something to log something on a hook that has nothing to 
do with an incoming connection, it comes down to you building and populating 
the request_rec from scratch or using libcurl.  It really depends on your 
ultimate objective here.

Joe




> 
> On Thu, May 6, 2010 at 12:40 PM, Joe Lewis  wrote:
> 
>> On May 6, 2010, at 8:40 AM, Some Guy wrote:
>> 
>>> I wanted to do something similar, but the Apache 2 APIs require a
>>> request_rec* in the lookup_uri method.  Tracing the code in request.c, it
>>> uses the passed in request_rec* in make_sub_request.
>>> 
>>> The example Joe provided won't compile, and the request_rec can't be NULL
>>> otherwise the code will segfault.  Any other ways to do this?
>> 
>> There are many ways - you can use libCURL to make the request, or you can
>> revisit the two code examples I gave you.  One was from my memory, then
>> realizing I had forgotten a lot of it, I scraped some code from a functional
>> module.  Did you notice both examples?  The bottom one was just to point you
>> in the right direction.  I have simplified the other one that I had scraped
>> from a functional module, and stuffed it into a fresh module generated by
>> "apxs -g -n subrequest", and it compiled quite nicely.  The diff :
>> 
>> 47a48,55
>>>request_rec   *subr;
>>>int return_code;
>>>subr = ap_sub_req_lookup_uri("/index.html",r,NULL);
>>>if ((subr != NULL) && (subr->status == HTTP_OK)) {
>>>return_code = ap_run_sub_req(subr);
>>>    ap_destroy_sub_req(subr);
>>>}
>>> 
>> 
>> 
>> I am presuming you copied and pasted my over simplified example at the
>> bottom of my response rather than using the top code section.
>> 
>> 
>> 
>> 
>>> 
>>> On Tue, Apr 20, 2010 at 4:35 PM, Joe Lewis  wrote:
>>> 
>>>> ((template_context *)f->ctx)->include_r =
>>>> ap_sub_req_lookup_uri(uri,f->r,((template_context
>>>> *)f->ctx)->include_filter);
>>>> apr_table_setn(((template_context
>>>> *)f->ctx)->include_r->notes,TEMPLATE_OVERRIDE_PARSER,"-");
>>>> if template_context *)f->ctx)->include_r != NULL) &&
>>>> (((template_context *)f->ctx)->include_r->status == HTTP_OK)) {
>>>> #ifdef DEBUG
>>>> ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, "mod_template:
>>>> mod_template_include() - calling ap_run_sub_req()");
>>>> 
>>>> On Apr 20, 2010, at 2:20 PM,  
>>>> wrote:
>>>> 
>>>>> 
>>>>> Hi. Can I build a request completely free and send it with
>>>>> ap_run_sub_req? I could not find any good documentation or examples.
>>>>> 
>>>>> Thanks
>>>>> Markus
>> 



Re: Doing a subrequest with ap_run_sub_req

2010-05-06 Thread Joe Lewis
On May 6, 2010, at 8:40 AM, Some Guy wrote:

> I wanted to do something similar, but the Apache 2 APIs require a
> request_rec* in the lookup_uri method.  Tracing the code in request.c, it
> uses the passed in request_rec* in make_sub_request.
> 
> The example Joe provided won't compile, and the request_rec can't be NULL
> otherwise the code will segfault.  Any other ways to do this?

There are many ways - you can use libCURL to make the request, or you can 
revisit the two code examples I gave you.  One was from my memory, then 
realizing I had forgotten a lot of it, I scraped some code from a functional 
module.  Did you notice both examples?  The bottom one was just to point you in 
the right direction.  I have simplified the other one that I had scraped from a 
functional module, and stuffed it into a fresh module generated by "apxs -g -n 
subrequest", and it compiled quite nicely.  The diff :

47a48,55
> request_rec   *subr;
> int return_code;
> subr = ap_sub_req_lookup_uri("/index.html",r,NULL);
> if ((subr != NULL) && (subr->status == HTTP_OK)) {
> return_code = ap_run_sub_req(subr);
> ap_destroy_sub_req(subr);
> }
>


I am presuming you copied and pasted my over simplified example at the bottom 
of my response rather than using the top code section.




> 
> On Tue, Apr 20, 2010 at 4:35 PM, Joe Lewis  wrote:
> 
>> ((template_context *)f->ctx)->include_r =
>> ap_sub_req_lookup_uri(uri,f->r,((template_context
>> *)f->ctx)->include_filter);
>> apr_table_setn(((template_context
>> *)f->ctx)->include_r->notes,TEMPLATE_OVERRIDE_PARSER,"-");
>> if template_context *)f->ctx)->include_r != NULL) &&
>> (((template_context *)f->ctx)->include_r->status == HTTP_OK)) {
>> #ifdef DEBUG
>> ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, "mod_template:
>> mod_template_include() - calling ap_run_sub_req()");
>> 
>> On Apr 20, 2010, at 2:20 PM,  
>> wrote:
>> 
>>> 
>>> Hi. Can I build a request completely free and send it with
>>> ap_run_sub_req? I could not find any good documentation or examples.
>>> 
>>> Thanks
>>> Markus


Re: Doing a subrequest with ap_run_sub_req

2010-04-20 Thread Joe Lewis
((template_context *)f->ctx)->include_r = 
ap_sub_req_lookup_uri(uri,f->r,((template_context *)f->ctx)->include_filter);
  apr_table_setn(((template_context 
*)f->ctx)->include_r->notes,TEMPLATE_OVERRIDE_PARSER,"-");
  if template_context *)f->ctx)->include_r != NULL) && (((template_context 
*)f->ctx)->include_r->status == HTTP_OK)) {
#ifdef DEBUG
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, "mod_template: 
mod_template_include() - calling ap_run_sub_req()");

On Apr 20, 2010, at 2:20 PM,   wrote:

> 
> Hi. Can I build a request completely free and send it with
> ap_run_sub_req? I could not find any good documentation or examples.
> 
> Thanks
> Markus

I learn by reading a lot of examples.  So, a very simple example :


request_rec   *req;
intretval;
ap_filter_t *filters;

filters = NULL;
req = ap_sub_req_lookup_uri("/robots.txt",filters);
retval = ap_run_sub_req(req);


Note that it sends the data back to the client, so if you are trying to capture 
the output of the sub request, you will have to create a filter that doesn't 
pass, but simply gathers the info.

Joe

RE: Fighting with build process 2.2.x on Sparc Solaris 10

2010-03-06 Thread Joe Lewis
On Fri, March 5, 2010 3:41 pm, Thomas, Peter wrote:
> Getting further [in addition to pulling down the obvious additional
> dependency, libnet]:
>

[snip]

>
> Undefined   first referenced
>  symbol in file
> __divdi3server/.libs/libmain.a(util_time.o)
> (symbol belongs to implicit dependency /usr/local/lib/libgcc_s.so.1)
> __moddi3server/.libs/libmain.a(util_time.o)
> (symbol belongs to implicit dependency /usr/local/lib/libgcc_s.so.1)
> __ashldi3   server/.libs/libmain.a(core.o)
> (symbol belongs to implicit dependency /usr/local/lib/libgcc_s.so.1)
> __ashrdi3   server/.libs/libmain.a(core.o)
> (symbol belongs to implicit dependency /usr/local/lib/libgcc_s.so.1)
> ld: fatal: Symbol referencing errors. No output written to httpd

Those "undefined symbols" errors talk about the symbol belonging to an
implicit dependency, libgcc_s.so.1.  A quick google search shows that you
are having trouble with libgcc.a.

Just an additional note, you might want to try the users list, not the
third-party modules devel list.  That list will relate much better to
compiling apache rather than to developing modules.

Joe



Re: Multiple handlers for the same directory/location

2010-02-11 Thread Joe Lewis
> Hi All,
>
> I'm looking into whether it's possible to reliably use multiple
> complimentary modules to handle the same directory or location.  The basic
> idea is to create separate modules that might be individually reusable
> (e.g. one handles GETs, another might handle PUT and DELETE).
>
> The obvious (naïve) approach that comes to mind is something like:
>
> - Each registers with ap_hook_handler()
> - Multiple Directory/Location directives, each with its own SetHandler
> - In this scenario, the last configuration merged in wins (that's the
> SetHandler value that r->handler will have on an incoming request)
>
> However, since it's good practice to check handler name in the request and
> decline if it's not yours, the second handler would be prevented from ever
> processing anything.
>
> I can also imagine making this work by modifying (at least) one of the
> handlers so that it isn't configured via SetHandler, and instead uses a
> different directive (a la mod_dav's "DAV on").  In this scenario, I could
> use ap_hook_fixups() to do check that this is a request I really want, and
> set r->handler there.
>
> Before I try this out, I just wanted to find out if there are established
> practices for accomplishing something like this, or if there are enough
> problems that I should just not attempt it.  One problem that I can think
> of offhand is that this probably makes it difficult to implement OPTIONS
> support properly.
>
> Any input would be much appreciated.
>
> Thanks,
>
> curt
>


Sounds like you are looking for more of a configuration rather than a
coding.  See the "LIMIT" section for more info.

Programmatically, just return declined if you don't want your handler to
process the request.

Joe



Re: OAuth WRAP apache module

2010-01-15 Thread Joe Lewis

Pedro Félix wrote:

[snip]

However, I would like to create a separate
building environment (not in the httpd source tree) with only my module and
all the artifacts required to build it under windows and linux. Any thoughts
or advices regarding this?
  


I do not know about the Windows-side (though Eric just posted something 
about that), but in Linux, this can be done using the apxs utility.


apxs -g -n auth_wrap

This will create a directory named auth_wrap, create the Makefile in it 
for compilation, and an example module source code.  Then, copy yours 
over the existing one, and you've got that set up.


--
Joe Lewis
www.silverhawk.net


Re: OAuth WRAP apache module

2010-01-14 Thread Joe Lewis

Pedro Félix wrote:

Hi,

I want to develop an apache module for the OAuth WRAP protocol:

  

[snip]

I'm familiar with architectures/pipelines for HTTP processing (e.g IIS or
ASP.NET), but not with Apache or Apache modules.
Could some one point me to the relevant documentation or code
frameworks/samples?

Thanks
Regards
Pedro Félix
	 

  
It may be easy enough to examine the source code for apache itself, and 
look at the basic authentication (modules/aaa/mod_auth_basic.c, 
approximately 300 lines of code).



--
Joe Lewis
www.silverhawk.net


Re: Linking in libraries to Apache Module

2009-12-07 Thread Joe Lewis

Devin Ceartas wrote:
The logic of my SQLite code works if I compile it as a stand-alone 
executable.


My mod_hello.c compiles and loads/works fine without the SQLite code

Combining the two, the module compiles and is installed, but the 
apache process dies immediately (core dump) every time it is loaded. 
Stripping out all the SQLite code and simply linking against SQLite 
causes this problem. In other words, with the same code:


apxs -cia -L/usr/local/lib -I/home/devin mod_hello.c
/* Works Fine, prints "hello world" */

apxs -cia -L/usr/local/lib -I/home/devin -lsqlite3 mod_hello.c
/* compiles but dies on apache load */
The platform is OpenBSD 4.6 with the platform's version of Apache 1.3 
and SQLite 3.6.20 downloaded from the SQLite site and compiled from 
source


Since I'm just getting started with C apache modules, I assume I'm 
missing something basic.


If using a Linux-based system, I'd suggest ensuring that ld.so.conf is 
setup to point to the directory or that the compile has the runtime path 
for the sqlite library.  For example, I have added  "-rpath 
/usr/local/lib -rpath /usr/local/lib/mysql" to my -L parameters for apxs 
to load mySQL external modules dynamically in the past.


Linux-based systems also have an "strace" command that may be used to 
figure out what libraries are missing.


--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/Rights that do not flow directly from duty well performed are not worth 
having.

   --Mohandas K. Gandhi/


Re: Debugging: child process 14446 still did not exit, sending a SIGTERM

2009-10-16 Thread Joe Lewis

Michael B Allen wrote:

On Fri, Oct 16, 2009 at 2:42 PM, Joe Lewis  wrote:
  

Michael B Allen wrote:


On Fri, Oct 16, 2009 at 1:10 PM, Joe Lewis  wrote:

  

Michael B Allen wrote:



I have a customer who very occasionally sees apache workers hang. I'm
pretty sure this is caused by an errant module but I don't know which
one.

Is there any way to determine which module is causing Apache workers to
hang?

Can I temporarily disable that SIGTERM so that I can have enough time
to attach GDB to the hanging processes?

Mike


  

Perhaps run it in a non-forking mode (httpd -X -k start) inside of gdb
and
see what it hangs on?



If I run it in gdb like you suggest:

 # gdb httpd
 (gdb) run -X -k start

I cannot get httpd to run module deinitialization. Meaning if I do
apachectl stop or httpd -X -k stop or graceful-stop in another
terminal, it just kills the whole process group. Since the problem is
hanging during module deinitialization I don't think this is going to
help me. How do I shutdown httpd so that it runs the module
deinitialization routines?

Otherwise does anyone have a web-svn pointer to the code that's
calling the SIGTERM? Maybe I can find a way to disable it.

Mike

  

Disabling SIGTERM for apache would be akin to leaving the landing gear of
your airplane on the ground when you take off.  How are you going to
properly shutdown apache if you completely kill the SIGTERM signals?



SIGTERM should not be used to stop processes. A process should
complete gracefully and call exit(2). Normally, this is what httpd
does. However if a child process takes too long, something is sending
a SIGTERM to *kill* the process. I assume this is Apache since it's
writing a message in error_log to that effect. This is what I want to
disable. Meaning, if a child process hangs, I want it to just sit
there stuck forever until an operator can login and attach gdb to it.

If I could find that part of the code, I might find a directive that
controls how long Apache waits before it sends the SIGTERM.

  

The "deinitialization" - are you just not seeing the messages you'd normally
see?  Or did apache just terminate (which is normal in gdb, which causes the
gdb session to terminate as well).



Right. I have an Apache module that writes to a separate log. When the
module is deinitialized, information is written to the log. Without
gdb, that information is correctly written to the log. When running in
gdb, nothing is written to the log. It seems the entire process group
is simply being killed. And thus the part of interest is not
accessible.

Mike
  


The SIGTERMS are occurring because apache has already attempted to stop 
a process gracefully, and it isn't stopping.  Rather than endlessly try 
and "gracefully" shutdown a child process, apache will presume that the 
process is just not going to respond.


You can always try the worker MPM rather than the prefork MPM.

As it stands, from the sound of the problem and the rarity of it (your 
previous descriptions), you are going to be "hit and miss" on tracking 
it down.  You could potentially recompile all of the modules and apache 
itself (placing debug log lines in each one), but the problems may 
actually go away in that case.  Especially if you switch versions.


I do know that some distributions' versions of apache exhibited behavior 
similar to what you have described (specifically, SuSE), so I don't know 
if compiling a new version would alleviate the customer gripe.


I only have two real suggestions : strace the processes, and hope the 
hard drive is big enough to capture the output from strace until the 
problems are encountered, or try upgrading the version of Apache.


Joe
--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   


/With every passing hour our solar system comes forty-three thousand 
miles closer to globular cluster 13 in the constellation Hercules, and 
still there are some misfits who continue to insist that there is no 
such thing as progress.

   --Ransom K. Ferm/


Re: Debugging: child process 14446 still did not exit, sending a SIGTERM

2009-10-16 Thread Joe Lewis

Michael B Allen wrote:

On Fri, Oct 16, 2009 at 1:10 PM, Joe Lewis  wrote:
  

Michael B Allen wrote:


I have a customer who very occasionally sees apache workers hang. I'm
pretty sure this is caused by an errant module but I don't know which
one.

Is there any way to determine which module is causing Apache workers to
hang?

Can I temporarily disable that SIGTERM so that I can have enough time
to attach GDB to the hanging processes?

Mike

  

Perhaps run it in a non-forking mode (httpd -X -k start) inside of gdb and
see what it hangs on?



If I run it in gdb like you suggest:

  # gdb httpd
  (gdb) run -X -k start

I cannot get httpd to run module deinitialization. Meaning if I do
apachectl stop or httpd -X -k stop or graceful-stop in another
terminal, it just kills the whole process group. Since the problem is
hanging during module deinitialization I don't think this is going to
help me. How do I shutdown httpd so that it runs the module
deinitialization routines?

Otherwise does anyone have a web-svn pointer to the code that's
calling the SIGTERM? Maybe I can find a way to disable it.

Mike
  
Disabling SIGTERM for apache would be akin to leaving the landing gear 
of your airplane on the ground when you take off.  How are you going to 
properly shutdown apache if you completely kill the SIGTERM signals?


The "deinitialization" - are you just not seeing the messages you'd 
normally see?  Or did apache just terminate (which is normal in gdb, 
which causes the gdb session to terminate as well).


Two possibilities - gdb and attach to a currently running child (and 
hope you get lucky), or strace the processes.


--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   


/The folly of intelligent people, clear-headed and narrow-visioned, has 
precipitated many catastrophies.

   --Alfred North Whitehead/


Re: Debugging: child process 14446 still did not exit, sending a SIGTERM

2009-10-16 Thread Joe Lewis

Michael B Allen wrote:

I have a customer who very occasionally sees apache workers hang. I'm
pretty sure this is caused by an errant module but I don't know which
one.

Is there any way to determine which module is causing Apache workers to hang?

Can I temporarily disable that SIGTERM so that I can have enough time
to attach GDB to the hanging processes?

Mike
  
Perhaps run it in a non-forking mode (httpd -X -k start) inside of gdb 
and see what it hangs on?


Joe

--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/Computers in the future may weigh no more than 1.5 tons."
   --JPopular Mechanics, forecasting the relentless march of science, 
1949/


Re: Help on debug an apache module

2009-08-04 Thread Joe Lewis

Replies to an e-mail should go below what you are replying to.

Jorge Bastos wrote:

Hi Ray,

Can't compile, it's the binaries from Debian SID.
No other solution, right?
  
You have two solutions - consult debian for debug packages to install, 
or compile it yourself as Ray suggested.


Joe
--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/Never say anything on the phone that you wouldn't want your mother to 
hear at your trial.

   --Sydney Biddle Barrows, the "Mayflower Madam"/


Re: process initialisation in prefork-MPM

2009-07-27 Thread Joe Lewis

ricardo13 wrote:

hi,

For example, That's right ??

#include 
static int global_variable;

static int init_child(request *r) 
{

  printf("HEllo World");
}

static void register_hooks(apr_pool_t *pool)
{
   ap_hook_child_init(init_child, NULL, NULL, APR_HOOK_MIDDLE);
}

/* the main config structure */
module AP_MODULE_DECLARE_DATA teste_module = {
   STANDARD20_MODULE_STUFF,
   NULL,/* create per-dirconfig structures */
   NULL,/* merge  per-dirconfig structures */
   NULL, /* create per-server config structures */
   NULL,/* merge  per-server config structures */
   NULL,/* table of config file commands   */
   register_hooks   /* register hooks  */
};

I was using post_config, but now I changes for child_init.

THank you
Ricardo



Joe Lewis-2 wrote:
  

ricardo13 wrote:


HI,

Sorry, but I'm using Worker MPM.
How do I declare variable using Worker MPM ?


Thank you
Ricardo
  
  
I always suggest the same method, regardless of the MPM, for 
configuration options. If you absolutely don't want to use shared memory 
and you use the worker MPM (threaded), you should be able to declare a 
regular variable with your programming language of choice as static 
variable, and don't reset it on a post_config unless it is only the 
first time post_config is being run (otherwise, as a thread is killed 
and started, it could reset your variable).


--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/An army is stengthened by labor and enervated by idleness.
--Vegetius, A.D. 4th Century/





  

That is the idea. I've always preferred post_config() myself.

--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/It's amazing that fans want to see me play. It's kind of scary. I guess 
that's what is wrong with our society.

-- John Kruk on being chosen to the 1993 All-Star team/


Re: process initialisation in prefork-MPM

2009-07-27 Thread Joe Lewis

ricardo13 wrote:

HI,

Sorry, but I'm using Worker MPM.
How do I declare variable using Worker MPM ?


Thank you
Ricardo
  


I always suggest the same method, regardless of the MPM, for 
configuration options. If you absolutely don't want to use shared memory 
and you use the worker MPM (threaded), you should be able to declare a 
regular variable with your programming language of choice as static 
variable, and don't reset it on a post_config unless it is only the 
first time post_config is being run (otherwise, as a thread is killed 
and started, it could reset your variable).


--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/An army is stengthened by labor and enervated by idleness.
--Vegetius, A.D. 4th Century/


Re: process initialisation in prefork-MPM

2009-07-27 Thread Joe Lewis
If only you had read the signature of the e-mail you just responded to 
regarding top-posting, your question would have appeared below the 
thread indicating that it does belong in this thread.


ricardo13 wrote:

HI,

One question.
How do I declare global variables ??

Thank you
Ricardo



Sorin Manolache wrote:
  

On 2008-12-22, Andrej van der Zee  wrote:


Hi,

 I need to initialise some structures for each process (in prefork MPM)
 when it is created, and need to be able to access these structures in
 ap_hook_post_read_request and ap_hook_log_transaction handlers. I
 would like to initialise the structures before the first HTTP request
 is being served by the process. How should I do this?
  

You hook child_init (ap_hook_child_init) and store your data in global
variables that are accessed by post_read_request and log_transaction.

S

--
A: Because it reverses the logical flow of conversation.
Q: Why is top-posting frowned upon?
A: Top-posting.
Q: What is the most annoying thing in e-mail?





  


Here we go. Global variables. In the prefork MPM, you are going to have 
to use shared memory segments. When you start, the first time you run 
your post config, create a shared memory segment. Then, on the other 
post configs (from inside of each process), attach to the shared memory 
handle, and set a "local" variable to your shared memory structure.


Joe
--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/Honolulu - it's got everything. Sand for the children, sun for the 
wife, sharks for the wife's mother.

--Ken Dodd/


Re: Probably OT. Difficulty implementing content handler Apache2

2009-07-09 Thread Joe Lewis

Bernard T. Higonnet wrote:

Here's my system

FreeBSD 7.1-RELEASE #0
Apache/2.2.8 (Unix) PHP/5.2.10 mod_perl/2.0.4 Perl/v5.8.8

I'm trying to create a content-handler.

I know that Apache finds the handler because if there's a syntax error 
in the perl, Apache reports

the error.

If however, there is no syntax error, everything falls into a deep 
dark hole: the browser (Firefox
3.0a2 under FreeBSD and Firefox 3.5 under XP) shows a beautiful empty 
screen while both access and
error logs for Apache have no knowledge of the request. IE6 under XP 
says "This page cannot be
displayed" and asserts a server or DNS error. So I conclude that 
Apache sends nothing at all back to

the browser.


I know the feeling all too well.



This happens no matter what the code is, code which I have lifted from 
the Internet such as


http://cpansearch.perl.org/src/GOZER/mod_perl-2.0.1/docs/os/win32/config.pod) 
or

http://www.gossamer-threads.com/lists/modperl/modperl/99882



The Apache conf file has this in it


SetHandler modperl
PerlResponseHandler Apache2::Footer




I apologize for mailing to this list but have not found a better a 
place...


TIA
Bernard Higonnet



After a few minutes of searching for some example code and slapping it 
together, I have an apache configuration that demonstrates the use of 
mod_perl :


_CODE_START

LoadModule perl_module modules/mod_perl.so
PerlResponseHandler Apache2::example
SetHandler modperl


package Apache2::example;

use 5;
use strict;
use Apache2::RequestRec;
use Apache2::RequestIO;
use Apache2::Const -compile => qw(DECLINED OK LOG_DEBUG);
use Apache2::Log -compile => qw(LOG_MARK);
use APR::Const -compile => qw(ENOTIME);

sub handler {
 my $r = shift();
#  $r->log_rerror(Apache2::Log::LOG_MARK, Apache2::Const::LOG_DEBUG, 
APR::Const::ENOTIME, "debug print");

 $r->log_error("debug print");

 if ($r->uri =~ m%^/my/uri/to/test%) {
   $r->content_type('text/html');
   $r->puts(<<"END");

Hello
Hello from this!

END

   return Apache2::Const::OK;
 }
 return Apache2::Const::DECLINED;
};

1;

_CODE_FINISH

Just paste that into a .conf file and include the .conf file into your 
apache.  Then, restart, and point a web browser to your server using the 
URI of /my/uri/to/test (e.g. http://example.com/my/uri/to/test).  You 
should get a simple "hello!", and see a "debug print" in your apache log 
file.  Keep in mind, with a module name like "Apache2::Footer", you 
probably want it to alter the content of a page to add a footer rather 
than create the complete content.


The replies in the one thread you provided a link to mention 
content-handlers versus filters, but I think they meant "content 
generators" instead of handlers.  The above is a content generator, not 
a filter, and as such may not be what you need, but should give you a 
good starting point.


Joe
--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/You hear people say it's not about the money? That's bull. I'm doing it 
for the money.

   -- John Kruk on accepting a job hosting a TV show on Fox Sports Net/


Re: [REALLY OT] How good is the mod_dosevasive default

2009-06-12 Thread Joe Lewis

Elison Smith wrote:

Any experience how good this default works for the average website? I would
prefer to not spend time making changes to this default.

Thanks!

  


Not a clue.  We program on this list, not configure.

The problem about how well the default settings perform for you depends 
on too many variables, and an in-depth knowledge of that particular 
module.  I've never looked at the code, but the variables will include 
things like how many hits the webserver is going to take (rate), how 
much data is going to be transferred (volume), how much memory and it's 
speed, CPU processing power, disk I/O, mother or daughter boards, 
network connectivity speeds, limits, what connections are 
firewalled... I think you get the idea.  No configuration is going 
to be alike.  Your special case would require time, and experience with 
your special case.


I always suggest starting with the defaults, and then modifying them as 
needed.  Defaults are usually intended for generic and multi-purpose 
configurations.


You can open up the source for the module and review it to see it's 
logic.  If you have questions about the code and what things do, just 
ask, but always include the excerpt of code (you get farther by not 
asking someone to go out and find the thing, download it, etc).  If you 
have questions about configuration, there are much better lists for 
those questions.


Joe


Re: Module segfault on Ubuntu apache

2009-05-16 Thread Joe Lewis

Fabio Zund wrote:
However, when I compile and test the module on the apache (also 
version 2.2.11) that comes with Ubuntu 9.04, all i get are segfaults.


Does anyone know differences between the original apache and the 
Ubuntu apache version? What in my module could cause such errors?


Unfortunately, I have never looked at the sources and patches used on 
ubuntu.  I would suggest looking at the patches they include with their 
source installation.  I think that would be a very good place to start.  
Additionally, debugging tools (e.g. gdb) might be a very good place to 
start.  Your hints for the day :  run "gdb httpd" (or whatever binary is 
used to start it, make sure you use the BINARY and not an init script), 
and then at the gdb prompt, enter "run -X" - this starts the binary in a 
single-instance mode.  Point the browser to it and generate the 
"errors".  Then type "bt" to get a back trace.  Outside of that and 
looking at the patches, I am unable to help.


Joe


Re: Using httpd.conf and htaccess

2009-05-05 Thread Joe Lewis

Michele Waldman wrote:

Looks like I need to use:
AllowOverride AuthConfig

Is this right?  Where do I put this?
  

Directory/'Location block that covers that particular directory or web 
location as defined in the httpd.conf file. Without that directive, 
commands may not be allowed in the .htaccess files.


Joe



--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/Sure, it's going to kill a lot of people, but they may be dying of 
something else anyway.
--Othal Brand, member of a Texas pesticide review board, on chlordane 
pesticide/


Re: error in the auth code? (I think I found the key piece of info)

2009-05-02 Thread Joe Lewis

Sam Carleton wrote:

Ok,  I think in my last email I covered up the actual problem by adding a
CRLF.  In the apache log file I am getting this:

Invalid URI in request http://schemas.xmlsoap.org/soap/envelope/";>http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="
http://www.w3.org/2001/XMLSchema";>trueSamPOST
/axis2/services/CatalogMgr HTTP/1.1

If you look at the very end, there is the beginning of the second request:
POST /axis2/services/CatalogMgr HTTP/1.1

How can these two requests get run together like this?  Is some buffer in my
Apache module not getting cleared correctly or is the client doing this?
Remember the client is simply WCF C#.

Sam

  
One more note.  If you are doing some input filtering, you might be the 
new request to the old filter data (tacking it onto the end of a 
pre-existing variable you had defined on a previous request).  That 
might explain it from a server-side.  The client side suggestions still 
stand, though it could be both.


Joe


Re: error in the auth code? (I think I found the key piece of info)

2009-05-02 Thread Joe Lewis

Sam Carleton wrote:

Ok,  I think in my last email I covered up the actual problem by adding a
CRLF.  In the apache log file I am getting this:

Invalid URI in request http://schemas.xmlsoap.org/soap/envelope/";>http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="
http://www.w3.org/2001/XMLSchema";>trueSamPOST
/axis2/services/CatalogMgr HTTP/1.1

If you look at the very end, there is the beginning of the second request:
POST /axis2/services/CatalogMgr HTTP/1.1

How can these two requests get run together like this?  Is some buffer in my
Apache module not getting cleared correctly or is the client doing this?
Remember the client is simply WCF C#.

Sam

  
I expect that the client is doing this.  Since you are using C#, it will 
try and make every request under the same connection.  With what you 
have described, it is more than likely a problem with the client trying 
to run things together.  I'd  try and force it to HTTP 1.0 (if you can) 
on the client side.  That will force subsequent requests to the same 
server to create new TCP connections, rather than reusing.  If that does 
work, then it is definitely in the client trying to bleed stuff together 
and not buffering properly.  (That is actually what I expect).


Joe


Re: Regarding setup modules for server 2.2

2009-04-16 Thread Joe Lewis

fortanu82 wrote:
Hi 
I have to completely replace the Apache 1.3 HTTP server with Apache 2.2.

In Apache 1.3 modules like mod_fastcgi, mod_perl and mod_oprocmgr are
present.

Now I just wanted to confirm two things, 
1) If our application does not use any CGI or perl scripts, Is it necessary

to have the modules like mod_perl and mod_fastcgi to be present in the
sever.
  


Wrong list.  This is a programming list, not the user list.  But just so 
you don't go away empty handed, your application only requires mod_perl 
or mod_fastcgi if you hook into them from your apache module.



2) mod_oprocmgr is configured in Apache 1.3 and when I am looking to
configure the mod_oprocmgr for Apache 2.2, the module (.so) file is not
present. Now my question is - Is this module not required in Apache 2.2? If
it is required, how could I install and configure this module. 
  
Apache is not allowed to release an oracle-specific module.  You will 
have to install this on your own.


Thanks!
Joe
--
Joe Lewis

/Whenever people agree with me I always feel I must be wrong.
   --Oscar Wilde (1854-1900):/


Re: post_config on reload

2009-03-13 Thread Joe Lewis

Sorin Manolache wrote:

On Fri, Mar 13, 2009 at 16:21, Andrej van der Zee
 wrote:
  

Hi,

Do not do this -  a restart should be a restart, not a half of a restart.


 You should be reinitializing whatever you do on a restart as well as a
start.  That's the whole point.

I have one phrase that should illustrate why : memory leak.

For example, if your extension creates another thread or spawns another
process and that other thread/process doesn't clean up on a restart and
contains a memory leak, what good is restart to you? Restart has suddenly
become pointless.

It is good etiquette to honour the concept of a restart.

  

Okay, point taken. My extension indeed creates a thread. How can I know that
a user issues a restart? In other words, where can I kill my thread?



Register a function with the cleanup of the conf pool. The conf pool
is destroyed prior to a restart/kill/reload.

You have an example in the code I've sent you.

S

  
Perfect answer!  Unfortunately, the post_config is called twice on a 
restart, and with different memory pointers, so shared memory handles, 
mutexes, etc, those will all suddenly disappear.  You'd be forced to 
initialize your post_config again or potentially segmentation fault the 
server.  So, that is a good excuse to implement some extra code to 
handle restarting a thread anyway.


Joe


Re: Making mod_auth_digest mysql

2009-02-12 Thread Joe Lewis

Michele Waldman wrote:

All the actual authentication if fine.  I wouldn't rely on cookies for
security.  It sounds like cookies would be a "fake" security.

I was thinking about creating a logout cookie.

Then, the popup would only happen if the user hacked their cookies.

Shame on them.

But it seems like such a hack to me.  I dread it.

I'm not seeing in your example how that 401 error would be generated.  What
would the htaccess look like?
  


[HTACCESS]
#AllowOverride AuthConfig
Order allow,deny
Allow from all

AuthName "Protected System"
AuthType Basic
AuthBasicProvider ldap
AuthzLDAPAuthoritative off
AuthLDAPUrl ldap://localhost/dc=localhost?mail?sub
AuthLDAPBindDN cn=directoryuser,dc=localhost
AuthLDAPBindPassword directoryuserpassword
AuthLDAPGroupAttribute memberuid
AuthCookieName VisitorID

require valid-user

ErrorDocument 401 /account/help/unauthorized.html
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R]

[/HTACCESS]

To document the file - the first stuff is actually for LDAP 
authentication, and mod_auth_cookie. The utility that sets the cookie 
never sets the cookie, on which the browser is supposed to remove it 
when closed. A log out is simply a cookie overwrite.


However, if you wish to demonstrate your apache module programming 
prowess, you can always create a mod_auth_cookie module that sets a 
SESSION variable, and then pulls the credentials from the session data 
rather than from a cookie - it can be as secure as anything out on the 
Internet today, depending on how you configure it to go. It can be as 
complex or as simple as you wish to make it. (I prefer simple - it's 
easier to troubleshoot if you have problems.)


Convoluted?
--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/They give you a round bat and they throw a round ball. And tell you to 
hit it square.

-- Willie Stargell/


Re: Making mod_auth_digest mysql

2009-02-12 Thread Joe Lewis

Michele Waldman wrote:

It is different that just authenticating.

Due to an htaccess authentication implementation, it requires a work around
to prevent those pesky popups the browsers produce.

I'm trying to do a spin on this:
http://www.berenddeboer.net/rest/authentication.html

Implementing the mod_auth_digest authenticating against mysql was all part
of this.

Michele
  


Sounds like you :
a) have your work cut out for you
or
b) can perform the task easily using pre-existing modules.

Problem 1 : If it is the "popup" login that you are trying to avoid, you 
can't by switching to "digest" instead of "basic" authentication. The 
only way around this is to inject the headers into the authentication on 
the SERVER side. An example module doing this is mod_auth_cookie, which 
takes a Cookie header (e.g. set by a PHP script) and converts it into 
the user credentials as if the browser had submitted basic authentication.


Problem 2 : Getting the popup if the browser didn't send the credentials 
(or the cookie as it would inject those credentials for the 
authentication). The way around this is to simply redirect to the 
"login" page that will "set the cookie" (or whatever you are using to 
inject the credentials into the incoming headers). This is a 
configuration side :


ErrorDocument 401 /login.jsp

Do not do a full URL redirect, as this will send the redirect back to 
the browser. A local URL redirect should allow the page to send contents 
back (e.g. a login form).


Let me try walking through an example using mod_auth_mysql, 
mod_auth_cookie, and PHP. The user opens their browser for the first 
time, and types in the website into the location bar. Browsing down into 
the side, they hit a page that is a protected resource according to 
apache. The ErrorDocument 401 kicks in using the local URI (which 
actually causes apache to create a sub-request to the local URI and 
returns the information), and returns a PHP login page. Filling out the 
form, and clicking submit, (remember, this will submit to what the PHP 
login page said to in the  tags), the PHP script sets a Login 
cookie, and sends a Location: header back to the browser telling it to 
bounce back to the original web page that was requested. (The PHP 
scripts would keep track of the Referer when it was hit, and just 
redirect back to it). At that point, the browser re-requests the page, 
but this time it submits the Login cookie. mod_auth_cookie recognizes 
the cookie, and injects the users credentials in the form of a Basic 
authentication, and passes control back to Apache. Apache then calls the 
mod_auth_mysql module, which verifies against the configured table. If 
it is wrong, it rejects the credentials and starts the ErrorDocument 401 
process again. If it is right, the page is allowed. And no pesky 
authentication dialog box. And the cookie can be set site wide. And 
still hide things that should be protected from the user.


Is that as clear as mud?
--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/Never invoke the gods unless you really want them to appear. It annoys 
them very much.

--G.K. Chesterton/


Re: Making mod_auth_digest mysql

2009-02-12 Thread Joe Lewis

Michele Waldman wrote:

There is not authentication requirement for logged_out it's in a higher
directory.
  


Okay, then. I'm afraid I am not understanding everything here. I doubt 
the wheel needs to be reimplemented, but it seems the push is in that 
direction. For my feeble mind, can you give a brief overview of what you 
are trying to accomplish?


As I see it, you were creating a mod_auth_digest_mysql . This now feels 
completely different than just an authentication.


--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/They're multi purpose. Not only do they put the clips on, but they take 
them off.
--Pratt & Whitney spokesperson explaining why the company charged the 
Air Force nearly $1,000 for an ordinary pair of pliers./


Re: Making mod_auth_digest mysql

2009-02-12 Thread Joe Lewis

Michele Waldman wrote:

I'm doing this:

RewriteEngine On
RewriteCond %{REMOTE_USER} .
RewriteRule ^.*$ - [S=1]
RewriteRule ^.*$ http://domain/logged_out.html?%{N} [R]

AuthType Digest
AuthName "account" 
AuthUserFile /path/.htpasswd

Require valid-user

1) The user is logged in.
2) The user logs out.
3) In ff, the user hits the backpage button.
4) The user gets a dialog box to login rather than being redirected.

Michele 
Are you trying to get the user to be redirected if they are not logged 
in? It shouldn't require hacking apache or rewriting a module. Try 
turning off the authentication requirement for the /logged_out.html 
page. Then, on a 401, send them to the login page. Probably similar to :


https://admin.sharktooth.org/account/

In this case, everything except the help files, and the utilities for 
assisting with logging in have been protected, while these resources 
have not. Is that what you are after?


--
Joe Lewis
Chief Nerd  SILVERHAWK <http://www.silverhawk.net/>   (801) 660-1900


/You know there is a problem with the education system when you realize 
that out of the 3 R's only one begins with an R.

--Dennis Miller/


Re: WELCOME to modules-dev@httpd.apache.org

2009-02-10 Thread Joe Lewis

dave wrote:

I tried defining a merge callback for both the server level and the
directory level, but that doesn't seem to change anything.

-dave
man...@gmail.com

  



I understand - you are using both directory AND server side configs.  
directory configs do not get created until a request.  And a merge 
should never return the same structure, meaning you should get new 
configs.  Even the directory configs don't get created until the request 
comes in.  In the handler, try setting two distinct variables, one to 
the server side and one to the directory config, and you should 
definitely see a difference.


Well done!
Joe


Re: WELCOME to modules-dev@httpd.apache.org

2009-02-10 Thread Joe Lewis

dave wrote:

Hi All,

I'm having trouble with the server_rec->module_config variable and perhaps I
am misunderstanding something.

static void get_resource(void *module_config) {
my_config *cfg = (my_config *)ap_get_module_config(module_config,
&my_module);
printf("module_config: %d\n", cfg);

//...
}


static int my_child_init(apr_pool_t *p, server_rec *s) {
printf("init server_config: %d\n", s->module_config);
get_resource(s->module_config);
//...
}

static int my_handler(request_rec *r){
//...
printf("request server_config: %d\n", r->server->module_config);
get_resource(r->server->module_config);
//...
}


  


So, how is the s->module_config being set?  I hope you are creating it 
in the per-server config create function.  Do you have that code for us 
to look at?


Joe


Re: Apache Version

2008-08-18 Thread Joe Lewis

John Hosie wrote:

OK. I know there are good things about each. But in this day, is Apache 2 yet "ready 
for prime time"? Or are we best still using one of the flavors of Apache 1?
  


Apache 2 is definitely ready.  I think apache 2.2 is definitely ready 
for primetime.  I'd stay away from 1.3 as it is primarily security 
fixes, AFAIK.


Joe


Re: does ibm http server implement ALL the features of apache httpd

2008-07-02 Thread Joe Lewis

apache a wrote:

this is what it tells on this page

http://httpd.apache.org/docs/2.2/mod/mod_asis.html

The contents of any file with a .asis extension will then be sent by Apache
to the client with almost no changes. In particular, HTTP headers are
derived from the file itself according to
mod_cgirules, so an
asis file must include valid headers, and may also use the CGI
Status: header to determine the HTTP response code.

it says ALMOST no changes

i was looking for absolutely no changes at all
  


First, IBM is the group you wish to talk to regarding whether or not it 
supports, alters, etc., any data.


As for the "absolutely no changes", there should be absolutely no 
changes if you DON'T put any added modules in line (e.g. output filters, 
etc) into the mix.  If you start playing with filters, the data can 
change, and it's the modules that really have control over what 
changes.  Due to the modular form of apache, apache cannot guarantee 
anything.  If you REALLY want absolute control, write your own web server.


Again, if you desire to know what the IBM-compiled web server is capable 
of, please contact them.  On this list, you may only get "unofficial" 
and "word-of-mouth" answers, which may or may not be accurate.  It 
shouldn't take a rocket scientist to understand the concept that one 
should go to the producer to understand the product.  Since IBM compiled 
it, they may have patches in there that effect the things you ask about.


Joe


Re: debugging a timeout issue

2008-05-09 Thread Joe Lewis

Sam Carleton wrote:

On Fri, May 9, 2008 at 12:23 AM, Graham Dumpleton
<[EMAIL PROTECTED]> wrote:
  

Since you see one request but not the second, one thing I would
perhaps suggest doing is turn off KeepAlive and see if that makes a
difference with the client.



I am wondering, I do not see the timeout bug but my customer is seeing
it.  Does it make sense that the same client application configured
the same way talking to Apache configured the same way might show
different KeepAlive behavior?

Sam
  


Especially if it is based on a different (e.g. updated) .NET framework.  
The previous suggestions to utilize Wireshark or even tcpdump (if in the 
*nix world) will help you check the connection.


IF the client has a network address translation or a firewall that ends 
up dropping a packet, you will see that with the network trace.  (Get 
both halves - from the client and from the server, and compare them).


--
Joseph Lewis 


  1   2   >