Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3279a7e659 | ||
|
|
88e4aed397 | ||
|
|
1c2a42af9c | ||
|
|
f61c275395 | ||
|
|
23b44e67df | ||
|
|
f7d0ea8784 | ||
|
|
be9ce3ad26 | ||
|
|
e88c426966 | ||
|
|
bf7a671d87 | ||
|
|
f72ebfe0d8 | ||
|
|
c25c7a947f | ||
|
|
194e1ad9cc | ||
|
|
3b5e17d579 | ||
|
|
771425700d | ||
|
|
7be408859d | ||
|
|
7889aa4951 | ||
|
|
f590a7d738 | ||
|
|
cc70fc6f43 | ||
|
|
e19889ff5b | ||
|
|
0ca3a710da |
No files matched your search
@@ -1,5 +1,40 @@
|
|||||||
|
2001-08-27 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/log.c (log_message): Fixed a problem where the connect
|
||||||
|
messages were not getting through if the log level was set to
|
||||||
|
INFO.
|
||||||
|
|
||||||
|
* src/tinyproxy.h: Moved some of the includes around so that
|
||||||
|
tinyproxy can compile correctly on FreeBSD systems.
|
||||||
|
|
||||||
|
* src/thread.c: Added the pthread_attr_t structure since we're
|
||||||
|
going to be using a non-default sized stack because some OS's have
|
||||||
|
a stack size which is too small.
|
||||||
|
|
||||||
|
* configure.in: Added a test for detecting FreeBSD's -pthread
|
||||||
|
mechanism for telling GCC to use POSIX threading.
|
||||||
|
|
||||||
|
* src/utils.c (httperr): Fixed the MIME type. Should be be
|
||||||
|
text/html, not text/mime. Fix one bug, add two new ones. Sigh.
|
||||||
|
|
||||||
2001-08-26 Robert James Kaes <rjkaes@flarenet.com>
|
2001-08-26 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/utils.c (httperr): Split the headers from the actual message
|
||||||
|
and include more headers like Date, Server, Content-Length,
|
||||||
|
etc. Also set the type for the error message to const char*.
|
||||||
|
|
||||||
|
* src/reqs.c (process_method): Fixed a SEGV problem if an invalid
|
||||||
|
request was submitted.
|
||||||
|
|
||||||
|
* Makefile.am (EXTRA_DIST): Don't include ./reconf in the
|
||||||
|
tarball.
|
||||||
|
|
||||||
|
* src/log.c (log_message): Fixed a problem with the new LOG_CONN
|
||||||
|
log level.
|
||||||
|
|
||||||
|
* configure.in: The debugging code was being included even on
|
||||||
|
non-debugging builds.
|
||||||
|
|
||||||
* src/anonymous.c (anonymous_insert): Moved the creation of the
|
* src/anonymous.c (anonymous_insert): Moved the creation of the
|
||||||
search tree into the anonymous_insert() function. Therefore, the
|
search tree into the anonymous_insert() function. Therefore, the
|
||||||
search tree is _not_ created until the first insertion. This
|
search tree is _not_ created until the first insertion. This
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
EXTRA_DIST = configure acconfig.h aclocal.m4 acinclude.m4 reconf
|
EXTRA_DIST = configure acconfig.h aclocal.m4 acinclude.m4
|
||||||
SUBDIRS = src doc
|
SUBDIRS = src doc
|
||||||
@@ -3,21 +3,32 @@
|
|||||||
====
|
====
|
||||||
|
|
||||||
Well so much for the 1.4.0 version being the best tinyproxy---there
|
Well so much for the 1.4.0 version being the best tinyproxy---there
|
||||||
were bugs. The most serious was that anonymous filtering was not
|
were bugs. The most serious was a segmentation fault problem when an
|
||||||
actually working. Another bug fix is that on Debian systems (and
|
invalid request was received. Also, anonymous filtering was not
|
||||||
maybe others) child threads would not be closed if they had been
|
actually working. Another bug fix is that on Debian systems (and maybe
|
||||||
created after tinyproxy had been started. Finally, if
|
others) child threads would not be closed if they had been created
|
||||||
MaxClientRequests was set to 0, the status of the thread was not going
|
after tinyproxy had been started. Finally, if MaxClientRequests was
|
||||||
back to T_WAITING.
|
set to 0, the status of the thread was not going back to T_WAITING.
|
||||||
|
|
||||||
Okay, now on to the new features. There is only one feature which is
|
Okay, now on to the new features. There is a new Connect log
|
||||||
the new Connect log level. This is basically "Info" without info's
|
level. This is basically "Info" without info's noise. Also, the error
|
||||||
noise.
|
reporting function sends back more HTTP headers, which should lead to
|
||||||
|
a more standards compliant proxy.
|
||||||
|
|
||||||
There are a couple of features which I'm working on for the next
|
There are a couple of features which I'm working on for the next
|
||||||
release. There has been requests for logging on tunnelled
|
release. There has been requests for logging on tunnelled
|
||||||
connections. Also, some people would like HTTP filtering on tunnelled
|
connections. Also, some people would like HTTP filtering on tunnelled
|
||||||
connections.
|
connections. Finally, I do have the information to include SSL
|
||||||
|
connections, so I will be including it in the next release.
|
||||||
|
|
||||||
So, the above bugs are fixed, hopefully there are no other ones. The
|
So, the above bugs are fixed, hopefully there are no other ones. The
|
||||||
new features will be worked into the next few releases.
|
new features will be worked into the next few releases.
|
||||||
|
|
||||||
|
Update
|
||||||
|
------
|
||||||
|
2001-08-27 - Fix one bug and two more crop up. The MIME type was
|
||||||
|
incorrect in the httperr() function; this has been fixed.
|
||||||
|
Jeffrey D. Wheelhouse included a patch to increase the stack size on
|
||||||
|
some machine (notably FreeBSD) and also included a patch to allow
|
||||||
|
tinyproxy to compile on FreeBSD. I really hope that _this_ is that
|
||||||
|
last minor-minor version for a while.
|
||||||
+9
-3
@@ -1,4 +1,4 @@
|
|||||||
dnl $Id: configure.in,v 1.16 2001-08-26 21:22:09 rjkaes Exp $
|
dnl $Id: configure.in,v 1.19 2001-08-27 17:47:25 rjkaes Exp $
|
||||||
|
|
||||||
dnl Devlopers, please strive to achieve this order:
|
dnl Devlopers, please strive to achieve this order:
|
||||||
dnl
|
dnl
|
||||||
@@ -19,7 +19,7 @@ AC_INIT()
|
|||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
AC_DEFINE_UNQUOTED(TARGET_SYSTEM, "$target")
|
AC_DEFINE_UNQUOTED(TARGET_SYSTEM, "$target")
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE(tinyproxy,1.4.1)
|
AM_INIT_AUTOMAKE(tinyproxy,1.4.1.4)
|
||||||
AM_CONFIG_HEADER(config.h)
|
AM_CONFIG_HEADER(config.h)
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
@@ -106,7 +106,12 @@ else
|
|||||||
if test "$ac_cv_lib_pthreads_pthread_create" = "yes"; then
|
if test "$ac_cv_lib_pthreads_pthread_create" = "yes"; then
|
||||||
CFLAGS="-D_REENTRANT $CFLAGS"
|
CFLAGS="-D_REENTRANT $CFLAGS"
|
||||||
else
|
else
|
||||||
AC_MSG_ERROR(You must have a POSIX compliant threading library installed)
|
AC_CHECK_LIB(c_r, pthread_create)
|
||||||
|
if test "$ac_cv_c_r_pthread_create" = "yes"; then
|
||||||
|
CFLAGS="-pthread -D_REENTRANT $CFLAGS"
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR(You must have a POSIX compliant threading library installed)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -212,6 +217,7 @@ if test "$enable_debug" = "yes" ; then
|
|||||||
YFLAGS="-v -d"
|
YFLAGS="-v -d"
|
||||||
else
|
else
|
||||||
dnl No debugging information, include the optimizations
|
dnl No debugging information, include the optimizations
|
||||||
|
CFLAGS="-DNDEBUG $CFLAGS"
|
||||||
YFLAGS="-d"
|
YFLAGS="-d"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,11 @@ against the current tree and I'll integrate it if possible.
|
|||||||
much of a problem. Just need to modify the process_method() code
|
much of a problem. Just need to modify the process_method() code
|
||||||
to look up the URL and rewrite it. If we want to go really fancy
|
to look up the URL and rewrite it. If we want to go really fancy
|
||||||
with RegEx mapping this could get ugly. :)
|
with RegEx mapping this could get ugly. :)
|
||||||
- Ed Avis suggests having tinyproxy have the ability to send the data
|
- Have the ability to send the data from the connections through an
|
||||||
from the connections through an external filtering program. I kind of
|
external filtering program. I kind of like this idea, but I don't
|
||||||
like this idea, but I don't really have a good way of doing it yet.
|
really have a good way of doing it yet.
|
||||||
|
Suggested: Ed Avis
|
||||||
- Handle Secure Socket Layer (SSL) connections (usually port 443).
|
- Handle Secure Socket Layer (SSL) connections (usually port 443).
|
||||||
- Allow selective logging. For example a person may only want to log
|
- Include the ability to rewrite both incoming and outgoing headers.
|
||||||
error messages.
|
- Log requests for tunnelled connections
|
||||||
- Include the ability to rewrite both incoming and outgoing headers.
|
- Allow HTTP header filtering through tunnelled connections
|
||||||
+1
-1
@@ -116,4 +116,4 @@ Allow 192.168.1.0/25
|
|||||||
# no Anonymous keyword is present, then all header are allowed through.
|
# no Anonymous keyword is present, then all header are allowed through.
|
||||||
#
|
#
|
||||||
#Anonymous Host
|
#Anonymous Host
|
||||||
#Anonymous Authorization
|
#Anonymous Authorization
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: log.c,v 1.9 2001-08-26 21:10:04 rjkaes Exp $
|
/* $Id: log.c,v 1.11 2001-08-27 17:44:55 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Logs the various messages which tinyproxy produces to either a log file or
|
* Logs the various messages which tinyproxy produces to either a log file or
|
||||||
* the syslog daemon. Not much to it...
|
* the syslog daemon. Not much to it...
|
||||||
@@ -76,13 +76,10 @@ void log_message(short int level, char *fmt, ...)
|
|||||||
/*
|
/*
|
||||||
* Figure out if we should write the message or not.
|
* Figure out if we should write the message or not.
|
||||||
*/
|
*/
|
||||||
if (log_level != LOG_CONN) {
|
if (level == LOG_INFO && log_level == LOG_CONN)
|
||||||
if (level > log_level && level != LOG_CONN)
|
return;
|
||||||
return;
|
else if (level > log_level && level != LOG_CONN && log_level != LOG_INFO)
|
||||||
} else {
|
return;
|
||||||
if (level == LOG_INFO)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
#ifdef HAVE_SYSLOG_H
|
||||||
if (config.syslog && level == LOG_CONN)
|
if (config.syslog && level == LOG_CONN)
|
||||||
|
|||||||
+10
-8
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: reqs.c,v 1.15 2001-08-26 21:11:55 rjkaes Exp $
|
/* $Id: reqs.c,v 1.16 2001-08-27 03:44:22 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This is where all the work in tinyproxy is actually done. Incoming
|
* This is where all the work in tinyproxy is actually done. Incoming
|
||||||
* connections have a new thread created for them. The thread then
|
* connections have a new thread created for them. The thread then
|
||||||
@@ -122,14 +122,14 @@ static int process_method(struct conn_s *connptr)
|
|||||||
log_message(LOG_ERR, "clientreq: regcomp");
|
log_message(LOG_ERR, "clientreq: regcomp");
|
||||||
httperr(connptr, 503, HTTP503ERROR);
|
httperr(connptr, 503, HTTP503ERROR);
|
||||||
update_stats(STAT_BADCONN);
|
update_stats(STAT_BADCONN);
|
||||||
goto COMMON_EXIT;
|
goto EARLY_EXIT;
|
||||||
}
|
}
|
||||||
if (regexec(&preg, inbuf, NMATCH, pmatch, 0) != 0) {
|
if (regexec(&preg, inbuf, NMATCH, pmatch, 0) != 0) {
|
||||||
log_message(LOG_ERR, "clientreq: regexec");
|
log_message(LOG_ERR, "clientreq: regexec");
|
||||||
regfree(&preg);
|
regfree(&preg);
|
||||||
httperr(connptr, 503, HTTP503ERROR);
|
httperr(connptr, 503, HTTP503ERROR);
|
||||||
update_stats(STAT_BADCONN);
|
update_stats(STAT_BADCONN);
|
||||||
goto COMMON_EXIT;
|
goto EARLY_EXIT;
|
||||||
}
|
}
|
||||||
regfree(&preg);
|
regfree(&preg);
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ static int process_method(struct conn_s *connptr)
|
|||||||
peer_ipaddr, inbuf);
|
peer_ipaddr, inbuf);
|
||||||
httperr(connptr, 400, HTTP400ERROR);
|
httperr(connptr, 400, HTTP400ERROR);
|
||||||
update_stats(STAT_BADCONN);
|
update_stats(STAT_BADCONN);
|
||||||
goto COMMON_EXIT;
|
goto EARLY_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = pmatch[URI_IND].rm_eo - pmatch[URI_IND].rm_so;
|
len = pmatch[URI_IND].rm_eo - pmatch[URI_IND].rm_so;
|
||||||
@@ -157,7 +157,7 @@ static int process_method(struct conn_s *connptr)
|
|||||||
peer_ipaddr);
|
peer_ipaddr);
|
||||||
httperr(connptr, 503, HTTP503ERROR);
|
httperr(connptr, 503, HTTP503ERROR);
|
||||||
update_stats(STAT_BADCONN);
|
update_stats(STAT_BADCONN);
|
||||||
goto COMMON_EXIT;
|
goto EARLY_EXIT;
|
||||||
}
|
}
|
||||||
memcpy(buffer, inbuf + pmatch[URI_IND].rm_so, len);
|
memcpy(buffer, inbuf + pmatch[URI_IND].rm_so, len);
|
||||||
buffer[len] = '\0';
|
buffer[len] = '\0';
|
||||||
@@ -166,7 +166,7 @@ static int process_method(struct conn_s *connptr)
|
|||||||
log_message(LOG_ERR, "clientreq: Problem with explode_uri");
|
log_message(LOG_ERR, "clientreq: Problem with explode_uri");
|
||||||
httperr(connptr, 503, HTTP503ERROR);
|
httperr(connptr, 503, HTTP503ERROR);
|
||||||
update_stats(STAT_BADCONN);
|
update_stats(STAT_BADCONN);
|
||||||
goto COMMON_EXIT;
|
goto EARLY_EXIT;
|
||||||
}
|
}
|
||||||
safefree(buffer);
|
safefree(buffer);
|
||||||
|
|
||||||
@@ -287,9 +287,11 @@ static int process_method(struct conn_s *connptr)
|
|||||||
free_uri(uri);
|
free_uri(uri);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
COMMON_EXIT:
|
COMMON_EXIT:
|
||||||
safefree(request);
|
|
||||||
free_uri(uri);
|
free_uri(uri);
|
||||||
|
|
||||||
|
EARLY_EXIT:
|
||||||
|
safefree(request);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-3
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: thread.c,v 1.6 2001-08-26 21:14:30 rjkaes Exp $
|
/* $Id: thread.c,v 1.7 2001-08-27 17:45:50 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Handles the creation/destruction of the various threads required for
|
* Handles the creation/destruction of the various threads required for
|
||||||
* processing incoming connections.
|
* processing incoming connections.
|
||||||
@@ -42,6 +42,9 @@ struct thread_s {
|
|||||||
static struct thread_s *thread_ptr;
|
static struct thread_s *thread_ptr;
|
||||||
static pthread_mutex_t mlock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t mlock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
/* Used to override the default statck size. */
|
||||||
|
static pthread_attr_t thread_attr;
|
||||||
|
|
||||||
static struct thread_config_s {
|
static struct thread_config_s {
|
||||||
unsigned int maxclients, maxrequestsperchild;
|
unsigned int maxclients, maxrequestsperchild;
|
||||||
unsigned int maxspareservers, minspareservers, startservers;
|
unsigned int maxspareservers, minspareservers, startservers;
|
||||||
@@ -146,6 +149,13 @@ int thread_pool_create(void)
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize thread_attr to contain a non-default stack size
|
||||||
|
* because the default on some OS's is too small.
|
||||||
|
*/
|
||||||
|
pthread_attr_init(&thread_attr);
|
||||||
|
pthread_attr_setstacksize(&thread_attr, (1024 * 1024));
|
||||||
|
|
||||||
if (thread_config.maxclients == 0) {
|
if (thread_config.maxclients == 0) {
|
||||||
log_message(LOG_ERR, "You must set MaxClients to a value greater than 0");
|
log_message(LOG_ERR, "You must set MaxClients to a value greater than 0");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -167,7 +177,7 @@ int thread_pool_create(void)
|
|||||||
for (i = 0; i < thread_config.startservers; i++) {
|
for (i = 0; i < thread_config.startservers; i++) {
|
||||||
thread_ptr[i].status = T_WAITING;
|
thread_ptr[i].status = T_WAITING;
|
||||||
servers_waiting++;
|
servers_waiting++;
|
||||||
pthread_create(&thread_ptr[i].tid, NULL, &thread_main, &thread_ptr[i]);
|
pthread_create(&thread_ptr[i].tid, &thread_attr, &thread_main, &thread_ptr[i]);
|
||||||
}
|
}
|
||||||
for (i = thread_config.startservers; i < thread_config.maxclients; i++) {
|
for (i = thread_config.startservers; i < thread_config.maxclients; i++) {
|
||||||
thread_ptr[i].status = T_EMPTY;
|
thread_ptr[i].status = T_EMPTY;
|
||||||
@@ -189,7 +199,7 @@ int thread_main_loop(void)
|
|||||||
if (servers_waiting < thread_config.minspareservers) {
|
if (servers_waiting < thread_config.minspareservers) {
|
||||||
for (i = 0; i < thread_config.maxclients; i++) {
|
for (i = 0; i < thread_config.maxclients; i++) {
|
||||||
if (thread_ptr[i].status == T_EMPTY) {
|
if (thread_ptr[i].status == T_EMPTY) {
|
||||||
pthread_create(&thread_ptr[i].tid, NULL, &thread_main, &thread_ptr[i]);
|
pthread_create(&thread_ptr[i].tid, &thread_attr, &thread_main, &thread_ptr[i]);
|
||||||
thread_ptr[i].status = T_WAITING;
|
thread_ptr[i].status = T_WAITING;
|
||||||
thread_ptr[i].connects = 0;
|
thread_ptr[i].connects = 0;
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tinyproxy.h,v 1.11 2001-08-26 21:18:04 rjkaes Exp $
|
/* $Id: tinyproxy.h,v 1.12 2001-08-27 17:46:20 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'tinyproxy.c' for a detailed description.
|
* See 'tinyproxy.c' for a detailed description.
|
||||||
*
|
*
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
/*
|
/*
|
||||||
* Include standard headers which are used through-out tinyproxy
|
* Include standard headers which are used through-out tinyproxy
|
||||||
*/
|
*/
|
||||||
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_SYS_SELECT_H
|
#ifdef HAVE_SYS_SELECT_H
|
||||||
# include <sys/select.h>
|
# include <sys/select.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -41,10 +42,9 @@
|
|||||||
# include <time.h>
|
# include <time.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|||||||
+49
-8
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: utils.c,v 1.4 2001-05-27 02:38:46 rjkaes Exp $
|
/* $Id: utils.c,v 1.6 2001-08-27 17:46:50 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Misc. routines which are used by the various functions to handle strings
|
* Misc. routines which are used by the various functions to handle strings
|
||||||
* and memory allocation and pretty much anything else we can think of. Also,
|
* and memory allocation and pretty much anything else we can think of. Also,
|
||||||
@@ -61,25 +61,66 @@ char *xstrstr(char *haystack, char *needle, size_t length,
|
|||||||
/*
|
/*
|
||||||
* Display an error to the client.
|
* Display an error to the client.
|
||||||
*/
|
*/
|
||||||
int httperr(struct conn_s *connptr, int err, char *msg)
|
#define HEADER_SIZE (1024 * 8)
|
||||||
|
int httperr(struct conn_s *connptr, int err, const char *msg)
|
||||||
{
|
{
|
||||||
static char *premsg = "HTTP/1.0 %d %s\r\n" \
|
static char *headers = \
|
||||||
"Content-type: text/html\r\n\r\n" \
|
"HTTP/1.0 %d %s\r\n" \
|
||||||
|
"Server: %s/%s\r\n" \
|
||||||
|
"Date: %s\r\n" \
|
||||||
|
"Content-Type: text/html\r\n" \
|
||||||
|
"Content-Length: %d\r\n" \
|
||||||
|
"Connection: close\r\n" \
|
||||||
|
"\r\n";
|
||||||
|
|
||||||
|
static char *message = \
|
||||||
"<html><head><title>%s</title></head>\r\n" \
|
"<html><head><title>%s</title></head>\r\n" \
|
||||||
"<body>\r\n" \
|
"<body>\r\n" \
|
||||||
"<font size=\"+2\">Cache Error!</font><br>\r\n" \
|
"<font size=\"+2\">Cache Error!</font><br>\r\n" \
|
||||||
"An error of type %d occurred: %s\r\n" \
|
"An error of type %d occurred: %s\r\n" \
|
||||||
"<hr>\r\n" \
|
"<hr>\r\n" \
|
||||||
"<font size=\"-1\"><em>Generated by %s</em></font>\r\n" \
|
"<font size=\"-1\"><em>Generated by %s/%s</em></font>\r\n" \
|
||||||
"</body></html>\r\n";
|
"</body></html>\r\n";
|
||||||
|
|
||||||
connptr->output_message = malloc(MAXBUFFSIZE);
|
char *header_buffer;
|
||||||
if (!connptr->output_message) {
|
char *message_buffer;
|
||||||
|
int output_size;
|
||||||
|
char timebuf[30];
|
||||||
|
time_t global_time;
|
||||||
|
|
||||||
|
header_buffer = malloc(HEADER_SIZE);
|
||||||
|
if (!header_buffer) {
|
||||||
log_message(LOG_CRIT, "Out of memory!");
|
log_message(LOG_CRIT, "Out of memory!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(connptr->output_message, MAXBUFFSIZE, premsg, err, msg, msg, err, msg, VERSION);
|
message_buffer = malloc(MAXBUFFSIZE);
|
||||||
|
if (!message_buffer) {
|
||||||
|
log_message(LOG_CRIT, "Out of memory!");
|
||||||
|
safefree(header_buffer);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
global_time = time(NULL);
|
||||||
|
strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&global_time));
|
||||||
|
|
||||||
|
snprintf(message_buffer, MAXBUFFSIZE - 1, message, msg, err, msg, PACKAGE, VERSION);
|
||||||
|
snprintf(header_buffer, HEADER_SIZE - 1, headers, err, msg, PACKAGE, VERSION, timebuf, strlen(message_buffer));
|
||||||
|
|
||||||
|
output_size = strlen(message_buffer) + strlen(header_buffer);
|
||||||
|
connptr->output_message = malloc(output_size + 1);
|
||||||
|
if (!connptr->output_message) {
|
||||||
|
log_message(LOG_CRIT, "Out of memory!");
|
||||||
|
safefree(header_buffer);
|
||||||
|
safefree(message_buffer);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
strlcpy(connptr->output_message, header_buffer, output_size);
|
||||||
|
strlcat(connptr->output_message, message_buffer, output_size);
|
||||||
|
|
||||||
|
safefree(header_buffer);
|
||||||
|
safefree(message_buffer);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: utils.h,v 1.4 2001-05-27 02:38:46 rjkaes Exp $
|
/* $Id: utils.h,v 1.5 2001-08-27 03:45:34 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'utils.h' for a detailed description.
|
* See 'utils.h' for a detailed description.
|
||||||
*
|
*
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
extern char *xstrstr(char *haystack, char *needle, size_t length,
|
extern char *xstrstr(char *haystack, char *needle, size_t length,
|
||||||
bool_t case_sensitive);
|
bool_t case_sensitive);
|
||||||
|
|
||||||
extern int httperr(struct conn_s *connptr, int err, char *msg);
|
extern int httperr(struct conn_s *connptr, int err, const char *msg);
|
||||||
|
|
||||||
extern void makedaemon(void);
|
extern void makedaemon(void);
|
||||||
extern void pidfile_create(const char *path);
|
extern void pidfile_create(const char *path);
|
||||||
|
|||||||
Reference in new issue
Block a user