Can a module control the socket transport protocol? - revisited

2013-11-06 Thread Jon Leighton
I'm revisiting this question (from several months ago), primarily 
because I know more now that I did then - though still not enough. :)


There are a couple places in the httpd code that state or imply that 
httpd is not restricted to TCP - that other network transport protocols 
can be used. In particular, core.c:register_hooks() explicitly mentions 
other modules installing alternate network transports, and 
http_connection.h mentions the install_network_transport hook. I 
haven't been able to find any information at all on the 
install_network_transport hook, and I'm wondering if the comment is 
actually meant to refer to alternatives to HTTP, rather than TCP.


I'm also wondering if the comment in core.c refers only to the core 
being network transport agnostic, and implies nothing about the MPMs, 
which appear to me to be effectively hard coded to TCP.


Is it possible to add a loadable module to an MPM? If not, then it seems 
like the only option is to create my own MPM. If so, then the trick 
would be to get any sockets I create into the MPM's list of listening 
sockets, so they can be polled - but even that doesn't seem possible. 
The problem as I see it is that one of the key variables (the number of 
listening sockets), is private to the MPM.


Does anyone really know if httpd can support alternate transport 
protocols? Does the comment in core.c simply indicate that the core is 
network transport agnostic, and imply nothing about the MPMs?


Thanks for any help/comments on this.

- Jon Leighton


mod_proxy reverse proxying and AH01179: balancer slotmem_create failed

2013-11-06 Thread Thomas Eckert
As of late I'm seeing a lot of

  AH01179: balancer slotmem_create failed

error messages which prevent apache2 from starting. I do have

  DefaultRuntimeDir /var/run/apache2

set. For some reasons there appear to be left-over .shm files in the
DefaultRunTimeDir between stop-starts/restarts which then get picked up by
mod_slotmem when mod_proxy asks it for shared memory. Unfortunately, those
.shm files sometimes have the wrong size and get rejected by the
mod_slotmem code due to size mismatch.

To me it looks like this situation suffers from the same issue as reported
in https://issues.apache.org/bugzilla/show_bug.cgi?id=55449
though I only have one user (nobody) for all the worker processes.

I get the systems back up and running by deleting all .shm files in the
DefaultRunTimeDir between stop-starts/restarts but this seems fragile to
me. Another workaround, as crude as it is, seems to be disabling the
reusing of existing shared memory segments by setting

  fbased = 0;

in modules/slotmem/mod_slotmem_shm.c in slotmem_create().

Neither of those two appraoches seems right to me. I do need at least a
temporary workaround since this is causing major havoc.


Re: mod_proxy reverse proxying and AH01179: balancer slotmem_create failed

2013-11-06 Thread Jim Jagielski
Is BalancerPersist Off or On?

Those .shm files should only stick around if we want to
persist state across restarts.

On Nov 6, 2013, at 8:39 AM, Thomas Eckert thomas.r.w.eck...@gmail.com wrote:

 As of late I'm seeing a lot of
 
   AH01179: balancer slotmem_create failed
 
 error messages which prevent apache2 from starting. I do have
 
   DefaultRuntimeDir /var/run/apache2
 
 set. For some reasons there appear to be left-over .shm files in the 
 DefaultRunTimeDir between stop-starts/restarts which then get picked up by 
 mod_slotmem when mod_proxy asks it for shared memory. Unfortunately, those 
 .shm files sometimes have the wrong size and get rejected by the mod_slotmem 
 code due to size mismatch.
 
 To me it looks like this situation suffers from the same issue as reported in 
 https://issues.apache.org/bugzilla/show_bug.cgi?id=55449
 though I only have one user (nobody) for all the worker processes.
 
 I get the systems back up and running by deleting all .shm files in the 
 DefaultRunTimeDir between stop-starts/restarts but this seems fragile to me. 
 Another workaround, as crude as it is, seems to be disabling the reusing of 
 existing shared memory segments by setting
 
   fbased = 0;
 
 in modules/slotmem/mod_slotmem_shm.c in slotmem_create().
 
 Neither of those two appraoches seems right to me. I do need at least a 
 temporary workaround since this is causing major havoc.



Re: mod_proxy reverse proxying and AH01179: balancer slotmem_create failed

2013-11-06 Thread Thomas Eckert
It is not mentioned specifically in the configuration files, so it defaults
to Off according to
http://httpd.apache.org/docs/current/mod/mod_proxy.html#balancerpersist


On Wed, Nov 6, 2013 at 3:44 PM, Jim Jagielski j...@jagunet.com wrote:

 Is BalancerPersist Off or On?

 Those .shm files should only stick around if we want to
 persist state across restarts.

 On Nov 6, 2013, at 8:39 AM, Thomas Eckert thomas.r.w.eck...@gmail.com
 wrote:

  As of late I'm seeing a lot of
 
AH01179: balancer slotmem_create failed
 
  error messages which prevent apache2 from starting. I do have
 
DefaultRuntimeDir /var/run/apache2
 
  set. For some reasons there appear to be left-over .shm files in the
 DefaultRunTimeDir between stop-starts/restarts which then get picked up by
 mod_slotmem when mod_proxy asks it for shared memory. Unfortunately, those
 .shm files sometimes have the wrong size and get rejected by the
 mod_slotmem code due to size mismatch.
 
  To me it looks like this situation suffers from the same issue as
 reported in https://issues.apache.org/bugzilla/show_bug.cgi?id=55449
  though I only have one user (nobody) for all the worker processes.
 
  I get the systems back up and running by deleting all .shm files in the
 DefaultRunTimeDir between stop-starts/restarts but this seems fragile to
 me. Another workaround, as crude as it is, seems to be disabling the
 reusing of existing shared memory segments by setting
 
fbased = 0;
 
  in modules/slotmem/mod_slotmem_shm.c in slotmem_create().
 
  Neither of those two appraoches seems right to me. I do need at least
 a temporary workaround since this is causing major havoc.




Re: error log providers, multiple vhosts, mod_syslog

2013-11-06 Thread Jeff Trawick
On Tue, Oct 29, 2013 at 7:04 AM, Jeff Trawick traw...@gmail.com wrote:

 On Tue, Oct 29, 2013 at 5:30 AM, Jan Kaluža jkal...@redhat.com wrote:

 On 10/25/2013 03:37 PM, Jeff Trawick wrote:

 I'm hoping to get back to this discussion soon.  I also have a 2.4.x
 patch I've played with that is roughly in sync with trunk (though syslog
 logging support isn't a provider in the 2.4.x version).


 Does your patch fix stderr logging? I wanted to write proof of concept
 logger as described by Rüdiger below, but I didn't manage to find a time
 for it recently :(. If you have working solution for that, I wouldn't waste
 my time :).


 No, I just have a backport to 2.4.x with accommodation for syslog.


What are the thoughts around handling stderr?

In some cases it is just junk if not wrapped in a proper message (i.e.,
there can be a requirement that error log be completely parseable and/or a
requirement that stderr has timestamps or other info).  But it seems to
require a thread of execution to implement that in order to avoid blocking
the writer.  (Recently I encountered a situation where a third-party module
called some library during httpd init that wrote an initialization message
directly to stderr, and the message was stuck in the stdio buffer and
forked into every child process for later, multiple appearances :) )

I guess an error log provider could be given the opportunity to route
stderr wherever it wants, but that doesn't handle the existing suckage of
random, un-timestamped stuff in the log for normal configurations.  I guess
you could have mod_stderr that may or may not be enabled if you wanted
stderr handled more cleanly (groan), whether or not you had a provider for
ap_log calls.







 Thanks,
 Jan Kaluza


 On Thu, Oct 17, 2013 at 8:33 AM, Plüm, Rüdiger, Vodafone Group
 ruediger.pl...@vodafone.com mailto:ruediger.pl...@vodafone.com
 wrote:



   -Original Message-
   From: Jan Kaluža
   Sent: Donnerstag, 17. Oktober 2013 13:21
   To: dev@httpd.apache.org mailto:dev@httpd.apache.org
   Subject: Re: error log providers, multiple vhosts, mod_syslog
  
   There's another problem with log providers and vhosts and I think
 I have
   no idea how to fix it without doing dirty hacks...
  
   The problem is with ap_open_logs function, which does following:
  
   1. Main server log is opened (open_error_log()). If this log uses
 error
   log provider, s_main-error_log is set to NULL.
  
   2. When there is no s_main-error_log, stderr is redirected to
 /dev/null.

 Hmm. This points out another issue when using an error log provider
 for the main server log:
 We lose everything that the server or other programs like
 CGI-scripts write to the stderr FD as it
 is simply written to /dev/null. Don't we need to have a separate
 process in this case that
 like a piped logger reads from the reading end of the stderr pipe
 and writes it
 via ap_server_conf-errorlog_provider-writer to the log?

  
   3. Error logs for vhosts are opened (another open_error_log()).
 If there
   is some problem when opening these logs, any ap_log_error() call
 is sent
   to /dev/null.

 Wouldn't it try to call s-errorlog_provider-writer in line 1196
 and Segfault if s-errorlog_provider
 is NULL because of some bad classic configuration that simply
 failed?

 Regards

 Rüdiger




 --
 Born in Roswell... married an alien...
 http://emptyhammock.com/





 --
 Born in Roswell... married an alien...
 http://emptyhammock.com/




-- 
Born in Roswell... married an alien...
http://emptyhammock.com/


apache sql module with suexec

2013-11-06 Thread Donatas Abraitis
Hello,

I'm trying to write a module which would work with httpd.worker. It will
per-request fetch row from mysql returning documentroot, servername, user,
group.

How can I setuid(), setgid()?

I have fetched these user/group from DB using mod_dbd module and now want
to set using suEXEC these user/group.

   apr_uid_t _uid;
   apr_gid_t _gid;
   apr_uid_current(_uid, _gid, r-pool);
   ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, apt_user/group:
%d/%d, _uid, _gid);

   if(setuid(500)) {
  ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, apt_user:
%d, getuid());
   }

Apache log gives:

[Wed Nov 06 10:16:42 2013] [crit] [client X] user: ton
[Wed Nov 06 10:16:42 2013] [crit] [client X] apt_user/group: 48/48
[Wed Nov 06 10:16:42 2013] [crit] [client X] apt_user: 48
[Wed Nov 06 10:16:42 2013] [crit] [client X] group: group-ton

-- 
Donatas


Re: mod_proxy reverse proxying and AH01179: balancer slotmem_create failed

2013-11-06 Thread Jim Jagielski
try this:


slotmem.patch
Description: Binary data


On Nov 6, 2013, at 9:59 AM, Thomas Eckert thomas.r.w.eck...@gmail.com wrote:

 It is not mentioned specifically in the configuration files, so it defaults 
 to Off according to 
 http://httpd.apache.org/docs/current/mod/mod_proxy.html#balancerpersist
 
 
 On Wed, Nov 6, 2013 at 3:44 PM, Jim Jagielski j...@jagunet.com wrote:
 Is BalancerPersist Off or On?
 
 Those .shm files should only stick around if we want to
 persist state across restarts.
 
 On Nov 6, 2013, at 8:39 AM, Thomas Eckert thomas.r.w.eck...@gmail.com wrote:
 
  As of late I'm seeing a lot of
 
AH01179: balancer slotmem_create failed
 
  error messages which prevent apache2 from starting. I do have
 
DefaultRuntimeDir /var/run/apache2
 
  set. For some reasons there appear to be left-over .shm files in the 
  DefaultRunTimeDir between stop-starts/restarts which then get picked up by 
  mod_slotmem when mod_proxy asks it for shared memory. Unfortunately, those 
  .shm files sometimes have the wrong size and get rejected by the 
  mod_slotmem code due to size mismatch.
 
  To me it looks like this situation suffers from the same issue as reported 
  in https://issues.apache.org/bugzilla/show_bug.cgi?id=55449
  though I only have one user (nobody) for all the worker processes.
 
  I get the systems back up and running by deleting all .shm files in the 
  DefaultRunTimeDir between stop-starts/restarts but this seems fragile to 
  me. Another workaround, as crude as it is, seems to be disabling the 
  reusing of existing shared memory segments by setting
 
fbased = 0;
 
  in modules/slotmem/mod_slotmem_shm.c in slotmem_create().
 
  Neither of those two appraoches seems right to me. I do need at least a 
  temporary workaround since this is causing major havoc.
 
 



Re: error log providers, multiple vhosts, mod_syslog

2013-11-06 Thread William A. Rowe Jr.
On Wed, 6 Nov 2013 10:05:25 -0500
Jeff Trawick traw...@gmail.com wrote:
 
 What are the thoughts around handling stderr?
 
 In some cases it is just junk if not wrapped in a proper message
 (i.e., there can be a requirement that error log be completely
 parseable and/or a requirement that stderr has timestamps or other
 info).  But it seems to require a thread of execution to implement
 that in order to avoid blocking the writer.  (Recently I encountered
 a situation where a third-party module called some library during
 httpd init that wrote an initialization message directly to stderr,
 and the message was stuck in the stdio buffer and forked into every
 child process for later, multiple appearances :) )
 
 I guess an error log provider could be given the opportunity to route
 stderr wherever it wants, but that doesn't handle the existing
 suckage of random, un-timestamped stuff in the log for normal
 configurations.  I guess you could have mod_stderr that may or may
 not be enabled if you wanted stderr handled more cleanly (groan),
 whether or not you had a provider for ap_log calls.

The windows nt event logging logic faced the same issue (and was the
reason for the early _commit() call :), so stderr is shifted to a pipe
to 'decorate' it into the event log queue, which would look very similar
for timestamps/other annotations into a syslog provider.