|
@@ -68,6 +68,9 @@
|
|
|
|
|
|
extern int quiet_level;
|
|
|
|
|
|
+
|
|
|
+static const char unix_socket_prefix[] = "unix:";
|
|
|
+
|
|
|
|
|
|
* option names, or alternative option names, to their current values. */
|
|
|
static config_abbrev_t option_abbrevs_[] = {
|
|
@@ -200,7 +203,6 @@ static config_var_t option_vars_[] = {
|
|
|
V(ControlPortWriteToFile, FILENAME, NULL),
|
|
|
V(ControlSocket, LINELIST, NULL),
|
|
|
V(ControlSocketsGroupWritable, BOOL, "0"),
|
|
|
- V(SocksSocket, LINELIST, NULL),
|
|
|
V(SocksSocketsGroupWritable, BOOL, "0"),
|
|
|
V(CookieAuthentication, BOOL, "0"),
|
|
|
V(CookieAuthFileGroupReadable, BOOL, "0"),
|
|
@@ -1050,20 +1052,6 @@ options_act_reversible(const or_options_t *old_options, char **msg)
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-#ifndef HAVE_SYS_UN_H
|
|
|
- if (options->SocksSocket || options->SocksSocketsGroupWritable) {
|
|
|
- *msg = tor_strdup("Unix domain sockets (SocksSocket) not supported "
|
|
|
- "on this OS/with this build.");
|
|
|
- goto rollback;
|
|
|
- }
|
|
|
-#else
|
|
|
- if (options->SocksSocketsGroupWritable && !options->SocksSocket) {
|
|
|
- *msg = tor_strdup("Setting SocksSocketGroupWritable without setting"
|
|
|
- "a SocksSocket makes no sense.");
|
|
|
- goto rollback;
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
if (running_tor) {
|
|
|
int n_ports=0;
|
|
|
|
|
@@ -5620,6 +5608,55 @@ warn_nonlocal_controller_ports(smartlist_t *ports, unsigned forbid)
|
|
|
#define CL_PORT_TAKES_HOSTNAMES (1u<<5)
|
|
|
#define CL_PORT_IS_UNIXSOCKET (1u<<6)
|
|
|
|
|
|
+#ifdef HAVE_SYS_UN_H
|
|
|
+
|
|
|
+
|
|
|
+ * path is found. Return 0 on success. On error, a negative value is
|
|
|
+ * returned, -ENOENT if no Unix statement found, -EINVAL if the socket path
|
|
|
+ * is empty and -ENOSYS if AF_UNIX is not supported (see function in the
|
|
|
+ * #else statement below). */
|
|
|
+
|
|
|
+int
|
|
|
+config_parse_unix_port(const char *addrport, char **path_out)
|
|
|
+{
|
|
|
+ tor_assert(path_out);
|
|
|
+ tor_assert(addrport);
|
|
|
+
|
|
|
+ if (strcmpstart(addrport, unix_socket_prefix)) {
|
|
|
+
|
|
|
+ return -ENOENT;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (strlen(addrport + strlen(unix_socket_prefix)) == 0) {
|
|
|
+
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ *path_out = tor_strdup(addrport + strlen(unix_socket_prefix));
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+#else
|
|
|
+
|
|
|
+int
|
|
|
+config_parse_unix_port(const char *addrport, char **path_out)
|
|
|
+{
|
|
|
+ tor_assert(path_out);
|
|
|
+ tor_assert(addrport);
|
|
|
+
|
|
|
+ if (strcmpstart(addrport, unix_socket_prefix)) {
|
|
|
+
|
|
|
+ return -ENOENT;
|
|
|
+ }
|
|
|
+
|
|
|
+ log_warn(LD_CONFIG,
|
|
|
+ "Port configuration %s is for an AF_UNIX socket, but we have no"
|
|
|
+ "support available on this platform",
|
|
|
+ escaped(addrport));
|
|
|
+ return -ENOSYS;
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
|
|
|
* Parse port configuration for a single port type.
|
|
|
*
|
|
@@ -5681,6 +5718,7 @@ parse_port_config(smartlist_t *out,
|
|
|
const unsigned takes_hostnames = flags & CL_PORT_TAKES_HOSTNAMES;
|
|
|
const unsigned is_unix_socket = flags & CL_PORT_IS_UNIXSOCKET;
|
|
|
int got_zero_port=0, got_nonzero_port=0;
|
|
|
+ char *unix_socket_path = NULL;
|
|
|
|
|
|
|
|
|
* though. */
|
|
@@ -5785,7 +5823,7 @@ parse_port_config(smartlist_t *out,
|
|
|
|
|
|
for (; ports; ports = ports->next) {
|
|
|
tor_addr_t addr;
|
|
|
- int port;
|
|
|
+ int port, ret;
|
|
|
int sessiongroup = SESSION_GROUP_UNSET;
|
|
|
unsigned isolation = ISO_DEFAULT;
|
|
|
int prefer_no_auth = 0;
|
|
@@ -5814,8 +5852,26 @@ parse_port_config(smartlist_t *out,
|
|
|
|
|
|
|
|
|
addrport = smartlist_get(elts, 0);
|
|
|
- if (is_unix_socket) {
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ ret = config_parse_unix_port(addrport, &unix_socket_path);
|
|
|
+ if (ret < 0 && ret != -ENOENT) {
|
|
|
+ if (ret == -EINVAL) {
|
|
|
+ log_warn(LD_CONFIG, "Empty Unix socket path.");
|
|
|
+ }
|
|
|
+ goto err;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (unix_socket_path &&
|
|
|
+ ! conn_listener_type_supports_af_unix(listener_type)) {
|
|
|
+ log_warn(LD_CONFIG, "%sPort does not support unix sockets", portname);
|
|
|
+ goto err;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (unix_socket_path) {
|
|
|
+ port = 1;
|
|
|
+ } else if (is_unix_socket) {
|
|
|
+ unix_socket_path = tor_strdup(addrport);
|
|
|
if (!strcmp(addrport, "0"))
|
|
|
port = 0;
|
|
|
else
|
|
@@ -6005,12 +6061,13 @@ parse_port_config(smartlist_t *out,
|
|
|
}
|
|
|
|
|
|
if (out && port) {
|
|
|
- size_t namelen = is_unix_socket ? strlen(addrport) : 0;
|
|
|
+ size_t namelen = unix_socket_path ? strlen(unix_socket_path) : 0;
|
|
|
port_cfg_t *cfg = port_cfg_new(namelen);
|
|
|
- if (is_unix_socket) {
|
|
|
+ if (unix_socket_path) {
|
|
|
tor_addr_make_unspec(&cfg->addr);
|
|
|
- memcpy(cfg->unix_addr, addrport, strlen(addrport) + 1);
|
|
|
+ memcpy(cfg->unix_addr, unix_socket_path, namelen + 1);
|
|
|
cfg->is_unix_addr = 1;
|
|
|
+ tor_free(unix_socket_path);
|
|
|
} else {
|
|
|
tor_addr_copy(&cfg->addr, &addr);
|
|
|
cfg->port = port;
|
|
@@ -6160,13 +6217,6 @@ parse_ports(or_options_t *options, int validate_only,
|
|
|
*msg = tor_strdup("Invalid ControlSocket configuration");
|
|
|
goto err;
|
|
|
}
|
|
|
- if (parse_port_config(ports, options->SocksSocket, NULL,
|
|
|
- "SocksSocket",
|
|
|
- CONN_TYPE_AP_LISTENER, NULL, 0,
|
|
|
- CL_PORT_IS_UNIXSOCKET) < 0) {
|
|
|
- *msg = tor_strdup("Invalid SocksSocket configuration");
|
|
|
- goto err;
|
|
|
- }
|
|
|
}
|
|
|
if (! options->ClientOnly) {
|
|
|
if (parse_port_config(ports,
|
|
@@ -6210,8 +6260,6 @@ parse_ports(or_options_t *options, int validate_only,
|
|
|
!! count_real_listeners(ports, CONN_TYPE_OR_LISTENER);
|
|
|
options->SocksPort_set =
|
|
|
!! count_real_listeners(ports, CONN_TYPE_AP_LISTENER);
|
|
|
- options->SocksSocket_set =
|
|
|
- !! count_real_listeners(ports, CONN_TYPE_AP_LISTENER);
|
|
|
options->TransPort_set =
|
|
|
!! count_real_listeners(ports, CONN_TYPE_AP_TRANS_LISTENER);
|
|
|
options->NATDPort_set =
|