diff options
114 files changed, 453 insertions, 192 deletions
diff --git a/.travis.yml b/.travis.yml index 1fee931e24..ccd2107fd2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,9 @@ env: - ASCIIDOC_OPTIONS="--disable-asciidoc" ## Our default rust version is the minimum supported version - RUST_VERSION="1.31.0" + ## Turn off tor's sandbox in chutney, until we fix sandbox errors that are + ## triggered by Ubuntu Xenial and Bionic. See #32722. + - CHUTNEY_TOR_SANDBOX="0" matrix: ## This matrix entry is required, but it doesn't actually create any jobs - @@ -51,10 +54,6 @@ matrix: ## Chutney is a fast job, clang is slower on Linux, so we do Chutney clang - env: CHUTNEY="yes" CHUTNEY_ALLOW_FAILURES="2" SKIP_MAKE_CHECK="yes" compiler: clang - ## (Linux only) Use an older Linux image (Ubuntu Trusty) - ## The Xenial and Bionic images cause permissions issues for chutney, - ## this is a workaround, until we fix #32240. - dist: trusty ## We check asciidoc with distcheck, to make sure we remove doc products ## We use Linux clang, because there are no other Linux clang jobs - env: DISTCHECK="yes" ASCIIDOC_OPTIONS="" SKIP_MAKE_CHECK="yes" @@ -120,8 +119,7 @@ addons: - libnss3-dev - libscrypt-dev - libseccomp-dev - ## zstd doesn't exist in Ubuntu Trusty - #- libzstd + - libzstd-dev ## Optional build dependencies - coccinelle - shellcheck diff --git a/Makefile.am b/Makefile.am index 2dd3a7aa3f..811694f0b6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -389,6 +389,10 @@ coverage-html-full: all genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info" # For scripts: avoid src/ext and src/trunnel. +# Keep these lists consistent: +# - OWNED_TOR_C_FILES in Makefile.am +# - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook +# - try_parse in check_cocci_parse.sh OWNED_TOR_C_FILES=\ $(top_srcdir)/src/lib/*/*.[ch] \ $(top_srcdir)/src/core/*/*.[ch] \ diff --git a/changes/bug29819 b/changes/bug29819 new file mode 100644 index 0000000000..d37ac83d66 --- /dev/null +++ b/changes/bug29819 @@ -0,0 +1,8 @@ + o Minor bugfixes (linux seccomp sandbox): + - Correct how we use libseccomp. Particularly, stop assuming that + rules are applied in a particular order or that more rules are + processed after the first match. Neither is the case! In libseccomp + <2.4.0 this lead to some rules having no effect. Libseccomp 2.4.0 + changed how rules are generated leading to a different ordering + which in turn lead to a fatal crash during startup. Fixes bug + 29819; bugfix on 0.2.5.1-alpha. Patch by Peter Gerber. diff --git a/changes/bug32639 b/changes/bug32639 new file mode 100644 index 0000000000..1237ba074f --- /dev/null +++ b/changes/bug32639 @@ -0,0 +1,4 @@ + o Minor bugfixes (onion services): + - In cancel_descriptor_fetches(), use connection_list_by_type_purpose() + instead of connection_list_by_type_state(). Fixes bug 32639; bugfix on + 0.3.2.1-alpha. Patch by Neel Chauhan. diff --git a/changes/bug32771 b/changes/bug32771 new file mode 100644 index 0000000000..606bcf4be4 --- /dev/null +++ b/changes/bug32771 @@ -0,0 +1,4 @@ + o Minor bugfixes (logging, crash): + - Avoid a possible crash when trying to log a (fatal) assertion failure + about mismatched magic numbers in configuration objects. Fixes bug 32771; + bugfix on 0.4.2.1-alpha. diff --git a/changes/bug32841 b/changes/bug32841 new file mode 100644 index 0000000000..48568f6a61 --- /dev/null +++ b/changes/bug32841 @@ -0,0 +1,4 @@ + o Minor bugfixes (linux seccomp sandbox): + - Fix crash when reloading logging configuration while the + experimental sandbox is enabled. Fixes bug 32841; bugfix + on 0.4.1.7. Patch by Peter Gerber. diff --git a/changes/ticket32172 b/changes/ticket32172 new file mode 100644 index 0000000000..a661617999 --- /dev/null +++ b/changes/ticket32172 @@ -0,0 +1,4 @@ + o Minor features (tests, Android): + - When running the unit tests on Android, create temporary files + in a subdirectory of /data/local/tmp. Closes ticket + 32172. Based on a patch from Hans-Christoph Steiner. diff --git a/changes/ticket32240 b/changes/ticket32240 new file mode 100644 index 0000000000..35cc3df27e --- /dev/null +++ b/changes/ticket32240 @@ -0,0 +1,4 @@ + o Testing: + - Turn off Tor's Sandbox in Chutney jobs, and run those jobs on Ubuntu + Bionic. Turning off the Sandbox is a work-around, until we fix the + sandbox errors in 32722. Closes ticket 32240. diff --git a/changes/ticket32242 b/changes/ticket32242 new file mode 100644 index 0000000000..d63d5a586e --- /dev/null +++ b/changes/ticket32242 @@ -0,0 +1,2 @@ + o Testing (continuous integration): + - Use zstd in our Travis Linux builds. Closes ticket 32242. diff --git a/changes/ticket32765 b/changes/ticket32765 new file mode 100644 index 0000000000..a9663a5df3 --- /dev/null +++ b/changes/ticket32765 @@ -0,0 +1,4 @@ + o Minor bugfixes (correctness checks): + - Use GCC/Clang's printf-checking feature to make sure that + tor_assertf() arguments are correctly typed. Fixes bug 32765; + bugfix on 0.4.1.1-alpha. diff --git a/changes/ticket32779 b/changes/ticket32779 new file mode 100644 index 0000000000..1b7ccaa7ed --- /dev/null +++ b/changes/ticket32779 @@ -0,0 +1,3 @@ + o Documentation: + - Add documentation in 'HelpfulTools.md' to describe how to build a tag + file. Closes ticket 32779. diff --git a/changes/ticket32807 b/changes/ticket32807 new file mode 100644 index 0000000000..07f8716e1f --- /dev/null +++ b/changes/ticket32807 @@ -0,0 +1,4 @@ + o Removed features: + - The option "TestingEstimatedDescriptorPropagationTime" is now marked as + obsolete. It has had no effect since 0.3.0.7, when clients stopped + rejecting consensuses "from the future". Closes ticket 32807. diff --git a/doc/HACKING/HelpfulTools.md b/doc/HACKING/HelpfulTools.md index cba57e875d..866b321287 100644 --- a/doc/HACKING/HelpfulTools.md +++ b/doc/HACKING/HelpfulTools.md @@ -315,6 +315,30 @@ If you use emacs for editing Tor and nothing else, you could always just say: There is probably a better way to do this. No, we are probably not going to clutter the files with emacs stuff. +Building a tag file (code index) +-------------------------------- + +Many functions in tor use `MOCK_IMPL` wrappers for unit tests. Your +tag-building program must be told how to handle this syntax. + +If you're using emacs, you can generate an emacs-compatible tag file using +`make tags`. This will run your system's `etags`. Tor's build system assumes +that you're using the emacs-specific version of `etags` (bundled under the +`xemacs21-bin` package on Debian). This is incompatible with other versions of +`etags` such as the version provided by Exuberant Ctags. + +If you're using vim or emacs, you can also use Universal Ctags to build a tag +file using the syntax: + + ctags -R -D 'MOCK_IMPL(r,h,a)=r h a' . + +If you're using an older version of Universal Ctags, you can use the following +instead: + + ctags -R --mline-regex-c='/MOCK_IMPL\([^,]+,\W*([a-zA-Z0-9_]+)\W*,/\1/f/{mgroup=1}' . + +A vim-compatible tag file will be generated by default. If you use emacs, add +the `-e` flag to generate an emacs-compatible tag file. Doxygen ------- diff --git a/doc/tor.1.txt b/doc/tor.1.txt index aad37204c9..85369dfcef 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -3256,7 +3256,6 @@ The following options are used for running a testing Tor network. TestingV3AuthInitialVoteDelay 20 seconds TestingV3AuthInitialDistDelay 20 seconds TestingAuthDirTimeToLearnReachability 0 minutes - TestingEstimatedDescriptorPropagationTime 0 minutes TestingServerDownloadInitialDelay 0 TestingClientDownloadInitialDelay 0 TestingServerConsensusDownloadInitialDelay 0 @@ -3292,11 +3291,6 @@ The following options are used for running a testing Tor network. are Running until this much time has passed. Changing this requires that **TestingTorNetwork** is set. (Default: 30 minutes) -[[TestingEstimatedDescriptorPropagationTime]] **TestingEstimatedDescriptorPropagationTime** __N__ **minutes**|**hours**:: - Clients try downloading server descriptors from directory caches after this - time. Changing this requires that **TestingTorNetwork** is set. (Default: - 10 minutes) - [[TestingMinFastFlagThreshold]] **TestingMinFastFlagThreshold** __N__ **bytes**|**KBytes**|**MBytes**|**GBytes**|**TBytes**|**KBits**|**MBits**|**GBits**|**TBits**:: Minimum value for the Fast flag. Overrides the ordinary minimum taken from the consensus when TestingTorNetwork is set. (Default: 0.) diff --git a/scripts/coccinelle/check_cocci_parse.sh b/scripts/coccinelle/check_cocci_parse.sh index 220b405940..aaa586c093 100755 --- a/scripts/coccinelle/check_cocci_parse.sh +++ b/scripts/coccinelle/check_cocci_parse.sh @@ -21,8 +21,49 @@ exitcode=0 export TOR_COCCI_EXCEPTIONS_FILE="${TOR_COCCI_EXCEPTIONS_FILE:-$scripts_cocci/exceptions.txt}" -if ! command -v spatch; then - echo "Install coccinelle's spatch to check cocci C parsing!" +PURPOSE="cocci C parsing" + +echo "Checking spatch:" + +if ! command -v spatch ; then + echo "Install coccinelle's spatch to check $PURPOSE." + exit "$exitcode" +fi + +# Returns true if $1 is greater than or equal to $2 +version_ge() +{ + if test "$1" = "$2" ; then + # return true + return 0 + fi + LOWER_VERSION="$(printf '%s\n' "$1" "$2" | $SORT_V | head -n 1)" + # implicit return + test "$LOWER_VERSION" != "$1" +} + +# 'sort -V' is a gnu extension +SORT_V="sort -V" +# Use 'sort -n' if 'sort -V' doesn't work +if ! version_ge "1" "0" ; then + echo "Your 'sort -V' command appears broken. Falling back to 'sort -n'." + echo "Some spatch version checks may give the wrong result." + SORT_V="sort -n" +fi + +# Print the full spatch version, for diagnostics +spatch --version + +MIN_SPATCH_V="1.0.4" +# This pattern needs to handle version strings like: +# spatch version 1.0.0-rc19 +# spatch version 1.0.6 compiled with OCaml version 4.05.0 +SPATCH_V=$(spatch --version | head -1 | \ + sed 's/spatch version \([0-9][^ ]*\).*/\1/') + +if ! version_ge "$SPATCH_V" "$MIN_SPATCH_V" ; then + echo "Tor requires coccinelle spatch >= $MIN_SPATCH_V to check $PURPOSE." + echo "But you have $SPATCH_V. Please install a newer version." exit "$exitcode" fi @@ -32,6 +73,10 @@ if test $# -ge 1 ; then else cd "$top" || exit 1 # This is the layout in 0.3.5 + # Keep these lists consistent: + # - OWNED_TOR_C_FILES in Makefile.am + # - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook + # - try_parse in check_cocci_parse.sh "$try_parse" \ src/lib/*/*.[ch] \ src/core/*/*.[ch] \ @@ -44,7 +89,7 @@ else fi if test "$exitcode" != 0 ; then - echo "Please fix these cocci parsing errors in the above files" + echo "Please fix these $PURPOSE errors in the above files" echo "Set VERBOSE=1 for more details" echo "Try running test-operator-cleanup or 'make autostyle-operators'" echo "As a last resort, you can modify scripts/coccinelle/exceptions.txt" diff --git a/scripts/git/pre-commit.git-hook b/scripts/git/pre-commit.git-hook index 95d566b17d..d5a75f2794 100755 --- a/scripts/git/pre-commit.git-hook +++ b/scripts/git/pre-commit.git-hook @@ -19,6 +19,10 @@ if [ $# -eq 0 ]; then # Use the appropriate owned tor source list to filter the changed files if [ -d src/lib ]; then # This is the layout in 0.3.5 + # Keep these lists consistent: + # - OWNED_TOR_C_FILES in Makefile.am + # - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook + # - try_parse in check_cocci_parse.sh CHECK_FILES="$($CHECK_FILTER \ src/lib/*/*.[ch] \ src/core/*/*.[ch] \ diff --git a/scripts/git/pre-push.git-hook b/scripts/git/pre-push.git-hook index 6a85e951a8..8b5efb0a9d 100755 --- a/scripts/git/pre-push.git-hook +++ b/scripts/git/pre-push.git-hook @@ -65,6 +65,10 @@ do # files if [ -d src/lib ]; then # This is the layout in 0.3.5 + # Keep these lists consistent: + # - OWNED_TOR_C_FILES in Makefile.am + # - CHECK_FILES in pre-commit.git-hook and pre-push.git-hook + # - try_parse in check_cocci_parse.sh CHECK_FILES="$($CHECK_FILTER \ src/lib/*/*.[ch] \ src/core/*/*.[ch] \ @@ -81,7 +85,7 @@ do src/or/*/*.[ch] \ src/test/*.[ch] \ src/test/*/*.[ch] \ - src/tools/*.[ch] + src/tools/*.[ch] \ )" fi diff --git a/src/app/config/config.c b/src/app/config/config.c index 5ea8cec6a6..72ab065fb5 100644 --- a/src/app/config/config.c +++ b/src/app/config/config.c @@ -337,7 +337,6 @@ static const config_var_t option_vars_[] = { OBSOLETE("AuthDirRejectUnlisted"), OBSOLETE("AuthDirListBadDirs"), V(AuthDirListBadExits, BOOL, "0"), - V(AuthDirMaxServersPerAddr, POSINT, "2"), OBSOLETE("AuthDirMaxServersPerAuthAddr"), V(AuthDirHasIPv6Connectivity, BOOL, "0"), VAR("AuthoritativeDirectory", BOOL, AuthoritativeDir, "0"), @@ -452,7 +451,7 @@ static const config_var_t option_vars_[] = { V(EnforceDistinctSubnets, BOOL, "1"), V_D(EntryNodes, ROUTERSET, NULL), V(EntryStatistics, BOOL, "0"), - V(TestingEstimatedDescriptorPropagationTime, INTERVAL, "10 minutes"), + OBSOLETE("TestingEstimatedDescriptorPropagationTime"), V_D(ExcludeNodes, ROUTERSET, NULL), V_D(ExcludeExitNodes, ROUTERSET, NULL), OBSOLETE("ExcludeSingleHopRelays"), @@ -4124,7 +4123,6 @@ options_validate_cb(const void *old_options_, void *options_, char **msg) CHECK_DEFAULT(TestingV3AuthInitialDistDelay); CHECK_DEFAULT(TestingV3AuthVotingStartOffset); CHECK_DEFAULT(TestingAuthDirTimeToLearnReachability); - CHECK_DEFAULT(TestingEstimatedDescriptorPropagationTime); CHECK_DEFAULT(TestingServerDownloadInitialDelay); CHECK_DEFAULT(TestingClientDownloadInitialDelay); CHECK_DEFAULT(TestingServerConsensusDownloadInitialDelay); @@ -4152,12 +4150,6 @@ options_validate_cb(const void *old_options_, void *options_, char **msg) if (options_validate_dirauth_testing(old_options, options, msg) < 0) return -1; - if (options->TestingEstimatedDescriptorPropagationTime < 0) { - REJECT("TestingEstimatedDescriptorPropagationTime must be non-negative."); - } else if (options->TestingEstimatedDescriptorPropagationTime > 60*60) { - COMPLAIN("TestingEstimatedDescriptorPropagationTime is insanely high."); - } - if (options->TestingClientMaxIntervalWithoutRequest < 1) { REJECT("TestingClientMaxIntervalWithoutRequest is way too low."); } else if (options->TestingClientMaxIntervalWithoutRequest > 3600) { diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h index a3d63d9208..4915be187c 100644 --- a/src/app/config/or_options_st.h +++ b/src/app/config/or_options_st.h @@ -467,8 +467,6 @@ struct or_options_t { int AuthDirListBadExits; /**< True iff we should list bad exits, * and vote for all other exits as good. */ - int AuthDirMaxServersPerAddr; /**< Do not permit more than this - * number of servers per IP address. */ int AuthDirHasIPv6Connectivity; /**< Boolean: are we on IPv6? */ int AuthDirPinKeys; /**< Boolean: Do we enforce key-pinning? */ @@ -725,11 +723,6 @@ struct or_options_t { * altered on testing networks. */ int TestingAuthDirTimeToLearnReachability; - /** Clients don't download any descriptor this recent, since it will - * probably not have propagated to enough caches. Only altered on testing - * networks. */ - int TestingEstimatedDescriptorPropagationTime; - /** Schedule for when servers should download things in general. Only * altered on testing networks. */ int TestingServerDownloadInitialDelay; diff --git a/src/app/config/testnet.inc b/src/app/config/testnet.inc index 0ed3c38627..f146a03cd1 100644 --- a/src/app/config/testnet.inc +++ b/src/app/config/testnet.inc @@ -17,7 +17,6 @@ { "TestingV3AuthInitialVoteDelay", "20 seconds" }, { "TestingV3AuthInitialDistDelay", "20 seconds" }, { "TestingAuthDirTimeToLearnReachability", "0 minutes" }, -{ "TestingEstimatedDescriptorPropagationTime", "0 minutes" }, { "MinUptimeHidServDirectoryV2", "0 minutes" }, { "TestingServerDownloadInitialDelay", "0" }, { "TestingClientDownloadInitialDelay", "0" }, diff --git a/src/app/main/main.c b/src/app/main/main.c index 6029ed3d2d..4275a98bd0 100644 --- a/src/app/main/main.c +++ b/src/app/main/main.c @@ -67,7 +67,6 @@ #include "lib/osinfo/uname.h" #include "lib/sandbox/sandbox.h" #include "lib/fs/lockfile.h" -#include "lib/net/resolve.h" #include "lib/tls/tortls.h" #include "lib/evloop/compat_libevent.h" #include "lib/encoding/confline.h" diff --git a/src/app/main/shutdown.c b/src/app/main/shutdown.c index cc07b921c3..df273b960b 100644 --- a/src/app/main/shutdown.c +++ b/src/app/main/shutdown.c @@ -43,7 +43,6 @@ #include "feature/nodelist/networkstatus.h" #include "feature/nodelist/nodelist.h" #include "feature/nodelist/routerlist.h" -#include "feature/nodelist/routerlist.h" #include "feature/relay/ext_orport.h" #include "feature/relay/relay_config.h" #include "feature/rend/rendcache.h" diff --git a/src/app/main/subsystem_list.c b/src/app/main/subsystem_list.c index a343207c1c..8b217715a5 100644 --- a/src/app/main/subsystem_list.c +++ b/src/app/main/subsystem_list.c @@ -66,13 +66,9 @@ const subsys_fns_t *tor_subsystems[] = { &sys_mainloop, &sys_or, -#ifdef HAVE_MODULE_RELAY &sys_relay, -#endif -#ifdef HAVE_MODULE_DIRAUTH &sys_dirauth, -#endif }; const unsigned n_tor_subsystems = ARRAY_LENGTH(tor_subsystems); diff --git a/src/core/include.am b/src/core/include.am index 83230fb3ca..911932d46b 100644 --- a/src/core/include.am +++ b/src/core/include.am @@ -157,6 +157,11 @@ LIBTOR_APP_A_SOURCES = \ src/feature/stats/rephist.c \ src/feature/stats/predict_ports.c +# +# Sources that we only add for the real libtor_a, and not for testing. +# +LIBTOR_APP_A_STUB_SOURCES = + if BUILD_NT_SERVICES LIBTOR_APP_A_SOURCES += src/app/main/ntmain.c endif @@ -199,13 +204,19 @@ MODULE_DIRAUTH_SOURCES = \ if BUILD_MODULE_RELAY LIBTOR_APP_A_SOURCES += $(MODULE_RELAY_SOURCES) +else +LIBTOR_APP_A_STUB_SOURCES += src/feature/relay/relay_stub.c endif if BUILD_MODULE_DIRAUTH LIBTOR_APP_A_SOURCES += $(MODULE_DIRAUTH_SOURCES) +else +LIBTOR_APP_A_STUB_SOURCES += src/feature/dirauth/dirauth_stub.c endif -src_core_libtor_app_a_SOURCES = $(LIBTOR_APP_A_SOURCES) +src_core_libtor_app_a_SOURCES = \ + $(LIBTOR_APP_A_SOURCES) \ + $(LIBTOR_APP_A_STUB_SOURCES) if UNITTESTS_ENABLED # Add the sources of the modules that are needed for tests to work here. @@ -344,6 +355,8 @@ noinst_HEADERS += \ src/feature/dirauth/bridgeauth.h \ src/feature/dirauth/bwauth.h \ src/feature/dirauth/dirauth_config.h \ + src/feature/dirauth/dirauth_options.inc \ + src/feature/dirauth/dirauth_options_st.h \ src/feature/dirauth/dirauth_periodic.h \ src/feature/dirauth/dirauth_sys.h \ src/feature/dirauth/dircollate.h \ diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c index 368041f924..50fd12319e 100644 --- a/src/core/mainloop/connection.c +++ b/src/core/mainloop/connection.c @@ -65,8 +65,7 @@ * Define this so we get channel internal functions, since we're implementing * part of a subclass (channel_tls_t). */ -#define TOR_CHANNEL_INTERNAL_ -#define CONNECTION_PRIVATE +#define CHANNEL_OBJECT_PRIVATE #include "app/config/config.h" #include "core/mainloop/connection.h" #include "core/mainloop/mainloop.h" diff --git a/src/core/mainloop/periodic.c b/src/core/mainloop/periodic.c index efc6a63165..490d23c244 100644 --- a/src/core/mainloop/periodic.c +++ b/src/core/mainloop/periodic.c @@ -29,7 +29,6 @@ #include "app/config/config.h" #include "core/mainloop/mainloop.h" #include "core/mainloop/periodic.h" -#include "lib/evloop/compat_libevent.h" /** We disable any interval greater than this number of seconds, on the * grounds that it is probably an absolute time mistakenly passed in as a diff --git a/src/core/or/channel.c b/src/core/or/channel.c index 1641a96800..2faf638756 100644 --- a/src/core/or/channel.c +++ b/src/core/or/channel.c @@ -52,10 +52,10 @@ * Define this so channel.h gives us things only channel_t subclasses * should touch. */ -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE /* This one's for stuff only channel.c and the test suite should see */ -#define CHANNEL_PRIVATE_ +#define CHANNEL_FILE_PRIVATE #include "core/or/or.h" #include "app/config/config.h" diff --git a/src/core/or/channel.h b/src/core/or/channel.h index 7f5bd9bf2f..0f6fa228dd 100644 --- a/src/core/or/channel.h +++ b/src/core/or/channel.h @@ -563,13 +563,13 @@ void channel_free_all(void); void channel_dumpstats(int severity); void channel_listener_dumpstats(int severity); -#ifdef TOR_CHANNEL_INTERNAL_ +#ifdef CHANNEL_OBJECT_PRIVATE -#ifdef CHANNEL_PRIVATE_ +#ifdef CHANNEL_FILE_PRIVATE STATIC void channel_add_to_digest_map(channel_t *chan); -#endif /* defined(CHANNEL_PRIVATE_) */ +#endif /* defined(CHANNEL_FILE_PRIVATE) */ /* Channel operations for subclasses and internal use only */ @@ -648,7 +648,7 @@ void channel_notify_flushed(channel_t *chan); /* Handle stuff we need to do on open like notifying circuits */ void channel_do_open_actions(channel_t *chan); -#endif /* defined(TOR_CHANNEL_INTERNAL_) */ +#endif /* defined(CHANNEL_OBJECT_PRIVATE) */ /* Helper functions to perform operations on channels */ diff --git a/src/core/or/channelpadding.c b/src/core/or/channelpadding.c index 2b8314db89..9c95858bb3 100644 --- a/src/core/or/channelpadding.c +++ b/src/core/or/channelpadding.c @@ -9,9 +9,9 @@ * @brief Link-level padding code. **/ -/* TOR_CHANNEL_INTERNAL_ define needed for an O(1) implementation of +/* CHANNEL_OBJECT_PRIVATE define needed for an O(1) implementation of * channelpadding_channel_to_channelinfo() */ -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #include "core/or/or.h" #include "core/or/channel.h" diff --git a/src/core/or/channeltls.c b/src/core/or/channeltls.c index e9497651ef..a5710c7f40 100644 --- a/src/core/or/channeltls.c +++ b/src/core/or/channeltls.c @@ -34,7 +34,7 @@ * Define this so channel.h gives us things only channel_t subclasses * should touch. */ -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define CHANNELTLS_PRIVATE diff --git a/src/core/or/channeltls.h b/src/core/or/channeltls.h index ff703a4979..720adbdd25 100644 --- a/src/core/or/channeltls.h +++ b/src/core/or/channeltls.h @@ -22,7 +22,7 @@ struct curve25519_public_key_t; #define TLS_CHAN_MAGIC 0x8a192427U -#ifdef TOR_CHANNEL_INTERNAL_ +#ifdef CHANNEL_OBJECT_PRIVATE struct channel_tls_t { /* Base channel_t struct */ @@ -31,7 +31,7 @@ struct channel_tls_t { or_connection_t *conn; }; -#endif /* defined(TOR_CHANNEL_INTERNAL_) */ +#endif /* defined(CHANNEL_OBJECT_PRIVATE) */ channel_t * channel_tls_connect(const tor_addr_t *addr, uint16_t port, const char *id_digest, diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c index 49a63c50a1..c67b19f065 100644 --- a/src/core/or/circuitlist.c +++ b/src/core/or/circuitlist.c @@ -99,7 +99,6 @@ #include "lib/compress/compress_zstd.h" #include "lib/buf/buffers.h" -#define OCIRC_EVENT_PRIVATE #include "core/or/ocirc_event.h" #include "ht.h" diff --git a/src/core/or/connection_or.c b/src/core/or/connection_or.c index 4c93351e31..24a4af045e 100644 --- a/src/core/or/connection_or.c +++ b/src/core/or/connection_or.c @@ -27,7 +27,7 @@ * Define this so we get channel internal functions, since we're implementing * part of a subclass (channel_tls_t). */ -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define CONNECTION_OR_PRIVATE #define ORCONN_EVENT_PRIVATE #include "core/or/channel.h" diff --git a/src/core/or/or.h b/src/core/or/or.h index c044936d38..4d6afc2b0b 100644 --- a/src/core/or/or.h +++ b/src/core/or/or.h @@ -24,7 +24,6 @@ #include "lib/arch/bytes.h" #include "lib/cc/compat_compiler.h" -#include "lib/cc/torint.h" #include "lib/container/map.h" #include "lib/buf/buffers.h" #include "lib/container/smartlist.h" diff --git a/src/core/or/scheduler.c b/src/core/or/scheduler.c index 063342480a..023e9bf1b9 100644 --- a/src/core/or/scheduler.c +++ b/src/core/or/scheduler.c @@ -5,14 +5,13 @@ #include "app/config/config.h" #include "lib/evloop/compat_libevent.h" -#define SCHEDULER_PRIVATE_ +#define SCHEDULER_PRIVATE #define SCHEDULER_KIST_PRIVATE #include "core/or/scheduler.h" #include "core/mainloop/mainloop.h" #include "lib/buf/buffers.h" -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #include "core/or/channeltls.h" -#include "lib/evloop/compat_libevent.h" #include "core/or/or_connection_st.h" diff --git a/src/core/or/scheduler.h b/src/core/or/scheduler.h index b82f8730b0..8b3995e61d 100644 --- a/src/core/or/scheduler.h +++ b/src/core/or/scheduler.h @@ -136,7 +136,7 @@ MOCK_DECL(void, scheduler_channel_has_waiting_cells, (channel_t *chan)); * These functions are only visible to the scheduling system, the current * scheduler implementation, and tests. *****************************************************************************/ -#ifdef SCHEDULER_PRIVATE_ +#ifdef SCHEDULER_PRIVATE /********************************* * Defined in scheduler.c @@ -212,7 +212,7 @@ extern int32_t sched_run_interval; scheduler_t *get_vanilla_scheduler(void); -#endif /* defined(SCHEDULER_PRIVATE_) */ +#endif /* defined(SCHEDULER_PRIVATE) */ #endif /* !defined(TOR_SCHEDULER_H) */ diff --git a/src/core/or/scheduler_kist.c b/src/core/or/scheduler_kist.c index 660c222a31..a074b66ae4 100644 --- a/src/core/or/scheduler_kist.c +++ b/src/core/or/scheduler_kist.c @@ -13,10 +13,10 @@ #include "app/config/config.h" #include "core/mainloop/connection.h" #include "feature/nodelist/networkstatus.h" -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #include "core/or/channel.h" #include "core/or/channeltls.h" -#define SCHEDULER_PRIVATE_ +#define SCHEDULER_PRIVATE #include "core/or/scheduler.h" #include "lib/math/fp.h" diff --git a/src/core/or/scheduler_vanilla.c b/src/core/or/scheduler_vanilla.c index bd84a4e4ef..fb8cd65a86 100644 --- a/src/core/or/scheduler_vanilla.c +++ b/src/core/or/scheduler_vanilla.c @@ -8,9 +8,9 @@ #include "core/or/or.h" #include "app/config/config.h" -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #include "core/or/channel.h" -#define SCHEDULER_PRIVATE_ +#define SCHEDULER_PRIVATE #include "core/or/scheduler.h" /***************************************************************************** diff --git a/src/feature/control/control_hs.h b/src/feature/control/control_hs.h index 35ac1b22d4..41ba1ee89b 100644 --- a/src/feature/control/control_hs.h +++ b/src/feature/control/control_hs.h @@ -29,5 +29,5 @@ int handle_control_onion_client_auth_view(control_connection_t *conn, const control_cmd_args_t *args); -#endif +#endif /* !defined(TOR_CONTROL_HS_H) */ diff --git a/src/feature/dirauth/.may_include b/src/feature/dirauth/.may_include index 424c745c12..a9bb274699 100644 --- a/src/feature/dirauth/.may_include +++ b/src/feature/dirauth/.may_include @@ -1 +1,2 @@ *.h +feature/dirauth/*.inc diff --git a/src/feature/dirauth/dirauth_config.c b/src/feature/dirauth/dirauth_config.c index 552f851461..b7e160c241 100644 --- a/src/feature/dirauth/dirauth_config.c +++ b/src/feature/dirauth/dirauth_config.c @@ -15,6 +15,7 @@ #include "lib/encoding/confline.h" #include "lib/confmgt/confmgt.h" +#include "lib/conf/confdecl.h" /* Required for dirinfo_type_t in or_options_t */ #include "core/or/or.h" @@ -28,6 +29,7 @@ #include "feature/dirauth/dirauth_periodic.h" #include "feature/dirauth/dirvote.h" #include "feature/dirauth/guardfraction.h" +#include "feature/dirauth/dirauth_options_st.h" /* Copied from config.c, we will refactor later in 29211. */ #define REJECT(arg) \ @@ -438,3 +440,23 @@ options_act_dirauth_stats(const or_options_t *old_options, return 0; } + +/* Declare the options field table for dirauth_options */ +#define CONF_CONTEXT TABLE +#include "feature/dirauth/dirauth_options.inc" +#undef CONF_CONTEXT + +/** Magic number for dirauth_options_t. */ +#define DIRAUTH_OPTIONS_MAGIC 0x41757448 + +/** + * Declare the configuration options for the dirauth module. + **/ +const config_format_t dirauth_options_fmt = { + .size = sizeof(dirauth_options_t), + .magic = { "dirauth_options_t", + DIRAUTH_OPTIONS_MAGIC, + offsetof(dirauth_options_t, magic) }, + .vars = dirauth_options_t_vars, +}; + diff --git a/src/feature/dirauth/dirauth_config.h b/src/feature/dirauth/dirauth_config.h index b494ca685e..d21fb69d1e 100644 --- a/src/feature/dirauth/dirauth_config.h +++ b/src/feature/dirauth/dirauth_config.h @@ -39,6 +39,8 @@ int options_act_dirauth_mtbf(const struct or_options_t *old_options); int options_act_dirauth_stats(const struct or_options_t *old_options, bool *print_notice_out); +extern const struct config_format_t dirauth_options_fmt; + #else /* !defined(HAVE_MODULE_DIRAUTH) */ /** When tor is compiled with the dirauth module disabled, it can't be diff --git a/src/feature/dirauth/dirauth_options.inc b/src/feature/dirauth/dirauth_options.inc new file mode 100644 index 0000000000..6b66f1e289 --- /dev/null +++ b/src/feature/dirauth/dirauth_options.inc @@ -0,0 +1,18 @@ +/* Copyright (c) 2001 Matej Pfajfar. + * Copyright (c) 2001-2004, Roger Dingledine. + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2019, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * @file dirauth_options.inc + * @brief Declare configuration options for the crypto_ops module. + **/ + +/** Holds configuration about our directory authority options. */ +BEGIN_CONF_STRUCT(dirauth_options_t) + +/** Do not permit more than this number of servers per IP address. */ +CONF_VAR(AuthDirMaxServersPerAddr, POSINT, 0, "2") + +END_CONF_STRUCT(dirauth_options_t) diff --git a/src/feature/dirauth/dirauth_options_st.h b/src/feature/dirauth/dirauth_options_st.h new file mode 100644 index 0000000000..93b9cb45bc --- /dev/null +++ b/src/feature/dirauth/dirauth_options_st.h @@ -0,0 +1,22 @@ +/* Copyright (c) 2001 Matej Pfajfar. + * Copyright (c) 2001-2004, Roger Dingledine. + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2019, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * @file dirauth_options_st.h + * @brief Structure dirauth_options_t to hold directory authority options. + **/ + +#ifndef TOR_FEATURE_DIRAUTH_DIRAUTH_OPTIONS_ST_H +#define TOR_FEATURE_DIRAUTH_DIRAUTH_OPTIONS_ST_H + +#include "lib/conf/confdecl.h" +#define CONF_CONTEXT STRUCT +#include "feature/dirauth/dirauth_options.inc" +#undef CONF_CONTEXT + +typedef struct dirauth_options_t dirauth_options_t; + +#endif /* !defined(TOR_FEATURE_DIRAUTH_DIRAUTH_OPTIONS_ST_H) */ diff --git a/src/feature/dirauth/dirauth_stub.c b/src/feature/dirauth/dirauth_stub.c new file mode 100644 index 0000000000..d902d56d2b --- /dev/null +++ b/src/feature/dirauth/dirauth_stub.c @@ -0,0 +1,33 @@ +/* Copyright (c) 2001 Matej Pfajfar. + * Copyright (c) 2001-2004, Roger Dingledine. + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2019, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * @file dirauth_stub.c + * @brief Stub declarations for use when dirauth module is disabled. + **/ + +#include "orconfig.h" +#include "feature/dirauth/dirauth_sys.h" +#include "lib/conf/conftypes.h" +#include "lib/conf/confdecl.h" +#include "lib/subsys/subsys.h" + +/* Declare the options field table for dirauth_options */ +#define CONF_CONTEXT STUB_TABLE +#include "feature/dirauth/dirauth_options.inc" +#undef CONF_CONTEXT + +static const config_format_t dirauth_options_stub_fmt = { + .vars = dirauth_options_t_vars, +}; + +const struct subsys_fns_t sys_dirauth = { + .name = "dirauth", + .supported = false, + .level = DIRAUTH_SUBSYS_LEVEL, + + .options_format = &dirauth_options_stub_fmt +}; diff --git a/src/feature/dirauth/dirauth_sys.c b/src/feature/dirauth/dirauth_sys.c index 090e9129f2..6ec25681e7 100644 --- a/src/feature/dirauth/dirauth_sys.c +++ b/src/feature/dirauth/dirauth_sys.c @@ -17,9 +17,14 @@ #include "feature/dirauth/dirauth_periodic.h" #include "feature/dirauth/keypin.h" #include "feature/dirauth/process_descs.h" +#include "feature/dirauth/dirauth_config.h" + +#include "feature/dirauth/dirauth_options_st.h" #include "lib/subsys/subsys.h" +static const dirauth_options_t *global_dirauth_options; + static int subsys_dirauth_initialize(void) { @@ -34,12 +39,31 @@ subsys_dirauth_shutdown(void) dirvote_free_all(); dirserv_clear_measured_bw_cache(); keypin_close_journal(); + global_dirauth_options = NULL; +} + +const dirauth_options_t * +dirauth_get_options(void) +{ + tor_assert(global_dirauth_options); + return global_dirauth_options; +} + +static int +dirauth_set_options(void *arg) +{ + dirauth_options_t *opts = arg; + global_dirauth_options = opts; + return 0; } const struct subsys_fns_t sys_dirauth = { .name = "dirauth", .supported = true, - .level = 70, + .level = DIRAUTH_SUBSYS_LEVEL, .initialize = subsys_dirauth_initialize, .shutdown = subsys_dirauth_shutdown, + + .options_format = &dirauth_options_fmt, + .set_options = dirauth_set_options, }; diff --git a/src/feature/dirauth/dirauth_sys.h b/src/feature/dirauth/dirauth_sys.h index 86c8d8ba3e..6f116855df 100644 --- a/src/feature/dirauth/dirauth_sys.h +++ b/src/feature/dirauth/dirauth_sys.h @@ -12,10 +12,17 @@ #ifndef DIRAUTH_SYS_H #define DIRAUTH_SYS_H -#ifdef HAVE_MODULE_DIRAUTH +struct dirauth_options_t; +const struct dirauth_options_t *dirauth_get_options(void); extern const struct subsys_fns_t sys_dirauth; -#endif +/** + * Subsystem level for the directory-authority system. + * + * Defined here so that it can be shared between the real and stub + * definitions. + **/ +#define DIRAUTH_SUBSYS_LEVEL 70 #endif /* !defined(DIRAUTH_SYS_H) */ diff --git a/src/feature/dirauth/dirvote.c b/src/feature/dirauth/dirvote.c index 043bbfc227..13003bf639 100644 --- a/src/feature/dirauth/dirvote.c +++ b/src/feature/dirauth/dirvote.c @@ -41,10 +41,12 @@ #include "feature/dirauth/dirvote.h" #include "feature/dirauth/authmode.h" #include "feature/dirauth/shared_random_state.h" +#include "feature/dirauth/dirauth_sys.h" #include "feature/nodelist/authority_cert_st.h" #include "feature/dircache/cached_dir_st.h" #include "feature/dirclient/dir_server_st.h" +#include "feature/dirauth/dirauth_options_st.h" #include "feature/nodelist/document_signature_st.h" #include "feature/nodelist/microdesc_st.h" #include "feature/nodelist/networkstatus_st.h" @@ -4228,7 +4230,7 @@ compare_routerinfo_by_ip_and_bw_(const void **a, const void **b) static digestmap_t * get_possible_sybil_list(const smartlist_t *routers) { - const or_options_t *options = get_options(); + const dirauth_options_t *options = dirauth_get_options(); digestmap_t *omit_as_sybil; smartlist_t *routers_by_ip = smartlist_new(); uint32_t last_addr; diff --git a/src/feature/dirauth/guardfraction.h b/src/feature/dirauth/guardfraction.h index 9f01ded838..cae4777605 100644 --- a/src/feature/dirauth/guardfraction.h +++ b/src/feature/dirauth/guardfraction.h @@ -16,7 +16,7 @@ STATIC int dirserv_read_guardfraction_file_from_str(const char *guardfraction_file_str, smartlist_t *vote_routerstatuses); -#endif /* defined(DIRSERV_PRIVATE) */ +#endif int dirserv_read_guardfraction_file(const char *fname, smartlist_t *vote_routerstatuses); diff --git a/src/feature/dirauth/keypin.c b/src/feature/dirauth/keypin.c index 3ca2c3ef91..991b7be037 100644 --- a/src/feature/dirauth/keypin.c +++ b/src/feature/dirauth/keypin.c @@ -15,8 +15,6 @@ #include "lib/cc/torint.h" #include "lib/crypt_ops/crypto_digest.h" #include "lib/crypt_ops/crypto_format.h" -#include "lib/crypt_ops/crypto_format.h" -#include "lib/ctime/di_ops.h" #include "lib/ctime/di_ops.h" #include "lib/encoding/binascii.h" #include "lib/encoding/time_fmt.h" diff --git a/src/feature/dircache/dirserv.c b/src/feature/dircache/dirserv.c index 85331bfeaa..53bb9814a7 100644 --- a/src/feature/dircache/dirserv.c +++ b/src/feature/dircache/dirserv.c @@ -3,7 +3,6 @@ * Copyright (c) 2007-2019, The Tor Project, Inc. */ /* See LICENSE for licensing information */ -#define DIRSERV_PRIVATE #include "core/or/or.h" #include "app/config/config.h" diff --git a/src/feature/dircommon/voting_schedule.c b/src/feature/dircommon/voting_schedule.c index 5576ec69f7..76915f6be2 100644 --- a/src/feature/dircommon/voting_schedule.c +++ b/src/feature/dircommon/voting_schedule.c @@ -8,7 +8,6 @@ * tor. The full feature is built as part of the dirauth module. **/ -#define VOTING_SCHEDULE_PRIVATE #include "feature/dircommon/voting_schedule.h" #include "core/or/or.h" diff --git a/src/feature/dirparse/policy_parse.c b/src/feature/dirparse/policy_parse.c index 7562ae409b..cad623d560 100644 --- a/src/feature/dirparse/policy_parse.c +++ b/src/feature/dirparse/policy_parse.c @@ -9,7 +9,7 @@ * \brief Code to parse address policies. **/ -#define EXPOSE_ROUTERDESC_TOKEN_TABLE +#define ROUTERDESC_TOKEN_TABLE_PRIVATE #include "core/or/or.h" diff --git a/src/feature/dirparse/routerparse.c b/src/feature/dirparse/routerparse.c index f78c46f186..d4c0a11f14 100644 --- a/src/feature/dirparse/routerparse.c +++ b/src/feature/dirparse/routerparse.c @@ -50,7 +50,7 @@ * </ul> **/ -#define EXPOSE_ROUTERDESC_TOKEN_TABLE +#define ROUTERDESC_TOKEN_TABLE_PRIVATE #include "core/or/or.h" #include "app/config/config.h" diff --git a/src/feature/dirparse/routerparse.h b/src/feature/dirparse/routerparse.h index f9a13f2168..f2e59f0f24 100644 --- a/src/feature/dirparse/routerparse.h +++ b/src/feature/dirparse/routerparse.h @@ -40,7 +40,7 @@ int find_single_ipv6_orport(const smartlist_t *list, void routerparse_init(void); void routerparse_free_all(void); -#ifdef EXPOSE_ROUTERDESC_TOKEN_TABLE +#ifdef ROUTERDESC_TOKEN_TABLE_PRIVATE extern const struct token_rule_t routerdesc_token_table[]; #endif diff --git a/src/feature/hs/hs_client.c b/src/feature/hs/hs_client.c index b5030da473..6656ab2edb 100644 --- a/src/feature/hs/hs_client.c +++ b/src/feature/hs/hs_client.c @@ -145,7 +145,7 @@ static void cancel_descriptor_fetches(void) { smartlist_t *conns = - connection_list_by_type_state(CONN_TYPE_DIR, DIR_PURPOSE_FETCH_HSDESC); + connection_list_by_type_purpose(CONN_TYPE_DIR, DIR_PURPOSE_FETCH_HSDESC); SMARTLIST_FOREACH_BEGIN(conns, connection_t *, conn) { const hs_ident_dir_conn_t *ident = TO_DIR_CONN(conn)->hs_ident; if (BUG(ident == NULL)) { diff --git a/src/feature/hs/hs_config.c b/src/feature/hs/hs_config.c index ed577daf7d..3c302e70b3 100644 --- a/src/feature/hs/hs_config.c +++ b/src/feature/hs/hs_config.c @@ -23,8 +23,6 @@ * every option that is common to all version (config_generic_service). **/ -#define HS_CONFIG_PRIVATE - #include "feature/hs/hs_common.h" #include "feature/hs/hs_config.h" #include "feature/hs/hs_client.h" diff --git a/src/feature/hs/hs_service.c b/src/feature/hs/hs_service.c index 3d152afa16..cfa5d6c6ec 100644 --- a/src/feature/hs/hs_service.c +++ b/src/feature/hs/hs_service.c @@ -30,7 +30,6 @@ #include "feature/rend/rendservice.h" #include "lib/crypt_ops/crypto_ope.h" #include "lib/crypt_ops/crypto_rand.h" -#include "lib/crypt_ops/crypto_rand.h" #include "lib/crypt_ops/crypto_util.h" #include "feature/hs/hs_circuit.h" diff --git a/src/feature/hs_common/shared_random_client.c b/src/feature/hs_common/shared_random_client.c index f5328e6e10..999472a862 100644 --- a/src/feature/hs_common/shared_random_client.c +++ b/src/feature/hs_common/shared_random_client.c @@ -8,7 +8,6 @@ * as part of the dirauth module. **/ -#define SHARED_RANDOM_CLIENT_PRIVATE #include "feature/hs_common/shared_random_client.h" #include "app/config/config.h" diff --git a/src/feature/relay/relay_stub.c b/src/feature/relay/relay_stub.c new file mode 100644 index 0000000000..36daaa7bd7 --- /dev/null +++ b/src/feature/relay/relay_stub.c @@ -0,0 +1,20 @@ +/* Copyright (c) 2001 Matej Pfajfar. + * Copyright (c) 2001-2004, Roger Dingledine. + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2019, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * @file relay_stub.c + * @brief Stub declarations for use when relay module is disabled. + **/ + +#include "orconfig.h" +#include "feature/relay/relay_sys.h" +#include "lib/subsys/subsys.h" + +const struct subsys_fns_t sys_relay = { + .name = "relay", + .supported = false, + .level = RELAY_SUBSYS_LEVEL, +}; diff --git a/src/feature/relay/relay_sys.c b/src/feature/relay/relay_sys.c index 106e88b2a5..dfddff27f2 100644 --- a/src/feature/relay/relay_sys.c +++ b/src/feature/relay/relay_sys.c @@ -42,7 +42,7 @@ subsys_relay_shutdown(void) const struct subsys_fns_t sys_relay = { .name = "relay", .supported = true, - .level = 50, + .level = RELAY_SUBSYS_LEVEL, .initialize = subsys_relay_initialize, .shutdown = subsys_relay_shutdown, }; diff --git a/src/feature/relay/relay_sys.h b/src/feature/relay/relay_sys.h index aa387369b5..ba3b5ccf4e 100644 --- a/src/feature/relay/relay_sys.h +++ b/src/feature/relay/relay_sys.h @@ -12,10 +12,14 @@ #ifndef TOR_FEATURE_RELAY_RELAY_SYS_H #define TOR_FEATURE_RELAY_RELAY_SYS_H -#ifdef HAVE_MODULE_RELAY - extern const struct subsys_fns_t sys_relay; -#endif +/** + * Subsystem level for the relay system. + * + * Defined here so that it can be shared between the real and stub + * definitions. + **/ +#define RELAY_SUBSYS_LEVEL 50 #endif /* !defined(TOR_FEATURE_RELAY_RELAY_SYS_H) */ diff --git a/src/feature/relay/selftest.c b/src/feature/relay/selftest.c index f8b54ff45d..abc87437d1 100644 --- a/src/feature/relay/selftest.c +++ b/src/feature/relay/selftest.c @@ -12,8 +12,6 @@ * their own bandwidth, before publishing. */ -#define SELFTEST_PRIVATE - #include "core/or/or.h" #include "app/config/config.h" diff --git a/src/lib/conf/confdecl.h b/src/lib/conf/confdecl.h index 294a1e7173..723aea1878 100644 --- a/src/lib/conf/confdecl.h +++ b/src/lib/conf/confdecl.h @@ -51,6 +51,7 @@ #undef CONF_CONTEXT #include "lib/cc/tokpaste.h" +#include "lib/cc/torint.h" /** * Begin the definition of a configuration object called `name`. @@ -134,6 +135,28 @@ .initvalue = initval \ }, /**@}*/ + +/* @defgroup STUB_TABLE_MACROS Internal macros: stub table declarations, + * for use when a module is disabled. + * Implementation helpers: the regular confdecl macros expand to these + * when CONF_CONTEXT is defined to LL_TABLE. Don't use them directly. + * @{*/ +#define BEGIN_CONF_STRUCT__STUB_TABLE(structname) \ + static const config_var_t structname##_vars[] = { +#define END_CONF_STRUCT__STUB_TABLE(structname) \ + { .member = { .name = NULL } } \ + }; +#define CONF_VAR__STUB_TABLE(varname, vartype, varflags, initval) \ + { \ + .member = \ + { .name = #varname, \ + .type = CONFIG_TYPE_IGNORE, \ + .offset = -1, \ + }, \ + .flags = CFLG_GROUP_DISABLED, \ + }, +/**@}*/ + #endif /* !defined(COCCI) */ /** Type aliases for the "commonly used" configuration types. diff --git a/src/lib/conf/conftypes.h b/src/lib/conf/conftypes.h index 19ea997316..52f9fceb20 100644 --- a/src/lib/conf/conftypes.h +++ b/src/lib/conf/conftypes.h @@ -131,6 +131,9 @@ typedef struct struct_member_t { * * These 'magic numbers' are 32-bit values used to tag objects to make sure * that they have the correct type. + * + * If all fields in this structure are zero or 0, the magic-number check is + * not performed. */ typedef struct struct_magic_decl_t { /** The name of the structure */ @@ -199,6 +202,11 @@ typedef struct struct_magic_decl_t { * whenever the user tries to use it. **/ #define CFLG_WARN_OBSOLETE (1u<<7) +/** + * Flag to indicate that we should warn that an option applies only to + * a disabled module, whenever the user tries to use it. + **/ +#define CFLG_WARN_DISABLED (1u<<8) /** * A group of flags that should be set on all obsolete options and types. @@ -207,6 +215,13 @@ typedef struct struct_magic_decl_t { (CFLG_NOCOPY|CFLG_NOCMP|CFLG_NODUMP|CFLG_NOSET|CFLG_NOLIST|\ CFLG_WARN_OBSOLETE) +/** + * A group of fflags that should be set on all disabled options. + **/ +#define CFLG_GROUP_DISABLED \ + (CFLG_NOCOPY|CFLG_NOCMP|CFLG_NODUMP|CFLG_NOSET|CFLG_NOLIST|\ + CFLG_WARN_DISABLED) + /** A variable allowed in the configuration file or on the command line. */ typedef struct config_var_t { struct_member_t member; /** A struct member corresponding to this diff --git a/src/lib/confmgt/confmgt.c b/src/lib/confmgt/confmgt.c index c72efa847c..eaa4468d55 100644 --- a/src/lib/confmgt/confmgt.c +++ b/src/lib/confmgt/confmgt.c @@ -660,6 +660,9 @@ config_assign_value(const config_mgr_t *mgr, void *options, if (config_var_has_flag(var->cvar, CFLG_WARN_OBSOLETE)) { log_warn(LD_GENERAL, "Skipping obsolete configuration option \"%s\".", var->cvar->member.name); + } else if (config_var_has_flag(var->cvar, CFLG_WARN_DISABLED)) { + log_warn(LD_GENERAL, "This copy of Tor was built without support for " + "the option \"%s\". Skipping.", var->cvar->member.name); } return struct_var_kvassign(object, c, msg, &var->cvar->member); diff --git a/src/lib/confmgt/structvar.c b/src/lib/confmgt/structvar.c index de678d18c8..ce8e426cda 100644 --- a/src/lib/confmgt/structvar.c +++ b/src/lib/confmgt/structvar.c @@ -30,13 +30,28 @@ #include <stddef.h> /** + * Return true iff all fields on <b>decl</b> are NULL or 0, indicating that + * there is no object or no magic number to check. + **/ +static inline bool +magic_is_null(const struct_magic_decl_t *decl) +{ + return decl->typename == NULL && + decl->magic_offset == 0 && + decl->magic_val == 0; +} + +/** * Set the 'magic number' on <b>object</b> to correspond to decl. **/ void struct_set_magic(void *object, const struct_magic_decl_t *decl) { - tor_assert(object); tor_assert(decl); + if (magic_is_null(decl)) + return; + + tor_assert(object); uint32_t *ptr = STRUCT_VAR_P(object, decl->magic_offset); *ptr = decl->magic_val; } @@ -47,14 +62,17 @@ struct_set_magic(void *object, const struct_magic_decl_t *decl) void struct_check_magic(const void *object, const struct_magic_decl_t *decl) { - tor_assert(object); tor_assert(decl); + if (magic_is_null(decl)) + return; + + tor_assert(object); const uint32_t *ptr = STRUCT_VAR_P(object, decl->magic_offset); tor_assertf(*ptr == decl->magic_val, "Bad magic number on purported %s object. " - "Expected %"PRIu32"x but got "PRIu32"x.", - decl->magic_val, *ptr); + "Expected %"PRIu32"x but got %"PRIu32"x.", + decl->typename, decl->magic_val, *ptr); } /** diff --git a/src/lib/confmgt/type_defs.c b/src/lib/confmgt/type_defs.c index 7200218f74..00932511ab 100644 --- a/src/lib/confmgt/type_defs.c +++ b/src/lib/confmgt/type_defs.c @@ -23,7 +23,6 @@ #include "lib/confmgt/unitparse.h" #include "lib/cc/compat_compiler.h" -#include "lib/conf/conftypes.h" #include "lib/container/smartlist.h" #include "lib/encoding/confline.h" #include "lib/encoding/time_fmt.h" diff --git a/src/lib/crypt_ops/aes_openssl.c b/src/lib/crypt_ops/aes_openssl.c index d493b1846b..f5cc97ff68 100644 --- a/src/lib/crypt_ops/aes_openssl.c +++ b/src/lib/crypt_ops/aes_openssl.c @@ -39,7 +39,6 @@ DISABLE_GCC_WARNING(redundant-decls) ENABLE_GCC_WARNING(redundant-decls) -#include "lib/crypt_ops/aes.h" #include "lib/log/log.h" #include "lib/ctime/di_ops.h" diff --git a/src/lib/crypt_ops/crypto_rand_fast.c b/src/lib/crypt_ops/crypto_rand_fast.c index 8625ebd1c9..166c67c87b 100644 --- a/src/lib/crypt_ops/crypto_rand_fast.c +++ b/src/lib/crypt_ops/crypto_rand_fast.c @@ -32,7 +32,6 @@ * request. */ -#define CRYPTO_RAND_FAST_PRIVATE #define CRYPTO_PRIVATE #include "lib/crypt_ops/crypto_rand.h" diff --git a/src/lib/crypt_ops/crypto_util.c b/src/lib/crypt_ops/crypto_util.c index 5e3f4a87a1..beb45792ad 100644 --- a/src/lib/crypt_ops/crypto_util.c +++ b/src/lib/crypt_ops/crypto_util.c @@ -10,8 +10,6 @@ * \brief Common cryptographic utilities. **/ -#define CRYPTO_UTIL_PRIVATE - #include "lib/crypt_ops/crypto_util.h" #include "lib/cc/compat_compiler.h" diff --git a/src/lib/err/backtrace.c b/src/lib/err/backtrace.c index ce8ddcd7c0..62088c1f46 100644 --- a/src/lib/err/backtrace.c +++ b/src/lib/err/backtrace.c @@ -54,7 +54,7 @@ #include "lib/cc/ctassert.h" -#define EXPOSE_CLEAN_BACKTRACE +#define BACKTRACE_PRIVATE #include "lib/err/backtrace.h" #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \ diff --git a/src/lib/err/backtrace.h b/src/lib/err/backtrace.h index 7e09a0a5a7..21303105e2 100644 --- a/src/lib/err/backtrace.h +++ b/src/lib/err/backtrace.h @@ -29,11 +29,11 @@ const char *get_tor_backtrace_version(void); #define log_backtrace(sev, dom, msg) \ log_backtrace_impl((sev), (dom), (msg), tor_log) -#ifdef EXPOSE_CLEAN_BACKTRACE +#ifdef BACKTRACE_PRIVATE #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \ defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION) void clean_backtrace(void **stack, size_t depth, const ucontext_t *ctx); #endif -#endif /* defined(EXPOSE_CLEAN_BACKTRACE) */ +#endif /* defined(BACKTRACE_PRIVATE) */ #endif /* !defined(TOR_BACKTRACE_H) */ diff --git a/src/lib/log/util_bug.h b/src/lib/log/util_bug.h index d0a311ac61..b7dcefcd96 100644 --- a/src/lib/log/util_bug.h +++ b/src/lib/log/util_bug.h @@ -247,10 +247,12 @@ void tor_assertion_failed_(const char *fname, unsigned int line, const char *func, const char *expr, - const char *fmt, ...); + const char *fmt, ...) + CHECK_PRINTF(5,6); void tor_bug_occurred_(const char *fname, unsigned int line, const char *func, const char *expr, - int once, const char *fmt, ...); + int once, const char *fmt, ...) + CHECK_PRINTF(6,7); void tor_abort_(void) ATTR_NORETURN; diff --git a/src/lib/math/prob_distr.c b/src/lib/math/prob_distr.c index 1d17486662..02dbc5de54 100644 --- a/src/lib/math/prob_distr.c +++ b/src/lib/math/prob_distr.c @@ -68,7 +68,7 @@ DECLARE_PROB_DISTR_DOWNCAST_FN(logistic) DECLARE_PROB_DISTR_DOWNCAST_FN(log_logistic) DECLARE_PROB_DISTR_DOWNCAST_FN(genpareto) DECLARE_PROB_DISTR_DOWNCAST_FN(weibull) -#endif +#endif /* !defined(COCCI) */ /** * Count number of one bits in 32-bit word. diff --git a/src/lib/net/inaddr.c b/src/lib/net/inaddr.c index d9ae7cd562..a655ca6ad8 100644 --- a/src/lib/net/inaddr.c +++ b/src/lib/net/inaddr.c @@ -35,11 +35,11 @@ * (Like inet_aton(str,addr), but works on Windows and Solaris.) */ int -tor_inet_aton(const char *str, struct in_addr* addr) +tor_inet_aton(const char *str, struct in_addr *addr) { unsigned a,b,c,d; char more; - if (tor_sscanf(str, "%3u.%3u.%3u.%3u%c", &a,&b,&c,&d,&more) != 4) + if (tor_sscanf(str, "%3u.%3u.%3u.%3u%c", &a, &b, &c, &d, &more) != 4) return 0; if (a > 255) return 0; if (b > 255) return 0; diff --git a/src/lib/net/socket.c b/src/lib/net/socket.c index e1b82251ed..b25be91f48 100644 --- a/src/lib/net/socket.c +++ b/src/lib/net/socket.c @@ -9,7 +9,6 @@ * sockets. **/ -#define SOCKET_PRIVATE #include "lib/net/socket.h" #include "lib/net/socketpair.h" #include "lib/net/address.h" diff --git a/src/lib/process/env.c b/src/lib/process/env.c index 3912ade197..88619d1e47 100644 --- a/src/lib/process/env.c +++ b/src/lib/process/env.c @@ -16,7 +16,6 @@ #include "lib/container/smartlist.h" #include "lib/log/util_bug.h" #include "lib/log/log.h" -#include "lib/malloc/malloc.h" #ifdef HAVE_UNISTD_H #include <unistd.h> diff --git a/src/lib/sandbox/sandbox.c b/src/lib/sandbox/sandbox.c index 0b316e9c6a..badf730f15 100644 --- a/src/lib/sandbox/sandbox.c +++ b/src/lib/sandbox/sandbox.c @@ -82,7 +82,7 @@ #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \ defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION) #define USE_BACKTRACE -#define EXPOSE_CLEAN_BACKTRACE +#define BACKTRACE_PRIVATE #include "lib/err/backtrace.h" #endif /* defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && ... */ @@ -143,6 +143,7 @@ static int filter_nopar_gen[] = { SCMP_SYS(clock_gettime), SCMP_SYS(close), SCMP_SYS(clone), + SCMP_SYS(dup), SCMP_SYS(epoll_create), SCMP_SYS(epoll_wait), #ifdef __NR_epoll_pwait @@ -491,24 +492,6 @@ sb_open(scmp_filter_ctx ctx, sandbox_cfg_t *filter) } } - rc = seccomp_rule_add_1(ctx, SCMP_ACT_ERRNO(EACCES), SCMP_SYS(open), - SCMP_CMP_MASKED(1, O_CLOEXEC|O_NONBLOCK|O_NOCTTY|O_NOFOLLOW, - O_RDONLY)); - if (rc != 0) { - log_err(LD_BUG,"(Sandbox) failed to add open syscall, received libseccomp " - "error %d", rc); - return rc; - } - - rc = seccomp_rule_add_1(ctx, SCMP_ACT_ERRNO(EACCES), SCMP_SYS(openat), - SCMP_CMP_MASKED(2, O_CLOEXEC|O_NONBLOCK|O_NOCTTY|O_NOFOLLOW, - O_RDONLY)); - if (rc != 0) { - log_err(LD_BUG,"(Sandbox) failed to add openat syscall, received " - "libseccomp error %d", rc); - return rc; - } - return 0; } @@ -562,23 +545,6 @@ sb_chown(scmp_filter_ctx ctx, sandbox_cfg_t *filter) return 0; } -static int -sb__sysctl(scmp_filter_ctx ctx, sandbox_cfg_t *filter) -{ - int rc; - (void) filter; - (void) ctx; - - rc = seccomp_rule_add_0(ctx, SCMP_ACT_ERRNO(EPERM), SCMP_SYS(_sysctl)); - if (rc != 0) { - log_err(LD_BUG,"(Sandbox) failed to add _sysctl syscall, " - "received libseccomp error %d", rc); - return rc; - } - - return 0; -} - /** * Function responsible for setting up the rename syscall for * the seccomp filter sandbox. @@ -1147,7 +1113,6 @@ static sandbox_filter_func_t filter_func[] = { sb_chmod, sb_open, sb_openat, - sb__sysctl, sb_rename, #ifdef __NR_fcntl64 sb_fcntl64, @@ -1524,14 +1489,14 @@ install_syscall_filter(sandbox_cfg_t* cfg) int rc = 0; scmp_filter_ctx ctx; - ctx = seccomp_init(SCMP_ACT_TRAP); + ctx = seccomp_init(SCMP_ACT_ERRNO(EPERM)); if (ctx == NULL) { log_err(LD_BUG,"(Sandbox) failed to initialise libseccomp context"); rc = -1; goto end; } - // protectign sandbox parameter strings + // protecting sandbox parameter strings if ((rc = prot_strings(ctx, cfg))) { goto end; } diff --git a/src/test/conf_examples/dirauth_2/expected b/src/test/conf_examples/dirauth_2/expected new file mode 100644 index 0000000000..19ab024ed3 --- /dev/null +++ b/src/test/conf_examples/dirauth_2/expected @@ -0,0 +1 @@ +AuthDirMaxServersPerAddr 8 diff --git a/src/test/conf_examples/dirauth_2/expected_log b/src/test/conf_examples/dirauth_2/expected_log new file mode 100644 index 0000000000..88611fee9d --- /dev/null +++ b/src/test/conf_examples/dirauth_2/expected_log @@ -0,0 +1 @@ +Read configuration file diff --git a/src/test/conf_examples/dirauth_2/expected_log_no_dirauth b/src/test/conf_examples/dirauth_2/expected_log_no_dirauth new file mode 100644 index 0000000000..01110c5d8c --- /dev/null +++ b/src/test/conf_examples/dirauth_2/expected_log_no_dirauth @@ -0,0 +1 @@ +This copy of Tor was built without support for the option "AuthDirMaxServersPerAddr". Skipping.
\ No newline at end of file diff --git a/src/test/conf_examples/dirauth_2/expected_log_no_dirauth_relay b/src/test/conf_examples/dirauth_2/expected_log_no_dirauth_relay new file mode 100644 index 0000000000..01110c5d8c --- /dev/null +++ b/src/test/conf_examples/dirauth_2/expected_log_no_dirauth_relay @@ -0,0 +1 @@ +This copy of Tor was built without support for the option "AuthDirMaxServersPerAddr". Skipping.
\ No newline at end of file diff --git a/src/test/conf_examples/dirauth_2/expected_no_dirauth b/src/test/conf_examples/dirauth_2/expected_no_dirauth new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/src/test/conf_examples/dirauth_2/expected_no_dirauth diff --git a/src/test/conf_examples/dirauth_2/expected_no_dirauth_relay b/src/test/conf_examples/dirauth_2/expected_no_dirauth_relay new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/src/test/conf_examples/dirauth_2/expected_no_dirauth_relay diff --git a/src/test/conf_examples/dirauth_2/torrc b/src/test/conf_examples/dirauth_2/torrc new file mode 100644 index 0000000000..bd1cdbc8b9 --- /dev/null +++ b/src/test/conf_examples/dirauth_2/torrc @@ -0,0 +1,5 @@ +# +# This will get accepted if the module is enabled, and ignored if the module +# is disabled. +# +AuthDirMaxServersPerAddr 8 diff --git a/src/test/fakecircs.c b/src/test/fakecircs.c index 82a8722ba8..369a85d7b3 100644 --- a/src/test/fakecircs.c +++ b/src/test/fakecircs.c @@ -6,7 +6,6 @@ * \brief Fake circuits API for unit test. **/ -#define CHANNEL_PRIVATE #define CIRCUITBUILD_PRIVATE #define CIRCUITLIST_PRIVATE #define CRYPT_PATH_PRIVATE @@ -22,7 +21,7 @@ #include "core/or/relay.h" #include "core/or/relay_crypto_st.h" -#include "fakecircs.h" +#include "test/fakecircs.h" /** Return newly allocated OR circuit using the given nchan and pchan. It must * be freed with the free_fake_orcirc(). */ diff --git a/src/test/test_bridges.c b/src/test/test_bridges.c index 879ae6636b..5dd3d05541 100644 --- a/src/test/test_bridges.c +++ b/src/test/test_bridges.c @@ -550,8 +550,6 @@ test_bridges_get_transport_by_bridge_addrport_no_ptlist(void *arg) sweep_bridge_list(); } -#define PT_PRIVATE - /** * Calling get_transport_by_bridge_addrport() with the address and port of a * configured bridge which uses a pluggable transport should return 0 and set diff --git a/src/test/test_channel.c b/src/test/test_channel.c index 6a6bc9d810..0353032796 100644 --- a/src/test/test_channel.c +++ b/src/test/test_channel.c @@ -1,8 +1,8 @@ /* Copyright (c) 2013-2019, The Tor Project, Inc. */ /* See LICENSE for licensing information */ -#define TOR_CHANNEL_INTERNAL_ -#define CHANNEL_PRIVATE_ +#define CHANNEL_OBJECT_PRIVATE +#define CHANNEL_FILE_PRIVATE #include "core/or/or.h" #include "core/or/channel.h" /* For channel_note_destroy_not_pending */ diff --git a/src/test/test_channelpadding.c b/src/test/test_channelpadding.c index 885246628e..0c610efd97 100644 --- a/src/test/test_channelpadding.c +++ b/src/test/test_channelpadding.c @@ -1,7 +1,7 @@ /* Copyright (c) 2016-2019, The Tor Project, Inc. */ /* See LICENSE for licensing information */ -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define MAINLOOP_PRIVATE #define NETWORKSTATUS_PRIVATE #define TOR_TIMERS_PRIVATE diff --git a/src/test/test_channeltls.c b/src/test/test_channeltls.c index 054d3910e4..f41a58e0a1 100644 --- a/src/test/test_channeltls.c +++ b/src/test/test_channeltls.c @@ -5,7 +5,7 @@ #include <math.h> -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #include "core/or/or.h" #include "lib/net/address.h" #include "lib/buf/buffers.h" diff --git a/src/test/test_circuitlist.c b/src/test/test_circuitlist.c index 5cebdbeda0..d9a5927fd9 100644 --- a/src/test/test_circuitlist.c +++ b/src/test/test_circuitlist.c @@ -1,7 +1,7 @@ /* Copyright (c) 2013-2019, The Tor Project, Inc. */ /* See LICENSE for licensing information */ -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define CIRCUITBUILD_PRIVATE #define CIRCUITLIST_PRIVATE #define HS_CIRCUITMAP_PRIVATE diff --git a/src/test/test_circuitmux.c b/src/test/test_circuitmux.c index f0b0465579..8ff1f9c9e5 100644 --- a/src/test/test_circuitmux.c +++ b/src/test/test_circuitmux.c @@ -1,7 +1,7 @@ /* Copyright (c) 2013-2019, The Tor Project, Inc. */ /* See LICENSE for licensing information */ -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define CIRCUITMUX_PRIVATE #define CIRCUITMUX_EWMA_PRIVATE #define RELAY_PRIVATE diff --git a/src/test/test_circuitpadding.c b/src/test/test_circuitpadding.c index 70e2081c55..cfb24c032c 100644 --- a/src/test/test_circuitpadding.c +++ b/src/test/test_circuitpadding.c @@ -1,4 +1,4 @@ -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define TOR_TIMERS_PRIVATE #define CIRCUITPADDING_PRIVATE #define CIRCUITPADDING_MACHINES_PRIVATE @@ -27,7 +27,6 @@ #include "core/crypto/relay_crypto.h" #include "core/or/protover.h" #include "feature/nodelist/nodelist.h" -#include "lib/evloop/compat_libevent.h" #include "app/config/config.h" #include "feature/nodelist/routerstatus_st.h" diff --git a/src/test/test_circuitstats.c b/src/test/test_circuitstats.c index 9bfaabeb2f..f554a781d2 100644 --- a/src/test/test_circuitstats.c +++ b/src/test/test_circuitstats.c @@ -4,7 +4,7 @@ #define CIRCUITBUILD_PRIVATE #define CIRCUITSTATS_PRIVATE #define CIRCUITLIST_PRIVATE -#define CHANNEL_PRIVATE_ +#define CHANNEL_FILE_PRIVATE #include "core/or/or.h" #include "test/test.h" diff --git a/src/test/test_controller_events.c b/src/test/test_controller_events.c index 9267aa0e43..db4530ef41 100644 --- a/src/test/test_controller_events.c +++ b/src/test/test_controller_events.c @@ -2,7 +2,7 @@ /* See LICENSE for licensing information */ #define CONNECTION_PRIVATE -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define CONTROL_PRIVATE #define CONTROL_EVENTS_PRIVATE #define OCIRC_EVENT_PRIVATE diff --git a/src/test/test_dir.c b/src/test/test_dir.c index 02465b07f0..523c0719fb 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -11,7 +11,6 @@ #define CONTROL_GETINFO_PRIVATE #define DIRCACHE_PRIVATE #define DIRCLIENT_PRIVATE -#define DIRSERV_PRIVATE #define DIRVOTE_PRIVATE #define DLSTATUS_PRIVATE #define HIBERNATE_PRIVATE diff --git a/src/test/test_dos.c b/src/test/test_dos.c index bda9908e6c..7472da2af1 100644 --- a/src/test/test_dos.c +++ b/src/test/test_dos.c @@ -2,7 +2,7 @@ /* See LICENSE for licensing information */ #define DOS_PRIVATE -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define CIRCUITLIST_PRIVATE #include "core/or/or.h" diff --git a/src/test/test_hs_cache.c b/src/test/test_hs_cache.c index c39a4b644d..fd673c9990 100644 --- a/src/test/test_hs_cache.c +++ b/src/test/test_hs_cache.c @@ -10,7 +10,7 @@ #define DIRCACHE_PRIVATE #define DIRCLIENT_PRIVATE #define HS_CACHE_PRIVATE -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #include "trunnel/ed25519_cert.h" #include "feature/hs/hs_cache.h" diff --git a/src/test/test_hs_client.c b/src/test/test_hs_client.c index 515462e4b7..b3cf79848c 100644 --- a/src/test/test_hs_client.c +++ b/src/test/test_hs_client.c @@ -10,7 +10,7 @@ #define CRYPTO_PRIVATE #define MAINLOOP_PRIVATE #define HS_CLIENT_PRIVATE -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define CIRCUITBUILD_PRIVATE #define CIRCUITLIST_PRIVATE #define CONNECTION_PRIVATE diff --git a/src/test/test_hs_control.c b/src/test/test_hs_control.c index dab0a8c609..7890724309 100644 --- a/src/test/test_hs_control.c +++ b/src/test/test_hs_control.c @@ -28,8 +28,6 @@ #include "feature/nodelist/routerstatus_st.h" #include "lib/crypt_ops/crypto_format.h" -#include "test/test_helpers.h" - #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> #endif diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c index daed1cda84..8bf0405f74 100644 --- a/src/test/test_hs_service.c +++ b/src/test/test_hs_service.c @@ -19,7 +19,7 @@ #define MAINLOOP_PRIVATE #define NETWORKSTATUS_PRIVATE #define STATEFILE_PRIVATE -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define HS_CLIENT_PRIVATE #define CRYPT_PATH_PRIVATE diff --git a/src/test/test_link_handshake.c b/src/test/test_link_handshake.c index 7d79eb1edb..f22b9920be 100644 --- a/src/test/test_link_handshake.c +++ b/src/test/test_link_handshake.c @@ -5,7 +5,7 @@ #define CHANNELTLS_PRIVATE #define CONNECTION_PRIVATE -#define TOR_CHANNEL_INTERNAL_ +#define CHANNEL_OBJECT_PRIVATE #define TORTLS_PRIVATE #include "core/or/or.h" diff --git a/src/test/test_options.c b/src/test/test_options.c index e3b86c81ad..b99ae78932 100644 --- a/src/test/test_options.c +++ b/src/test/test_options.c @@ -2001,7 +2001,6 @@ test_options_validate__testing(void *ignored) ENSURE_DEFAULT(TestingV3AuthInitialDistDelay, 3000); ENSURE_DEFAULT(TestingV3AuthVotingStartOffset, 3000); ENSURE_DEFAULT(TestingAuthDirTimeToLearnReachability, 3000); - ENSURE_DEFAULT(TestingEstimatedDescriptorPropagationTime, 3000); ENSURE_DEFAULT(TestingServerDownloadInitialDelay, 3000); ENSURE_DEFAULT(TestingClientDownloadInitialDelay, 3000); ENSURE_DEFAULT(TestingServerConsensusDownloadInitialDelay, 3000); @@ -3872,22 +3871,16 @@ test_options_validate__testing_options(void *ignored) TEST_TESTING_OPTION(TestingAuthDirTimeToLearnReachability, -1, 8000, "must be non-negative.", ENABLE_AUTHORITY_BRIDGE); - TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, -1, 3601, - "must be non-negative.", ""); TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, -1, 3601, "is way too low.", ""); TEST_TESTING_OPTION(TestingDirConnectionMaxStall, 1, 3601, "is way too low.", ""); - TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, -1, 3601, - "must be non-negative.", ENABLE_AUTHORITY_V3); TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, -1, 3601, "is way too low.", ENABLE_AUTHORITY_V3); TEST_TESTING_OPTION(TestingDirConnectionMaxStall, 1, 3601, "is way too low.", ENABLE_AUTHORITY_V3); - TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, -1, 3601, - "must be non-negative.", ENABLE_AUTHORITY_BRIDGE); TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, -1, 3601, "is way too low.", ENABLE_AUTHORITY_BRIDGE); TEST_TESTING_OPTION(TestingDirConnectionMaxStall, 1, 3601, diff --git a/src/test/test_options_act.c b/src/test/test_options_act.c index 0a9be28c54..a3c44e66c5 100644 --- a/src/test/test_options_act.c +++ b/src/test/test_options_act.c @@ -40,10 +40,10 @@ get_file_mode(const char *fname, unsigned *permissions_out) TT_DIE(("Bad mode %o on %s", mode_, (fn))); \ } \ STMT_END -#else +#else /* defined(_WIN32) */ /* "group-readable" isn't meaningful on windows */ #define assert_mode(fn,mask,expected) STMT_NIL -#endif +#endif /* !defined(_WIN32) */ static or_options_t *mock_opts; static const or_options_t * diff --git a/src/test/test_procmon.c b/src/test/test_procmon.c index e23578f4fd..4ade82470b 100644 --- a/src/test/test_procmon.c +++ b/src/test/test_procmon.c @@ -1,7 +1,6 @@ /* Copyright (c) 2010-2019, The Tor Project, Inc. */ /* See LICENSE for licensing information */ -#define PROCMON_PRIVATE #include "orconfig.h" #include "core/or/or.h" #include "test/test.h" diff --git a/src/test/test_pt.c b/src/test/test_pt.c index 0e391c1baa..268848b982 100644 --- a/src/test/test_pt.c +++ b/src/test/test_pt.c @@ -5,7 +5,6 @@ #include "orconfig.h" #define PT_PRIVATE -#define UTIL_PRIVATE #define STATEFILE_PRIVATE #define CONTROL_EVENTS_PRIVATE #define PROCESS_PRIVATE diff --git a/src/test/test_relay.c b/src/test/test_relay.c index f7809b47ef..5c95f9fe1a 100644 --- a/src/test/test_relay.c +++ b/src/test/test_relay.c @@ -10,7 +10,6 @@ #include "core/or/channeltls.h" #include "feature/stats/rephist.h" #include "core/or/relay.h" -#include "feature/stats/rephist.h" #include "lib/container/order.h" /* For init/free stuff */ #include "core/or/scheduler.h" diff --git a/src/test/test_relaycell.c b/src/test/test_relaycell.c index c65279fb25..14bd045df7 100644 --- a/src/test/test_relaycell.c +++ b/src/test/test_relaycell.c @@ -30,7 +30,6 @@ #include "core/or/half_edge_st.h" #include "feature/client/circpathbias.h" -#include "core/or/connection_edge.h" static int srm_ncalls; static entry_connection_t *srm_conn; diff --git a/src/test/test_scheduler.c b/src/test/test_scheduler.c index 39c4963fce..3d37cc837f 100644 --- a/src/test/test_scheduler.c +++ b/src/test/test_scheduler.c @@ -6,8 +6,8 @@ #include <math.h> #define SCHEDULER_KIST_PRIVATE -#define TOR_CHANNEL_INTERNAL_ -#define CHANNEL_PRIVATE_ +#define CHANNEL_OBJECT_PRIVATE +#define CHANNEL_FILE_PRIVATE #include "core/or/or.h" #include "app/config/config.h" #include "lib/evloop/compat_libevent.h" @@ -15,7 +15,7 @@ #include "core/or/channeltls.h" #include "core/mainloop/connection.h" #include "feature/nodelist/networkstatus.h" -#define SCHEDULER_PRIVATE_ +#define SCHEDULER_PRIVATE #include "core/or/scheduler.h" /* Test suite stuff */ diff --git a/src/test/test_util.c b/src/test/test_util.c index 5f46e4fcff..7f7e157c17 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -4,11 +4,8 @@ /* See LICENSE for licensing information */ #include "orconfig.h" -#define COMPAT_PRIVATE #define COMPAT_TIME_PRIVATE -#define UTIL_PRIVATE #define UTIL_MALLOC_PRIVATE -#define SOCKET_PRIVATE #define PROCESS_WIN32_PRIVATE #include "lib/testsupport/testsupport.h" #include "core/or/or.h" diff --git a/src/test/test_util_format.c b/src/test/test_util_format.c index 2859da66b2..57c3eee5be 100644 --- a/src/test/test_util_format.c +++ b/src/test/test_util_format.c @@ -7,7 +7,6 @@ #include "test/test.h" #include "lib/crypt_ops/crypto_rand.h" -#define UTIL_FORMAT_PRIVATE #include "lib/encoding/binascii.h" #define NS_MODULE util_format diff --git a/src/test/test_util_process.c b/src/test/test_util_process.c index 4d04eb6dfc..9c78a8c0e4 100644 --- a/src/test/test_util_process.c +++ b/src/test/test_util_process.c @@ -1,7 +1,6 @@ /* Copyright (c) 2010-2019, The Tor Project, Inc. */ /* See LICENSE for licensing information */ -#define UTIL_PROCESS_PRIVATE #include "orconfig.h" #include "core/or/or.h" diff --git a/src/test/testing_common.c b/src/test/testing_common.c index c28d02be77..03e013a268 100644 --- a/src/test/testing_common.c +++ b/src/test/testing_common.c @@ -89,6 +89,17 @@ setup_directory(void) (int)getpid(), rnd32); r = mkdir(temp_dir); } +#elif defined(__ANDROID__) + /* tor might not like the default perms, so create a subdir */ + tor_snprintf(temp_dir, sizeof(temp_dir), + "/data/local/tmp/tor_%d_%d_%s", + (int) getuid(), (int) getpid(), rnd32); + r = mkdir(temp_dir, 0700); + if (r) { + fprintf(stderr, "Can't create directory %s:", temp_dir); + perror(""); + exit(1); + } #else /* !defined(_WIN32) */ tor_snprintf(temp_dir, sizeof(temp_dir), "/tmp/tor_test_%d_%s", (int) getpid(), rnd32); @@ -97,7 +108,7 @@ setup_directory(void) /* undo sticky bit so tests don't get confused. */ r = chown(temp_dir, getuid(), getgid()); } -#endif /* defined(_WIN32) */ +#endif /* defined(_WIN32) || ... */ if (r) { fprintf(stderr, "Can't create directory %s:", temp_dir); perror(""); |