Compare commits

..
20 Commits
Author SHA1 Message Date
cvs2svn 825fdffc47 This commit was manufactured by cvs2svn to create tag
'release_1_5_1'.
2002-08-09 20:30:17 +00:00
Robert James Kaes ef0656db3e # Added the release not to the changelog 2002-08-09 20:30:16 +00:00
Robert James Kaes e30971a76c # Updated the version number to be 1.5.1 2002-08-09 20:28:16 +00:00
Robert James Kaes f8b5fe53e7 (main): Fixed up a bug reported by Oswald Buddenha where the log file was being initially created with the initial user's permissions, which is obviously a problem if tinyproxy is not running as the initial user. This is now fixed by delaying the creation of the log file until _after_ tinyproxy has been switched to the user it will run as. Confused yet? 2002-07-12 17:02:02 +00:00
Robert James Kaes 632f689209 # Bumped up the version number (rc4) 2002-07-11 18:47:00 +00:00
Robert James Kaes 8a95d10be2 # Updated the ChangeLog 2002-07-11 18:46:34 +00:00
Robert James Kaes ab574cbec0 (create_file_safely):
(pidfile_create): Changed all the error logging to write to standard error and then exit the program.  This will prevent segmentation fault problems from occurring because the log file could not be created properly.
2002-07-09 19:02:57 +00:00
Robert James Kaes 4932b87fc9 (malloc_shared_memory): Changed the static character array to include the ".XXXXXX" string already. This saves one system call when creating a temporary file name. 2002-07-09 18:52:32 +00:00
Robert James Kaes 01d2966cb8 Updated the "Support" section to include a link to the tinyproxy Bug Tracker system hosted by SourceForge. 2002-07-08 20:10:42 +00:00
Robert James Kaes bf0709cd98 Removed the -D_REENTRANT C flag since tinyproxy is no longer a multi-threaded program. 2002-07-05 03:55:27 +00:00
Robert James Kaes 96c5ee9065 Updated the ChangeLog. 2002-06-27 16:30:53 +00:00
Robert James Kaes dad3bb043a Updated the version number. 2002-06-27 16:30:38 +00:00
Robert James Kaes e50d0c4072 (child_make): Reset the various signals to the default signal handler so that the children can be properly destroyed. 2002-06-27 16:29:21 +00:00
Robert James Kaes 0a1885deb0 Updated the ChangeLog 2002-06-18 20:10:23 +00:00
Robert James Kaes cae69592be Updated the version number. 2002-06-18 20:08:36 +00:00
Robert James Kaes f0d7992765 (log_message): Changed the code so that the log is opened, written, and closed whenever a message is submitted. This allows the log file to be moved away, for example a rotating the log, and yet still have the information written to the correct file name by all the children. 2002-06-15 17:37:11 +00:00
Robert James Kaes ac5d67c11a Renamed the "log_rotation_request" boolean to "received_sighup".
(main): Removed the log file creation code because it has been moved into the log.c file.  Also, removed the explicit fclose() for the log file since it will be close when the program has exited.
2002-06-15 17:35:03 +00:00
Robert James Kaes 8a9db93977 (child_main_loop): Moved the filter re-initiation code into the loop. This code is activated whenever the SIGHUP signal is received. 2002-06-15 17:31:31 +00:00
Robert James Kaes fb688a2077 Removed the "logf" FILE structure from the config structure, and also renamed the "log_rotation_request" boolean to "received_sighup". 2002-06-15 17:29:59 +00:00
Robert James Kaes 2f84b170a6 Removed the rotate_log_files() function since I'm moving to an Apache style where the _user_ needs to move the log file themselves, and tinyproxy will continue to write to the original name. This allows more flexibility for users to determine their own log rotation scheme. 2002-06-15 17:28:19 +00:00
10 changed files with 149 additions and 158 deletions

No files matched your search

+66
View File
@@ -1,3 +1,69 @@
2002-08-09 Robert James Kaes <rjkaes@flarenet.com>
Released tinyproxy 1.5.1 (2002-08-09)
2002-07-09 Robert James Kaes <rjkaes@flarenet.com>
* src/utils.c: (create_file_safely):
(pidfile_create): Changed all the error logging to write to
standard error and then exit the program. This will prevent
segmentation fault problems from occurring because the log file
could not be created properly.
* src/heap.c (malloc_shared_memory):
Changed the static character array to include the ".XXXXXX" string
already. This saves one system call when creating a temporary
file name.
2002-07-08 Robert James Kaes <rjkaes@flarenet.com>
* README:
Updated the "Support" section to include a link to the tinyproxy
Bug Tracker system hosted by SourceForge.
2002-07-05 Robert James Kaes <rjkaes@flarenet.com>
* configure.ac:
Removed the -D_REENTRANT C flag since tinyproxy is no longer a
multi-threaded program.
2002-06-27 Robert James Kaes <rjkaes@flarenet.com>
* src/child.c (child_make):
Reset the various signals to the default signal handler so that
the children can be properly destroyed.
2002-06-15 Robert James Kaes <rjkaes@flarenet.com>
* src/log.c (log_message):
Changed the code so that the log is opened, written, and closed
whenever a message is submitted. This allows the log file to be
moved away, for example a rotating the log, and yet still have the
information written to the correct file name by all the children.
* src/tinyproxy.c:
Renamed the "log_rotation_request" boolean to "received_sighup".
(main): Removed the log file creation code because it has been
moved into the log.c file. Also, removed the explicit fclose()
for the log file since it will be close when the program has
exited.
* src/child.c (child_main_loop):
Moved the filter re-initiation code into the loop. This code is
activated whenever the SIGHUP signal is received.
* src/tinyproxy.h:
Removed the "logf" FILE structure from the config structure, and
also renamed the "log_rotation_request" boolean to
"received_sighup".
* src/utils.c, src/utils.h:
Removed the rotate_log_files() function since I'm moving to an
Apache style where the _user_ needs to move the log file
themselves, and tinyproxy will continue to write to the original
name. This allows more flexibility for users to determine their
own log rotation scheme.
2002-06-07 Robert James Kaes <rjkaes@flarenet.com>
* src/filter.c, src/filter.h:
+3 -4
View File
@@ -65,11 +65,10 @@
SUPPORT
-------
If you are having problems with tinyproxy, please report the problem
to either:
If you are having problems with tinyproxy, please submit a bug to the
tinyproxy Bug Tracking system hosted by SourceForge and located at:
Robert James Kaes <rjkaes@users.sourceforge.net>
Steven Young <sdyoung@users.sourceforge.net>
http://sourceforge.net/tracker/?group_id=2632
You may also wish to subscribe to the tinyproxy-user mailing list. To
do so please visit:
+2 -5
View File
@@ -1,4 +1,4 @@
dnl $Id: configure.ac,v 2.39 2002-06-07 18:45:58 rjkaes Exp $
dnl $Id: configure.ac,v 2.44 2002-08-09 20:28:16 rjkaes Exp $
dnl Devlopers, please strive to achieve this order:
dnl
@@ -14,7 +14,7 @@ dnl 8. System services
dnl
dnl Read the Autoconf manual for details.
AC_INIT([tinyproxy], [1.5.1pre6], [rjkaes@users.sourceforge.net])
AC_INIT([tinyproxy], [1.5.1], [rjkaes@users.sourceforge.net])
AC_CONFIG_SRCDIR([src/tinyproxy.c])
AC_PREREQ(2.52)
@@ -27,9 +27,6 @@ AC_DEFINE_UNQUOTED(TARGET_SYSTEM, ["$target"])
AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h)
dnl Set the default CFLAGS
CFLAGS="-D_REENTRANT"
dnl Check if we're compiling on a weird platform :)
AC_AIX
AC_ISC_POSIX
+20 -4
View File
@@ -1,4 +1,4 @@
/* $Id: child.c,v 1.3 2002-06-05 17:02:15 rjkaes Exp $
/* $Id: child.c,v 1.5 2002-06-27 16:29:21 rjkaes Exp $
*
* Handles the creation/destruction of the various children required for
* processing incoming connections.
@@ -19,6 +19,8 @@
#include "tinyproxy.h"
#include "child.h"
#include "daemon.h"
#include "filter.h"
#include "heap.h"
#include "log.h"
#include "reqs.h"
@@ -242,6 +244,13 @@ child_make(struct child_s* ptr)
if ((pid = fork()) > 0)
return pid; /* parent */
/*
* Reset the SIGNALS so that the child can be reaped.
*/
set_signal_handler(SIGCHLD, SIG_DFL);
set_signal_handler(SIGTERM, SIG_DFL);
set_signal_handler(SIGHUP, SIG_DFL);
child_main(ptr); /* never returns */
return -1;
}
@@ -372,9 +381,16 @@ child_main_loop(void)
sleep(5);
/* Handle log rotation if it was requested */
if (log_rotation_request) {
rotate_log_files();
log_rotation_request = FALSE;
if (received_sighup) {
#ifdef FILTER_ENABLE
if (config.filter) {
filter_destroy();
filter_init();
}
log_message(LOG_NOTICE, "Re-reading filter file.");
#endif /* FILTER_ENABLE */
received_sighup = FALSE;
}
}
}
+4 -5
View File
@@ -1,4 +1,4 @@
/* $Id: heap.c,v 1.4 2002-06-05 17:01:09 rjkaes Exp $
/* $Id: heap.c,v 1.5 2002-07-09 18:52:32 rjkaes Exp $
*
* Debugging versions of various heap related functions are combined
* here. The debugging versions include assertions and also print
@@ -105,14 +105,13 @@ malloc_shared_memory(size_t size)
{
int fd;
void* ptr;
char buffer[128];
char buffer[32];
static char* shared_file = "/tmp/tinyproxy.shared";
static char* shared_file = "/tmp/tinyproxy.shared.XXXXXX";
assert(size > 0);
strlcpy(buffer, shared_file, sizeof(buffer) - 8);
strlcat(buffer, ".XXXXXX", sizeof(buffer));
strlcpy(buffer, shared_file, sizeof(buffer));
if ((fd = mkstemp(buffer)) == -1)
return (void *)MAP_FAILED;
+13 -9
View File
@@ -1,4 +1,4 @@
/* $Id: log.c,v 1.21 2002-06-06 20:24:21 rjkaes Exp $
/* $Id: log.c,v 1.22 2002-06-15 17:37:11 rjkaes Exp $
*
* Logs the various messages which tinyproxy produces to either a log file or
* the syslog daemon. Not much to it...
@@ -22,6 +22,7 @@
#include "hashmap.h"
#include "heap.h"
#include "log.h"
#include "utils.h"
static char *syslog_level[] = {
NULL,
@@ -68,7 +69,6 @@ log_message(int level, char *fmt, ...)
{
va_list args;
time_t nowtime;
FILE *cf;
char time_string[TIME_LENGTH];
#if defined(HAVE_SYSLOG_H) && !defined(HAVE_VSYSLOG_H)
@@ -130,19 +130,23 @@ log_message(int level, char *fmt, ...)
# endif
} else {
#endif
FILE* log_file;
int fd;
fd = create_file_safely(config.logf_name, FALSE);
log_file = fdopen(fd, "w+");
nowtime = time(NULL);
/* Format is month day hour:minute:second (24 time) */
strftime(time_string, TIME_LENGTH, "%b %d %H:%M:%S",
localtime(&nowtime));
if (!(cf = config.logf))
cf = stderr;
fprintf(cf, "%-9s %s [%ld]: ", syslog_level[level],
fprintf(log_file, "%-9s %s [%ld]: ", syslog_level[level],
time_string, (long int) getpid());
vfprintf(cf, fmt, args);
fprintf(cf, "\n");
fflush(cf);
vfprintf(log_file, fmt, args);
fprintf(log_file, "\n");
fclose(log_file);
#ifdef HAVE_SYSLOG_H
}
#endif
+9 -28
View File
@@ -1,4 +1,4 @@
/* $Id: tinyproxy.c,v 1.36 2002-06-06 20:28:02 rjkaes Exp $
/* $Id: tinyproxy.c,v 1.38 2002-07-12 17:02:02 rjkaes Exp $
*
* The initialize routine. Basically sets up all the initial stuff (logfile,
* listening socket, config options, etc.) and then sits there and loops
@@ -46,7 +46,7 @@ extern FILE *yyin;
*/
struct config_s config;
float load = 0.00;
bool_t log_rotation_request = FALSE;
bool_t received_sighup = FALSE;
bool_t processed_config_file = FALSE;
/*
@@ -60,7 +60,7 @@ takesig(int sig)
switch (sig) {
case SIGHUP:
log_rotation_request = TRUE;
received_sighup = TRUE;
break;
case SIGTERM:
@@ -170,6 +170,8 @@ main(int argc, char **argv)
}
#endif /* HAVE_SETRLIMIT */
log_message(LOG_INFO, "Initializing " PACKAGE " ...");
/*
* Process the various options
*/
@@ -211,7 +213,6 @@ main(int argc, char **argv)
exit(EX_SOFTWARE);
}
yyparse();
processed_config_file = TRUE;
#if defined(TUNNEL_SUPPORT) && defined(UPSTREAM_SUPPORT)
if (config.tunnel_name && config.upstream_name) {
@@ -224,29 +225,12 @@ main(int argc, char **argv)
/* Open the log file if not using syslog */
if (config.syslog == FALSE) {
int log_file_fd;
if (!config.logf_name) {
fprintf(stderr,
"%s: You MUST set a LogFile in the configuration file.\n",
argv[0]);
exit(EX_SOFTWARE);
}
log_file_fd = create_file_safely(config.logf_name, FALSE);
if (log_file_fd < 0) {
fprintf(stderr,
"Could not safely create logfile \"%s\".\n",
config.logf_name);
exit(EX_CANTCREAT);
}
config.logf = fdopen(log_file_fd, "w+");
if (!config.logf) {
fprintf(stderr, "Could not write to log file \"%s\".\n",
config.logf_name);
exit(EX_CANTCREAT);
}
} else {
if (godaemon == TRUE)
openlog("tinyproxy", LOG_PID, LOG_DAEMON);
@@ -254,10 +238,6 @@ main(int argc, char **argv)
openlog("tinyproxy", LOG_PID, LOG_USER);
}
log_message(LOG_INFO, PACKAGE " " VERSION " starting...");
send_stored_logs();
/*
* Set the default values if they were not set in the config file.
*/
@@ -372,6 +352,9 @@ main(int argc, char **argv)
exit(EX_SOFTWARE);
}
processed_config_file = TRUE;
send_stored_logs();
/*
* These signals are only for the parent process.
*/
@@ -422,9 +405,7 @@ main(int argc, char **argv)
filter_destroy();
#endif /* FILTER_ENABLE */
if (config.syslog == FALSE)
fclose(config.logf);
else
if (config.syslog)
closelog();
exit(EX_OK);
+2 -3
View File
@@ -1,4 +1,4 @@
/* $Id: tinyproxy.h,v 1.32 2002-05-27 01:59:28 rjkaes Exp $
/* $Id: tinyproxy.h,v 1.33 2002-06-15 17:29:59 rjkaes Exp $
*
* See 'tinyproxy.c' for a detailed description.
*
@@ -26,7 +26,6 @@
#define MAX_IDLE_TIME (60 * 10) /* 10 minutes of no activity */
struct config_s {
FILE *logf;
char *logf_name;
bool_t syslog;
int port;
@@ -61,7 +60,7 @@ struct config_s {
/* Global Structures used in the program */
extern struct config_s config;
extern bool_t log_rotation_request;
extern bool_t received_sighup;
extern bool_t processed_config_file;
#endif
+29 -97
View File
@@ -1,4 +1,4 @@
/* $Id: utils.c,v 1.32 2002-05-31 18:26:30 rjkaes Exp $
/* $Id: utils.c,v 1.34 2002-07-09 19:02:57 rjkaes Exp $
*
* 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,
@@ -154,10 +154,10 @@ create_file_safely(const char *filename, bool_t truncate_file)
* existing", exit.
*/
if (errno != ENOENT) {
log_message(LOG_ERR,
"create_file_safely: Error checking file %s: %s.",
filename, strerror(errno));
return -1;
fprintf(stderr,
"%s: Error checking file %s: %s\n",
PACKAGE, filename, strerror(errno));
exit(EX_IOERR);
}
/*
@@ -167,10 +167,10 @@ create_file_safely(const char *filename, bool_t truncate_file)
*/
if ((fildes =
open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
log_message(LOG_ERR,
"create_file_safely: Could not create file %s: %s.",
filename, strerror(errno));
return -1;
fprintf(stderr,
"%s: Could not create file %s: %s\n",
PACKAGE, filename, strerror(errno));
exit(EX_CANTCREAT);
}
} else {
struct stat fstatinfo;
@@ -184,10 +184,10 @@ create_file_safely(const char *filename, bool_t truncate_file)
* Open an existing file.
*/
if ((fildes = open(filename, flags)) < 0) {
log_message(LOG_ERR,
"create_file_safely: Could not open file %s: %s.",
filename, strerror(errno));
return -1;
fprintf(stderr,
"%s: Could not open file %s: %s\n",
PACKAGE, filename, strerror(errno));
exit(EX_IOERR);
}
/*
@@ -198,11 +198,11 @@ create_file_safely(const char *filename, bool_t truncate_file)
|| lstatinfo.st_mode != fstatinfo.st_mode
|| lstatinfo.st_ino != fstatinfo.st_ino
|| lstatinfo.st_dev != fstatinfo.st_dev) {
log_message(LOG_ERR,
"create_file_safely: The file %s has been changed before it could be opened.",
filename);
fprintf(stderr,
"%s: The file %s has been changed before it could be opened\n",
PACKAGE, filename);
close(fildes);
return -1;
exit(EX_IOERR);
}
/*
@@ -213,11 +213,11 @@ create_file_safely(const char *filename, bool_t truncate_file)
* st_mode check would also find this)
*/
if (fstatinfo.st_nlink > 1 || !S_ISREG(lstatinfo.st_mode)) {
log_message(LOG_ERR,
"create_file_safely: The file %s has too many links, or is not a regular file: %s.",
filename, strerror(errno));
fprintf(stderr,
"%s: The file %s has too many links, or is not a regular file: %s\n",
PACKAGE, filename, strerror(errno));
close(fildes);
return -1;
exit(EX_IOERR);
}
/*
@@ -241,10 +241,10 @@ create_file_safely(const char *filename, bool_t truncate_file)
close(fildes);
if ((fildes =
open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
log_message(LOG_ERR,
"create_file_safely: Could not open file %s: %s.",
filename, strerror(errno));
return -1;
fprintf(stderr,
"%s: Could not open file %s: %s.",
PACKAGE, filename, strerror(errno));
exit(EX_IOERR);
}
#endif /* HAVE_FTRUNCATE */
}
@@ -271,82 +271,14 @@ pidfile_create(const char *filename)
* Open a stdio file over the low-level one.
*/
if ((fd = fdopen(fildes, "w")) == NULL) {
log_message(LOG_ERR,
"pidfile_create: fdopen() error on PID file %s: %s.",
filename, strerror(errno));
fprintf(stderr,
"%s: Could not write PID file %s: %s.",
PACKAGE, filename, strerror(errno));
close(fildes);
unlink(filename);
exit(1);
exit(EX_IOERR);
}
fprintf(fd, "%ld\n", (long) getpid());
fclose(fd);
}
/*
* Rotate the current log file. This is performed whenever a SIGHUP is
* received.
*/
void
rotate_log_files(void)
{
char* rename_file;
int log_file_des;
FILE *old_fd;
FILE* new_fd;
log_message(LOG_NOTICE, "SIGHUP received, cleaning up.");
#ifdef FILTER_ENABLE
if (config.filter) {
filter_destroy();
filter_init();
}
log_message(LOG_NOTICE, "Re-reading filter file.");
#endif /* FILTER_ENABLE */
if (config.logf) {
rename_file = safemalloc(strlen(config.logf_name) + 5);
if (!rename_file) {
log_message(LOG_CRIT,
"Could not allocate memory when trying to rotate the log file; therefore, the log has not been rotated.");
return;
}
strcpy(rename_file, config.logf_name);
strcat(rename_file, ".rot");
rename(config.logf_name, rename_file);
log_file_des = create_file_safely(config.logf_name, TRUE);
if (log_file_des < 0) {
log_message(LOG_CRIT,
"Could not properly create the new log file; therefore the log has not been rotated.");
/* Switch the file name back */
rename(rename_file, config.logf_name);
safefree(rename_file);
return;
}
old_fd = config.logf;
if (!(new_fd = fdopen(log_file_des, "w"))) {
log_message(LOG_CRIT,
"Could not create the new log file; therefore, the log has not been rotated.");
/* Switch the file name back */
rename(rename_file, config.logf_name);
safefree(rename_file);
}
config.logf = new_fd;
fclose(old_fd);
log_message(LOG_NOTICE, "Log file rotated.");
safefree(rename_file);
}
log_message(LOG_NOTICE,
"Finished cleaning memory/connections.");
}
+1 -3
View File
@@ -1,4 +1,4 @@
/* $Id: utils.h,v 1.19 2002-05-31 18:27:13 rjkaes Exp $
/* $Id: utils.h,v 1.20 2002-06-15 17:28:19 rjkaes Exp $
*
* See 'utils.h' for a detailed description.
*
@@ -32,6 +32,4 @@ extern int indicate_http_error(struct conn_s* connptr, int number, const char *s
extern void pidfile_create(const char *path);
extern int create_file_safely(const char *filename, bool_t truncate_file);
extern void rotate_log_files(void);
#endif