mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
Add UnixSocketsGroupWritable config flag
When running a system-wide instance of Tor on Unix-like systems, having a ControlSocket is a quite handy mechanism to access Tor control channel. But it would be easier if access to the Unix domain socket can be granted by making control users members of the group running the Tor process. This change introduces a UnixSocketsGroupWritable option, which will create Unix domain sockets (and thus ControlSocket) 'g+rw'. This allows ControlSocket to offer same access control measures than ControlPort+CookieAuthFileGroupReadable. See <http://bugs.debian.org/552556> for more details.
This commit is contained in:
parent
2b9c5ee301
commit
d41ac64ad6
@ -167,6 +167,11 @@ Other options can be specified either on the command-line (--option
|
|||||||
Like ControlPort, but listens on a Unix domain socket, rather than a TCP
|
Like ControlPort, but listens on a Unix domain socket, rather than a TCP
|
||||||
socket. (Unix and Unix-like systems only.)
|
socket. (Unix and Unix-like systems only.)
|
||||||
|
|
||||||
|
**UnixSocketsGroupWritable** **0**|**1**::
|
||||||
|
If this option is set to 0, don't allow the filesystem group to read and
|
||||||
|
write unix sockets (e.g. ControlSocket). If the option is set to 1, make
|
||||||
|
the control socket readable and writable by the default GID. (Default: 0)
|
||||||
|
|
||||||
**HashedControlPassword** __hashed_password__::
|
**HashedControlPassword** __hashed_password__::
|
||||||
Don't allow any connections on the control port except when the other
|
Don't allow any connections on the control port except when the other
|
||||||
process knows the password whose one-way hash is __hashed_password__. You
|
process knows the password whose one-way hash is __hashed_password__. You
|
||||||
|
@ -209,6 +209,7 @@ static config_var_t _option_vars[] = {
|
|||||||
V(ControlPortFileGroupReadable,BOOL, "0"),
|
V(ControlPortFileGroupReadable,BOOL, "0"),
|
||||||
V(ControlPortWriteToFile, FILENAME, NULL),
|
V(ControlPortWriteToFile, FILENAME, NULL),
|
||||||
V(ControlSocket, LINELIST, NULL),
|
V(ControlSocket, LINELIST, NULL),
|
||||||
|
V(UnixSocketsGroupWritable, BOOL, "0"),
|
||||||
V(CookieAuthentication, BOOL, "0"),
|
V(CookieAuthentication, BOOL, "0"),
|
||||||
V(CookieAuthFileGroupReadable, BOOL, "0"),
|
V(CookieAuthFileGroupReadable, BOOL, "0"),
|
||||||
V(CookieAuthFile, STRING, NULL),
|
V(CookieAuthFile, STRING, NULL),
|
||||||
@ -952,7 +953,7 @@ options_act_reversible(or_options_t *old_options, char **msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_SYS_UN_H
|
#ifndef HAVE_SYS_UN_H
|
||||||
if (options->ControlSocket) {
|
if (options->ControlSocket || options->UnixSocketsGroupWritable) {
|
||||||
*msg = tor_strdup("Unix domain sockets (ControlSocket) not supported"
|
*msg = tor_strdup("Unix domain sockets (ControlSocket) not supported"
|
||||||
" on this OS/with this build.");
|
" on this OS/with this build.");
|
||||||
goto rollback;
|
goto rollback;
|
||||||
|
@ -966,6 +966,13 @@ connection_create_listener(const struct sockaddr *listensockaddr,
|
|||||||
tor_socket_strerror(tor_socket_errno(s)));
|
tor_socket_strerror(tor_socket_errno(s)));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
if (get_options()->UnixSocketsGroupWritable) {
|
||||||
|
if (chmod(address, 0660) < 0) {
|
||||||
|
log_warn(LD_FS,"Unable to make %s group-readable.", address);
|
||||||
|
tor_close_socket(s);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (listen(s,SOMAXCONN) < 0) {
|
if (listen(s,SOMAXCONN) < 0) {
|
||||||
log_warn(LD_NET, "Could not listen on %s: %s", address,
|
log_warn(LD_NET, "Could not listen on %s: %s", address,
|
||||||
|
@ -2445,6 +2445,7 @@ typedef struct {
|
|||||||
int ControlPort; /**< Port to listen on for control connections. */
|
int ControlPort; /**< Port to listen on for control connections. */
|
||||||
config_line_t *ControlSocket; /**< List of Unix Domain Sockets to listen on
|
config_line_t *ControlSocket; /**< List of Unix Domain Sockets to listen on
|
||||||
* for control connections. */
|
* for control connections. */
|
||||||
|
int UnixSocketsGroupWritable; /**< Boolean: Are unix sockets g+rw? */
|
||||||
int DirPort; /**< Port to listen on for directory connections. */
|
int DirPort; /**< Port to listen on for directory connections. */
|
||||||
int DNSPort; /**< Port to listen on for DNS requests. */
|
int DNSPort; /**< Port to listen on for DNS requests. */
|
||||||
int AssumeReachable; /**< Whether to publish our descriptor regardless. */
|
int AssumeReachable; /**< Whether to publish our descriptor regardless. */
|
||||||
|
Loading…
Reference in New Issue
Block a user