You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Alan Olsen <al...@clueserver.org> on 2000/04/25 23:29:10 UTC

[PATCH] Adding referer info to error_log

I wrote this to help debug a bunch of contractor-provided web pages.  We
had lots of error messages of missing images and pages, with no clue of
where to find what was referencing the page.  (I find it strange that you
can modify every log file in Apache *except* the error_log.  Any reason
for this or just an oversight? (But if you speced it wrong, where would
you write the errors?))

Disclaimer: 
This is real quick and dirty.  It took less than 15 minutes to research
and write.  It seems to work fine on my machine, but who knows what it
will do to yours.  It probably has at least one thing done wrong.  The
patch parameters are probably wrong, but since it has been many years
since I have generated a patch, you get what you pay for.

The file being modified is src/main/http_log.c.

------- cut here ----------

--- http_log.c	Wed Feb  2 12:43:49 2000
+++ http_log.c.new	Tue Apr 25 02:04:33 2000
@@ -388,6 +388,11 @@
 	len += ap_snprintf(errstr + len, sizeof(errstr) - len,
 		"[client %s] ", r->connection->remote_ip);
     }
+    if (r && r->headers_in) {
+        /* A hack to add referer to error_log - aro 04/24/00 */
+        len += ap_snprintf(errstr + len, sizeof(errstr) - len,
+                "[referer %s] ", ap_table_get(r->headers_in,"Referer") );
+    }
     if (!(level & APLOG_NOERRNO)
 	&& (save_errno != 0)
 #ifdef WIN32


---- end of patch condition reached ---


alan@ctrl-alt-del.com | Note to AOL users: for a quick shortcut to reply
Alan Olsen            | to my mail, just hit the ctrl, alt and del keys.
    "In the future, everything will have its 15 minutes of blame."


Re: [PATCH 2.0] difftime for apr (was Short list of stuff to consider pre alpha)

Posted by Jeff Trawick <tr...@bellsouth.net>.
> From: "William A. Rowe, Jr." <wr...@lnd.com>
> Date: Sat, 15 Apr 2000 20:50:25 -0500
> Content-Type: text/plain;
> 	charset="iso-8859-1"
> X-Priority: 3 (Normal)
> X-MSMail-Priority: Normal
> Importance: Normal
> X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
> X-UIDL: f9da2c964ac0833710d272b8719405c9
> 
> > Personally, I don't think ap_difftime() is so necessary but it won't
> > hurt my feelings if it goes in.
> 
> I can see situations (login duration) where the desired result is
> more like 60 minutes.  To make things clearer, what would you think
> of the 32 bit function to be named ap_short_difftime(), to distinguish
> that it cannot be a very large interval?

But then you'd want to rename ap_interval_time_t to
ap_short_interval_time_t too, right :) ?


-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

RE: [PATCH 2.0] difftime for apr (was Short list of stuff to consider pre alpha)

Posted by "William A. Rowe, Jr." <wr...@lnd.com>.
> Hmmm...  I get more than 35 seconds worth of microseconds.  Feel free
> to correct my math.
 
Obviously... my brain was elsewhere for that note...

> That is good enough for me, and I don't need to make those 32-bit
> processors work very hard to pass it around and perform arithmetic
> operations with it.
> 
> Personally, I don't think ap_difftime() is so necessary but it won't
> hurt my feelings if it goes in.

I can see situations (login duration) where the desired result is
more like 60 minutes.  To make things clearer, what would you think
of the 32 bit function to be named ap_short_difftime(), to distinguish
that it cannot be a very large interval?

Re: [PATCH 2.0] difftime for apr (was Short list of stuff to consider pre alpha)

Posted by Jeff Trawick <tr...@bellsouth.net>.
> > From: William A. Rowe, Jr. [mailto:wrowe@lnd.com]
> > Sent: Thursday, April 27, 2000 1:00 PM
> > 
> > Suggestions (I won't have extra time on this till next week, 
> > but really
> > want to see some of this in the new package, all builds, there is one
> > odd error left in the win32 build, relating to the poll changes, that
> > I don't have time to look at) -
> 
> I'm following up, since there is one set within these suggestions
> that I'm loath to implement until some others take a look;
> 
> > 6) add ap_difftime... but this really points out the weakness of this type!
> >    I really, really believe that ap_interval_time_t must be 64 bits,
> >    but that's a patch in and of itself, with some cpu ramifications.
> > 
> > 8) fix up mod_auth_digest.c - but this requires some VERY CAREFUL review.
> >    Not that it was any good with times before... but let's assure it is right.
> 
> Using the current declarations, ap_interval_time_t is restricted to just a little
> over 35 seconds... that's rather absurd!  I don't like the patch for that reason,
> but I'm not about to go flipping ap_interval_time_t to 64 bits without some more
> feedback from other platforms.

Hmmm...  I get more than 35 seconds worth of microseconds.  Feel free
to correct my math.

Let's calculate...  A 32-bit signed integer can store up to 
2,147,483,647 microseconds.  Divide that by the number of microseconds
in a second (1,000,000) and you get 2,147 seconds worth of
microseconds in an ap_interval_time_t.  That is 35 minutes and 46-odd
seconds. 

That is good enough for me, and I don't need to make those 32-bit
processors work very hard to pass it around and perform arithmetic
operations with it.

Personally, I don't think ap_difftime() is so necessary but it won't
hurt my feelings if it goes in.

Have fun,

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

RE: [PATCH 2.0] difftime for apr (was Short list of stuff to consider pre alpha)

Posted by "William A. Rowe, Jr." <wr...@lnd.com>.
> From: William A. Rowe, Jr. [mailto:wrowe@lnd.com]
> Sent: Thursday, April 27, 2000 1:00 PM
> 
> Suggestions (I won't have extra time on this till next week, 
> but really
> want to see some of this in the new package, all builds, there is one
> odd error left in the win32 build, relating to the poll changes, that
> I don't have time to look at) -

I'm following up, since there is one set within these suggestions
that I'm loath to implement until some others take a look;

> 6) add ap_difftime... but this really points out the weakness of this type!
>    I really, really believe that ap_interval_time_t must be 64 bits,
>    but that's a patch in and of itself, with some cpu ramifications.
> 
> 8) fix up mod_auth_digest.c - but this requires some VERY CAREFUL review.
>    Not that it was any good with times before... but let's assure it is right.

Using the current declarations, ap_interval_time_t is restricted to just a little
over 35 seconds... that's rather absurd!  I don't like the patch for that reason,
but I'm not about to go flipping ap_interval_time_t to 64 bits without some more
feedback from other platforms.



[PATCH 2.0] Short list of stuff to consider pre alpha (since some is broke already)

Posted by "William A. Rowe, Jr." <wr...@lnd.com>.
Suggestions (I won't have extra time on this till next week, but really
want to see some of this in the new package, all builds, there is one
odd error left in the win32 build, relating to the poll changes, that
I don't have time to look at) -

1) create an ap_base64.h to extract those declarations from ap.h

2) CORE_PRIVATE doesn't belong in library functions, remove from ap_base64.c

3) use apr headers for declarations in ap.lib stuff
   *** why was this undone in support/htdigest.c, ryan?

4) crossed up declarations of strcasecmp fixed with proper HAVE_STRCASECMP
   declarations where that assignment is made in os/win32/os.h
   Eliminates a ton of compiler errors.

5) clean up windows headers in apr... we really need only a limited subset.
   We can restrict more later.

6) add ap_difftime... but this really points out the weakness of this type!
   I really, really believe that ap_interval_time_t must be 64 bits,
   but that's a patch in and of itself, with some cpu ramifications.

7) fix a lingering ungetch reference.

8) fix up mod_auth_digest.c - but this requires some VERY CAREFUL review.
   Not that it was any good with times before... but let's assure it is right.

9) fix up mod_isapi - lots of flakey things (setting last error to 0? ...
   I don't have time to review today, so created TODO_ERROR to mark those
   that need review.  ERROR didn't mean what the coder intended.)

Index: apache-2.0/src/include/ap_base64.h
=== Begin New File ap_base64.h ====================================
/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * The ap_vsnprintf/ap_snprintf functions are based on, and used with the
 * permission of, the  SIO stdio-replacement strx_* functions by Panos
 * Tsirigotis <pa...@alumni.cs.colorado.edu> for xinetd.
 */

#ifndef APACHE_BASE64_H
#define APACHE_BASE64_H

#ifdef __cplusplus
extern "C" {
#endif

/* Simple BASE64 encode/decode functions.
 * 
 * As we might encode binary strings, hence we require the length of
 * the incoming plain source. And return the length of what we decoded.
 *
 * The decoding function takes any non valid char (i.e. whitespace, \0
 * or anything non A-Z,0-9 etc as terminal.
 * 
 * plain strings/binary sequences are not assumed '\0' terminated. Encoded
 * strings are neither. But propably should.
 *
 */
API_EXPORT(int) ap_base64encode_len(int len);
API_EXPORT(int) ap_base64encode(char * coded_dst, const char *plain_src,int len_plain_src);
API_EXPORT(int) ap_base64encode_binary(char * coded_dst, const unsigned char *plain_src,int len_plain_src);

API_EXPORT(int) ap_base64decode_len(const char * coded_src);
API_EXPORT(int) ap_base64decode(char * plain_dst, const char *coded_src);
API_EXPORT(int) ap_base64decode_binary(unsigned char * plain_dst, const char *coded_src);

#ifdef __cplusplus
}
#endif

#endif	/* !APACHE_BASE64_H */
--- End new file ap_base64.h --------------------------------------

Index: apache-2.0/src/ap/ap_base64.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/ap/ap_base64.c,v
retrieving revision 1.6
diff -u -r1.6 ap_base64.c
--- ap_base64.c	2000/04/07 02:45:11	1.6
+++ ap_base64.c	2000/04/27 15:12:57
@@ -62,12 +62,9 @@
  * ugly 'len' functions, which is quite a nasty cost.
  */
 
-#define CORE_PRIVATE
-#include <string.h>
-
 #include "ap.h"
+#include "ap_base64.h"
 
-#include "ap_config.h"
 #ifdef CHARSET_EBCDIC
 #include "ebcdic.h"
 #endif				/* CHARSET_EBCDIC */
Index: apache-2.0/src/ap/ap_sha1.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/ap/ap_sha1.c,v
retrieving revision 1.6
diff -u -r1.6 ap_sha1.c
--- ap_sha1.c	2000/03/31 07:02:31	1.6
+++ ap_sha1.c	2000/04/27 15:12:59
@@ -82,12 +82,11 @@
  *	This code is hereby placed in the public domain
  */
 
-#include <string.h>
 
-#include "ap_config.h"
-#include "httpd.h"
-#include "ap_sha1.h"
 #include "ap.h"
+#include "ap_base64.h"
+#include "ap_sha1.h"
+#include "apr_lib.h"
 #ifdef CHARSET_EBCDIC
 #include "ebcdic.h"
 #endif /*CHARSET_EBCDIC*/
Index: apache-2.0/src/include/ap.h
===================================================================
RCS file: /cvs/apache/apache-2.0/src/include/ap.h,v
retrieving revision 1.10
diff -u -r1.10 ap.h
--- ap.h	2000/03/31 07:18:46	1.10
+++ ap.h	2000/04/27 15:13:00
@@ -50,10 +50,6 @@
  * individuals on behalf of the Apache Software Foundation.  For more
  * information on the Apache Software Foundation, please see
  * <http://www.apache.org/>.
- *
- * The ap_vsnprintf/ap_snprintf functions are based on, and used with the
- * permission of, the  SIO stdio-replacement strx_* functions by Panos
- * Tsirigotis <pa...@alumni.cs.colorado.edu> for xinetd.
  */
 
 #ifndef APACHE_AP_H
@@ -95,26 +91,6 @@
 #ifndef CORE_EXPORT_NONSTD
 #define CORE_EXPORT_NONSTD	API_EXPORT_NONSTD
 #endif
-
-/* Simple BASE64 encode/decode functions.
- * 
- * As we might encode binary strings, hence we require the length of
- * the incoming plain source. And return the length of what we decoded.
- *
- * The decoding function takes any non valid char (i.e. whitespace, \0
- * or anything non A-Z,0-9 etc as terminal.
- * 
- * plain strings/binary sequences are not assumed '\0' terminated. Encoded
- * strings are neither. But propably should.
- *
- */
-API_EXPORT(int) ap_base64encode_len(int len);
-API_EXPORT(int) ap_base64encode(char * coded_dst, const char *plain_src,int len_plain_src);
-API_EXPORT(int) ap_base64encode_binary(char * coded_dst, const unsigned char *plain_src,int len_plain_src);
-
-API_EXPORT(int) ap_base64decode_len(const char * coded_src);
-API_EXPORT(int) ap_base64decode(char * plain_dst, const char *coded_src);
-API_EXPORT(int) ap_base64decode_binary(unsigned char * plain_dst, const char *coded_src);
 
 #ifdef __cplusplus
 }
Index: apache-2.0/src/main/util.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/main/util.c,v
retrieving revision 1.39
diff -u -r1.39 util.c
--- util.c	2000/04/24 12:00:43	1.39
+++ util.c	2000/04/27 15:13:11
@@ -73,6 +73,7 @@
 
 #include "ap_config.h"
 #include "ap.h"
+#include "ap_base64.h"
 #include "httpd.h"
 #include "http_main.h"
 #include "http_log.h"
Index: apache-2.0/src/modules/standard/mod_auth_digest.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/modules/standard/mod_auth_digest.c,v
retrieving revision 1.13
diff -u -r1.13 mod_auth_digest.c
--- mod_auth_digest.c	2000/04/26 07:14:37	1.13
+++ mod_auth_digest.c	2000/04/27 15:13:19
@@ -94,7 +94,7 @@
 #include "http_request.h"
 #include "http_log.h"
 #include "http_protocol.h"
-#include "ap.h"
+#include "ap_base64.h"
 #include "ap_ctype.h"
 #include "util_uri.h"
 #include "util_md5.h"
Index: apache-2.0/src/os/win32/os.h
===================================================================
RCS file: /cvs/apache/apache-2.0/src/os/win32/os.h,v
retrieving revision 1.21
diff -u -r1.21 os.h
--- os.h	2000/04/14 15:59:17	1.21
+++ os.h	2000/04/27 15:13:23
@@ -131,6 +131,10 @@
 
 #define MODULE_VAR_EXPORT   __declspec(dllexport)
 
+
+#define HAVE_STRCASECMP
+#define HAVE_STRNCASECMP
+
 #define strcasecmp(s1, s2) stricmp(s1, s2)
 #define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
 #define lstat(x, y) stat(x, y)
Index: apache-2.0/src/lib/apr/include/apr.hw
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/include/apr.hw,v
retrieving revision 1.6
diff -u -r1.6 apr.hw
--- apr.hw	2000/04/25 21:18:02	1.6
+++ apr.hw	2000/04/27 17:53:33
@@ -61,19 +61,42 @@
 #ifndef APR_H
 #define APR_H
 
+/* Has windows.h already been included?  If so, our preferences don't matter,
+ * but we will still need the winsock things no matter what was included.
+ * If not, include a restricted set of windows headers to our tastes.
+ */
+#ifndef _WINDOWS_
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
 #endif
 #ifndef _WIN32_WINNT
-/* 
- * Compile the server including all the Windows NT 4.0 header files by 
- * default.
- */
 #define _WIN32_WINNT 0x0400
 #endif
+#ifndef NOUSER
+#define NOUSER
+#endif
+#ifndef NOGDI
+#define NOGDI
+#endif
+#ifndef NONLS
+#define NONLS
+#endif
+#ifndef NOMCX
+#define NOMCX
+#endif
+#ifndef NOIME
+#define NOIME
+#endif
 #include <windows.h>
+/* The _very_few_ missing declarations from the restricted set of win headers
+ * (If this list becomes extensive, re-enable required headers above 
+ */
+#define SW_HIDE             0
+#else /* _WINDOWS_ */
 #include <winsock2.h>
 #include <mswsock.h>
+#endif /* !_WINDOWS_ */
+
 #include <sys/types.h>
 #include <stddef.h>
 #include <stdio.h>
Index: apache-2.0/src/lib/apr/include/apr_private.hw
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/include/apr_private.hw,v
retrieving revision 1.11
diff -u -r1.11 apr_private.hw
--- apr_private.hw	2000/04/23 12:06:47	1.11
+++ apr_private.hw	2000/04/27 17:53:34
@@ -65,19 +65,41 @@
 #ifndef APR_CONFIG_H
 #define APR_CONFIG_H
 
+/* Has windows.h already been included?  If so, our preferences don't matter,
+ * but if not, include a restricted set of windows headers to our tastes.
+ */
+#ifndef _WINDOWS_
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
 #endif
 #ifndef _WIN32_WINNT
-/* 
- * Compile the server including all the Windows NT 4.0 header files by 
- * default.
- */
 #define _WIN32_WINNT 0x0400
 #endif
+#ifndef NOUSER
+#define NOUSER
+#endif
+#ifndef NOGDI
+#define NOGDI
+#endif
+#ifndef NONLS
+#define NONLS
+#endif
+#ifndef NOMCX
+#define NOMCX
+#endif
+#ifndef NOIME
+#define NOIME
+#endif
 #include <windows.h>
+/* The _very_few_ missing declarations from the restricted set of win headers
+ * (If this list becomes extensive, re-enable required headers above 
+ */
+#define SW_HIDE             0
+#else /* _WINDOWS_ */
 #include <winsock2.h>
 #include <mswsock.h>
+#endif /* !_WINDOWS_ */
+
 #include <sys/types.h>
 #include <stddef.h>
 #include <stdio.h>
Index: apache-2.0/src/lib/apr/file_io/win32/pipe.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/file_io/win32/pipe.c,v
retrieving revision 1.15
diff -u -r1.15 pipe.c
--- pipe.c	2000/04/27 11:19:30	1.15
+++ pipe.c	2000/04/27 17:53:32
@@ -101,7 +101,6 @@
     (*in)->pipe = 1;
     (*in)->fname = ap_pstrdup(cont, "PIPE");
     (*in)->timeout = -1;
-    (*in)->ungetchar = -1;
 
     (*out) = (ap_file_t *)ap_pcalloc(cont, sizeof(ap_file_t));
     (*out)->cntxt = cont;
Index: apache-2.0/src/lib/apr/aprlib.def
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/aprlib.def,v
retrieving revision 1.24
diff -u -r1.24 aprlib.def
--- aprlib.def	2000/04/24 14:57:53	1.24
+++ aprlib.def	2000/04/27 17:53:30
@@ -249,3 +249,4 @@
 	ap_generate_random_bytes @228
 	ap_strnatcmp @229
 	ap_strnatcasecmp @230
+	ap_difftime @231
Index: apache-2.0/src/lib/apr/include/apr_time.h
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/include/apr_time.h,v
retrieving revision 1.18
diff -u -r1.18 apr_time.h
--- apr_time.h	2000/04/16 04:46:56	1.18
+++ apr_time.h	2000/04/27 17:53:34
@@ -71,6 +71,8 @@
 /* intervals for I/O timeouts, in microseconds */
 typedef ap_int32_t ap_interval_time_t;
 
+#define AP_INTERVAL_TIME_MAX 2147483647
+
 #ifdef WIN32
 #define AP_USEC_PER_SEC ((LONGLONG) 1000000)
 #else
@@ -110,6 +112,19 @@
     ap_int32_t tm_isdst; /* daylight saving time */
     ap_int32_t tm_gmtoff; /* seconds east of UTC */
 } ap_exploded_time_t;
+
+/*
+
+=head1 ap_interval_time_t ap_difftime(ap_time_t start, ap_time_t end)
+
+B<return the elapsed time in usec, accurate to little more than +-35 minutes>
+
+    arg 1) the starting time
+    arg 2) the ending time
+
+=cut
+ */
+ap_interval_time_t ap_difftime(ap_time_t start, ap_time_t end);
 
 /*
 
Index: apache-2.0/src/lib/apr/time/unix/time.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/time/unix/time.c,v
retrieving revision 1.24
diff -u -r1.24 time.c
--- time.c	2000/04/14 15:58:53	1.24
+++ time.c	2000/04/27 17:53:36
@@ -55,6 +55,16 @@
 #include "atime.h"
 #include "apr_portable.h"
 
+ap_interval_time_t ap_difftime(ap_time_t start, ap_time_t end)
+{
+    ap_time_t diff = end - start;
+    if (diff < -(ap_time_t) AP_INTERVAL_TIME_MAX)
+        diff = -(ap_time_t) AP_INTERVAL_TIME_MAX;
+    else if (diff > (ap_time_t) AP_INTERVAL_TIME_MAX)
+        diff = (ap_time_t) AP_INTERVAL_TIME_MAX;
+    return (ap_interval_time_t) diff;    
+}
+
 ap_status_t ap_ansi_time_to_ap_time(ap_time_t *result, time_t input)
 {
     *result = (ap_time_t)input * AP_USEC_PER_SEC;
Index: apache-2.0/src/lib/apr/time/win32/time.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/time/win32/time.c,v
retrieving revision 1.10
diff -u -r1.10 time.c
--- time.c	2000/04/14 15:58:54	1.10
+++ time.c	2000/04/27 17:53:37
@@ -103,6 +103,16 @@
     return;
 }
 
+ap_interval_time_t ap_difftime(ap_time_t start, ap_time_t end)
+{
+    ap_time_t diff = end - start;
+    if (diff < -(ap_time_t) AP_INTERVAL_TIME_MAX)
+        diff = -(ap_time_t) AP_INTERVAL_TIME_MAX;
+    else if (diff > (ap_time_t) AP_INTERVAL_TIME_MAX)
+        diff = (ap_time_t) AP_INTERVAL_TIME_MAX;
+    return (ap_interval_time_t) diff;    
+}
+
 ap_status_t ap_ansi_time_to_ap_time(ap_time_t *result, time_t input)
 {
     *result = (ap_time_t) input * AP_USEC_PER_SEC;
Index: apache-2.0/src/modules/standard/mod_auth_digest.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/modules/standard/mod_auth_digest.c,v
retrieving revision 1.13
diff -u -r1.13 mod_auth_digest.c
--- mod_auth_digest.c	2000/04/26 07:14:37	1.13
+++ mod_auth_digest.c	2000/04/27 17:53:53
@@ -94,7 +94,7 @@
 #include "http_request.h"
 #include "http_log.h"
 #include "http_protocol.h"
-#include "ap.h"
+#include "ap_base64.h"
 #include "ap_ctype.h"
 #include "util_uri.h"
 #include "util_md5.h"
@@ -116,7 +116,7 @@
     const char  *realm;
     const char **qop_list;
     AP_SHA1_CTX  nonce_ctx;
-    long         nonce_lifetime;
+    ap_interval_time_t nonce_lifetime;
     const char  *nonce_format;
     int          check_nc;
     const char  *algorithm;
@@ -127,8 +127,8 @@
 
 #define	DFLT_ALGORITHM	"MD5"
 
-#define	DFLT_NONCE_LIFE	300000L	/* millis */
-#define NEXTNONCE_DELTA	30000	/* millis */
+#define	DFLT_NONCE_LIFE	(300 * AP_USEC_PER_SEC)	/* usec */
+#define NEXTNONCE_DELTA	(30  * AP_USEC_PER_SEC)	/* usec */
 
 
 #define NONCE_TIME_LEN	(((sizeof(ap_time_t)+2)/3)*4)
@@ -444,7 +444,7 @@
 static const char *set_qop(cmd_parms *cmd, void *config, const char *op)
 {
     digest_config_rec *conf = (digest_config_rec *) config;
-    const char **tmp;
+    char **tmp;
     int cnt;
 
     if (!strcasecmp(op, "none")) {
@@ -478,9 +478,9 @@
 				      const char *t)
 {
     char *endptr;
-    long  lifetime;
-				/* convert from seconds to millis */
-    lifetime = 1000*strtol(t, &endptr, 10); 
+    ap_interval_time_t lifetime;
+				/* convert from seconds to usec */
+    lifetime = (ap_interval_time_t)(AP_USEC_PER_SEC * strtod(t, &endptr)); 
     if (endptr < (t+strlen(t)) && !ap_isspace(*endptr))
 	return ap_pstrcat(cmd->pool, "Invalid time in AuthDigestNonceLifetime: ", t, NULL);
 
@@ -1281,7 +1281,7 @@
 static int check_nonce(request_rec *r, digest_header_rec *resp,
 		       const digest_config_rec *conf)
 {
-    double dt;
+    ap_interval_time_t dt;
     time_rec nonce_time;
     char tmp, hash[NONCE_HASH_LEN+1];
 
@@ -1308,8 +1308,7 @@
 	return AUTH_REQUIRED;
     }
 
-    dt = r->request_time - nonce_time.time;
-    /* dt = difftime(r->request_time, nonce_time.time); */
+    dt = ap_difftime(r->request_time, nonce_time.time);
     if (conf->nonce_lifetime > 0 && dt < 0) {
 	ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
 		      "Digest: invalid nonce %s received - user attempted "
@@ -1322,8 +1321,8 @@
 	if (dt > conf->nonce_lifetime) {
 	    ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0,r,
 			  "Digest: user %s: nonce expired (%.2lf seconds old - max lifetime %.2lf) - sending new nonce", 
-			  r->user, ((double)dt)/1000, 
-			  ((double)(conf->nonce_lifetime))/1000);
+			  r->user, (double)(dt / AP_USEC_PER_SEC), 
+			  (double)(conf->nonce_lifetime / AP_USEC_PER_SEC));
 	    note_digest_auth_failure(r, conf, resp, 1);
 	    return AUTH_REQUIRED;
 	}
@@ -1783,7 +1782,7 @@
      */
     if (conf->nonce_lifetime > 0) {
 	/* send nextnonce if current nonce will expire in less than 30 secs */
-	if (difftime(r->request_time, resp->nonce_time) > (conf->nonce_lifetime-NEXTNONCE_DELTA)) {
+	if ((resp->nonce_time - r->request_time) > (conf->nonce_lifetime - NEXTNONCE_DELTA)) {
 	    nextnonce = ap_pstrcat(r->pool, ", nextnonce=\"",
 				   gen_nonce(r->pool, r->request_time,
 					     resp->opaque, r->server, conf),
Index: apache-2.0/src/os/win32/mod_isapi.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/os/win32/mod_isapi.c,v
retrieving revision 1.7
diff -u -r1.7 mod_isapi.c
--- mod_isapi.c	2000/04/15 19:23:08	1.7
+++ mod_isapi.c	2000/04/27 17:54:01
@@ -88,6 +88,10 @@
 /* We use the exact same header file as the original */
 #include <HttpExt.h>
 
+/* TODO: Unknown errors that must be researched for correct codes */
+
+#define TODO_ERROR 1
+
 /* Seems IIS does not enforce the requirement for \r\n termination on HSE_REQ_SEND_RESPONSE_HEADER,
    define this to conform */
 #define RELAX_HEADER_RULE
@@ -370,7 +374,7 @@
     }
 
     if ((writ = ap_rwrite(Buffer, *lpwdwBytes, r)) == EOF) {
-            SetLastError(ERROR); /* TODO: Find the right error code */
+            SetLastError(WSAEDISCON); /* TODO: Find the right error code */
             return FALSE;
     }
 
@@ -453,7 +457,7 @@
                 if (!lf) { /* Huh? Invalid data, I think */
                         ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
                                     "ISA sent invalid headers: %s", r->filename);
-                        SetLastError(ERROR);    /* XXX: Find right error */
+                        SetLastError(TODO_ERROR);
                         return FALSE;
                 }
 
@@ -473,7 +477,7 @@
                 }
 
                 if (!(value = strchr(data, ':'))) {
-                        SetLastError(ERROR);    /* TODO: Find right error */
+                        SetLastError(TODO_ERROR);
                         ap_log_rerror(APLOG_MARK, APLOG_ERR, SERVER_ERROR, r,
                                           "ISA sent invalid headers", r->filename);
                         return FALSE;


Re: [PATCH] Adding referer info to error_log

Posted by Alan Olsen <al...@clueserver.org>.
On Tue, 25 Apr 2000, Joshua Slive wrote:

> On Tue, 25 Apr 2000, Alan Olsen wrote:
> 
> > I wrote this to help debug a bunch of contractor-provided web pages.  We
> > had lots of error messages of missing images and pages, with no clue of
> > where to find what was referencing the page.  (I find it strange that you
> > can modify every log file in Apache *except* the error_log.  Any reason
> > for this or just an oversight? (But if you speced it wrong, where would
> > you write the errors?))
> > 
> 
> Can you help me understand why this is any better than grepping
> the access_log (in combined format) for 404 errors?

To be honest, I did not think of that.

Also, it helped me catch some truly bizzare code errors that were calling
cgi.

Oh well.  It was an interesting learning experience.

alan@ctrl-alt-del.com | Note to AOL users: for a quick shortcut to reply
Alan Olsen            | to my mail, just hit the ctrl, alt and del keys.
    "In the future, everything will have its 15 minutes of blame."


Re: [PATCH] Adding referer info to error_log

Posted by Joshua Slive <sl...@finance.commerce.ubc.ca>.
On Tue, 25 Apr 2000, Alan Olsen wrote:

> I wrote this to help debug a bunch of contractor-provided web pages.  We
> had lots of error messages of missing images and pages, with no clue of
> where to find what was referencing the page.  (I find it strange that you
> can modify every log file in Apache *except* the error_log.  Any reason
> for this or just an oversight? (But if you speced it wrong, where would
> you write the errors?))
> 

Can you help me understand why this is any better than grepping
the access_log (in combined format) for 404 errors?

-- 
Joshua Slive
slive@finance.commerce.ubc.ca
http://finance.commerce.ubc.ca/~slive/
Phone: (604) 822-1871




Re: [PATCH] Adding referer info to error_log

Posted by Alan Olsen <al...@clueserver.org>.
On Tue, 25 Apr 2000, Alan Olsen wrote:

> I wrote this to help debug a bunch of contractor-provided web pages.  We
> had lots of error messages of missing images and pages, with no clue of
> where to find what was referencing the page.  (I find it strange that you
> can modify every log file in Apache *except* the error_log.  Any reason
> for this or just an oversight? (But if you speced it wrong, where would
> you write the errors?))

> The file being modified is src/main/http_log.c.

[snip]

Oops. Forgot to mention that this is patched against 1.3.12.  I have a
slightly different version for 2.0a2.  (The error handling code for that
section seems just a wee bit different. I tried to closely follow the code
used for inserting thecalling IP address into the logs.)

alan@ctrl-alt-del.com | Note to AOL users: for a quick shortcut to reply
Alan Olsen            | to my mail, just hit the ctrl, alt and del keys.
    "In the future, everything will have its 15 minutes of blame."