Commit Graph

24869 Commits

Author SHA1 Message Date
Nick Mathewson
25d66a3391 add missing docs in crypto_digest* 2019-10-28 08:27:42 -04:00
Nick Mathewson
f751cc020f Documentation cleanup in confmacros.h 2019-10-26 17:24:22 -04:00
Nick Mathewson
16dffa523e Rename confparse.[ch] identifiers to confmgt.[ch] identifiers.
This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        confparse.h confmgt.h \
        confparse.c confmgt.c \
        CONFPARSE_PRIVATE CONFMGT_PRIVATE \
        TOR_CONFPARSE_H TOR_CONFMGT_H
2019-10-26 10:09:03 -04:00
Nick Mathewson
2402d95715 Rename confparse.[ch] to confmgt.[ch]
This will break compilation until includes etc are fixed.
2019-10-26 10:07:14 -04:00
Nick Mathewson
407fb0c35c Move config_format_t and allied definitions into conftypes.h
Since these are needed by every module that is _configurable_, they
belong in lib/conf, not lib/confmgt.
2019-10-26 10:05:03 -04:00
Nick Mathewson
e7993dc046 Merge branch 'ticket31241_v3' 2019-10-25 08:10:39 -04:00
Nick Mathewson
63f2a310cb config,state: check magic in all callbacks. 2019-10-25 08:09:05 -04:00
Nick Mathewson
aa6b4b62db confparse: Add a function to check the magic of a toplevel object. 2019-10-25 08:08:43 -04:00
teor
0ae530c8f6
test: Use SEVERITY_MASK_IDX() to find the LOG_* mask indexes
In the unit tests.

Fixes a regression to bug 31334; bug not in any released version of tor.
2019-10-25 17:23:46 +10:00
teor
60aa6dac34
Merge remote-tracking branch 'tor-github/pr/1467' 2019-10-25 17:17:39 +10:00
teor
a91f52a443
Merge branch 'maint-0.4.2' 2019-10-25 10:38:22 +10:00
Nick Mathewson
620e40bcfc test_options: add a test for options_trial_assign()
This function is used by controllers to set options.  I refactored
it a bit when refactoring options validation, so it needs to get
tested.
2019-10-24 20:38:02 -04:00
Nick Mathewson
06475f30e9 tests: set DataDirectory_option as well as DataDirectory.
options_validate_cb() derives DataDirectory (which we use) from
DataDirectory_option (which the user sets).  I want to add a test
that will call options_validate_cb(), but it will fail unless it
derives the same value.
2019-10-24 20:38:02 -04:00
Nick Mathewson
4d53bbeafb config: make options_act*() mockable.
I'll need this for testing options_trial_assign().
2019-10-24 20:38:02 -04:00
teor
c8aa3cc17d
Merge remote-tracking branch 'tor-github/pr/1466' into maint-0.4.2 2019-10-25 10:38:01 +10:00
Nick Mathewson
f796bf3aa5 Extend confmgr tests to handle validation callbacks. 2019-10-24 20:37:53 -04:00
Nick Mathewson
d17aa09308 config.c: Turn options_transition_allowed() into a proper callback 2019-10-24 20:30:32 -04:00
Nick Mathewson
bd891f517f config.c: extract validate, check-transition, and set into a function
This eliminates duplicated code.  The options_validate() function
itself is now tests-only.
2019-10-24 20:30:32 -04:00
Nick Mathewson
e0ae137df5 Write a new set of config validation callbacks.
Unlike legacy_validate_fn_t, these callbacks have separation of
duties, into:

    * early normalization and computation.
    * validation
    * transition checking
    * late normalization and computation

Only the first and last steps get mutable objects.  Only the
transition-checking step gets to see the previous values of this
object.
2019-10-24 20:30:32 -04:00
Nick Mathewson
dc6d7f072d Make foo_validate() functions call config_validate().
The former foo_validate() functions are now toplevel
legacy_validate_fn callbacks.  The new foo_validate() functions now
call them.

This change lets us remove the old shared_random disk state
validation callback entirely.
2019-10-24 20:30:32 -04:00
Nick Mathewson
0cb4238537 Add a config_validate() function to invoke verify callbacks.
As we turn our monolithic configuration objects into suites of
smaller module-specific configuration objects, we will want each one
to be able to provide its own verification callbacks.  That means
that instead of invoking these verification callbacks directly, we will
want to call them via the configuration manager object.
2019-10-24 20:30:32 -04:00
Nick Mathewson
4a248bafba Rename validate_fn{,_t} to start with "legacy_".
The current API of this callback mixes responsibilities, including:
  * validation
  * transition checking
  * processing (modifying) the configuration object.

These will have to be disentangled piece by piece, so for now, we'll
have "legacy" validate functions as well.

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        validate_fn_t legacy_validate_fn_t \
        validate_fn legacy_validate_fn
2019-10-24 20:30:32 -04:00
Nick Mathewson
24ee44df90 test_options: stop generating old_data entirely.
Now that we no longer use it anywhere, we can remove this variable
from the test data structure.
2019-10-24 20:30:32 -04:00
Nick Mathewson
7c0f966668 test_options: don't pass an old_options argument to options_validate()
This input was inessential, and none of the tests actually depended
on it or tested anything about it (as can be seen from the fact that
tests all still pass when it's removed).

I tried to generate this commit with a coccinelle script, but it had
trouble parsing a lot of options_validate as it stands.  Instead, I
did a search-and-replace to replace "tdata->old_opt," with "NULL,".
2019-10-24 20:30:32 -04:00
Nick Mathewson
27dbf20bf4 Use named-member syntax for initializing config_format_t objects
I'm about to mess with their lists of callbacks, and I don't want to
proliferate lists where we say "NULL, NULL, NULL, ..."
2019-10-24 20:30:32 -04:00
teor
c00602cc34
Merge branch 'maint-0.4.2' 2019-10-25 09:42:14 +10:00
teor
acd27f4b41
Merge remote-tracking branch 'tor-github/pr/1464' into maint-0.4.2 2019-10-25 09:41:48 +10:00
Nick Mathewson
570d1367ea bump to 0.4.2.3-alpha-dev 2019-10-24 15:55:22 -04:00
Nick Mathewson
7bf4220a1b test_options: Use 64-bit comparisons when checking domain masks.
This prevents a warning when building for 32-bit targets.

Fixes bug 32269; bug not in any released Tor.
2019-10-24 12:37:27 -04:00
David Goulet
3867ca4925 dir: Return 503 code when rejecting single hop request
Single hop rejection (POST and GET) for HS v3 descriptor now return a 503 code
which is more accurate code from dir-spec.txt and from other rejection case in
the code.

For instance if you are not a relay and you get a POST request, a 503 code is
sent back with a rejection message.

Part of #31958

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-24 11:25:05 -04:00
David Goulet
985717675c dir: Remove connection_dir_is_anonymous() logging
First, remove the HSDir mention which should not be in that generic function.
Second, move them to debug() level since they are possible error case.

Part of #31958

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-24 11:23:31 -04:00
David Goulet
09468cc58b dir: Look if circuit is closed in connection_dir_is_anonymous()
Before inspecting the p_chan, we must check if the circuit is marked for close
because if it is the case, the channels are nullified from the circuit.

Several valid cases can mark the circuit for close of the directory
connection.

Fixes #31958

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-24 11:08:25 -04:00
David Goulet
ed57a04a65 hs-v3: Remove a BUG() caused by an acceptable race
hs_client_purge_state() and hs_cache_clean_as_client() can remove a descriptor
from the client cache with a NEWNYM or simply when the descriptor expires.

Which means that for an INTRO circuit being established during that time, once
it opens, we lookup the descriptor to get the IP object but hey surprised, no
more descriptor.

The approach here is minimalist that is accept the race and close the circuit
since we can not continue. Before that, the circuit would stay opened and the
client wait the SockTimeout.

Fixers #28970.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-24 08:50:01 -04:00
Nick Mathewson
76939cf293 Bump to 0.4.2.3-alpha 2019-10-23 20:25:34 -04:00
teor
20606b8a15
Merge remote-tracking branch 'tor-github/pr/1447' 2019-10-24 10:00:47 +10:00
teor
34509e78c6
Merge remote-tracking branch 'tor-github/pr/1449' 2019-10-23 22:59:16 +10:00
teor
27965f1ef2
Merge remote-tracking branch 'tor-github/pr/1284' into maint-0.3.5 2019-10-23 08:30:48 +10:00
teor
003be727c4
Merge remote-tracking branch 'tor-github/pr/1256' into maint-0.3.5 2019-10-23 08:28:03 +10:00
teor
339c18d6c7
Tidy whitespace around some STMT_BEGINs and STMT_ENDs 2019-10-23 07:37:39 +10:00
Nick Mathewson
1cdc030c3d Merge branch 'maint-0.4.2' 2019-10-22 14:47:28 -04:00
Nick Mathewson
2ed194c9a9 Merge remote-tracking branch 'tor-github/pr/1441' into maint-0.4.2 2019-10-22 14:46:10 -04:00
Nick Mathewson
6bc2b41e54 config validation: make the "old_options" argument const.
We can't do this with the "options" argument yet, since several
places in the code change those right now.
2019-10-22 14:24:09 -04:00
Nick Mathewson
3656fdae98 test_options: remove def_opt member of test data. 2019-10-22 14:24:09 -04:00
Nick Mathewson
86a1d670ac test_options: remove "dflt" part of setup_options().
It is no longer used anywhere.
2019-10-22 14:24:09 -04:00
Nick Mathewson
475a1dc9be Remove a pair of now-unused default-options arguments. 2019-10-22 14:24:03 -04:00
Nick Mathewson
3dc0944acd test_options: Fix options_validate() calls in macros.
Coccinelle missed these.
2019-10-22 14:24:03 -04:00
Nick Mathewson
41e6e2f496 Use coccinelle to fix most options_validate() call sites.
There was one that it could not find because it was in a macro definition.

I used the following semantic patch:

@@
expression e1, e2, e3, e4, e5;
@@
 options_validate(e1,
 e2,
- e3,
- e4,
 e5)
2019-10-22 14:01:42 -04:00
Nick Mathewson
8a27023d21 Remove unused arguments from options_validate().
This change breaks compilation; a subsequent commit will fix it with
a coccinelle patch.
2019-10-22 13:56:11 -04:00
Nick Mathewson
697d99e504 validate_fn(): remove now-unused defaults and from_setconf.
These arguments were only used by options_validate, and are now
ignored even there.
2019-10-22 13:52:40 -04:00
Nick Mathewson
7d75e1dbdf Merge remote-tracking branch 'tor-github/pr/1446' 2019-10-22 12:52:32 -04:00