Commit Graph

24694 Commits

Author SHA1 Message Date
Nick Mathewson
261ec900db Remove variable declarations from macros in test_addr_parse()
Instead, put them in the function itself.

This is an attempt to fix the gcc warning about the "variable
tracking size limit exceeded".
2019-09-12 18:07:47 +03:00
Nick Mathewson
34bab120df Ticket 31687: fix for tor_isinf() as well
tor_isinf() was new in 0.4.0, and also needs to look at the
same rules as clamp_double_to_i64()
2019-09-12 09:53:13 -04:00
Nick Mathewson
0327f9a075 Merge branch 'ticket31687_035' into ticket31687_040 2019-09-12 09:51:04 -04:00
Nick Mathewson
87944cecfc Merge remote-tracking branch 'tor-github/pr/1300' 2019-09-12 08:50:09 -04:00
Nick Mathewson
ae6e60281c Update include.am files to refer to new location of confparse.[ch]
Tests should now pass again.
2019-09-11 10:22:01 -04:00
Nick Mathewson
a90d1918af Update #includes to point to confparse.h in its new location.
This commit was automatically generated by running
scripts/maint/rectify_include_paths.py .
2019-09-11 10:17:20 -04:00
Nick Mathewson
87ca9e4d2a Move confparse.[ch] into src/lib/confmgt/
This commit only does code movement, and does not clean up after
itself.  As such, it will break compilation.  I'm separating it for
ease of review.
2019-09-11 10:16:10 -04:00
Nick Mathewson
bf8c3164b6 Add new entries to lib/confmgt ".may_include" file
confparse.[ch] will need these; checkIncludes confirms that we have
not introduced a cycle.
2019-09-11 10:13:57 -04:00
David Goulet
41261c3b5c Merge branch 'tor-github/pr/1296' 2019-09-11 09:42:31 -04:00
Nick Mathewson
478141e617 Document inconsistent usage of config_var_is_listable()
See also ticket 31654.
2019-09-11 09:42:19 -04:00
Nick Mathewson
e61bfd0bfd Extract common list of flags to use for obsolete variables. 2019-09-11 09:42:19 -04:00
Nick Mathewson
fe5033d3b0 Clarify documentation on config_var_is_listable()
Here we make it clear we're only looking at listable variable names,
not at whether the variables themselves are gettable.

Also, remove an extraneous h.

(This commit is not a fixup, because of rebase conflicts.)
2019-09-11 09:42:19 -04:00
Nick Mathewson
14f48cb083 Add test_cmdline.sh to distribution. 2019-09-11 09:42:19 -04:00
Nick Mathewson
7a8ea0d3c3 integration test for --list-torrc-options
(This option tests our existing behavior, not necessarily the most
sensible behavior.)
2019-09-11 09:42:19 -04:00
Nick Mathewson
5ffe6ec0e3 Test: Make sure NOLIST options are not listed. 2019-09-11 09:42:19 -04:00
Nick Mathewson
bbd40e690e Revise documentation on CFLG_* flags 2019-09-11 09:42:19 -04:00
Nick Mathewson
0d6d96396c Remove all CVFLAG_* usage. 2019-09-11 09:42:19 -04:00
Nick Mathewson
5ca5d196ac Remove all VTFLAG_* usage. 2019-09-11 09:42:19 -04:00
Nick Mathewson
9b571d4729 confparse, conftypes: Replace flags with their new names.
The old names remain as #defines that cause variables to get one or
more flags.

Now every flag-testing function in confparse.c tests exactly one flag.
2019-09-11 09:42:19 -04:00
Nick Mathewson
1b3b6d9f2d Replace low-level {var_type,struct_var}_is_*() with flag inspection
Since the flags are now stored with compatible numbering, we can
just OR them together and see whether the flag we want is in the
result.

(Net code removal!)
2019-09-11 09:42:19 -04:00
Nick Mathewson
4b92f4c83a Re-number VTFLAG_* values so they don't conflict with CVFLAG_* 2019-09-11 09:42:19 -04:00
Nick Mathewson
c650ab8061 Move VTFLAG_* declarations to conftypes.h 2019-09-11 09:42:19 -04:00
Nick Mathewson
03e4183043 typed_var: Make flags into an unsigned OR of bits.
Using a bitfield here will enable us to unify the var_type_def_t flags
with the config_var_t flags.

(This commit does not yet do that unification, and does not yet
rename or refactor any flags.  It only changes booleans into bits.)
2019-09-11 09:42:19 -04:00
Nick Mathewson
4f6b592691 struct_var: refactor struct_var_is*() functions to delegate
Previously they checked the individual flags inside var_type_def_t;
now they call the appropriate var_type_is_*() functions.

(These functions will be removed entirely by the end of this branch.)
2019-09-11 09:42:19 -04:00
Nick Mathewson
7171ce2a2a config: make config_var_is_dumpable static. 2019-09-11 09:42:19 -04:00
Nick Mathewson
8d685aee7c config: rename "contained" to "derived", and explain it better.
Don't use "derived" directly, but check its implications for listing
and copying.
2019-09-11 09:42:19 -04:00
Nick Mathewson
668e3a7709 config: Introduce the concept of an "ungettable" variable.
We had though to make all obsolete and invisible variables
ungettable, so that GETCONF would reject them.  But it turns out
that this isn't the current behavior of GETCONF with those
variables.  So for now, I'm leaving the current behavior unchanged.
(See ticket 31647 for a proposal to change the behavior.)
2019-09-11 09:42:19 -04:00
Nick Mathewson
3bf38ffff5 Document config_var_is_dumpable and config_var_is_settable. 2019-09-11 09:42:19 -04:00
David Goulet
049705fc1c Merge branch 'tor-github/pr/1311' 2019-09-11 09:36:28 -04:00
George Kadianakis
3b32f2508c Merge branch 'tor-github/pr/1307' 2019-09-11 16:19:21 +03:00
Nick Mathewson
0891a31ad3 madvise: tolerate EINVAL and ENOSYS when minherit fails
These errors can occur if we are built on a system with support for
madvise(MADV_NOFORK) but then we are run on a system whose kernel
does not support that flag.

If the error is something that we don't tolerate at all, we now log
it before crashing.

Fixes bug 31696.  I am calling this a bugfix on 0.4.1.1-alpha, where
we actually started using the map_anon code.

This is similar to, but not the same as, the fix for #31570.
2019-09-11 09:13:50 -04:00
Nick Mathewson
9d60495903 Use strtod, not atof, for parsing doubles in the configuration.
This lets us detect erroneous doubles, which previously we could not
do.

Fixes bug 31475; bugfix on commit 00a9e3732e, a.k.a svn:r136.
2019-09-10 19:01:32 -04:00
Nick Mathewson
97f7efa9e3 pf: when extracting an IPv6 address, make sure we got an IPv6 address
Our code assumes that when we're configured to get IPv6 addresses
out of a TRANS_PF transparent proxy connection, we actually will.
But we didn't check that, and so FreeBSD started warning us about a
potential NULL pointer dereference.

Fixes part of bug 31687; bugfix on 0.2.3.4-alpha when this code was
added.
2019-09-10 11:07:25 -04:00
Nick Mathewson
51475aee57 fp.c: Suppress float-conversion warnings on FreeBSD.
We used to do this on Windows only, but it appears to affect
multiple platforms when building with certain versions of GCC, and a
common pattern for defining the floating-point classifier functions.

Fixes part of 31687. I'm calling this a bugfux on 31687, when we
started suppressing these warnings on Windows.
2019-09-10 10:55:44 -04:00
Nick Mathewson
e7d7e04155 Do not look inside bogus microdesc when listing its digest as invalid
We have code in microdescs_parse_from_string() to record the digests
of microdescriptors that we could not parse.  But right now, that
code looks at the md->digest field, which is a bit inelegant, and
will stand in the way of sensible refactoring.

Instead, use a local variable to hold the digest.
2019-09-10 09:10:49 -04:00
Nick Mathewson
7282213bd3 Extract saved_location_to_string() from microdesc parsing.
We may be able to use this function in other places in the future;
if so, we should move it to somewhere more useful.

Part of 31675.
2019-09-10 09:10:49 -04:00
Nick Mathewson
d8ef6b1548 Add a unit test for ed25519 identity parsing in microdescriptors
This test makes sure that we parse ed25519 identities to get the
correct data from them.  It also tests:

   * That a microdescriptor may not have two ed25519 identities.
   * That a microdescriptor may not have an ed25519 identity that is
     not a valid base64-encoded ed25519 key.
   * That a microdescriptor may have an unrecognized identity type.

It will help test the refactoring of ticket31675.
2019-09-10 09:10:49 -04:00
teor
39c7f46d36
main: add some newlines to the subsystem list, for readability 2019-09-10 09:06:36 +10:00
teor
5fa75a6cd4
main: remove level number comments from the subsystem list (master)
Part of 31615.
2019-09-10 09:04:38 +10:00
teor
987768b077
Merge branch 'bug31615_041' into bug31615_master
Merged modified lines from bug31615_041, and unmodified lines
from master.
2019-09-10 09:03:37 +10:00
teor
f1c57cd1e5
main: remove level number comments from the subsystem list (0.4.1)
Part of 31615.
2019-09-10 08:44:35 +10:00
teor
7e22d99346
Merge branch 'bug31615_040' into bug31615_041
Merged modified lines from bug31615_040, and unmodified lines
from maint-0.4.1.
2019-09-10 08:43:13 +10:00
teor
2e2a35b694 main: remove level number comments from the subsystem list (0.4.0)
These levels get out of date really easily: we'll implement a level
dump command in tor in 31614.

They also cause conflicts and inconsistencies when merging forward
level changes.

Part of 31615.
2019-09-10 08:35:56 +10:00
David Goulet
409df19b5a build: The <sys/sysctl.h> is now deprecated on Linux
Closes #31673
2019-09-09 17:07:08 -04:00
David Goulet
484710f25b build: The <sys/sysctl.h> is now deprecated on Linux
Closes #31673
2019-09-09 17:05:23 -04:00
Nick Mathewson
6846d14868 Merge branch 'ticket30924_042_04_squashed_merged' 2019-09-09 12:35:27 -04:00
Nick Mathewson
a642a4cbd7 Merge branch 'ticket30924_042_04_squashed' into ticket30924_042_04_squashed_merged 2019-09-09 11:10:53 -04:00
David Goulet
622c2c7884 hs-v3: Rename validation function in hs_intropoint.c
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-09-09 11:07:51 -04:00
David Goulet
385f6bcfcc hs-v3: Move DoS parameter check against 0
Move it outside of the validation function since 0 is a valid value but
disables defenses.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-09-09 11:07:36 -04:00
David Goulet
f16fc262e5 Merge branch 'tor-github/pr/1298' 2019-09-09 11:05:51 -04:00
David Goulet
1e7c7870e8 Merge branch 'tor-github/pr/1287' 2019-09-09 10:51:19 -04:00
teor
1609916c79
log: Close log and err file descriptors before aborting
Part of 31594.
2019-09-09 14:56:42 +10:00
teor
a22fbab986
log: Don't close file log fds that are being used by the err module
Instead, dup() file log fds, before passing them to the err module.

Closes 31613, part of 31594.
2019-09-09 14:56:28 +10:00
teor
d02ced4caf
torerr: Close sigsafe fds on shutdown
And clear the list of error fds.

Part of 31594.
2019-09-09 14:56:17 +10:00
teor
612b0a4139 subsys: Make the subsystem init order match the module dependencies
Fix levels for subsystems that depend on log/err
* winprocess (security) doesn't use err:
  * call windows process security APIs as early as possible
  * init err after winprocess
  * move wallclock so it's still after err
* network and time depend on log:
  * make sure that network and time can use logging.
  * init network and time after log

Add comments explaining the module init order.

Fixes bug 31615; bugfix on 0.4.0.1-alpha.
2019-09-06 16:58:53 +10:00
teor
670d402621 entrynodes: Make routine descriptor expiry notice logs less alarming
When tor is missing descriptors for some primary entry guards, make the
log message less alarming. It's normal for descriptors to expire, as long
as tor fetches new ones soon after.

Fixes bug 31657; bugfix on 0.3.3.1-alpha.
2019-09-06 16:43:14 +10:00
Nick Mathewson
a727d4a3a1 Remove unused struct_var_* functions.
These turned out to be unnecessary, so let's not keep them around
and let them start getting complicated.

Closes ticket 31630.
2019-09-05 15:24:54 -04:00
Nick Mathewson
16cf9424c1 config: Invert sense of _is_invisible, and rename to is_listable() 2019-09-05 11:32:32 -04:00
Nick Mathewson
22e7d33735 config: replace config_var_is_cumulative with is_replaced_on_set()
This change replaces the higher-level property check to match our
intended flag factoring.
2019-09-05 11:32:32 -04:00
George Kadianakis
545c21e23d Merge branch 'tor-github/pr/1295' 2019-09-05 17:13:29 +03:00
George Kadianakis
ddd01541b9 Merge branch 'tor-github/pr/1294' 2019-09-05 17:12:19 +03:00
George Kadianakis
fb56b4c2bf Merge branch 'tor-github/pr/1293' 2019-09-05 17:10:07 +03:00
George Kadianakis
c750ec20ab Merge branch 'tor-github/pr/1291' 2019-09-05 17:09:20 +03:00
George Kadianakis
c29f05b159 Merge branch 'tor-github/pr/1292' 2019-09-05 17:06:58 +03:00
George Kadianakis
cdd7e88970 Merge branch 'tor-github/pr/1261' 2019-09-05 17:02:53 +03:00
Neel Chauhan
0127888b06 Add tests for IPv6 exit policies on microdescriptors 2019-09-05 17:02:45 +03:00
Neel Chauhan
be4a60945d Check IPv6 exit policies on microdescriptors in node_exit_policy_rejects_all() 2019-09-05 17:02:45 +03:00
Nick Mathewson
eb909c4e43 config: note that some arguments are required. 2019-09-05 07:57:36 -04:00
teor
1203e137be
Merge commit '763fd0ad66' into maint-0.4.0
tor-github/pr/1174, but with the last commit re-worded to remove
the fixup, because fixups break our push rules.
2019-09-05 11:42:26 +10:00
Nick Mathewson
88839ab2ac Remove _ex suffix from typed_var_*_ex() functions.
Now that the variants of these functions that took config_line_t are
gone, there is no longer any reason for the remaining variants to
have "ex" at the end of their names.

This commit was made by running this perl script over all the files
in src/:

#!/usr/bin/perl -w -i -p

s{typed_var_(assign|free|encode|copy|eq|ok|kvassign|kvencode|mark_fragile)_ex}
 {typed_var_$1}g;
2019-09-04 15:01:49 -04:00
Nick Mathewson
161c392a4f typedvar: remove now-unused functions taking config_type_t.
These functions are no longer used.

Part of 31629.
2019-09-04 14:54:59 -04:00
Nick Mathewson
b3c2867715 Document fields of struct_magic_decl_t. 2019-09-04 14:23:19 -04:00
Nick Mathewson
3db56aeeb8 Document warn_deprecated_option(). 2019-09-04 14:23:19 -04:00
Nick Mathewson
39316da9b6 Document return value of config_mgr_add_format(). 2019-09-04 14:23:19 -04:00
Nick Mathewson
39dd2e2aa8 Document validate_fn_t as it stands.
Also document that it will be changed in a later branch.
2019-09-04 14:23:19 -04:00
Nick Mathewson
aeda598fd5 config_assign: Document CAL_* options.
These were sort of described in config_assign() documentation, but
not so well.
2019-09-04 14:23:19 -04:00
Nick Mathewson
577ea20b3a Document configuration and abbreviation types. 2019-09-04 14:23:19 -04:00
Nick Mathewson
3aba13f779 buffers: use ptrdiff_t to indicate offsets.
Previously we used int in some places and off_t for others.  Neither
is correct: ptrdiff_t is right for differences between pointers.
(off_t is only for offsets and sizes on the filesystem.)
2019-09-04 12:06:27 -04:00
Nick Mathewson
ec724fe8c8 rendclient: use ptrdiff, not off_t, for offset of DH field.
The off_t type is only useful for offsets on the filesystem.  For
in-memory offsets, use ptrdiff_t.
2019-09-04 12:06:27 -04:00
Nick Mathewson
b39ee42904 compat_compiler: fix documentation for STRUCT_VAR_P
Previously we had said that off_t was a reasonable type to hold the
result of offsetof().  That isn't so: ptrdiff_t is correct.
2019-09-04 12:06:27 -04:00
Nick Mathewson
dc199f40fb smartlist_pqueue: use ptrdiff_t instead of int for offsets.
This is technically correct, but should not matter in practice,
since we don't use this on any structs whose size exceeds INT_MAX.
2019-09-04 12:06:27 -04:00
Nick Mathewson
03ce67d378 config: explain CONFIG_TYPE_EXTENDED
Also add an explanation of a possible future refactoring where we
might remove the config_type_t enumeration entierly.

Fixes ticket 31624.

No changes file, since this is a comment-only change.
2019-09-04 11:54:42 -04:00
Nick Mathewson
870874fec8 config: Make CLEAR with a nonempty value into a nonfatal assertion.
When we parse a CLEAR line (e.g., "/OrPort" or /OrPort blah blah"),
we always suppress the value, even if one exists.  That means that
the block of code was meant to handle CLEAR lines didn't actually do
anything, since we previously handled them the same way as with
other empty values.

Closes ticket 31529.
2019-09-04 11:28:21 -04:00
Nick Mathewson
539158f2be config: use ptrdiff_t for all field-offset members.
Previously we used int here, but it is more correct to use
ptrdiff_t.  (This never actually matters for our code in practice,
since the structure we are managing here never exceed INT_MAX in
size.)
2019-09-04 10:50:09 -04:00
David Goulet
34f3fcef40 Merge branch 'tor-github/pr/1290' 2019-09-04 10:33:49 -04:00
Nick Mathewson
46a3820652 Merge remote-tracking branch 'tor-github/pr/1270' 2019-09-04 09:52:35 -04:00
Nick Mathewson
c683896b7c Update routerset reset test to use new mgr API. 2019-09-04 08:42:34 -04:00
Nick Mathewson
17a870a64b Merge branch 'ticket31240v2_merged_2' into ticket31240v2_merged_2_merged 2019-09-04 08:41:42 -04:00
teor
9c798dd5a5
torerr: Fix a comment typo and update the comment for format_number_sigsafe()
Closes 31612.
2019-09-04 14:06:58 +10:00
teor
193c74faf9
Merge branch 'bug31571_041' into bug31571_master 2019-09-04 13:57:39 +10:00
teor
abe1f4f23e
Merge branch 'bug31571_040' into bug31571_041 2019-09-04 13:57:36 +10:00
teor
0cee6f498c
Merge branch 'bug31571_035' into bug31571_040 2019-09-04 13:57:31 +10:00
teor
a836dd2530
Merge branch 'maint-0.3.5' into bug31571_035 2019-09-04 13:57:15 +10:00
teor
f311d0676c backtrace: Check the return values of snprintf() and strncpy()
We can't use strlcat() or strlcpy() in torerr, because they are defined
in string/compat_string.h on some platforms, and string uses torerr.

Part of 31571.
2019-09-04 13:51:22 +10:00
George Kadianakis
7fa624537c Merge branch 'tor-github/pr/1269' 2019-09-03 17:11:25 +03:00
Nick Mathewson
a617001fd4 Merge remote-tracking branch 'tor-github/pr/1279' 2019-09-03 09:47:25 -04:00
Nick Mathewson
52342327c7 madvise: tolerate EINVAL and ENOSYS
These errors can occur if we are built on a system with support for
madvise(MADV_NOFORK) but then we are run on a system whose kernel
does not support that flag.

If the error is something that we don't tolerate at all, we now log
it before crashing.

Fixes bug 31570.  I am calling this a bugfix on 0.4.1.1-alpha, where
we actually started using the map_anon code.
2019-09-02 14:49:53 -04:00
Nick Mathewson
01bda9bed1 Merge branch 'maint-0.4.1' 2019-09-02 14:11:32 -04:00
Nick Mathewson
e3a458e441 Merge branch 'ticket12399_035' into maint-0.4.1 2019-09-02 14:11:18 -04:00
rl1987
05fa1689eb Change loglevel of message 'Hash of session info was not as expected' 2019-09-02 14:09:39 -04:00
Neel Chauhan
d22ed05dc0 Space out the arguments to the cell functions in rend_process_relay_cell() 2019-08-30 18:58:00 -04:00
teor
a52a5e0099
Merge branch 'maint-0.3.5' into maint-0.4.0 2019-08-30 23:33:01 +10:00
teor
1132dc9f75
Merge remote-tracking branch 'tor-github/pr/1181' into maint-0.3.5 2019-08-30 23:24:05 +10:00
teor
b66712d85b
Merge remote-tracking branch 'tor-github/pr/1117' into maint-0.3.5 2019-08-30 23:22:18 +10:00
teor
4662cbec7b
Merge remote-tracking branch 'tor-github/pr/1114' into maint-0.3.5 2019-08-30 23:20:59 +10:00
teor
c55591825f
torerr: Try harder to flush raw assert messages before process termination
Some platforms (macOS, maybe others?) can swallow the last write before an
abort. This issue is probably caused by a race condition between write
buffer cache flushing, and process termination. So we write an extra
newline, to make sure that the message always gets through.

Fixes bug 31571; bugfix on 0.3.5.1-alpha.
2019-08-30 21:51:11 +10:00
teor
65a1d86491
torerr: Log the Tor backtrace version when a raw assertion fails
Part of 31571.
2019-08-30 21:51:07 +10:00
teor
743bc0028b
backtrace: Log the Tor backtrace version whenever we log a backtrace
Previously, we just logged it in the crash handler.

Part of 31571.
2019-08-30 21:51:03 +10:00
teor
e2a7d08aa7
backtrace: Always set a backtrace Tor version
We want to report the tor version, even on platforms that don't have
backtrace support (like Android).

This commit stores the backtrace Tor version, regardless of USE_BACKTRACE.

Preparation for 31571.
2019-08-30 21:50:57 +10:00
Nick Mathewson
fb0e8966f0 Stub more functions in dirvote headers to fix more of 31552. 2019-08-29 11:18:42 -04:00
Nick Mathewson
4256ee0d37 Stub out some more functions in dirvote/*.h, fix compilation.
This fixes LTO compilation for Android and -O0 compilation in
general, when --disable-module-dirauth is provided.

Fixes bug 31552; bugfix on 0.4.1.1-alpha.
2019-08-29 09:50:38 -04:00
Nick Mathewson
c281fa0da2 Describe clear_cfg_fn_t better. 2019-08-29 09:14:51 -04:00
David Goulet
960d989415 Merge branch 'tor-github/pr/1257' 2019-08-29 08:56:04 -04:00
David Goulet
7c99a4ddde Merge branch 'maint-0.4.1' 2019-08-29 08:55:58 -04:00
David Goulet
ff905f8e1e Merge branch 'tor-github/pr/1256' into maint-0.4.1 2019-08-29 08:55:31 -04:00
David Goulet
337b733cfc Merge branch 'tor-github/pr/1255' into maint-0.4.1 2019-08-29 08:55:27 -04:00
teor
063cf9cd23 string: macOS --enable-fragile-hardening uses safe string functions
Comment-only change.
2019-08-29 13:10:34 +10:00
teor
ec6fbf1ca6 nodelist: Use safe string functions in describe.c
Rewrite format_node_description() and router_get_verbose_nickname() to
use strlcpy() and strlcat(). The previous implementation used memcpy()
and pointer arithmetic, which was error-prone.

Closes ticket 31545. This is CID 1452819.
2019-08-29 13:09:08 +10:00
Nick Mathewson
1ef084c5fc test_confparse: verify that clearing a routerset sets it to NULL. 2019-08-28 12:28:17 -04:00
Nick Mathewson
f0c1f96adc Document configuration type definition functions for routerset_t
These functions are all used to implement the ROUTERSET_type_defn
object, which maps strings to and from routerset_t configuration
variables for the configuration module.
2019-08-28 12:23:36 -04:00
Nick Mathewson
2074fed664 Routerset config parsing: represent empty sets as NULL.
routerset_t has two representations of an empty routerset: NULL, and
a set containing no elements.  But some of our config code assumes
that empty routersets are represented as NULL.  So let's give it
what it assumes.

Fixes bug 31495. Bugfix on e16b90b88a76; but not in any released
Tor.
2019-08-28 11:53:28 -04:00
Nick Mathewson
04ab357df8 Remove extraneous "n" from comment in routerset.c 2019-08-28 11:39:31 -04:00
Nick Mathewson
b1d7ddfb02 Merge branch 'ticket31240v2' into ticket31240v2_merged_2 2019-08-28 09:46:59 -04:00
Nick Mathewson
a3e99c5f1e Add a test for clear_fn support in handling non-managed fields 2019-08-28 09:42:17 -04:00
Nick Mathewson
577e628743 Fix typo in a comment on config_mgr_get_obj_mutable() 2019-08-28 09:42:17 -04:00
Nick Mathewson
c967b5c9ba Add a test for dumping a compound configuration 2019-08-28 09:42:17 -04:00
Nick Mathewson
8db3859cc6 Simple tests for nested configuration formats
One test makes sure that the toplevel magic numbers are distinct.

One test makes sure that we can parse a configuration object
with two sub-objects.
2019-08-28 09:42:17 -04:00
Nick Mathewson
d9fe9f5ede Confmgr tests: test deprecations and abbreviations. 2019-08-28 09:42:17 -04:00
Nick Mathewson
e4162cdb38 Start on test cases for the multi-object feature of confmgr.
This test case, at this point, only constructs the confmgr object.
More code to come.
2019-08-28 09:42:17 -04:00
Nick Mathewson
cb5f8ace79 Tests for config_find_option_name()
Fix a bug in config_find_option_name() where it did not consider
the abbreviations table.
2019-08-28 09:42:17 -04:00
Nick Mathewson
aa3f0c4788 Add tests for variable-listing functions.
This discovered a bug related to an extra & in
config_mgr_list_deprecated_vars(): fix that.
2019-08-28 09:42:17 -04:00
Nick Mathewson
380d3ee168 Better explain config_clear_fn_t 2019-08-28 09:42:17 -04:00
Nick Mathewson
06da2c0d28 Document or_state_t.substates_ 2019-08-28 09:42:17 -04:00
Nick Mathewson
3af1cee6d9 Document or_options_t.subconfigs_ 2019-08-28 09:42:17 -04:00
Nick Mathewson
12d980027a document return lifespans for config_mgr_list_vars() 2019-08-28 09:42:17 -04:00
Nick Mathewson
9cfc811c37 Fix typo in comment about FallbackDir handling 2019-08-28 09:42:17 -04:00
Nick Mathewson
3a530ae535 Document types for config_get_changes() 2019-08-28 09:42:17 -04:00
Nick Mathewson
760d0c056f finish a comment explaining all_abbrevs 2019-08-28 09:42:17 -04:00
Nick Mathewson
638e58379a Partial support for multiplicity in configuration objects
A configuration manager, in addition to a top-level format object,
may now also know about a suite of sub-formats.  Top-level
configuration objects, in turn, may now have a suite of
sub-objects.
2019-08-28 09:40:53 -04:00
Nick Mathewson
38b770bbbb Make a config_suite_t type to hold multiple config sub-objects
Right now, it doesn't do anything; this patch is meant to make sure
that we're doing memory management correctly.
2019-08-28 09:40:53 -04:00
Nick Mathewson
47654d3249 Refactor config free logic to use a single path.
The right way to free a config object is now to wrap config_free(),
always.  Instead of creating an alternative free function, objects
should provide an alternative clear callback to free any fields that
the configuration manager doesn't manage.

This lets us simplify our code a little, and lets us extend the
confparse.c code to manage additional fields in config_free.
2019-08-28 09:40:53 -04:00
Nick Mathewson
3d1f9f583a Use special magic to enforce manager/object connection.
Every time we finalize a config manager, we now generate a new magic
number for it, so that we'll get an assertion failure if we ever try
to use an object with a different configuration manager than the one
that generated it.
2019-08-28 09:40:46 -04:00
George Kadianakis
78e084a12e Merge branch 'tor-github/pr/1267' 2019-08-27 11:47:46 +03:00
George Kadianakis
92a8573d22 Merge branch 'tor-github/pr/1258' 2019-08-27 11:45:18 +03:00
George Kadianakis
0d7f76d7ca Merge branch 'tor-github/pr/1234' 2019-08-27 11:44:13 +03:00
George Kadianakis
5782cee71d Merge branch 'tor-github/pr/1237' 2019-08-27 11:43:10 +03:00
Nick Mathewson
8af92b6577 test_address: parenthesize macro arguments.
It's good style to always add parentheses when using macro
arguments, in case somebody someday provides an argument that
contains an operator you don't expect, or causes the expression to
parse differently.
2019-08-26 20:03:16 -04:00
Nick Mathewson
5eca338107 In tests, make sure that "ri" is freed on all paths.
In Tor's tests, the tt_*() macros can call "goto done" on failure.
When that happens, we need to make sure that all of our allocated
memory still gets freed, or else Coverity will complain.
2019-08-26 20:03:11 -04:00
Neel Chauhan
c8e69e63f9 Add test for dirserv_router_has_valid_address() 2019-08-26 20:02:11 -04:00
Neel Chauhan
d9a7d47798 Check for private IPv6 addresses in dirserv_router_has_valid_address() 2019-08-26 18:21:56 -04:00
David Goulet
d819dfbded Merge branch 'tor-github/pr/1239' 2019-08-26 14:35:27 -04:00
David Goulet
cbe5f9571f test: Unit tests HS DoS torrc options
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:47 +03:00
David Goulet
461d231289 hs-v3: Refactor DoS cell extension parameters validation
Move everything to its own function in order to better log, document and tests
the introduction point validation process.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:47 +03:00
David Goulet
1c4607b132 hs-v3: Clarify comment in hs_dos.c
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:47 +03:00
David Goulet
292e9b0c00 hs-v3: Log info INTRO2 DoS defenses service values
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:47 +03:00
David Goulet
a98f5099c4 hs-v3: Missing intro circuit INTRO2 DoS enabled flag
When consensus changes, we also need to update the circuit INTRO2 defenses
enabled flag and not only the token bucket.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:47 +03:00
David Goulet
94a2221708 hs-v3: Privatize access to HS DoS consensus param
Remove the public functions returning the HS DoS consensus param or default
values as it is exclusively used internally now.

Rename the param_* variables to consensus_param_* for better code semantic.

Finally, make some private functions available to unit tests.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
184c76e339 hs-v3: Cleanup usage of consensus param in hs_dos.c
This commit makes it that the hs_dos.c file only uses the consensus parameter
variables set when we initialize and when the consensus changes.

There is no need to call each time networkstatus_get_param(), which is
expensive, when we want access to a consensus value.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
82639a8c7b hs-v3: Move to hs_dos.c INTRO2 defenses initialization
A bit cleaner especially that the next commit(s) will make the consensus param
interface private to hs_dos.c so we expose as little as we can outside of the
subsystem.

Part of #30924

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
1c554334ac test: Adapt HS DoS test to use latest parameter
We added a flag on the circuit to know if the DoS defenses are enabled or not.
Before, it was solely the consensus parameter.

Part of #30924

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
4c71accc49 test: Handling of ESTABLISH_INTRO DoS extension
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
dde073764c test: Build DoS cell extension
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
aee66c80bd hs-v3: Don't apply DoS defenses if circuit has not been flagged
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
724d9eb84b hs-v3: Parse ESTABLISH_INTRO cell extension
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
d692c5fd03 hs-v3: Encode DoS ESTABLISH_INTRO cell extension
This commit makes tor add the DoS cell extension to the ESTABLISH_INTRO cell
if the defense is enabled on the service side with a torrc option.

Furthermore, the cell extension is only added if the introduction point
supports it. The protover version HSIntro=5 is looked for.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
7faf10495f hs-v3: Rename INTRO2 consensus param getters
Make it clear that these functions return the consensus param only.
Introduction point can not set those values with a torrc option.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
6c79172924 hs-v3: Add protover HSIntro=5
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
5419fd5d9f hs-v3: Implement torrc DoS defenses options
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
e4856d1bbf trunnel: Add prop305 ESTABLISH_INTRO DoS cell extension
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
David Goulet
414e90025d trunnel: Remove typo in cell extention field name
There can be multiple fields in a cell extension but individually, it is
singular.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-26 15:53:46 +03:00
Nick Mathewson
cde662e259 clarify usage of __ and ___ prefixes on config options 2019-08-24 17:46:08 -04:00
Nick Mathewson
078ba326a1 Make a function for NODUMP. 2019-08-24 17:40:48 -04:00
Nick Mathewson
eb54fe8f97 Make config_var_is_invisible a function. 2019-08-24 17:32:46 -04:00
Nick Mathewson
65511a45ad Fix comment: ___ options are now that way because of the INVISIBLE flag. 2019-08-24 17:26:02 -04:00
Nick Mathewson
03247c8eaa whitespace fix 2019-08-24 17:11:41 -04:00
Neel Chauhan
14654d5c97 Remove the unused circuit_type field from hs_ident_circuit_t and hs_ident_circuit_new() 2019-08-23 14:04:05 -04:00
teor
55580d063d
hs: Remove an outdated comment 2019-08-23 16:26:44 +10:00
teor
65935f6da7
Merge branch 'bug23818_035' into bug23818_master 2019-08-23 16:26:32 +10:00
teor
e2e1c07fd2
hs: v3 single onion services fall back to 3-hop intro for unreachable nodes
Previously, v3 single onion services failed when all intro nodes were
unreachable via a 1-hop path. Now, we select intros that are only available
via a 3-hop path, and use a 3-hop path to connect to them.

Fixes bug 23507; bugfix on 0.3.2.1-alpha.
2019-08-23 16:22:49 +10:00
teor
229a982405
hs: Always use a 3-hop path when a v3 single onion intro fails
Previously, we always used a 1-hop path, no matter how many times a v3
single onion intro failed.

Fixes bug 23818; bugfix on 0.3.2.1-alpha.
2019-08-23 15:09:55 +10:00
teor
c94904b359
hs: Always use a 3-hop path when a v3 single onion rend fails
Previously, we used a 1-hop path when a single onion rend failed
immediately, and a 3-hop path when it failed after trying to build
a circuit.

Fixes bug 23818; bugfix on 0.3.2.1-alpha.
2019-08-23 15:09:43 +10:00
teor
14b5f40b54
Merge branch 'bug23818_029' into bug23818_035 2019-08-23 15:09:19 +10:00
teor
144084d6fa
rendservice: Always use a 3-hop path when a v2 single onion intro fails
Previously, we always used a 1-hop path, no matter how many times a v2
single onion intro failed.

Fixes bug 23818; bugfix on 0.2.9.3-alpha.
2019-08-23 15:02:20 +10:00
teor
dc08f8ac70
rendservice: Always use a 3-hop path when a v2 single onion rend fails
Previously, we used a 1-hop path when a single onion rend failed
immediately, and a 3-hop path when it failed after trying to build
a circuit.

Fixes bug 23818; bugfix on 0.2.9.3-alpha.
2019-08-23 15:01:48 +10:00
Nick Mathewson
2780cbb9cb Merge branch 'ticket30935' into ticket30935_merged 2019-08-22 17:25:35 -04:00
David Goulet
d475d7c2fb Merge branch 'tor-github/pr/1244' 2019-08-22 17:10:22 -04:00
teor
1ebff4d7f3 test/nodelist: Add unit tests for describe.c
Part of 21003.
2019-08-23 00:02:33 +10:00
teor
e8ba094c3e nodelist: Clear buffers and detect more caller errors in describe.c
Part of 21003.
2019-08-22 23:51:32 +10:00
Nick Mathewson
cc48eff2d3 Merge branch 'ticket31176' into ticket31176_merged 2019-08-21 09:46:20 -04:00
Nick Mathewson
edf5a327c5 Merge branch 'ticket30914' into ticket30914_merged 2019-08-20 13:57:05 -04:00
Nick Mathewson
3b2a732073 bump to 0.4.1.5-dev 2019-08-20 11:15:45 -04:00
Nick Mathewson
0bf980705e Fix a memory-leak warning in test_circuitbuid.c
Coverity wants us to free everything that we are potentially
allocating, even stuff where allocating it would be a bug.  Adding
a smartlist_free() here will fix the warning.

Fixes bug 31452; bugfix on 16a0b7ed67, which is not in
any released Tor.  This is CID 1447292.
2019-08-19 16:21:55 -04:00
Nick Mathewson
87a3c5b110 Fix 64-bit return issue in parse_log_domain()
If unsigned int is 32-bits long, then our old code would give a
wrong result with any log domain whose mask was >= (1<<32).
Fortunately, there are no such log domains right now: the domain
mask is only 64 bits long to accommodate some flags.

Found by coverity as CID 1452041.

Fixes bug 31451; bugfix on 0.4.1.4-rc.
2019-08-19 13:59:57 -04:00
Nick Mathewson
ab92881d9a Update version to 0.4.1.5 2019-08-19 11:35:48 -04:00
Nick Mathewson
e5812c91d6 Merge remote-tracking branch 'tor-github/pr/1231' 2019-08-19 11:34:27 -04:00
Nick Mathewson
29bd43ab03 Merge remote-tracking branch 'tor-github/pr/1224' 2019-08-19 11:26:58 -04:00
Nick Mathewson
6a89b01049 Merge remote-tracking branch 'tor-github/pr/1230' into maint-0.4.1 2019-08-19 11:11:32 -04:00
Nick Mathewson
e7aabfce61 Merge remote-tracking branch 'tor-github/pr/1235' 2019-08-19 11:10:21 -04:00
Nick Mathewson
deccd3aa6a Merge remote-tracking branch 'tor-github/pr/1225' 2019-08-19 11:08:44 -04:00
George Kadianakis
4185ef29fd Merge branch 'tor-github/pr/1122' 2019-08-19 18:06:05 +03:00