Skip to content

Commit

Permalink
Merge branch 'sandbox_refactor'
Browse files Browse the repository at this point in the history
  • Loading branch information
nmathewson committed Jun 27, 2018
2 parents b9b05e4 + 05040a9 commit 2113603
Show file tree
Hide file tree
Showing 25 changed files with 60 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ uptime-*.json
/src/lib/libtor-malloc-testing.a
/src/lib/libtor-net.a
/src/lib/libtor-net-testing.a
/src/lib/libtor-sandbox.a
/src/lib/libtor-sandbox-testing.a
/src/lib/libtor-string.a
/src/lib/libtor-string-testing.a
/src/lib/libtor-smartlist-core.a
Expand Down
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ endif
# "Common" libraries used to link tor's utility code.
TOR_UTIL_LIBS = \
src/common/libor.a \
src/lib/libtor-sandbox.a \
src/lib/libtor-container.a \
src/lib/libtor-net.a \
src/lib/libtor-log.a \
Expand All @@ -57,6 +58,7 @@ TOR_UTIL_LIBS = \
# and tests)
TOR_UTIL_TESTING_LIBS = \
src/common/libor-testing.a \
src/lib/libtor-sandbox-testing.a \
src/lib/libtor-container-testing.a \
src/lib/libtor-net-testing.a \
src/lib/libtor-log-testing.a \
Expand Down
2 changes: 1 addition & 1 deletion src/common/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ SecureZeroMemory(PVOID ptr, SIZE_T cnt)
#include "lib/container/smartlist.h"
#include "lib/wallclock/tm_cvt.h"
#include "lib/net/address.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"

/** As open(path, flags, mode), but return an fd with the close-on-exec mode
* set. */
Expand Down
3 changes: 0 additions & 3 deletions src/common/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ LIBOR_A_SRC = \
src/common/util.c \
src/common/util_format.c \
src/common/util_process.c \
src/common/sandbox.c \
src/common/storagedir.c \
src/common/token_bucket.c \
src/common/workqueue.c \
Expand Down Expand Up @@ -84,9 +83,7 @@ COMMONHEADERS = \
src/common/confline.h \
src/common/handles.h \
src/common/memarea.h \
src/common/linux_syscalls.inc \
src/common/procmon.h \
src/common/sandbox.h \
src/common/storagedir.h \
src/common/timers.h \
src/common/token_bucket.h \
Expand Down
2 changes: 1 addition & 1 deletion src/common/storagedir.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "common/compat.h"
#include "common/confline.h"
#include "common/memarea.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"
#include "common/storagedir.h"
#include "lib/log/torlog.h"
#include "common/util.h"
Expand Down
2 changes: 1 addition & 1 deletion src/common/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "lib/container/smartlist.h"
#include "lib/fdio/fdio.h"
#include "lib/net/address.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"
#include "lib/err/backtrace.h"
#include "common/util_process.h"
#include "common/util_format.h"
Expand Down
1 change: 1 addition & 0 deletions src/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include src/lib/lock/include.am
include src/lib/log/include.am
include src/lib/malloc/include.am
include src/lib/net/include.am
include src/lib/sandbox/include.am
include src/lib/string/include.am
include src/lib/smartlist_core/include.am
include src/lib/testsupport/include.am
Expand Down
1 change: 1 addition & 0 deletions src/lib/crypt_ops/.may_include
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ lib/defs/*.h
lib/malloc/*.h
lib/err/*.h
lib/intmath/*.h
lib/sandbox/*.h
lib/string/*.h
lib/testsupport/testsupport.h
lib/log/*.h
Expand Down
1 change: 0 additions & 1 deletion src/lib/crypt_ops/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ ENABLE_GCC_WARNING(redundant-decls)
#include "lib/crypt_ops/aes.h"
#include "common/util.h"
#include "common/compat.h"
#include "common/sandbox.h"
#include "common/util_format.h"

#include "keccak-tiny/keccak-tiny.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/crypt_ops/crypto_rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "common/compat.h"
#include "lib/crypt_ops/compat_openssl.h"
#include "lib/crypt_ops/crypto_util.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"
#include "lib/testsupport/testsupport.h"
#include "lib/log/torlog.h"
#include "common/util.h"
Expand Down
15 changes: 15 additions & 0 deletions src/lib/sandbox/.may_include
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
orconfig.h

lib/cc/*.h
lib/container/*.h
lib/err/*.h
lib/log/*.h
lib/malloc/*.h
lib/net/*.h
lib/sandbox/*.h
lib/sandbox/*.inc
lib/string/*.h

ht.h
siphash.h
tor_queue.h
18 changes: 18 additions & 0 deletions src/lib/sandbox/include.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

noinst_LIBRARIES += src/lib/libtor-sandbox.a

if UNITTESTS_ENABLED
noinst_LIBRARIES += src/lib/libtor-sandbox-testing.a
endif

src_lib_libtor_sandbox_a_SOURCES = \
src/lib/sandbox/sandbox.c

src_lib_libtor_sandbox_testing_a_SOURCES = \
$(src_lib_libtor_sandbox_a_SOURCES)
src_lib_libtor_sandbox_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
src_lib_libtor_sandbox_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)

noinst_HEADERS += \
src/lib/sandbox/linux_syscalls.inc \
src/lib/sandbox/sandbox.h
File renamed without changes.
12 changes: 7 additions & 5 deletions src/common/sandbox.c → src/lib/sandbox/sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>

#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"
#include "lib/container/map.h"
#include "lib/err/torerr.h"
#include "lib/log/torlog.h"
#include "lib/cc/torint.h"
#include "lib/net/resolve.h"
#include "common/util.h"
#include "tor_queue.h"
#include "lib/malloc/util_malloc.h"
#include "lib/string/scanf.h"

#include "tor_queue.h"
#include "ht.h"

#include "siphash.h"

#define DEBUGGING_CLOSE
Expand Down Expand Up @@ -1558,7 +1559,8 @@ install_syscall_filter(sandbox_cfg_t* cfg)
return (rc < 0 ? -rc : rc);
}

#include "linux_syscalls.inc"
#include "lib/sandbox/linux_syscalls.inc"

static const char *
get_syscall_name(int syscall_num)
{
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/or/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
#include "or/hs_config.h"
#include "or/rephist.h"
#include "or/router.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"
#include "common/util.h"
#include "or/routerlist.h"
#include "or/routerset.h"
Expand Down
2 changes: 1 addition & 1 deletion src/or/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
#include "or/routerlist.h"
#include "or/transports.h"
#include "or/routerparse.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"

#ifdef HAVE_PWD_H
#include <pwd.h>
Expand Down
2 changes: 1 addition & 1 deletion src/or/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#include "or/relay.h"
#include "or/router.h"
#include "ht.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"

#include "or/edge_connection_st.h"
#include "or/or_circuit_st.h"
Expand Down
2 changes: 1 addition & 1 deletion src/or/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
#include "common/util_process.h"
#include "or/ext_orport.h"
#include "common/memarea.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"

#include <event2/event.h>

Expand Down
2 changes: 1 addition & 1 deletion src/or/routerlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
#include "or/routerlist.h"
#include "or/routerparse.h"
#include "or/routerset.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"
#include "or/torcert.h"

#include "or/dirauth/dirvote.h"
Expand Down
2 changes: 1 addition & 1 deletion src/or/routerparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#include "or/routerkeys.h"
#include "or/routerlist.h"
#include "or/routerparse.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"
#include "or/shared_random_client.h"
#include "or/torcert.h"
#include "or/voting_schedule.h"
Expand Down
2 changes: 1 addition & 1 deletion src/or/statefile.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "or/main.h"
#include "or/rephist.h"
#include "or/router.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"
#include "or/statefile.h"

/** A list of state-file "abbreviations," for compatibility. */
Expand Down
1 change: 1 addition & 0 deletions src/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ pub fn main() {
// moving forward!
cfg.component("tor-crypt-ops-testing");
cfg.component("or-testing");
cfg.component("tor-sandbox");
cfg.component("tor-net");
cfg.component("tor-log");
cfg.component("tor-lock");
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "or/main.h"
#include "test/log_test_helpers.h"

#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"
#include "common/memarea.h"
#include "or/policies.h"
#include "test/test_helpers.h"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tor-resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "common/util.h"
#include "lib/net/address.h"
#include "lib/log/torlog.h"
#include "common/sandbox.h"
#include "lib/sandbox/sandbox.h"

#include <stdio.h>
#include <stdlib.h>
Expand Down

0 comments on commit 2113603

Please sign in to comment.