Commit | Line | Data |
---|---|---|
0301524b OS |
1 | Description: Debian has carried this patch since 1.8beta5-9.2 release, |
2 | I extracted it from upstream's source we distribute and keep it as patch | |
3 | I claim no ownership | |
4 | Last-update: 2016-11-07 | |
5 | Origin: vendor | |
6 | ||
7 | diff --git a/parser.c b/parser.c | |
8 | index 5b6d123..81245c8 100644 | |
9 | --- a/parser.c | |
10 | +++ b/parser.c | |
11 | @@ -6,10 +6,13 @@ | |
12 | ||
13 | #include <netinet/in.h> | |
14 | #include <sys/socket.h> | |
15 | +#include <sys/types.h> | |
16 | #include <arpa/inet.h> | |
17 | +#include <pwd.h> | |
18 | #include <string.h> | |
19 | #include <stdio.h> | |
20 | #include <stdlib.h> | |
21 | +#include <unistd.h> | |
22 | #include <errno.h> | |
23 | #include <config.h> | |
24 | #include "common.h" | |
25 | @@ -48,12 +51,11 @@ int read_config (char *filename, struct parsedfile *config) { | |
26 | ||
27 | /* If a filename wasn't provided, use the default */ | |
28 | if (filename == NULL) { | |
29 | - strncpy(line, CONF_FILE, sizeof(line) - 1); | |
30 | - /* Insure null termination */ | |
31 | - line[sizeof(line) - 1] = (char) 0; | |
32 | - filename = line; | |
33 | + filename = find_config(line); | |
34 | } | |
35 | ||
36 | + show_msg(MSGDEBUG, "using %s as configuration file\n", line); | |
37 | + | |
38 | /* Read the configuration file */ | |
39 | if ((conf = fopen(filename, "r")) == NULL) { | |
40 | show_msg(MSGERR, "Could not open socks configuration file " | |
41 | diff --git a/tsocks.8 b/tsocks.8 | |
42 | index e056460..9e46070 100644 | |
43 | --- a/tsocks.8 | |
44 | +++ b/tsocks.8 | |
45 | @@ -34,13 +34,13 @@ manual page. | |
46 | ||
47 | .BR tsocks | |
48 | is a library to allow transparent SOCKS proxying. It wraps the normal | |
49 | -connect() function. When a connection is attempted, it consults the | |
50 | -configuration file (which is defined at configure time but defaults to | |
51 | -/etc/tsocks.conf) and determines if the IP address specified is local. If | |
52 | -it is not, the library redirects the connection to a SOCKS server | |
53 | -specified in the configuration file. It then negotiates that connection | |
54 | -with the SOCKS server and passes the connection back to the calling | |
55 | -program. | |
56 | +connect() function. When a connection is attempted, it consults the | |
57 | +configuration file (which is defined at configure time but defaults to | |
58 | +~/.tsocks.conf and if that file cannot be accessed, to /etc/tsocks.conf) | |
59 | +and determines if the IP address specified is local. If it is not, the | |
60 | +library redirects the connection to a SOCKS server specified in the | |
61 | +configuration file. It then negotiates that connection with the SOCKS | |
62 | +server and passes the connection back to the calling program. | |
63 | ||
64 | .BR tsocks | |
65 | is designed for use in machines which are firewalled from then | |
66 | @@ -59,7 +59,7 @@ Some configuration options can be specified at run time using environment | |
67 | variables as follows: | |
68 | ||
69 | .TP | |
70 | -.I TSOCKS_CONFFILE | |
71 | +.I TSOCKS_CONF_FILE | |
72 | This environment variable overrides the default location of the tsocks | |
73 | configuration file. This variable is not honored if the program tsocks | |
74 | is embedded in is setuid. In addition this environment variable can | |
75 | diff --git a/tsocks.c b/tsocks.c | |
76 | index 9cfdfff..0a16712 100644 | |
77 | --- a/tsocks.c | |
78 | +++ b/tsocks.c | |
79 | @@ -289,11 +289,13 @@ int connect(CONNECT_SIGNATURE) { | |
80 | show_msg(MSGDEBUG, "Picked server %s for connection\n", | |
81 | (path->address ? path->address : "(Not Provided)")); | |
82 | if (path->address == NULL) { | |
83 | - if (path == &(config->defaultserver)) | |
84 | + if (path == &(config->defaultserver)) { | |
85 | show_msg(MSGERR, "Connection needs to be made " | |
86 | "via default server but " | |
87 | "the default server has not " | |
88 | - "been specified\n"); | |
89 | + "been specified. Falling back to direct connection.\n"); | |
90 | + return(realconnect(__fd, __addr, __len)); | |
91 | + } | |
92 | else | |
93 | show_msg(MSGERR, "Connection needs to be made " | |
94 | "via path specified at line " | |
95 | diff --git a/tsocks.conf.5 b/tsocks.conf.5 | |
96 | index ea7a3b3..a2a7959 100644 | |
97 | --- a/tsocks.conf.5 | |
98 | +++ b/tsocks.conf.5 | |
99 | @@ -126,6 +126,15 @@ specified in the current path block should be used to access any IPs in the | |
100 | range 150.0.0.0 to 150.255.255.255 when the connection request is for ports | |
101 | 80-1024. | |
102 | ||
103 | +.TP | |
104 | +.I fallback | |
105 | +This directive allows to fall back to direct connection if no default | |
106 | +server present in the configuration and fallback = yes. | |
107 | +If fallback = no or not specified and there is no default server, the | |
108 | +tsocks gives an error message and aborts. | |
109 | +This parameter protects the user against accidentally establishing | |
110 | +unwanted unsockified (ie. direct) connection. | |
111 | + | |
112 | .SH UTILITIES | |
113 | tsocks comes with two utilities that can be useful in creating and verifying | |
114 | the tsocks configuration file. |