Commit Graph

335 Commits

Author SHA1 Message Date
Nick Mathewson
6cea2bd498 Document takes_argument_t and its members. 2019-10-08 12:59:22 -04:00
Nick Mathewson
4c25ea6703 Rename TAKES_NO_ARGUMENT to ARGUMENT_NONE.
I'm doing this for consistency, so that all the values for this enum
have the same prefix.

This is an automated commit, generated by the following shell commands:

for fn in $(git ls-tree --name-only -r HEAD src |grep '\.[ch]$'); do \
    perl -i -pe 's!\bTAKES_NO_ARGUMENT\b!ARGUMENT_NONE!g;' "$fn"; \
done
2019-10-08 12:59:22 -04:00
Nick Mathewson
c42a79499a Extract the enumeration that tells Tor what command it is running. 2019-10-08 12:59:18 -04:00
Nick Mathewson
53116ca0b7 Re-run "make autostyle" with improved annotate_ifdef_directives 2019-09-30 08:57:37 -04:00
George Kadianakis
9318682109 Merge branch 'tor-github/pr/1346' 2019-09-30 13:56:51 +03:00
Nick Mathewson
194dbea24d Run "make autostyle" with new "annotate_ifdef_directives" 2019-09-26 15:52:45 -04:00
teor
d1eab05834
lock: Avoid some undefined behaviour when freeing mutexes.
Fixes bug 31736; bugfix on 0.0.7.
2019-09-26 12:37:25 +10: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
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
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
0d6d96396c Remove all CVFLAG_* 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
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
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
Nick Mathewson
a642a4cbd7 Merge branch 'ticket30924_042_04_squashed' into ticket30924_042_04_squashed_merged 2019-09-09 11:10:53 -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
ddd01541b9 Merge branch 'tor-github/pr/1294' 2019-09-05 17:12:19 +03:00
George Kadianakis
c750ec20ab Merge branch 'tor-github/pr/1291' 2019-09-05 17:09:20 +03:00
Nick Mathewson
eb909c4e43 config: note that some arguments are required. 2019-09-05 07:57:36 -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
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
teor
a52a5e0099
Merge branch 'maint-0.3.5' into maint-0.4.0 2019-08-30 23:33:01 +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
Nick Mathewson
c281fa0da2 Describe clear_cfg_fn_t better. 2019-08-29 09:14:51 -04:00
Nick Mathewson
b1d7ddfb02 Merge branch 'ticket31240v2' into ticket31240v2_merged_2 2019-08-28 09:46:59 -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
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
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
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
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
2780cbb9cb Merge branch 'ticket30935' into ticket30935_merged 2019-08-22 17:25:35 -04:00
Nick Mathewson
edf5a327c5 Merge branch 'ticket30914' into ticket30914_merged 2019-08-20 13:57:05 -04:00
Nick Mathewson
c214402a56 Merge branch 'maint-0.4.1' 2019-08-19 10:37:22 -04:00
Nick Mathewson
90f4ed2335 Merge branch 'maint-0.3.5' into maint-0.4.0 2019-08-19 10:37:21 -04:00
Nick Mathewson
5653b93a1d Merge branch 'maint-0.2.9' into maint-0.3.5 2019-08-19 10:37:21 -04:00
Nick Mathewson
bba64c9882 Merge branch 'maint-0.4.0' into maint-0.4.1 2019-08-19 10:37:21 -04:00
teor
20943d00f1
Merge branch 'maint-0.3.5' into maint-0.4.0 2019-08-12 13:10:05 +10:00
teor
31fb2bceb5
Merge remote-tracking branch 'tor-github/pr/1066' into maint-0.3.5 2019-08-12 09:53:59 +10:00
teor
789fdbed05
Merge remote-tracking branch 'tor-github/pr/1065' into maint-0.3.5 2019-08-12 09:52:56 +10:00
teor
f65f4b5c38
Merge remote-tracking branch 'tor-github/pr/1020' into maint-0.3.5 2019-08-12 09:49:53 +10:00
David Goulet
c5b00c5a51 hs-v3: Add consensus parameters for DoS defenses
Part of #15516

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-08-06 07:58:14 -04:00
Nick Mathewson
57e87cc86c Use config_new() to construct configuration objects.
We'll need to do it this way once the objects become more complex.
2019-07-24 15:21:56 -04:00
Nick Mathewson
c32d485942 Remove src/core/ and src/feature dependencies from confparse.c
This C file will eventually belong in lib/confmgt, so it needs to
have only low-level dependencies.  Now that it no longers needs
routerset.c, we can adjust its includes accordingly.

I'm not moving the file yet, since it would make fixup commits on
earlier branches here really hard to do.
2019-07-24 15:21:56 -04:00
Nick Mathewson
a1b2817abe Sort variables in config_mgr_t.all_vars alphabetically 2019-07-24 15:21:56 -04:00
Nick Mathewson
f8b193a74a Make config_var and config_fmt const.
Now that we have a reasonable implementation for overriding the
default options for TestingTorNetwork, we don't need to modify
config_var_t structs any more.  And therefore, we can have constant
format options, like reasonable people.
2019-07-24 15:21:56 -04:00
Nick Mathewson
dde091ebc7 Add a "freeze" function for config_mgr_t objects.
It's important to make sure that we don't change a config_mgr_t
after we start using it to make objects, or we could get into
inconsistent states.  This feature is the start of a safety
mechanism to prevent this problem.
2019-07-24 15:21:56 -04:00
Nick Mathewson
f306d12b58 Refactor handling of TestingTorNetwork
Previously, when TestingTorNetwork was set, we would manually adjust
the initvalue members of a bunch of other config_var_t, and then
re-run the early parts or parsing the options.

Now we treat the initvalue fields as immutable, but instead assign
to them in options_init(), as early as possible.  Rather than
re-running the early parts of options, we just re-call the
options_init_from_string() function.

This patch de-kludges some of our code pretty handily.  I think it
could later handle authorities and fallbacks, but for now I think we
should leave those alone.
2019-07-24 15:21:56 -04:00
Nick Mathewson
7abd43ac5f Change CONFIG_CHECK() macro to not need a config_format_t
We'll want it to check all the subsidiary structures of the
options object.
2019-07-24 15:21:56 -04:00
Nick Mathewson
627ab9dba3 Fix every place in config.c that knew about option_vars_.
Iterating over this array was once a good idea, but now that we are
going to have a separate structure for each submodule's
configuration variables, we should indirect through the config_mgr_t
object.
2019-07-24 15:21:56 -04:00
Nick Mathewson
89a3051365 Lower responsibility for listing changed options into confparse.c 2019-07-24 15:21:56 -04:00
Nick Mathewson
7e91d4f572 Replace config_find_option with a variant that exposes less 2019-07-24 15:21:56 -04:00
Nick Mathewson
769fe81717 Start teaching config_mgr_t to handle sub-objects and sub-formats
The eventual design here will be that multiple config_format_t
objects get registered with a single config_mgr_t.  That
config_mgr_t manages a "top-level" object, which has a pointer to
the other objects.

I had earlier thought of a different design, where there would be no
top-level object, and config_mgr_t would deal with a container
instead.  But this would require a bunch of invasive refactoring
that I don't think we should do just yet.
2019-07-24 15:21:56 -04:00
Nick Mathewson
e8dc513bd0 Add a config_mgr_t type to wrap config_format_t
Remember that our goal in the present refactoring is to allow each
subsystem to declare its own configuration structure and
variables.  To do this, each module will get its own
config_format_t, and so we'll want a different structure that wraps
several config_format_t objects.  This is a "config_mgr_t".
2019-07-24 15:21:56 -04:00
David Goulet
ef2dd1ba96 Merge branch 'tor-github/pr/1116' 2019-07-23 09:46:29 -04:00
Nick Mathewson
c0ea6f9c64 Merge branch 'maint-0.4.1' 2019-07-01 14:25:13 -04:00
Nick Mathewson
2a42d6be27 Merge branch 'maint-0.3.5' into maint-0.4.0 2019-07-01 14:25:12 -04:00
Nick Mathewson
1dd9527897 Merge branch 'maint-0.2.9' into maint-0.3.5 2019-07-01 14:25:12 -04:00
Nick Mathewson
5e16601000 Merge branch 'maint-0.4.0' into maint-0.4.1 2019-07-01 14:25:12 -04:00
George Kadianakis
00acccac64 Merge branch 'tor-github/pr/1114' into maint-0.4.1 2019-06-26 10:51:12 +03:00
Nick Mathewson
f3330d2be3 Make "invisibility" and "undumpability" properties of variables.
Previously, these were magical things that we detected by checking
whether a variable's name was prefixed with two or three underscores.
2019-06-25 12:51:25 -04:00
Nick Mathewson
a7835202cf Turn several properties of types or variables into flags.
"unsettable" is a property of types.  LINELIST_V and OBSOLETE are
unsettable, meaning that they cannot be set by name.

"contained" is a property of types.  I'm hoping to find a better
name here.  LINELIST_S is "contained" because it always appears
within a LINELIST_V, and as such doesn't need to be dumped ore
copied independently.

"cumulative" is a property of types. Cumulative types can appear
more than once in a torrc without causing a warning, because they
add to each other rather than replacing each other.

"obsolete" is a property of variables.

"marking fragile" is now a command that struct members can accept.

With these changes, confparse and config no longer ever need to
mention CONFIG_TYPE_XYZ values by name.
2019-06-25 12:51:25 -04:00
Nick Mathewson
a114df9a04 Add a function to make sure all values in a config object are ok 2019-06-25 12:51:25 -04:00
Nick Mathewson
b6457d4c08 Extend macros to allow flag arguments. 2019-06-25 12:51:25 -04:00
Nick Mathewson
a91ed23403 Use structvar to find the types for config vars. 2019-06-25 12:51:25 -04:00
Nick Mathewson
53e969c137 Use struct_var_{copy,eq} in confparse.c. 2019-06-25 12:51:25 -04:00
Nick Mathewson
c553750e32 Move responsibility for config var macros
The testing-only parts now live in a conftesting.h; the shared parts
of the macros live in confmacros.h
2019-06-25 12:51:25 -04:00
Nick Mathewson
59317c8a23 Use struct_magic_decl to verify magic numbers in config objects 2019-06-25 12:51:25 -04:00
Nick Mathewson
4d101b39d7 Move config_var_t info conftypes.h 2019-06-25 12:51:25 -04:00
Nick Mathewson
3a4d67cf45 Port confparse to use struct_var in place of typed_var.
This requires changes to config_var_t, causing corresponding changes
throughout its users.
2019-06-25 12:51:25 -04:00