Compare commits

..
13 Commits
Author SHA1 Message Date
Mukund Sivaraman 18db1675a0 Update NEWS 2011-08-16 17:56:04 +05:30
Mukund Sivaraman 4d979df636 Bump version to 1.8.3 2011-08-16 17:45:06 +05:30
Mukund Sivaraman fc354343f9 Minor whitespace fix 2011-08-16 17:43:59 +05:30
Mukund Sivaraman 1db982793d [BB#90]: Fix bug in ACL netmask generation
Thanks to John Horne who diagnosed this issue and found the problem.
2011-03-04 14:47:54 +05:30
Mukund Sivaraman 95a6f8259c Validate port number specified in Port directive
This was asked in bug #90 comment #8.
2011-03-04 14:10:11 +05:30
Mukund Sivaraman 8b76f1a939 Update URLs of Tinyproxy 2011-02-28 12:46:46 +05:30
Mukund Sivaraman 121a11d8e5 Surround IPv6 literals with [] in Host: headers 2011-02-07 18:01:03 +05:30
Mukund Sivaraman 736e052dc1 Handle IPv6 literals in URLs correctly 2011-02-04 21:03:12 +05:30
Michael Adam aa197d6dc8 [BB#95] remove two comments that have become wrong by the fix. 2010-12-01 22:21:11 +01:00
Daniel Egger d13d575d29 [BB#95] Fix FilterURLs with transparent proxy support.
Pass a pointer to a char pointer to do_transparent_proxy so the reassembled URL
will actually end up back in the caller where it is needed for filtering
decisions. This fixes the problem that a tinyproxy configured with the
transparent proxy functionality and "FilterURLs Yes" would filter on everything
but the domain.

Signed-off-by: daniel.egger@sphairon.com
Signed-off-by: Michael Adam <obnox@samba.org>
2010-12-01 22:18:08 +01:00
Michael Adam c4b187c8ab README: correctly list --enable-transparent
--enable-transparent-proxy was renamed to --enable-transparent
in August 2004... :-)
2010-12-01 21:44:32 +01:00
Michael Adam 5012ce690f [BB#91] Fix upstream proxy support.
Patch by Jordi Mallach.
2010-08-24 22:50:53 +02:00
Michael Adam 4b75b634d9 upstream: clarify debug messages
There are frequent questions "what does 'No proxy for ...' mean?"
on the mailing list and IRC. Be more specific. (No upstream proxy ...)
Correspondingly, log "Found upstream proxy ... for ..."
2010-08-24 22:50:48 +02:00
11 changed files with 103 additions and 40 deletions

No files matched your search

+19
View File
@@ -1,6 +1,25 @@
Tinyproxy NEWS Tinyproxy NEWS
============== ==============
Version 1.8.3
-------------
This release mostly fixes support for IPv6, and also some security
bugs. Fixes to messages, etc. were also made.
Bugs resolved since version 1.8.2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* BB#91: Fix upstream proxy support
* BB#95: Fix FilterURLs with transparent proxy support
* BB#90: Fix bug in ACL netmask generation
Contributors
~~~~~~~~~~~~
Daniel Egger, John Horne, Michael Adam, Mukund Sivaraman.
Version 1.8.2 Version 1.8.2
------------- -------------
+8 -8
View File
@@ -15,7 +15,7 @@ administrator.
For more info, please visit: For more info, please visit:
https://www.banu.com/tinyproxy/ https://banu.com/tinyproxy/
Installation Installation
@@ -44,7 +44,7 @@ include:
domains and URLs. domains and URLs.
--enable-upstream Enable support for proxying connections --enable-upstream Enable support for proxying connections
through another proxy server. through another proxy server.
--enable-transparent-proxy --enable-transparent
Allow Tinyproxy to be used as a Allow Tinyproxy to be used as a
transparent proxy daemon transparent proxy daemon
--enable-static Compile a static version of Tinyproxy --enable-static Compile a static version of Tinyproxy
@@ -58,14 +58,14 @@ Support
If you are having problems with Tinyproxy, please submit a bug report If you are having problems with Tinyproxy, please submit a bug report
using Tinyproxy as the product at: using Tinyproxy as the product at:
https://www.banu.com/bugzilla/ https://banu.com/bugzilla/
You may also wish to subscribe to the Tinyproxy mailing lists. To do so You may also wish to subscribe to the Tinyproxy mailing lists. To do so
please visit: please visit:
https://www.banu.com/mailman/listinfo/tinyproxy-announce-list https://banu.com/mailman/listinfo/tinyproxy-announce-list
https://www.banu.com/mailman/listinfo/tinyproxy-users-list https://banu.com/mailman/listinfo/tinyproxy-users-list
https://www.banu.com/mailman/listinfo/tinyproxy-developers-list https://banu.com/mailman/listinfo/tinyproxy-developers-list
for more information on how to subscribe and post messages to the lists. for more information on how to subscribe and post messages to the lists.
@@ -79,11 +79,11 @@ source, please send a patch (preferably as a unified diff. i.e. `diff
repository to tinyproxy-developers-list. Please include a description repository to tinyproxy-developers-list. Please include a description
of what your patch does. of what your patch does.
Tinyproxy's git repository is git://www.banu.com/tinyproxy.git. The Tinyproxy's git repository is git://banu.com/tinyproxy.git. The
following command creates a local copy: following command creates a local copy:
---- ----
git clone git://www.banu.com/tinyproxy.git git clone git://banu.com/tinyproxy.git
---- ----
The easiest and preferred way to create a patch for submission is to The easiest and preferred way to create a patch for submission is to
+2 -2
View File
@@ -5,7 +5,7 @@ AC_PREREQ(2.54)
m4_define([tinyproxy_major_version], [1]) m4_define([tinyproxy_major_version], [1])
m4_define([tinyproxy_minor_version], [8]) m4_define([tinyproxy_minor_version], [8])
m4_define([tinyproxy_micro_version], [2]) m4_define([tinyproxy_micro_version], [3])
m4_define([tinyproxy_real_version], m4_define([tinyproxy_real_version],
[tinyproxy_major_version.tinyproxy_minor_version.tinyproxy_micro_version]) [tinyproxy_major_version.tinyproxy_minor_version.tinyproxy_micro_version])
m4_define([tinyproxy_version], [tinyproxy_real_version]) m4_define([tinyproxy_version], [tinyproxy_real_version])
@@ -19,7 +19,7 @@ m4_define([tinyproxy_stable],
m4_if(m4_eval(tinyproxy_minor_version % 2), [0], [yes], [no])) m4_if(m4_eval(tinyproxy_minor_version % 2), [0], [yes], [no]))
AC_INIT([Tinyproxy], [tinyproxy_version], AC_INIT([Tinyproxy], [tinyproxy_version],
[https://www.banu.com/tinyproxy/], [https://banu.com/tinyproxy/],
[tinyproxy]) [tinyproxy])
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
+21 -4
View File
@@ -66,8 +66,8 @@ struct acl_s {
* *
*/ */
static int static int
fill_netmask_array (char *bitmask_string, unsigned char array[], fill_netmask_array (char *bitmask_string, int v6,
size_t len) unsigned char array[], size_t len)
{ {
unsigned int i; unsigned int i;
unsigned long int mask; unsigned long int mask;
@@ -81,7 +81,14 @@ fill_netmask_array (char *bitmask_string, unsigned char array[],
|| (errno != 0 && mask == 0) || (endptr == bitmask_string)) || (errno != 0 && mask == 0) || (endptr == bitmask_string))
return -1; return -1;
/* valid range for a bit mask */ if (v6 == 0) {
/* The mask comparison is done as an IPv6 address, so
* convert to a longer mask in the case of IPv4
* addresses. */
mask += 12 * 8;
}
/* check valid range for a bit mask */
if (mask > (8 * len)) if (mask > (8 * len))
return -1; return -1;
@@ -160,6 +167,9 @@ int insert_acl (char *location, acl_access_t access_type, vector_t *access_list)
*/ */
p = strchr (location, '/'); p = strchr (location, '/');
if (p != NULL) { if (p != NULL) {
char dst[sizeof(struct in6_addr)];
int v6;
/* /*
* We have a slash, so it's intended to be an * We have a slash, so it's intended to be an
* IP address with mask * IP address with mask
@@ -171,8 +181,15 @@ int insert_acl (char *location, acl_access_t access_type, vector_t *access_list)
acl.type = ACL_NUMERIC; acl.type = ACL_NUMERIC;
memcpy (acl.address.ip.octet, ip_dst, IPV6_LEN); memcpy (acl.address.ip.octet, ip_dst, IPV6_LEN);
/* Check if the IP address before the netmask is
* an IPv6 address */
if (inet_pton(AF_INET6, location, dst) > 0)
v6 = 1;
else
v6 = 0;
if (fill_netmask_array if (fill_netmask_array
(p + 1, &(acl.address.ip.mask[0]), IPV6_LEN) (p + 1, v6, &(acl.address.ip.mask[0]), IPV6_LEN)
< 0) < 0)
return -1; return -1;
} else { } else {
+11 -3
View File
@@ -779,7 +779,15 @@ static HANDLE_FUNC (handle_bindsame)
static HANDLE_FUNC (handle_port) static HANDLE_FUNC (handle_port)
{ {
return set_int_arg (&conf->port, line, &match[2]); set_int_arg (&conf->port, line, &match[2]);
if (conf->port > 65535) {
fprintf (stderr, "Bad port number (%d) supplied for Port.\n",
conf->port);
return 1;
}
return 0;
} }
static HANDLE_FUNC (handle_maxclients) static HANDLE_FUNC (handle_maxclients)
@@ -1046,8 +1054,8 @@ static HANDLE_FUNC (handle_upstream)
return -1; return -1;
port = (int) get_long_arg (line, &match[7]); port = (int) get_long_arg (line, &match[7]);
if (match[9].rm_so != -1) { if (match[10].rm_so != -1) {
domain = get_string_arg (line, &match[9]); domain = get_string_arg (line, &match[10]);
if (domain) { if (domain) {
upstream_add (ip, port, domain, &conf->upstream_list); upstream_add (ip, port, domain, &conf->upstream_list);
safefree (domain); safefree (domain);
+1 -1
View File
@@ -280,7 +280,7 @@ int add_standard_vars (struct conn_s *connptr)
add_error_variable (connptr, "date", timebuf); add_error_variable (connptr, "date", timebuf);
add_error_variable (connptr, "website", add_error_variable (connptr, "website",
"https://www.banu.com/tinyproxy/"); "https://banu.com/tinyproxy/");
add_error_variable (connptr, "version", VERSION); add_error_variable (connptr, "version", VERSION);
add_error_variable (connptr, "package", PACKAGE); add_error_variable (connptr, "package", PACKAGE);
+1 -1
View File
@@ -172,7 +172,7 @@ display_usage (void)
printf ("\n" printf ("\n"
"For bug reporting instructions, please see:\n" "For bug reporting instructions, please see:\n"
"<https://www.banu.com/tinyproxy/>.\n"); "<https://banu.com/tinyproxy/>.\n");
} }
static int static int
+27 -2
View File
@@ -167,12 +167,18 @@ static void strip_username_password (char *host)
static int strip_return_port (char *host) static int strip_return_port (char *host)
{ {
char *ptr1; char *ptr1;
char *ptr2;
int port; int port;
ptr1 = strchr (host, ':'); ptr1 = strrchr (host, ':');
if (ptr1 == NULL) if (ptr1 == NULL)
return 0; return 0;
/* Check for IPv6 style literals */
ptr2 = strchr (ptr1, ']');
if (ptr2 != NULL)
return 0;
*ptr1++ = '\0'; *ptr1++ = '\0';
if (sscanf (ptr1, "%d", &port) != 1) /* one conversion required */ if (sscanf (ptr1, "%d", &port) != 1) /* one conversion required */
return 0; return 0;
@@ -212,6 +218,13 @@ static int extract_http_url (const char *url, struct request_s *request)
port = strip_return_port (request->host); port = strip_return_port (request->host);
request->port = (port != 0) ? port : HTTP_PORT; request->port = (port != 0) ? port : HTTP_PORT;
/* Remove any surrounding '[' and ']' from IPv6 literals */
p = strrchr (request->host, ']');
if (p && (*(request->host) == '[')) {
request->host++;
*p = '\0';
}
return 0; return 0;
ERROR_EXIT: ERROR_EXIT:
@@ -255,6 +268,7 @@ static int
establish_http_connection (struct conn_s *connptr, struct request_s *request) establish_http_connection (struct conn_s *connptr, struct request_s *request)
{ {
char portbuff[7]; char portbuff[7];
char dst[sizeof(struct in6_addr)];
/* Build a port string if it's not a standard port */ /* Build a port string if it's not a standard port */
if (request->port != HTTP_PORT && request->port != HTTP_PORT_SSL) if (request->port != HTTP_PORT && request->port != HTTP_PORT_SSL)
@@ -262,12 +276,23 @@ establish_http_connection (struct conn_s *connptr, struct request_s *request)
else else
portbuff[0] = '\0'; portbuff[0] = '\0';
if (inet_pton(AF_INET6, request->host, dst) > 0) {
/* host is an IPv6 address literal, so surround it with
* [] */
return write_message (connptr->server_fd,
"%s %s HTTP/1.0\r\n"
"Host: [%s]%s\r\n"
"Connection: close\r\n",
request->method, request->path,
request->host, portbuff);
} else {
return write_message (connptr->server_fd, return write_message (connptr->server_fd,
"%s %s HTTP/1.0\r\n" "%s %s HTTP/1.0\r\n"
"Host: %s%s\r\n" "Host: %s%s\r\n"
"Connection: close\r\n", "Connection: close\r\n",
request->method, request->path, request->method, request->path,
request->host, portbuff); request->host, portbuff);
}
} }
/* /*
@@ -418,7 +443,7 @@ BAD_REQUEST_ERROR:
} else { } else {
#ifdef TRANSPARENT_PROXY #ifdef TRANSPARENT_PROXY
if (!do_transparent_proxy if (!do_transparent_proxy
(connptr, hashofheaders, request, &config, url)) { (connptr, hashofheaders, request, &config, &url)) {
goto fail; goto fail;
} }
#else #else
+10 -16
View File
@@ -55,11 +55,11 @@ static int build_url (char **url, const char *host, int port, const char *path)
int int
do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders, do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
struct request_s *request, struct config_s *conf, struct request_s *request, struct config_s *conf,
char *url) char **url)
{ {
socklen_t length; socklen_t length;
char *data; char *data;
size_t ulen = strlen (url); size_t ulen = strlen (*url);
length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data); length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data);
if (length <= 0) { if (length <= 0) {
@@ -73,7 +73,7 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
connptr->client_fd); connptr->client_fd);
indicate_http_error (connptr, 400, "Bad Request", indicate_http_error (connptr, 400, "Bad Request",
"detail", "Unknown destination", "detail", "Unknown destination",
"url", url, NULL); "url", *url, NULL);
return 0; return 0;
} }
@@ -83,15 +83,12 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
request->port = ntohs (dest_addr.sin_port); request->port = ntohs (dest_addr.sin_port);
request->path = (char *) safemalloc (ulen + 1); request->path = (char *) safemalloc (ulen + 1);
strlcpy (request->path, url, ulen + 1); strlcpy (request->path, *url, ulen + 1);
/* url overwritten by the call below is the url passed build_url (url, request->host, request->port, request->path);
* to this function, and is not the url variable in the
* caller. */
build_url (&url, request->host, request->port, request->path);
log_message (LOG_INFO, log_message (LOG_INFO,
"process_request: trans IP %s %s for %d", "process_request: trans IP %s %s for %d",
request->method, url, connptr->client_fd); request->method, *url, connptr->client_fd);
} else { } else {
request->host = (char *) safemalloc (length + 1); request->host = (char *) safemalloc (length + 1);
if (sscanf (data, "%[^:]:%hu", request->host, &request->port) != if (sscanf (data, "%[^:]:%hu", request->host, &request->port) !=
@@ -101,15 +98,12 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
} }
request->path = (char *) safemalloc (ulen + 1); request->path = (char *) safemalloc (ulen + 1);
strlcpy (request->path, url, ulen + 1); strlcpy (request->path, *url, ulen + 1);
/* url overwritten by the call below is the url passed build_url (url, request->host, request->port, request->path);
* to this function, and is not the url variable in the
* caller. */
build_url (&url, request->host, request->port, request->path);
log_message (LOG_INFO, log_message (LOG_INFO,
"process_request: trans Host %s %s for %d", "process_request: trans Host %s %s for %d",
request->method, url, connptr->client_fd); request->method, *url, connptr->client_fd);
} }
if (conf->ipAddr && strcmp (request->host, conf->ipAddr) == 0) { if (conf->ipAddr && strcmp (request->host, conf->ipAddr) == 0) {
log_message (LOG_ERR, log_message (LOG_ERR,
@@ -118,7 +112,7 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
indicate_http_error (connptr, 400, "Bad Request", indicate_http_error (connptr, 400, "Bad Request",
"detail", "detail",
"You tried to connect to the machine " "You tried to connect to the machine "
"the proxy is running on", "url", url, "the proxy is running on", "url", *url,
NULL); NULL);
return 0; return 0;
} }
+1 -1
View File
@@ -32,7 +32,7 @@
extern int do_transparent_proxy (struct conn_s *connptr, extern int do_transparent_proxy (struct conn_s *connptr,
hashmap_t hashofheaders, hashmap_t hashofheaders,
struct request_s *request, struct request_s *request,
struct config_s *config, char *url); struct config_s *config, char **url);
#endif #endif
+2 -2
View File
@@ -202,10 +202,10 @@ struct upstream *upstream_get (char *host, struct upstream *up)
up = NULL; up = NULL;
if (up) if (up)
log_message (LOG_INFO, "Found proxy %s:%d for %s", log_message (LOG_INFO, "Found upstream proxy %s:%d for %s",
up->host, up->port, host); up->host, up->port, host);
else else
log_message (LOG_INFO, "No proxy for %s", host); log_message (LOG_INFO, "No upstream proxy for %s", host);
return up; return up;
} }