Commit Graph

24869 Commits

Author SHA1 Message Date
Nick Mathewson
931a5db2a7 Re-run make autostyle. 2019-10-22 09:40:31 -04:00
Nick Mathewson
b2d487ae22 Merge branch 'ticket31705_v2' into ticket31705_v2_merged
Conflicts:
	src/feature/dirparse/authcert_parse.c
	src/feature/dirparse/ns_parse.c
	src/feature/hs/hs_service.c
	src/lib/conf/conftesting.h
	src/lib/log/log.h
	src/lib/thread/threads.h
	src/test/test_options.c

These conflicts were mostly related to autostyle improvements, with
one or two due to doxygen fixes.
2019-10-22 09:39:06 -04:00
Nick Mathewson
7e7a4874b8 test_addr.c: use COCCI to suppress macros coccinelle cannot parse. 2019-10-22 09:32:13 -04:00
Nick Mathewson
0da349aa5e test.h: Use COCCI to suppress macros Coccinelle does not understand. 2019-10-22 09:32:13 -04:00
Nick Mathewson
0b862a7616 threads.h: coccinelle cannot understand a macro. 2019-10-22 09:32:13 -04:00
Nick Mathewson
4346e5569e ctassert.h: fix CTASSERT_DECL so coccinelle can parse it. 2019-10-22 09:32:13 -04:00
Nick Mathewson
189375fb5d ratelim.h: use COCCI to hide an initializer. 2019-10-22 09:32:13 -04:00
Nick Mathewson
c77f57d37b util_bug.h: Coccinelle does not understand IF_BUG_ONCE or #nodef. 2019-10-22 09:32:13 -04:00
Nick Mathewson
fb4b6b6436 weakrng.h: use COCCI to hide a macro coccinelle cannot parse. 2019-10-22 09:32:13 -04:00
Nick Mathewson
d1cdb1a24e Use STMT_BEGIN/END in parse_int.c so coccinelle can handle it. 2019-10-22 09:32:13 -04:00
Nick Mathewson
41f44d8760 smartlist.h: use COCCI to hide SMARTLIST_FOREACH_JOIN from Coccinelle 2019-10-22 09:32:13 -04:00
Nick Mathewson
514c61e406 namemap_st.h: Use COCCI to hide an initializer. 2019-10-22 09:32:13 -04:00
Nick Mathewson
2695f7e68c timeval.h: Coccinelle cannot understand timercmp. 2019-10-22 09:32:13 -04:00
Nick Mathewson
9f50a92a7e Fix a macro in address.c so coccinelle can understand it 2019-10-22 09:32:13 -04:00
Nick Mathewson
0abe89519b timers.c: define TIMEOUT_PUBLIC to no tokens when using COCCI. 2019-10-22 09:32:13 -04:00
Nick Mathewson
9453746b5e dispatch_naming.c: when COCCI is defined, disable unparseable macros. 2019-10-22 09:32:13 -04:00
Nick Mathewson
04a74d4aa7 conftesting.h: when COCCI is defined, disable unhandled macros 2019-10-22 09:32:13 -04:00
Nick Mathewson
3e41459dff confmacros.h: fix coccinelle parsing. 2019-10-22 09:32:13 -04:00
Nick Mathewson
54c5366aa1 feature/control: wrap some problem macros in COCCI 2019-10-22 09:32:13 -04:00
Nick Mathewson
ef5d1e6b65 consdiff disable a macro when running with COCCI 2019-10-22 09:32:13 -04:00
Nick Mathewson
d9bad0203b Disable a couple of iterator macros when COCCI is defined. 2019-10-22 09:32:13 -04:00
Nick Mathewson
67247fa9ac Use various COCCI tests to get mainloop.c to parse. 2019-10-22 09:32:13 -04:00
Nick Mathewson
4fad456148 test: Hide some test-declaration macro definitions to COCCI.
(These ones cause parsing failures.)
2019-10-22 09:32:13 -04:00
Nick Mathewson
c1e8e5bb32 Apparently coccinelle can't handle multiline #errors. 2019-10-22 09:32:13 -04:00
Nick Mathewson
b03c8c74ce COCCI: Disable some buffers.c macros that coccinelle can't handle. 2019-10-22 09:32:13 -04:00
Nick Mathewson
b867e97ce6 With COCCI defined, avoid PERIODIC_EVENT.
Coccinelle doesn't understand the particular pattern of token
pasting we have going on here.
2019-10-22 09:32:05 -04:00
Nick Mathewson
48be922160 COCCI: disable DOWLOAD_SCHEDULE macro 2019-10-22 09:31:31 -04:00
Nick Mathewson
630d8c7a1a With coccinelle, avoid includes in the middle of an expression. 2019-10-22 09:24:25 -04:00
Nick Mathewson
9871fcbcd9 Use #warning instead of #warn: one is C and one isn't. 2019-10-22 09:24:25 -04:00
Nick Mathewson
2d013bbe5c Merge remote-tracking branch 'tor-github/pr/1417' 2019-10-22 08:36:32 -04:00
Nick Mathewson
4413b030f2 Simplify CHECK_DEFAULT() logic a little further.
Since each of these tests only applies to testing networks, put them
all into a single block that checks for testing networks.

(I recommend reviewing with the "diff -b" option, since the change
is mostly indentation.)
2019-10-22 08:32:33 -04:00
Nick Mathewson
8d84e10e87 Make options_validate() no longer use its "defaults" argument.
It can just look at what the defaults are.

Closes ticket 32185.
2019-10-22 08:30:00 -04:00
Nick Mathewson
a1d5341374 Merge branch 'bug32175' 2019-10-22 07:51:30 -04:00
Nick Mathewson
65e80ce646 Merge branch 'from_setconf_removal_squashed' 2019-10-22 07:50:42 -04:00
Nick Mathewson
6d15fab2dc Extract log-granularity code into its own function.
This pleases practracker.
2019-10-22 07:50:13 -04:00
Nick Mathewson
9ac2c71cbd Add tests for options_init_logs() 2019-10-22 07:50:13 -04:00
Nick Mathewson
f4fc633937 Make a pair of add_*_log() functions mockable. 2019-10-22 07:50:13 -04:00
Nick Mathewson
ac3136a6fb Make options_init_logs STATIC for testing. 2019-10-22 07:50:13 -04:00
Nick Mathewson
98c3b3bb4c Update tests to handle new interpretation of quiet_level.
Two things needed to be changed.  First, we used to set quiet_level
to the default (QUIET_NONE) when running tests, since we would not
call anything that acted based upon it.  But since we sometimes call
options_init_logs(), we need to pre-set quiet_level to QUIET_SILENT
in the logs so that we don't add the default logs.  This did not
cause test failure: just unwanted logs.

Second, we had a test that checked whether options_validate was
messing with options->Logs correctly.  Since options_validate no
longer messes with the logs, we no longer want a test for this.
2019-10-22 07:50:13 -04:00
Nick Mathewson
e07b19d305 Rationalize handling of quiet_level in config.c
Formerly, we would use quiet_level as an excuse to rewrite the log
configuration, adding a default log line if none existed, and if
RunAsDaemon was not set, and if we were not being invoked via
setconf (!).

This is against our best practices for several reasons:
  * We should not be changing configured options except when the
    user tells us to do so.
  * We should especially not be changing options in the options_validate
    function.
  * Distinguishing whether we are being called from setconf adds a
    risky special-case.

Instead, this patch take a simpler approach: it changes the
interpretation of having no logging lines set to mean: If there is a
stdout, add a default log based on quiet_level.

Solves ticket 31999.
2019-10-22 07:50:13 -04:00
Nick Mathewson
cb13930f2b Fix a memory leak introduced by the changes to test_options.c
Since this code passes the same options to options_validate() more
than once, options_validate() needs to be prepared for that.  (This
previously worked by accident, since the smartlist of schedulers
wasn't initialized.)
2019-10-21 18:28:53 -04:00
Nick Mathewson
bd518b9ab1 Fix a memory leak introduced by changes to test_options.c
Since the FirewallPorts smartlist is now initialized, we can't just
overwrite it.
2019-10-21 18:28:08 -04:00
Nick Mathewson
5e2ffd6fd7 Fix up some Windows CI issues. 2019-10-21 15:31:56 -04:00
Nick Mathewson
171a741901 test_options.c: Remove TEST_OPTIONS_DEFAULT_VALUES
This finally became the empty string, since we no longer have to do
anything in individual test_options.c tests to make "" be a valid
set of options.  Now we can remove it at last.
2019-10-21 14:41:27 -04:00
Nick Mathewson
8a8d748837 Stop overriding ConnLimit in tests.
Now that ConnLimit is set to the default value in the
testing helper functions, the individual tests don't all need to
make sure it is set to something valid.
2019-10-21 14:27:55 -04:00
Nick Mathewson
56dddcbbcc test_options.c: remove weird usage of ConnLimit
Several of our tests assumed that ConnLimit would be set to 0 by
default, causing the default options not to be parseable.  These
tests had nothing to do with ConnLimit.
2019-10-21 14:24:58 -04:00
Nick Mathewson
78bf011663 Stop overriding MaxClientCircuitsPending in tests.
Now that MaxClientCircuitsPending is set to the default value in the
testing helper functions, the individual tests don't all need to
make sure it is set to something valid.
2019-10-21 14:19:19 -04:00
Nick Mathewson
b501cd907f test_options.c: remove weird usage of MaxClientCircuitsPending
Several of our tests assumed that MaxClientCircuitsPending would be
set to 0 by default, causing the default options not to be
parseable.  These tests had nothing to do with
MaxClientCircuitsPending.
2019-10-21 14:16:59 -04:00
Nick Mathewson
b6efe37661 Stop overriding KeepalivePeriod in tests.
Now that KeepalivePeriod is set to the default value in the testing
helper functions, the individual tests don't all need to make sure
it is set to something valid.
2019-10-21 14:14:49 -04:00
Nick Mathewson
79cd591228 test_options.c: remove weird usage of KeepalivePeriod.
Several of our tests assumed that KeepalivePeriod would be set to 0
by default, causing the default options not to be parseable.  These
tests had nothing to do with KeepalivePeriod.
2019-10-21 14:12:59 -04:00
Nick Mathewson
3f9920975f Remove a lot of cruft from TEST_OPTIONS_DEFAULT_VALUES.
This macro used to have a big list of "default" values that we
needed to set in the test_options tests in order to have reasonable
behavior.  But now that we initialize options objects to the default
settings in these tests, we no longer need such a long list of
things to replace.
2019-10-21 14:12:59 -04:00
Nick Mathewson
a10e4d737e test_options: use testing options with (almost) real defaults.
Previously, we just used options set to all 0s, but this causes some
pretty severe workarounds throughout the code, as our options fail
to validate, or count as "default" for the wrong reasons.

Note that in some places, we stop getting spurious warnings or
failures which the tests previously demanded.  In these cases, I've
changed the test behavior.

Fixes 32175.
2019-10-21 14:12:59 -04:00
Nick Mathewson
8378ad29e6 routermode.h: turn a comment into a doxygen comment. 2019-10-21 12:47:17 -04:00
Nick Mathewson
7dc78aca29 Merge remote-tracking branch 'tor-github/pr/1430' 2019-10-21 12:43:26 -04:00
Roger Dingledine
a7ccd9a997 respect accountingmax during soft hibernation
Relays now respect their AccountingMax bandwidth again. When relays
entered "soft" hibernation (which typically starts when we've hit
90% of our AccountingMax), we had stopped checking whether we should
enter hard hibernation. Soft hibernation refuses new connections and
new circuits, but the existing circuits can continue, meaning that
relays could have exceeded their configured AccountingMax.

This commit rolls back some of the cpu-saving fixes, where we tried
to avoid calling so many of our events while we're off the network.

That's because PERIODIC_EVENT_FLAG_NEED_NET checks net_is_disabled(),
which returns true even if we're only in soft hibernation.

Fixes bug 32108; bugfix on 0.4.0.1-alpha.
2019-10-21 04:14:42 -04:00
teor
7a72e71f74
Merge remote-tracking branch 'tor-github/pr/1434' 2019-10-21 15:24:22 +10:00
teor
4fde7699ee
test/getinfo: Remove unnecessary test code
Fix for 31684.
2019-10-21 14:21:41 +10:00
teor
92fa5239fc
control/getinfo: Use standard error handling
Use BUG() for coding errors, and `< 0` for error checks.

Fix to 31684.
2019-10-21 13:57:02 +10:00
teor
3b2525c375
Fix changes file and string typos
Part of 31684.
2019-10-21 13:56:58 +10:00
AmreshVenugopal
6413b2102f
control: Add GETINFO support for dumping microdesc consensus
- Allows control port to read microdesc consensus using:
GETINFO dir/status-vote/microdesc/consensus

add: Helper function `getinfo_helper_current_consensus`
test: check if GETINFO commands return expected consensus data.

Resolves 31684.
2019-10-21 13:54:55 +10:00
teor
77c85360f6
Merge branch 'maint-0.4.2' 2019-10-21 13:28:04 +10:00
teor
3539fdfd7a
Merge remote-tracking branch 'tor-github/pr/1168' 2019-10-21 13:09:48 +10:00
teor
04e9e74f1d
Merge remote-tracking branch 'tor-github/pr/1422' into maint-0.4.2 2019-10-21 13:07:39 +10:00
teor
a1f73cb93d
Merge branch 'maint-0.4.2' 2019-10-21 09:45:34 +10:00
teor
5dbdca0114
Merge remote-tracking branch 'tor-github/pr/1432' into maint-0.4.2 2019-10-21 09:45:18 +10:00
teor
5c8ecf364a
Merge remote-tracking branch 'tor-github/pr/1354' into maint-0.4.2 2019-10-21 09:44:42 +10:00
teor
042116e1fd
Merge branch 'maint-0.4.2' 2019-10-20 22:09:00 +10:00
teor
02e3e8eda5
hibernate: Fix repeated "bytes" in comment 2019-10-20 22:08:23 +10:00
teor
475dffee42
dirauth: Add a macro comment to have_module_dirauth() 2019-10-20 20:26:12 +10:00
teor
b266a804e9
test/parseconf: Add basic dirauth and bridgeauth tests
Part of 32123.
2019-10-20 20:25:58 +10:00
teor
0501ce9f13
test/parseconf: Expect different outputs when relay mode is disabled
Part of 32123.
2019-10-20 20:25:54 +10:00
teor
cf2b00d3f5
test/rebind: Make control formatting and log parsing more robust
* actually sleep when tor has not logged anything
* log at debug level when waiting for tor to log something
* backslash-replace bad UTF-8 characters in logs
* format control messages as ASCII: tor does not accept UTF-8 control commands

Fixes bug 31837; bugfix on 0.3.5.1-alpha.
2019-10-20 20:09:35 +10:00
teor
0a5ce8280c err: Use the correct type for cb_buf
Fixes bug 32060; bug not in any released version of tor.

Resolves CID 1454761.
2019-10-20 20:01:56 +10:00
Roger Dingledine
aab5d90858 Merge branch 'maint-0.4.2' 2019-10-20 05:56:16 -04:00
Roger Dingledine
8b4d7447ae fix easy typos 2019-10-20 05:52:32 -04:00
teor
012c44538c
test: Skip test scripts that require the relay module
When tor is built without the relay module.

Part of 32123.
2019-10-20 19:26:59 +10:00
teor
e2280d6f84
relay: Silence compiler warnings when relay mode is disabled
Part of 32123.
2019-10-20 19:26:55 +10:00
teor
57e86a6d74
relay: Implement HAVE_MODULE_RELAY for routermode.c
Part of 32123.
2019-10-20 19:26:48 +10:00
teor
7944b55ad1 feature: Move proxy_mode() into new files
proxy_mode() was in routermode.[ch], but it's actually a client
mode. Move it into client/proxymode.[ch].

Part of 32123.
2019-10-20 17:52:38 +10:00
Nick Mathewson
264c5312eb Merge branch 'maint-0.4.2' 2019-10-18 12:32:49 -04:00
Nick Mathewson
0994050c4a Merge remote-tracking branch 'tor-github/pr/1426' into maint-0.4.2 2019-10-18 12:32:29 -04:00
Nick Mathewson
7c5716d162 Merge branch 'maint-0.4.2' 2019-10-18 12:27:49 -04:00
Nick Mathewson
57c4af16f0 Merge remote-tracking branch 'tor-github/pr/1396' into maint-0.4.2 2019-10-18 12:27:39 -04:00
Nick Mathewson
fbd2fef220 Merge branch 'maint-0.4.2' of git-rw.torproject.org:/tor into maint-0.4.2 2019-10-18 12:25:55 -04:00
teor
1697019d5f
core: tabify a line in include.am 2019-10-18 16:56:50 +10:00
teor
d616214e47
Merge branch 'maint-0.4.2' 2019-10-18 12:05:20 +10:00
Alexander Færøy
389b37246e Remove overly strict assertions in transports.c.
This patch removes an overly strict tor_assert() and an ignorable BUG()
expression. Both of these would trigger if a PT was unable to configure
itself during startup. The easy way to trigger this is to configure an
obfs4 bridge where you make the obfs4 process try to bind on a port
number under 1024.

See: https://bugs.torproject.org/31091
2019-10-17 21:33:54 +02:00
Alexander Færøy
4ed06acb2a Add test to check if the exit callback is called in process_t upon process_exec() failures.
This patch adds a test to check for whether the exit callback is always
called when process_exec() fails, both on Windows and Unix.

See: https://bugs.torproject.org/31810
2019-10-17 20:52:32 +02:00
Alexander Færøy
7a64f6ea04 Ensure that the exit callback is called if CreateProcessA() fails on Windows.
This patch fixes an issue where the exit handler is not called for the
given process_t in case CreateProcessA() fails. This could, for example,
happen if the user tries to execute a binary that does not exist.

See: https://bugs.torproject.org/31810
2019-10-17 20:52:27 +02:00
Alexander Færøy
85b4a5c276 Handle errors from execve() in the Unix process backend more gracefully.
This patch removes a call to tor_assert_unreached() after execve()
failed. This assertion leads to the child process emitting a stack trace
on its standard output, which makes the error harder for the user to
demystify, since they think it is an internal error in Tor instead of
"just" being a "no such file or directory" error.

The process will now instead output "Error from child process: X" where
X is the stringified version of the errno value.

See: https://bugs.torproject.org/31810
2019-10-17 20:52:22 +02:00
Nick Mathewson
db18ff9120 Move code to add default log into quiet_level.c
I'm about to unify the code for handling this between main.c and
config.c.
2019-10-17 12:48:39 -04:00
Nick Mathewson
3a73f6612a Replace add_temp_log() with add_default_log().
We used to have this function so that we could mark our initial
log-to-stdout as specifically temporary so that we would delete it
once regular logs were configured.  But it's no longer necessary to
mark these logs as temporary, since we now use a mark-and-sweep
process to ensure that _all_ not-configured logs are closed when we
change our configuration.

Instead, this function will be the basis of a refactoring in how we
handle default logs.
2019-10-17 12:30:52 -04:00
Nick Mathewson
800b823c29 Merge branch 'cmdline_refactor' 2019-10-17 12:01:45 -04:00
Nick Mathewson
d97d7f0e48 Use an enum for quiet_level. 2019-10-17 12:01:40 -04:00
Nick Mathewson
b9f002dec6 Rename CMD_OTHER to CMD_IMMEDIATE 2019-10-17 12:01:40 -04:00
Nick Mathewson
d15223a385 fixup! Print the error message for --dump-config even if no arguments are given.
Fix a spelling error.
2019-10-17 12:01:40 -04:00
Nick Mathewson
763d955a17 Add a test for a command-line option without a value. 2019-10-17 12:01:40 -04:00
Nick Mathewson
bfdfaae040 Move responsibility for setting the "quiet level" into a table.
Previously this was done with a big list of options in main.c which
implied "hush" or "quiet".  One of these options ("--digests") no
longer existed, but we still checked for it.

Now we use the table of command-line-only arguments to set this
value.
2019-10-17 12:01:40 -04:00
Nick Mathewson
c529b3f8f1 Make the command-line parser understand "commands".
Previously these were implemented with a search in
options_init_from_torrc(), but that led to each option being
declared more than needed: once to say that it was a valid option,
and once to say what it meant.
2019-10-17 12:01:40 -04:00
Nick Mathewson
9826fb1981 Add a return type for the parsed commandline.
Previously it was stored in two outvars, but this is more
elegant. I'm going to be expanding this struct in later commits.
2019-10-17 12:01:40 -04:00