Commit Graph

335 Commits

Author SHA1 Message Date
Nick Mathewson
d3af23783c Document our top-level directories 2019-11-04 07:40:20 -05:00
Nick Mathewson
7fc077ed25 Add stub directory-level documentation for most source directories
This includes app, core, feature, lib, and tools, but excludes
ext, test, and trunnel.

This was generated by the following shell script:

cd src
for dname in $(find lib core feature app tools -type d |grep -v \\.deps$); do
    keyword="$(echo "$dname" |sed -e "s/\//_/" )"
    target="${dname}/${keyword}.dox"
    echo "$target"
    cat <<EOF >"$target"
/**
@dir ${dname}
@brief ${dname}
**/
EOF

    git add "$target"
done
2019-11-04 07:40:14 -05:00
teor
a18e84ad01
config: Improve some function comments 2019-10-31 11:11:51 +10:00
teor
4666ca73a1
config: Give warn_about_relative_paths() const args
Also gives make_path_absolute() const args.

Obviously correct fixes to already reviewed code.
2019-10-31 10:53:26 +10:00
Nick Mathewson
5a1dfca071 Fix 32167: comment in config.c 2019-10-30 16:05:48 -04:00
teor
30705e8294
app/config: Fix a comment typo in config.c
The options validation is now a callback.

Bugfix on 31241; not in any released version of tor.
2019-10-29 12:40:20 +10:00
David Goulet
b98631d280 Merge branch 'tor-github/pr/1476' 2019-10-28 08:47:57 -04:00
Nick Mathewson
30c6ab5150 doxygen: add @file declarations for src/app
If a file doesn't use the file command (either \file or @file),
Doxygen won't try to process it.
2019-10-26 11:41:43 -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
63f2a310cb config,state: check magic in all callbacks. 2019-10-25 08:09:05 -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
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
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
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
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
339c18d6c7
Tidy whitespace around some STMT_BEGINs and STMT_ENDs 2019-10-23 07:37:39 +10: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
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
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
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
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
ac3136a6fb Make options_init_logs STATIC for testing. 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
teor
57e86a6d74
relay: Implement HAVE_MODULE_RELAY for routermode.c
Part of 32123.
2019-10-20 19:26:48 +10: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
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
Nick Mathewson
6a2057a9f2 or_options_st.h: repair some doxygen comments. 2019-10-16 12:05:17 -04:00
Nick Mathewson
5e5e655e32 Doxygen: Fix mismatched filenames.
In 8 places, our \file declarations didn't match the actual files
they were in.
2019-10-16 08:18:26 -04:00
Nick Mathewson
911b16e6e7 config.c: make a couple of arguments const.
These functions do not modify their inputs, so they can take const
arguments.
2019-10-08 12:59:22 -04:00
Nick Mathewson
bd5ce112c9 Use C99 struct-initializer syntax in COMMANDLINE_ONLY_OPTIONS
I'm about to add more fields to this table, and this syntax change
will make it easier to do so.
2019-10-08 12:59:22 -04:00