Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa3b9d2168 |
No files matched your search
@@ -1,39 +1,5 @@
|
||||
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>
|
||||
|
||||
* src/heap.c (malloc_shared_memory):
|
||||
Removed the MMAP_ANON and open("/dev/zero") since they are not
|
||||
portable across a while enough spectrum of machines. Right now
|
||||
tinyproxy is using a "classic" temporary file method of sharing
|
||||
memory. This will likely be improved in the future.
|
||||
|
||||
* src/child.c, src/stats.c:
|
||||
Changed the tests on the return value from malloc_shared_memory()
|
||||
to make tinyproxy more portable, since we can't be certain that
|
||||
"if (!ret_value)" would actually detect a mmap() error.
|
||||
|
||||
* src/reqs.c (add_header_to_connection):
|
||||
Removed the "double_cgi" boolean, since tinyproxy now ignores all
|
||||
the headers after a "double CGI" situation has occurred.
|
||||
|
||||
+2
-2
@@ -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.34 2002-05-29 18:15:40 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.1pre4], [rjkaes@users.sourceforge.net])
|
||||
AC_INIT([tinyproxy], [1.5.1pre2], [rjkaes@users.sourceforge.net])
|
||||
AC_CONFIG_SRCDIR([src/tinyproxy.c])
|
||||
AC_PREREQ(2.52)
|
||||
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
/* $Id: child.c,v 1.2 2002-05-29 20:49:55 rjkaes Exp $
|
||||
/* $Id: child.c,v 1.1 2002-05-26 18:45:26 rjkaes Exp $
|
||||
*
|
||||
* Handles the creation/destruction of the various children required for
|
||||
* processing incoming connections.
|
||||
@@ -269,14 +269,14 @@ child_pool_create(void)
|
||||
}
|
||||
|
||||
child_ptr = calloc_shared_memory(child_config.maxclients,
|
||||
sizeof(struct child_s));
|
||||
sizeof(struct child_s));
|
||||
if (!child_ptr) {
|
||||
log_message(LOG_ERR, "Could not allocate memory for children.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
servers_waiting = malloc_shared_memory(sizeof(int));
|
||||
if (servers_waiting == MAP_FAILED) {
|
||||
if (!servers_waiting) {
|
||||
log_message(LOG_ERR, "Could not allocate memory for child counting.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
+12
-24
@@ -1,4 +1,4 @@
|
||||
/* $Id: heap.c,v 1.3 2002-05-29 20:51:35 rjkaes Exp $
|
||||
/* $Id: heap.c,v 1.2 2002-05-26 18:56:06 rjkaes Exp $
|
||||
*
|
||||
* Debugging versions of various heap related functions are combined
|
||||
* here. The debugging versions include assertions and also print
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include "tinyproxy.h"
|
||||
#include "heap.h"
|
||||
#include "text.h"
|
||||
|
||||
void *
|
||||
debugging_calloc(size_t nmemb, size_t size, const char *file,
|
||||
@@ -93,35 +92,24 @@ debugging_strdup(const char* s, const char* file, unsigned long line)
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a block of memory in the "shared" memory region.
|
||||
*
|
||||
* FIXME: This uses the most basic (and slowest) means of creating a
|
||||
* shared memory location. It requires the use of a temporary file. We might
|
||||
* want to look into something like MM (Shared Memory Library) for a better
|
||||
* solution.
|
||||
* Allocate a block of memory in the "shared" memory region
|
||||
*/
|
||||
void*
|
||||
malloc_shared_memory(size_t size)
|
||||
{
|
||||
int fd;
|
||||
void* ptr;
|
||||
char buffer[128];
|
||||
|
||||
static char* shared_file = "/tmp/tinyproxy.shared";
|
||||
|
||||
assert(size > 0);
|
||||
assert(shared_file != NULL);
|
||||
|
||||
#ifdef MAP_ANON
|
||||
ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
|
||||
#else
|
||||
fd = open("/dev/zero", O_RDWR, 0);
|
||||
|
||||
strlcpy(buffer, shared_file, sizeof(buffer) - 8);
|
||||
strlcat(buffer, ".XXXXXX", sizeof(buffer));
|
||||
|
||||
if ((fd = mkstemp(buffer)) == -1)
|
||||
return (void *)MAP_FAILED;
|
||||
unlink(buffer);
|
||||
|
||||
if (ftruncate(fd, size) == -1)
|
||||
return (void *)MAP_FAILED;
|
||||
ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
close(fd);
|
||||
#endif
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@@ -142,8 +130,8 @@ calloc_shared_memory(size_t nmemb, size_t size)
|
||||
length = nmemb * size;
|
||||
|
||||
ptr = malloc_shared_memory(length);
|
||||
if (ptr == MAP_FAILED)
|
||||
return ptr;
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
memset(ptr, 0, length);
|
||||
|
||||
|
||||
+2
-2
@@ -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
|
||||
* 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 */
|
||||
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);
|
||||
if (ret < 0)
|
||||
goto ERROR_EXIT;
|
||||
|
||||
+3
-4
@@ -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
|
||||
* 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);
|
||||
}
|
||||
|
||||
result = gethostbyaddr((char *)&name.sin_addr.s_addr, 4, AF_INET);
|
||||
result = gethostbyaddr(ipaddr, strlen(ipaddr), AF_INET);
|
||||
if (result) {
|
||||
strlcpy(string_addr, result->h_name, PEER_STRING_LENGTH);
|
||||
return 0;
|
||||
} else {
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
/* $Id: stats.c,v 1.12 2002-05-29 20:49:55 rjkaes Exp $
|
||||
/* $Id: stats.c,v 1.11 2002-05-29 17:31:01 rjkaes Exp $
|
||||
*
|
||||
* This module handles the statistics for tinyproxy. There are only two
|
||||
* public API functions. The reason for the functions, rather than just a
|
||||
@@ -45,7 +45,7 @@ void
|
||||
init_stats(void)
|
||||
{
|
||||
stats = malloc_shared_memory(sizeof(struct stat_s));
|
||||
if (stats == MAP_FAILED)
|
||||
if (!stats)
|
||||
return;
|
||||
|
||||
memset(stats, 0, sizeof(struct stat));
|
||||
|
||||
+3
-3
@@ -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,
|
||||
* listening socket, config options, etc.) and then sits there and loops
|
||||
@@ -230,7 +230,7 @@ main(int argc, char **argv)
|
||||
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) {
|
||||
fprintf(stderr,
|
||||
"Could not safely create logfile \"%s\".\n",
|
||||
@@ -238,7 +238,7 @@ main(int argc, char **argv)
|
||||
exit(EX_CANTCREAT);
|
||||
}
|
||||
|
||||
config.logf = fdopen(log_file_fd, "w+");
|
||||
config.logf = fdopen(log_file_fd, "w");
|
||||
if (!config.logf) {
|
||||
fprintf(stderr, "Could not write to log file \"%s\".\n",
|
||||
config.logf_name);
|
||||
|
||||
+11
-23
@@ -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
|
||||
* 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.
|
||||
*/
|
||||
int
|
||||
create_file_safely(const char *filename, bool_t truncate_file)
|
||||
create_file_safely(const char *filename)
|
||||
{
|
||||
struct stat lstatinfo;
|
||||
int fildes;
|
||||
@@ -155,7 +155,7 @@ create_file_safely(const char *filename, bool_t truncate_file)
|
||||
*/
|
||||
if (errno != ENOENT) {
|
||||
log_message(LOG_ERR,
|
||||
"create_file_safely: Error checking file %s: %s.",
|
||||
"create_file_safely: Error checking PID file %s: %s.",
|
||||
filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
@@ -168,24 +168,19 @@ 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.",
|
||||
"create_file_safely: Could not create PID file %s: %s.",
|
||||
filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
struct stat fstatinfo;
|
||||
int flags;
|
||||
|
||||
flags = O_RDWR;
|
||||
if (!truncate_file)
|
||||
flags |= O_APPEND;
|
||||
|
||||
/*
|
||||
* Open an existing file.
|
||||
*/
|
||||
if ((fildes = open(filename, flags)) < 0) {
|
||||
if ((fildes = open(filename, O_RDWR)) < 0) {
|
||||
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));
|
||||
return -1;
|
||||
}
|
||||
@@ -199,7 +194,7 @@ create_file_safely(const char *filename, bool_t truncate_file)
|
||||
|| 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.",
|
||||
"create_file_safely: The PID file %s has been changed before it could be opened.",
|
||||
filename);
|
||||
close(fildes);
|
||||
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)) {
|
||||
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));
|
||||
close(fildes);
|
||||
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
|
||||
* 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 =
|
||||
open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
|
||||
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));
|
||||
return -1;
|
||||
}
|
||||
@@ -264,7 +252,7 @@ pidfile_create(const char *filename)
|
||||
/*
|
||||
* Create a new file
|
||||
*/
|
||||
if ((fildes = create_file_safely(filename, TRUE)) < 0)
|
||||
if ((fildes = create_file_safely(filename)) < 0)
|
||||
exit(1);
|
||||
|
||||
/*
|
||||
@@ -318,7 +306,7 @@ rotate_log_files(void)
|
||||
|
||||
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) {
|
||||
log_message(LOG_CRIT,
|
||||
"Could not properly create the new log file; therefore the log has not been rotated.");
|
||||
|
||||
+2
-2
@@ -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.
|
||||
*
|
||||
@@ -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 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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user