[or-cvs] Implement Jason Holt"s SafeSocks config option.
arma at seul.org
arma at seul.org
Sun Mar 19 01:44:55 UTC 2006
Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or
Modified Files:
buffers.c config.c or.h
Log Message:
Implement Jason Holt's SafeSocks config option.
Also put a URL in the warning message for unsafe socks4 use --
previously we'd only had the URL for unsafe socks5 use. Oops.
Index: buffers.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/buffers.c,v
retrieving revision 1.189
retrieving revision 1.190
diff -u -p -d -r1.189 -r1.190
--- buffers.c 15 Mar 2006 23:36:57 -0000 1.189
+++ buffers.c 19 Mar 2006 01:44:53 -0000 1.190
@@ -897,11 +897,14 @@ fetch_from_buf_http(buf_t *buf,
* If <b>log_sockstype</b> is non-zero, then do a notice-level log of whether
* the connection is possibly leaking DNS requests locally or not.
*
+ * If <b>safe_socks</b> is true, then reject unsafe socks protocols.
+ *
* If returning 0 or -1, <b>req->address</b> and <b>req->port</b> are
* undefined.
*/
int
-fetch_from_buf_socks(buf_t *buf, socks_request_t *req, int log_sockstype)
+fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
+ int log_sockstype, int safe_socks)
{
unsigned char len;
char tmpbuf[INET_NTOA_BUF_LEN];
@@ -984,8 +987,11 @@ fetch_from_buf_socks(buf_t *buf, socks_r
"themselves may leak information. Consider using Socks4A "
"(e.g. via privoxy or socat) instead. For more information, "
"please see http://wiki.noreply.org/noreply/TheOnionRouter/"
- "TorFAQ#SOCKSAndDNS", req->port);
+ "TorFAQ#SOCKSAndDNS.%s", req->port,
+ safe_socks ? " Rejecting." : "");
// have_warned_about_unsafe_socks = 1; // (for now, warn every time)
+ if (safe_socks)
+ return -1;
}
return 1;
case 3: /* fqdn */
@@ -1075,8 +1081,13 @@ fetch_from_buf_socks(buf_t *buf, socks_r
"Your application (using socks4 on port %d) is giving Tor "
"only an IP address. Applications that do DNS resolves "
"themselves may leak information. Consider using Socks4A "
- "(e.g. via privoxy or socat) instead.", req->port);
+ "(e.g. via privoxy or socat) instead. For more information, "
+ "please see http://wiki.noreply.org/noreply/TheOnionRouter/"
+ "TorFAQ#SOCKSAndDNS.%s", req->port,
+ safe_socks ? " Rejecting." : "");
// have_warned_about_unsafe_socks = 1; // (for now, warn every time)
+ if (safe_socks)
+ return -1;
}
if (socks4_prot == socks4a) {
if (next+1 == buf->cur+buf->datalen) {
Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.536
retrieving revision 1.537
diff -u -p -d -r1.536 -r1.537
--- config.c 19 Mar 2006 01:21:58 -0000 1.536
+++ config.c 19 Mar 2006 01:44:53 -0000 1.537
@@ -218,6 +218,7 @@ static config_var_t _option_vars[] = {
VAR("RunAsDaemon", BOOL, RunAsDaemon, "0"),
VAR("RunTesting", BOOL, RunTesting, "0"),
VAR("SafeLogging", BOOL, SafeLogging, "1"),
+ VAR("SafeSocks", BOOL, SafeSocks, "0"),
VAR("ShutdownWaitLength", INTERVAL, ShutdownWaitLength, "30 seconds"),
VAR("SocksListenAddress", LINELIST, SocksListenAddress, NULL),
VAR("SocksPolicy", LINELIST, SocksPolicy, NULL),
Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.811
retrieving revision 1.812
diff -u -p -d -r1.811 -r1.812
--- or.h 19 Mar 2006 01:21:58 -0000 1.811
+++ or.h 19 Mar 2006 01:44:53 -0000 1.812
@@ -1379,6 +1379,8 @@ typedef struct {
* long do we wait before exiting? */
int SafeLogging; /**< Boolean: are we allowed to log sensitive strings
* such as addresses (0), or do we scrub them first (1)? */
+ int SafeSocks; /**< Boolean: should we outright refuse application
+ * connections that use socks4 or socks5-with-local-dns? */
#define LOG_PROTOCOL_WARN (get_options()->ProtocolWarnings ? \
LOG_WARN : LOG_INFO)
int ProtocolWarnings; /**< Boolean: when other parties screw up the Tor
@@ -1471,7 +1473,8 @@ int fetch_from_buf_http(buf_t *buf,
char **headers_out, size_t max_headerlen,
char **body_out, size_t *body_used, size_t max_bodylen,
int force_complete);
-int fetch_from_buf_socks(buf_t *buf, socks_request_t *req, int log_sockstype);
+int fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
+ int log_sockstype, int safe_socks);
int fetch_from_buf_control0(buf_t *buf, uint32_t *len_out, uint16_t *type_out,
char **body_out, int check_for_v1);
int fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len);
More information about the tor-commits
mailing list