Compare commits

..
1 Commits
Author SHA1 Message Date
cvs2svn 32af30e414 This commit was manufactured by cvs2svn to create tag
'rel_1_5_1pre3'.
2002-05-29 20:57:26 +00:00
7 changed files with 23 additions and 59 deletions

No files matched your search

-23
View File
@@ -1,26 +1,3 @@
2002-05-31 Robert James Kaes <rjkaes@flarenet.com>
* src/utils.c (create_file_safely):
Added the "truncate_file" boolean flag. This is needed since I
use this function for both the log file and the pid file, and they
behave differently when tinyproxy is started.
(pidfile_create): Call create_file_safely() with a TRUE
"truncate_file" flag so that the file is emptied whenever the pid
file is needed.
* src/tinyproxy.c:
The log file is now opened in "append" mode so that you can
restart tinyproxy without losing the log file.
* src/reqs.c (process_server_headers):
Since we're stripping off the carriage return and newline, we need
to add them back on when sending the response header to the
client.
* src/sock.c (getpeer_information):
Fixed a problem retrieving the FQDN of a host because I was
passing in an incorrect parameter to gethostbyaddr(). D'oh.
2002-05-29 Robert James Kaes <rjkaes@flarenet.com> 2002-05-29 Robert James Kaes <rjkaes@flarenet.com>
* src/heap.c (malloc_shared_memory): * src/heap.c (malloc_shared_memory):
+2 -2
View File
@@ -1,4 +1,4 @@
dnl $Id: configure.ac,v 2.36 2002-05-31 18:09:51 rjkaes Exp $ dnl $Id: configure.ac,v 2.35 2002-05-29 20:55:47 rjkaes Exp $
dnl Devlopers, please strive to achieve this order: dnl Devlopers, please strive to achieve this order:
dnl dnl
@@ -14,7 +14,7 @@ dnl 8. System services
dnl dnl
dnl Read the Autoconf manual for details. dnl Read the Autoconf manual for details.
AC_INIT([tinyproxy], [1.5.1pre4], [rjkaes@users.sourceforge.net]) AC_INIT([tinyproxy], [1.5.1pre3], [rjkaes@users.sourceforge.net])
AC_CONFIG_SRCDIR([src/tinyproxy.c]) AC_CONFIG_SRCDIR([src/tinyproxy.c])
AC_PREREQ(2.52) AC_PREREQ(2.52)
+2 -2
View File
@@ -1,4 +1,4 @@
/* $Id: reqs.c,v 1.81 2002-05-31 18:09:09 rjkaes Exp $ /* $Id: reqs.c,v 1.80 2002-05-29 18:11:57 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 child created for them. The child then * connections have a new child created for them. The child then
@@ -917,7 +917,7 @@ process_server_headers(struct conn_s *connptr)
} }
/* Send the saved response line first */ /* Send the saved response line first */
ret = write_message(connptr->client_fd, "%s\r\n", response_line); ret = safe_write(connptr->client_fd, response_line, strlen(response_line));
safefree(response_line); safefree(response_line);
if (ret < 0) if (ret < 0)
goto ERROR_EXIT; goto ERROR_EXIT;
+3 -4
View File
@@ -1,4 +1,4 @@
/* $Id: sock.c,v 1.38 2002-05-31 18:08:01 rjkaes Exp $ /* $Id: sock.c,v 1.37 2002-05-27 01:57:48 rjkaes Exp $
* *
* Sockets are created and destroyed here. When a new connection comes in from * Sockets are created and destroyed here. When a new connection comes in from
* a client, we need to copy the socket and the create a second socket to the * a client, we need to copy the socket and the create a second socket to the
@@ -221,11 +221,10 @@ getpeer_information(int fd, char* ipaddr, char* string_addr)
PEER_IP_LENGTH); PEER_IP_LENGTH);
} }
result = gethostbyaddr((char *)&name.sin_addr.s_addr, 4, AF_INET); result = gethostbyaddr(ipaddr, strlen(ipaddr), AF_INET);
if (result) { if (result) {
strlcpy(string_addr, result->h_name, PEER_STRING_LENGTH); strlcpy(string_addr, result->h_name, PEER_STRING_LENGTH);
return 0; return 0;
} else { } else
return -1; return -1;
}
} }
+3 -3
View File
@@ -1,4 +1,4 @@
/* $Id: tinyproxy.c,v 1.35 2002-05-31 18:24:36 rjkaes Exp $ /* $Id: tinyproxy.c,v 1.34 2002-05-27 01:58:41 rjkaes Exp $
* *
* The initialize routine. Basically sets up all the initial stuff (logfile, * The initialize routine. Basically sets up all the initial stuff (logfile,
* listening socket, config options, etc.) and then sits there and loops * listening socket, config options, etc.) and then sits there and loops
@@ -230,7 +230,7 @@ main(int argc, char **argv)
exit(EX_SOFTWARE); exit(EX_SOFTWARE);
} }
log_file_fd = create_file_safely(config.logf_name, FALSE); log_file_fd = create_file_safely(config.logf_name);
if (log_file_fd < 0) { if (log_file_fd < 0) {
fprintf(stderr, fprintf(stderr,
"Could not safely create logfile \"%s\".\n", "Could not safely create logfile \"%s\".\n",
@@ -238,7 +238,7 @@ main(int argc, char **argv)
exit(EX_CANTCREAT); exit(EX_CANTCREAT);
} }
config.logf = fdopen(log_file_fd, "w+"); config.logf = fdopen(log_file_fd, "w");
if (!config.logf) { if (!config.logf) {
fprintf(stderr, "Could not write to log file \"%s\".\n", fprintf(stderr, "Could not write to log file \"%s\".\n",
config.logf_name); config.logf_name);
+11 -23
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.31 2002-05-24 04:45:32 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,
@@ -138,7 +138,7 @@ indicate_http_error(struct conn_s* connptr, int number, const char* string)
* Safely creates filename and returns the low-level file descriptor. * Safely creates filename and returns the low-level file descriptor.
*/ */
int int
create_file_safely(const char *filename, bool_t truncate_file) create_file_safely(const char *filename)
{ {
struct stat lstatinfo; struct stat lstatinfo;
int fildes; int fildes;
@@ -155,7 +155,7 @@ create_file_safely(const char *filename, bool_t truncate_file)
*/ */
if (errno != ENOENT) { if (errno != ENOENT) {
log_message(LOG_ERR, log_message(LOG_ERR,
"create_file_safely: Error checking file %s: %s.", "create_file_safely: Error checking PID file %s: %s.",
filename, strerror(errno)); filename, strerror(errno));
return -1; return -1;
} }
@@ -168,24 +168,19 @@ create_file_safely(const char *filename, bool_t truncate_file)
if ((fildes = if ((fildes =
open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) { open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
log_message(LOG_ERR, log_message(LOG_ERR,
"create_file_safely: Could not create file %s: %s.", "create_file_safely: Could not create PID file %s: %s.",
filename, strerror(errno)); filename, strerror(errno));
return -1; return -1;
} }
} else { } else {
struct stat fstatinfo; struct stat fstatinfo;
int flags;
flags = O_RDWR;
if (!truncate_file)
flags |= O_APPEND;
/* /*
* Open an existing file. * Open an existing file.
*/ */
if ((fildes = open(filename, flags)) < 0) { if ((fildes = open(filename, O_RDWR)) < 0) {
log_message(LOG_ERR, log_message(LOG_ERR,
"create_file_safely: Could not open file %s: %s.", "create_file_safely: Could not open PID file %s: %s.",
filename, strerror(errno)); filename, strerror(errno));
return -1; return -1;
} }
@@ -199,7 +194,7 @@ create_file_safely(const char *filename, bool_t truncate_file)
|| lstatinfo.st_ino != fstatinfo.st_ino || lstatinfo.st_ino != fstatinfo.st_ino
|| lstatinfo.st_dev != fstatinfo.st_dev) { || lstatinfo.st_dev != fstatinfo.st_dev) {
log_message(LOG_ERR, log_message(LOG_ERR,
"create_file_safely: The file %s has been changed before it could be opened.", "create_file_safely: The PID file %s has been changed before it could be opened.",
filename); filename);
close(fildes); close(fildes);
return -1; return -1;
@@ -214,19 +209,12 @@ create_file_safely(const char *filename, bool_t truncate_file)
*/ */
if (fstatinfo.st_nlink > 1 || !S_ISREG(lstatinfo.st_mode)) { if (fstatinfo.st_nlink > 1 || !S_ISREG(lstatinfo.st_mode)) {
log_message(LOG_ERR, log_message(LOG_ERR,
"create_file_safely: The file %s has too many links, or is not a regular file: %s.", "create_file_safely: The PID file %s has too many links, or is not a regular file: %s.",
filename, strerror(errno)); filename, strerror(errno));
close(fildes); close(fildes);
return -1; return -1;
} }
/*
* Just return the file descriptor if we _don't_ want the file
* truncated.
*/
if (!truncate_file)
return fildes;
/* /*
* On systems which don't support ftruncate() the best we can * On systems which don't support ftruncate() the best we can
* do is to close the file and reopen it in create mode, which * do is to close the file and reopen it in create mode, which
@@ -242,7 +230,7 @@ create_file_safely(const char *filename, bool_t truncate_file)
if ((fildes = if ((fildes =
open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) { open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
log_message(LOG_ERR, log_message(LOG_ERR,
"create_file_safely: Could not open file %s: %s.", "create_file_safely: Could not open PID file %s: %s.",
filename, strerror(errno)); filename, strerror(errno));
return -1; return -1;
} }
@@ -264,7 +252,7 @@ pidfile_create(const char *filename)
/* /*
* Create a new file * Create a new file
*/ */
if ((fildes = create_file_safely(filename, TRUE)) < 0) if ((fildes = create_file_safely(filename)) < 0)
exit(1); exit(1);
/* /*
@@ -318,7 +306,7 @@ rotate_log_files(void)
rename(config.logf_name, rename_file); rename(config.logf_name, rename_file);
log_file_des = create_file_safely(config.logf_name, TRUE); log_file_des = create_file_safely(config.logf_name);
if (log_file_des < 0) { if (log_file_des < 0) {
log_message(LOG_CRIT, log_message(LOG_CRIT,
"Could not properly create the new log file; therefore the log has not been rotated."); "Could not properly create the new log file; therefore the log has not been rotated.");
+2 -2
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.18 2002-05-23 18:28:12 rjkaes Exp $
* *
* See 'utils.h' for a detailed description. * See 'utils.h' for a detailed description.
* *
@@ -30,7 +30,7 @@ extern int send_http_error_message(struct conn_s *connptr);
extern int indicate_http_error(struct conn_s* connptr, int number, const char *string); extern int indicate_http_error(struct conn_s* connptr, int number, const char *string);
extern void pidfile_create(const char *path); extern void pidfile_create(const char *path);
extern int create_file_safely(const char *filename, bool_t truncate_file); extern int create_file_safely(const char *filename);
extern void rotate_log_files(void); extern void rotate_log_files(void);