Setting the 'Server' header from my module

2009-01-11 Thread Jason Fister
Hi,

I am trying to set the 'Server' http header from within the module. I tried
the following:

apr_table_setn(request-headers_out, Server, MyServer);

but thats not working. I basically want to set a specific value for the
'Server' header.

I also looked in to mod_headers and tried

Header set Server MyServer

even that didn't work. Looks like the value of the 'Server' header is
getting set sometime much later and it overwrites the value that I am
setting.

If I should be sending this email to a different list, please let me know.


Jason


Re: Setting the 'Server' header from my module

2009-01-11 Thread Jason Fister

 This happens in ap_http_header_filter (the output filter that writes
 the headers when you first try to write some body).

 It looks like trunk will preserve a pre-existing header, but 2.2.x and
 earlier do not.


Eric...thanks for that information.

On further 'googling', I found this link which solved my problem.
http://www.onlamp.com/pub/a/apache/2004/09/23/apacheckbk.html


Thanks,
Jason


mod_lua headers_out

2009-01-11 Thread Bertrand Mansion
Hi,

My name is Bertrand Mansion, I live in Paris, France, I have been
mostly programming in PHP for the last few years and I am very excited
about mod_lua since I consider Lua is superior in many ways. I have
followed the development of mod_wombat and noticed that you changed
the way headers_in and headers_out are accessed, they were previously
tables, now only headers_in can be accessed through a headers_in()
method. I have written a method to have access to headers_out as well.
I am not sure it is perfect since I haven't coded with Lua and apr C
APIs before and many you thought already about something more clever.

Anyway, with this patch, you can do:
r:headers_out('Location', 'http://www.example.com') -- set the Location header
r:headers_out('Location) -- return the current value for header Location
r:headers_out('Location', nil) -- unset the Location header

There might be other options I haven't implemented for example:

r.headers_out['Location'] = 'http://www.example.com' -- like in
previous versions of mod_wombat
  or
r:headers_out{Location = 'http://www.example.com} -- but then it
becomes harder to unset a header (?)
  or
r.headers_out:set('Location', 'http://www.example.com')
r.headers_out:get('Location')
r.headers_out:unset('Location')

HTH

-
Bertrand Mansion
Mamasam
--- lua_request.c
+++ (clipboard)
@@ -447,6 +447,41 @@
 return 1;
 }
 
+static int req_headers_out(lua_State *L)
+{
+const char *key;
+const char *value;
+
+request_rec *r = apl_check_request_rec(L, 1);
+
+key = luaL_checkstring(L, 2);
+
+if (lua_isnone(L, 3) == 1) {
+/* getting a value from headers_out */
+value = apr_table_get(r-headers_out, key);
+if (value) {
+lua_pushstring(L, value);
+}
+else {
+lua_pushnil(L);
+}
+}
+else {
+if (lua_isnil(L, 3) == 1) {
+value = apr_table_get(r-headers_out, key);
+if (value) {
+apr_table_unset(r-headers_out, key);
+}
+}
+else {
+value = luaL_checkstring(L, 3);
+apr_table_set(r-headers_out, key, value);
+}
+}
+
+return 1;
+}
+
 /* handle r.status = 201 */
 static int req_newindex(lua_State *L)
 {
@@ -604,6 +639,8 @@
 
 apr_hash_set(dispatch, headers_in, APR_HASH_KEY_STRING,
  makefun(req_headers_in, APL_REQ_FUNTYPE_LUACFUN, p));
+apr_hash_set(dispatch, headers_out, APR_HASH_KEY_STRING,
+ makefun(req_headers_out, APL_REQ_FUNTYPE_LUACFUN, p));
 
 lua_pushlightuserdata(L, dispatch);
 lua_setfield(L, LUA_REGISTRYINDEX, Apache2.Request.dispatch);
@@ -668,4 +705,4 @@
 lua_boxpointer(L, r);
 luaL_getmetatable(L, Apache2.Request);
 lua_setmetatable(L, -2);
-}
\ No newline at end of file
+}


Re: svn commit: r733476 - /httpd/httpd/trunk/support/rotatelogs.c

2009-01-11 Thread Ruediger Pluem


On 01/11/2009 03:05 PM, rj...@apache.org wrote:
 Author: rjung
 Date: Sun Jan 11 06:05:39 2009
 New Revision: 733476
 
 URL: http://svn.apache.org/viewvc?rev=733476view=rev
 Log:
 Refactor rotatelogs to allow easier implementation
 of signal triggered log rotation.
 
 - move code into new functions checkRotate() and doRotate()
 - bundle config data and runtime data in two structs to
   allow easier passing to functions
 - Simplify bypass_io logic as a first use case for doRotate
   and rename flag to force_open to reflect the new logic
 
 
 Modified:
 httpd/httpd/trunk/support/rotatelogs.c
 
 Modified: httpd/httpd/trunk/support/rotatelogs.c
 URL: 
 http://svn.apache.org/viewvc/httpd/httpd/trunk/support/rotatelogs.c?rev=733476r1=733475r2=733476view=diff
 ==
 --- httpd/httpd/trunk/support/rotatelogs.c (original)
 +++ httpd/httpd/trunk/support/rotatelogs.c Sun Jan 11 06:05:39 2009
 @@ -64,6 +64,37 @@
  #define MAX_PATH1024
  #endif
  
 +typedef struct rotate_config rotate_config_t;
 +
 +struct rotate_config {
 +unsigned int sRotation;
 +int tRotation;
 +int utc_offset;
 +int use_localtime;
 +int use_strftime;
 +int force_open;
 +const char *szLogRoot;
 +};
 +
 +typedef struct rotate_status rotate_status_t;
 +
 +struct rotate_status {
 +apr_pool_t *pool;
 +apr_pool_t *pfile;
 +apr_pool_t *pfile_prev;
 +apr_file_t *nLogFD;
 +apr_file_t *nLogFDprev;
 +char filename[MAX_PATH];
 +char errbuf[ERRMSGSZ];
 +int needsRotate;
 +int tLogEnd;
 +int now;
 +int nMessCount;
 +};
 +
 +static rotate_config_t config;
 +static rotate_status_t status;

Why do they need to be global?

 +
  static void usage(const char *argv0, const char *reason)
  {
  if (reason) {
 @@ -110,22 +141,114 @@
  return (int)apr_time_sec(tNow) + utc_offset;
  }
  
 +void checkRotate(rotate_config_t *config, rotate_status_t *status) {
 +
 +if (status-nLogFD == NULL)
 +return;

No need to do further checks for status-nLogFD != NULL below.

 +if (config-tRotation) {
 +status-now = get_now(config-use_localtime, config-utc_offset);
 +if (status-nLogFD != NULL  status-now = status-tLogEnd) {
 +status-needsRotate = 1;
 +}
 +}
 +else if (config-sRotation) {
 +apr_finfo_t finfo;
 +apr_off_t current_size = -1;
 +
 +if ((status-nLogFD != NULL) 
 +(apr_file_info_get(finfo, APR_FINFO_SIZE, status-nLogFD) == 
 APR_SUCCESS)) {
 +current_size = finfo.size;
 +}
 +
 +if (current_size  config-sRotation) {
 +status-needsRotate = 1;
 +}
 +}
 +else {
 +fprintf(stderr, No rotation time or size specified\n);
 +exit(2);
 +}
 +
 +return;
 +}
 +

Regards

RĂ¼diger


Re: svn commit: r733476 - /httpd/httpd/trunk/support/rotatelogs.c

2009-01-11 Thread Rainer Jung

On 11.01.2009 15:53, Ruediger Pluem wrote:


On 01/11/2009 03:05 PM, rj...@apache.org wrote:

Author: rjung
Date: Sun Jan 11 06:05:39 2009
New Revision: 733476

URL: http://svn.apache.org/viewvc?rev=733476view=rev
Log:
Refactor rotatelogs to allow easier implementation
of signal triggered log rotation.

- move code into new functions checkRotate() and doRotate()
- bundle config data and runtime data in two structs to
   allow easier passing to functions
- Simplify bypass_io logic as a first use case for doRotate
   and rename flag to force_open to reflect the new logic


Modified:
 httpd/httpd/trunk/support/rotatelogs.c

Modified: httpd/httpd/trunk/support/rotatelogs.c
URL: 
http://svn.apache.org/viewvc/httpd/httpd/trunk/support/rotatelogs.c?rev=733476r1=733475r2=733476view=diff
==
--- httpd/httpd/trunk/support/rotatelogs.c (original)
+++ httpd/httpd/trunk/support/rotatelogs.c Sun Jan 11 06:05:39 2009
@@ -64,6 +64,37 @@
  #define MAX_PATH1024
  #endif

+typedef struct rotate_config rotate_config_t;
+
+struct rotate_config {
+unsigned int sRotation;
+int tRotation;
+int utc_offset;
+int use_localtime;
+int use_strftime;
+int force_open;
+const char *szLogRoot;
+};
+
+typedef struct rotate_status rotate_status_t;
+
+struct rotate_status {
+apr_pool_t *pool;
+apr_pool_t *pfile;
+apr_pool_t *pfile_prev;
+apr_file_t *nLogFD;
+apr_file_t *nLogFDprev;
+char filename[MAX_PATH];
+char errbuf[ERRMSGSZ];
+int needsRotate;
+int tLogEnd;
+int now;
+int nMessCount;
+};
+
+static rotate_config_t config;
+static rotate_status_t status;


Why do they need to be global?


I need them in the signal handler which will be introduced as the next 
step. The signal handler will allow to trigger rotation from outside.


...

+void checkRotate(rotate_config_t *config, rotate_status_t *status) {
+
+if (status-nLogFD == NULL)
+return;


No need to do further checks for status-nLogFD != NULL below.


Right, will be gone in the next commit.




Re: Graceful restart not so graceful?

2009-01-11 Thread Stefan Fritsch
Hi,

thanks for following up on this and sorry for the late response.

On Wednesday 07 January 2009, Jeff Trawick wrote:
 Initial testing of your idea for a timeout was promising.

I couldn't reproduce any hangs under linux with the patch you commited 
to trunk.

In my patch I tried to avoid that an idle apache wakes periodically 
for no good reasons. But if you don't think that is a problem, please 
backport your patch to 2.2.x.

Cheers,
Stefan


Re: mod_lua headers_out

2009-01-11 Thread Brian McCallister
On Sun, Jan 11, 2009 at 4:21 AM, Bertrand Mansion bmans...@mamasam.net wrote:

.. snip ..

 I have
 followed the development of mod_wombat and noticed that you changed
 the way headers_in and headers_out are accessed, they were previously
 tables

I would actually prefer to make them tables again -- in particular, to
put the  apr_table_t instance directly in as a boxed userdata.

Paul, any particular reason for making it a function rather than userdata?


 Anyway, with this patch, you can do:
 r:headers_out('Location', 'http://www.example.com') -- set the Location header
 r:headers_out('Location) -- return the current value for header Location
 r:headers_out('Location', nil) -- unset the Location header

 There might be other options I haven't implemented for example:

 r.headers_out['Location'] = 'http://www.example.com' -- like in
 previous versions of mod_wombat
  or
 r:headers_out{Location = 'http://www.example.com} -- but then it
 becomes harder to unset a header (?)
  or
 r.headers_out:set('Location', 'http://www.example.com')
 r.headers_out:get('Location')
 r.headers_out:unset('Location')

 HTH

 -
 Bertrand Mansion
 Mamasam



Re: Transfer Patch Rights for mod_fcgid ASF

2009-01-11 Thread pqf
Hi,
From the thread I get here: 
http://mail-archives.apache.org/mod_mbox/httpd-dev/200611.mbox/%3cdb4ef19e-148b-41a3-a27c-354b0d640...@gbiv.com%3e

The procedure is:

   (1) make this thread a formal vote

and, assuming that passes

   (2) fill out the incubation paperwork at
   http://incubator.apache.org/ip-clearance/index.html

and then

   (3) import the code under httpd/mod_wombat

Should someone start a vote or further discussion is needed?

Thanks


- Original Message - 
From: William A. Rowe, Jr. wr...@rowe-clan.net
To: dev@httpd.apache.org
Sent: Sunday, January 11, 2009 2:15 AM
Subject: Re: Transfer Patch Rights for mod_fcgid ASF


 Chris Darroch wrote:
 pqf wrote:
 
 Now both authors have subscribe this maillist and claimed to transfer
 all rights to the patch
 to the Apache Software Foundation, is it OK? Can we move forward now?
 
   Excellent question -- it would seem we have resolved the outstanding
 issues here, so what is the next step?  If we're looking to fast-track
 adoption, do we submit something to the httpd PMC, the Incubator, or
 some other body?  Take a vote?  Any guidance appreciated!
 
 Go ahead and review the threads under;
 
 http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fhttpd-dev+%22ip+clearance%22+mod_wombatie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:officialclient=firefox-a
 
 which is a pretty recent example.


accept mod_fcgid codebase into httpd project

2009-01-11 Thread William A. Rowe, Jr.
Based on the enthusiasm of the module authors to adopt the AL and offer
the mod_fcgid code to the httpd community, please vote

  +/-1
  [  ]  Accept mod_fcgid into httpd



Re: accept mod_fcgid codebase into httpd project

2009-01-11 Thread William A. Rowe, Jr.
   [+1]  Accept mod_fcgid into httpd

from me


Re: accept mod_fcgid codebase into httpd project

2009-01-11 Thread Albert Lash
+1

On Sun, Jan 11, 2009 at 10:53 PM, William A. Rowe, Jr.
wr...@rowe-clan.net wrote:
 Based on the enthusiasm of the module authors to adopt the AL and offer
 the mod_fcgid code to the httpd community, please vote

  +/-1
  [  ]  Accept mod_fcgid into httpd




patch for handling headers_in and headers_out as tables in mod_lua

2009-01-11 Thread Brian McCallister
The attached patch changes headers_in and headers_out handling in
mod_lua as boxed userdata rather than functions.

Basically we go from:

-- OLD
function handle(r)
  local host = r.headers_in(host)
  r:puts(host)
end

to

-- NEW
function handle(r)
  local host = r.headers_in['host']
  r:puts(host)

  -- and can now modify them
  r.headers_in['X-XX-Fake'] = 'rabbits!'
  r.headers_out['wombat'] = 'lua now!'
end

In order to treat tables idiommatically, it also corrects the
apl_push_apr_table(..) function to behave as a regular lua style push
function instead of a set function.

-Brian


apr_table_and_headers_in.patch
Description: Binary data


Re: mod_lua headers_out

2009-01-11 Thread Brian McCallister
Bertrand,

I just send in a patch on the message with subject patch for handling
headers_in and headers_out as tables in mod_lua which takes knowledge
of setting headers_in, headers_out off the request which, with that
patch, can just push the apr_table_t as a boxed pointer allowing
lua-style [] access and modification.

Does that work?

-Brian

On Sun, Jan 11, 2009 at 4:21 AM, Bertrand Mansion bmans...@mamasam.net wrote:
 Hi,

 My name is Bertrand Mansion, I live in Paris, France, I have been
 mostly programming in PHP for the last few years and I am very excited
 about mod_lua since I consider Lua is superior in many ways. I have
 followed the development of mod_wombat and noticed that you changed
 the way headers_in and headers_out are accessed, they were previously
 tables, now only headers_in can be accessed through a headers_in()
 method. I have written a method to have access to headers_out as well.
 I am not sure it is perfect since I haven't coded with Lua and apr C
 APIs before and many you thought already about something more clever.

 Anyway, with this patch, you can do:
 r:headers_out('Location', 'http://www.example.com') -- set the Location header
 r:headers_out('Location) -- return the current value for header Location
 r:headers_out('Location', nil) -- unset the Location header

 There might be other options I haven't implemented for example:

 r.headers_out['Location'] = 'http://www.example.com' -- like in
 previous versions of mod_wombat
  or
 r:headers_out{Location = 'http://www.example.com} -- but then it
 becomes harder to unset a header (?)
  or
 r.headers_out:set('Location', 'http://www.example.com')
 r.headers_out:get('Location')
 r.headers_out:unset('Location')

 HTH

 -
 Bertrand Mansion
 Mamasam



Re: accept mod_fcgid codebase into httpd project

2009-01-11 Thread Brian McCallister
+1

On Sun, Jan 11, 2009 at 7:55 PM, Albert Lash albert.l...@gmail.com wrote:
 +1

 On Sun, Jan 11, 2009 at 10:53 PM, William A. Rowe, Jr.
 wr...@rowe-clan.net wrote:
 Based on the enthusiasm of the module authors to adopt the AL and offer
 the mod_fcgid code to the httpd community, please vote

  +/-1
  [  ]  Accept mod_fcgid into httpd





Bug report for Apache httpd-1.3 [2009/01/11]

2009-01-11 Thread bugzilla
+---+
| Bugzilla Bug ID   |
| +-+
| | Status: UNC=Unconfirmed NEW=New ASS=Assigned|
| | OPN=ReopenedVER=Verified(Skipped Closed/Resolved)   |
| |   +-+
| |   | Severity: BLK=Blocker CRI=Critical  REG=Regression  MAJ=Major   |
| |   |   MIN=Minor   NOR=NormalENH=Enhancement TRV=Trivial |
| |   |   +-+
| |   |   | Date Posted |
| |   |   |  +--+
| |   |   |  | Description  |
| |   |   |  |  |
|10744|New|Nor|2002-07-12|suexec might fail to open log file|
|10747|New|Maj|2002-07-12|ftp SIZE command and 'smart' ftp servers results i|
|10760|New|Maj|2002-07-12|empty ftp directory listings from cached ftp direc|
|14518|Opn|Reg|2002-11-13|QUERY_STRING parts not incorporated by mod_rewrite|
|16013|Opn|Nor|2003-01-13|Fooling mod_autoindex + IndexIgnore   |
|16631|Inf|Min|2003-01-31|.htaccess errors logged outside the virtual host l|
|17318|Inf|Cri|2003-02-23|Abend on deleting a temporary cache file if proxy |
|19279|Inf|Min|2003-04-24|Invalid chmod options in solaris build|
|21637|Inf|Nor|2003-07-16|Timeout causes a status code of 200 to be logged  |
|21777|Inf|Min|2003-07-21|mod_mime_magic doesn't handle little gif files|
|22618|New|Maj|2003-08-21|MultiViews invalidates PATH_TRANSLATED if cgi-wrap|
|25057|Inf|Maj|2003-11-27|Empty PUT access control in .htaccess overrides co|
|26126|New|Nor|2004-01-14|mod_include hangs with request body   |
|26152|Ass|Nor|2004-01-15|Apache 1.3.29 and below directory traversal vulner|
|26790|New|Maj|2004-02-09|error deleting old cache file |
|29257|Opn|Nor|2004-05-27|Problem with apache-1.3.31 and mod_frontpage (dso,|
|29498|New|Maj|2004-06-10|non-anonymous ftp broken in mod_proxy |
|29538|Ass|Enh|2004-06-12|No facility used in ErrorLog to syslog|
|30207|New|Nor|2004-07-20|Piped logs don't close read end of pipe   |
|30877|New|Nor|2004-08-26|htpasswd clears passwd file on Sun when /var/tmp i|
|30909|New|Cri|2004-08-28|sporadic segfault resulting in broken connections |
|31975|New|Nor|2004-10-29|httpd-1.3.33: buffer overflow in htpasswd if calle|
|32078|New|Enh|2004-11-05|clean up some compiler warnings   |
|32539|New|Trv|2004-12-06|[PATCH] configure --enable-shared= brocken on SuSE|
|32974|Inf|Maj|2005-01-06|Client IP not set |
|33086|New|Nor|2005-01-13|unconsistency betwen 404 displayed path and server|
|33495|Inf|Cri|2005-02-10|Apache crashes with WSADuplicateSocket failed for|
|33772|New|Nor|2005-02-28|inconsistency in manual and error reporting by sue|
|33875|New|Enh|2005-03-07|Apache processes consuming CPU|
|34108|New|Nor|2005-03-21|mod_negotiation changes mtime to mtime of Document|
|34114|New|Nor|2005-03-21|Apache could interleave log entries when writing t|
|34404|Inf|Blk|2005-04-11|RewriteMap prg can not handle fpout   |
|34571|Inf|Maj|2005-04-22|Apache 1.3.33 stops logging  vhost|
|34573|Inf|Maj|2005-04-22|.htaccess not working / mod_auth_mysql|
|35424|New|Nor|2005-06-20|httpd disconnect in Timeout on CGI|
|35439|New|Nor|2005-06-21|Problem with remove /../ in util.c and mod_rewri|
|35547|Inf|Maj|2005-06-29|Problems with libapreq 1.2 and Apache::Cookie |
|3|New|Nor|2005-06-30|Can't find DBM on Debian Sarge|
|36375|Opn|Nor|2005-08-26|Cannot include http_config.h from C++ file|
|37166|New|Nor|2005-10-19|Under certain conditions, mod_cgi delivers an empt|
|37185|New|Enh|2005-10-20|AddIcon, AddIconByType for OpenDocument format|
|37252|New|Reg|2005-10-26|gen_test_char reject NLS string   |
|38989|New|Nor|2006-03-15|restart + piped logs stalls httpd for 24 minutes (|
|39104|New|Enh|2006-03-25|[FR] fix build with -Wl,--as-needed   |
|39287|New|Nor|2006-04-12|Incorrect If-Modified-Since validation (due to syn|
|39937|New|Nor|2006-06-30|Garbage output if README.html is gzipped or compre|
|40176|New|Nor|2006-08-03|magic and mime|
|40224|Ver|Nor|2006-08-10|System time crashes Apache @year 2038 (win32 only?|
|41279|New|Nor|2007-01-02|Apache 1.3.37 htpasswd is vulnerable to buffer ove|
|42355|New|Maj|2007-05-08|Apache 1.3 permits non-rfc HTTP error code = 600 |
|43626|New|Maj|2007-10-15|r-path_info returning invalid value  |