summaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-03-14 14:07:02 -0400
committerNick Mathewson <nickm@torproject.org>2016-03-14 14:07:02 -0400
commitdd7c99961774c19c6042100e660104c687ad6e22 (patch)
treeaac0e78501da57cff0b7a1e101d1e21a8ed4d890 /src/or/connection.c
parent0cdeac77e0332c37dd4cc7867e34214961db9009 (diff)
downloadtor-dd7c99961774c19c6042100e660104c687ad6e22.tar.gz
tor-dd7c99961774c19c6042100e660104c687ad6e22.zip
Make unix sockets work with the linux seccomp2 sandbox again
I didn't want to grant blanket permissions for chmod() and chown(), so here's what I had to do: * Grant open() on all parent directories of a unix socket * Write code to allow chmod() and chown() on a given file only. * Grant chmod() and chown() on the unix socket.
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 2c135cad62..19e4b41ca0 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -49,6 +49,7 @@
#include "routerlist.h"
#include "transports.h"
#include "routerparse.h"
+#include "sandbox.h"
#include "transports.h"
#ifdef USE_BUFFEREVENTS
@@ -1291,7 +1292,8 @@ connection_listener_new(const struct sockaddr *listensockaddr,
} else if (fstat(s, &st) == 0 &&
st.st_uid == pw->pw_uid && st.st_gid == pw->pw_gid) {
/* No change needed */
- } else if (chown(address, pw->pw_uid, pw->pw_gid) < 0) {
+ } else if (chown(sandbox_intern_string(address),
+ pw->pw_uid, pw->pw_gid) < 0) {
log_warn(LD_NET,"Unable to chown() %s socket: %s.",
address, strerror(errno));
goto err;
@@ -1317,7 +1319,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
* platforms. */
if (fstat(s, &st) == 0 && (st.st_mode & 0777) == mode) {
/* no change needed */
- } else if (chmod(address, mode) < 0) {
+ } else if (chmod(sandbox_intern_string(address), mode) < 0) {
log_warn(LD_FS,"Unable to make %s %s.", address, status);
goto err;
}