Commit Graph

3095 Commits

Author SHA1 Message Date
Nick Mathewson c09a613590 fs-mistrust: refactor ResolvePath to avoid temporary changes.
Previously we would temporarily put self.resolved into an invalid
state by adding a path component that might be a symlink.  With this
change, we create a new temporary path object (using Cow to avoid
unnecessary allocations) and only conditionally replace
self.resolved.
2022-05-03 10:03:32 -04:00
Nick Mathewson 8e25954c49 fs-mistrust: clarify and test behavior for ".." past the fs root. 2022-05-03 10:03:32 -04:00
Nick Mathewson c9e17c5aaa Add a must_use (suggested by @diziet). 2022-05-03 10:03:32 -04:00
Nick Mathewson 7254fc60eb fs-mistrust: more examples, documentation. 2022-05-03 10:03:32 -04:00
Nick Mathewson 7f27744ef7 Add a SecureDir API for checked access to directories
The only way to get a SecureDir is by having checked a directory.
Once you have one, it encourages you to open and create files and
directories with the right permissions, and checks them for you.
2022-05-03 10:03:32 -04:00
Nick Mathewson 75633109c2 Add functionality to inspect directory content permissions
Also, explain _why_ this is pretty important.
2022-05-03 10:03:32 -04:00
Nick Mathewson d574afa230 By default, forbid special files. 2022-05-03 10:03:32 -04:00
Nick Mathewson 2042d0934b Support for "create missing directory". 2022-05-03 10:03:32 -04:00
Nick Mathewson 712b46174d Add support for trusted group IDs. 2022-05-03 10:03:32 -04:00
Nick Mathewson c4a6c6d82e Implement support for the Sticky Bit. 2022-05-03 10:03:32 -04:00
Nick Mathewson c4a5a49b55 Second cut at a fs-mistrust crate.
This crate is meant to solve #315 by giving a way to make sure that
a file or directory is only accessible by trusted users.  I've tried
to explain carefully (in comments and documentation) what this crate
is doing and why, under the assumption that it will someday be read
by another person like me who does _not_ live and breathe unix file
permissions.  The crate is still missing some key features, noted in
the TODO section.

It differs from the first version of the crate by taking a more
principled approach to directory checking: it emulates the path
lookup process (reading symlinks and all) one path change at a time,
thus ensuring that we check every directory which could enable
an untrusted user to get to our target file, _or_ which could
enable them to get to any symlink that would get them to the target
file.

The API is also slightly different: It separates the `Mistrust`
object (where you configure what you do or do not trust) from the
`Verifier` (where you set up a check that you want to perform on a
single object).  Verifiers are set up to be a bit ephemeral,
so that it is hard to accidentally declare that _every_ object
is meant to be readable when you only mean that _some_ objects
may be readable.
2022-05-03 10:03:32 -04:00
eta a566f82d40 Merge branch 'config-sub' into 'main'
Replace much handwritten config code with use of derive_builder

See merge request tpo/core/arti!462
2022-04-22 17:15:27 +00:00
Ian Jackson 89824fc7ea arti-client: TorClientConfig: derive TorClientConfigBuilder
Replace handwritten builder struct, accessors, and builder function.
2022-04-22 17:48:03 +01:00
Ian Jackson 6da5c9af5e arti: ArtiConfig: derive ArtiConfigBuilder
Replace handwritten builder struct, accessors, and builder function.
2022-04-22 17:48:03 +01:00
Ian Jackson 79decd4ac8 logfiles: Introduce LogfileListConfigBuilder
In
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697
we decided not to do this.

However, having looked again at the way the FallbackList works, I
think there is a lot of value in making these two things (and anything
else like them[1]) as similar as possible.

[1] At least PreemptiveCircuitConfig.initial_predicted_ports and
NetworkConfig.authorities need the same treatment, and perhaps also
GuardUsage.restrictions (although there is no
GuardRestrictionBuilder).

In the irc discussion I imagined `LogfilesConfigBuilder` as opposed to
`LogfileConfigBuilder` (differing only in the `s`) which would be bad,
but we can use `List` instead.

We do *not* need to abstract away the validated version of the config.
Providing a type alias helps the derive_builder sub_builder DTRT
without needing special overrides.

I have split this commit so that we can drop it, if we conclude it's
not wanted.
2022-04-22 17:48:03 +01:00
Ian Jackson 33565ea618 logfiles: Adjust LoggingConfigBuilder::file and impl Deserialize
Change LoggingConfigBuilder to contain Vec<LogfileConfigBuilder>,
not Option<Vec<LogfileConfig>>.  That makes it sane to Deserialize.

Replace LoggingConfigBuilder's file(Vec<>) setter with the methods
discussed in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697
2022-04-22 17:48:03 +01:00
Ian Jackson 211cb1958e logfiles Rename LogfileConfig::file to files
It's a plural, and that fact is going to be exposed via serde, if it
isn't already.
2022-04-22 17:48:03 +01:00
Ian Jackson 962b6c32e1 fallback list: Introduce and use FallbackListBuilder
Now the network fallbacks configuration wants to Deserialize
a Vec<FallbackDirBuilder>, rather than validated Vec<FallbackDir>.

Methods on FallbackListBuilder are as per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697
mutatis mutandi for the fact that this struct has only fallbacks in it.
2022-04-22 17:48:03 +01:00
Ian Jackson 61425a96bd fallback list: Move default list into tor-guardmgr
This is where the FallbackList type is.  We are going to want to
provide a builder too, which ought to impl Default.

This means that the default value for the type must be next to the
type.  In any case, it was anomalous that it wasn't.

This commit is pure code motion.
2022-04-22 17:39:58 +01:00
Ian Jackson 91a8bc0c11 impl From<SubfieldBuildError> for ConfigBuildError
We are going to be using sub-field builders.
2022-04-22 16:46:32 +01:00
Ian Jackson 6da7a2e3e2 Use git source for derive_builder for now, for sub_builder feature
This commitid is the current head of my MR branch
  https://github.com/colin-kiegel/rust-derive-builder/pull/253
  https://github.com/ijackson/rust-derive-builder/tree/field-builder
Using the commitid prevents surprises if that branch is updated.

We will require this newer version of derive_builder.  The version
will need to be bumped again later, assuming the upstream MR is merged
and upstream do a release containing the needed changes.

We will need the new version of not only `derive_builder_core` (the
main macro implementation) but also`derive_builder` for a new error
type.
2022-04-21 14:07:28 +01:00
eta 225accd67e Merge branch 'typos' into 'main'
Fix typos

See merge request tpo/core/arti!461
2022-04-20 15:37:33 +00:00
Samanta Navarro ee78bd7f84 Use https instead of http
Keep http in license text.
2022-04-20 11:48:55 +00:00
Samanta Navarro d3031b437b Fix wording in FAQ 2022-04-20 11:48:45 +00:00
Samanta Navarro 142e57b03a Fix typos
Typos found with codespell.
2022-04-20 11:48:43 +00:00
Nick Mathewson ac8d444aa3 Merge branch 'ticket_282' into 'main'
Remove obsolete files from our state directory.

Closes #282

See merge request tpo/core/arti!457
2022-04-14 12:18:30 +00:00
Nick Mathewson 2847a57a1e Fix build with Rust 1.53; we can't use map_while 2022-04-14 07:32:05 -04:00
Ian Jackson b1d375c785 tor-persist::fs::clean: Log warnings for directory read failures 2022-04-14 10:14:03 +01:00
Nick Mathewson 93cd0bc383 tor-persist::fs::clean: Tweaks based on review.
Rename "deletable" to "obsolete".

Simplify function structure.

Report errors from `metadata()` and `modified()`.

Don't claim that we're going to delete something unless we are.

Comment about making CUTOFF configurable.
2022-04-13 19:44:52 -04:00
eta 41dd682552 Merge branch 'report-skew' into 'main'
Report skew estimates from arti-client

See merge request tpo/core/arti!455
2022-04-13 12:51:23 +00:00
Nick Mathewson 64699a2b99 Remove obsolete files from our state directory.
This patch removes files created by older versions of arti, if they
are at least 4 weeks old.

Closes #282
2022-04-12 17:15:05 -04:00
Nick Mathewson 526b00c9b2 Re-indent tor-persist/Cargo.toml. 2022-04-12 13:39:32 -04:00
eta 9689468a3a Merge branch 'typo' into 'main'
Fix typos

See merge request tpo/core/arti!453
2022-04-12 17:34:10 +00:00
eta bd28cd5bb7 Merge branch 'backoff_on_preemptive_circs' into 'main'
circmgr: back off on preemptive circuits if they fail consistently

Closes #437

See merge request tpo/core/arti!456
2022-04-12 17:33:45 +00:00
Nick Mathewson 4582dddca8 circmgr: back off on preemptive circuits if they fail consistently
Rather than running preemptive circuit construction every 10
seconds, we change it to back off when it is "failing".  (We define
"failing" as creating no new circuits, and as giving at least one
error.)

This change means that we'll have one less reason to hammer the
network when our connectivity is failed for some reason.

Closes #437.
Part of #329.
2022-04-12 09:19:10 -04:00
Nick Mathewson 482c022e23 circmgr: Remove now-unused scheduled entry points.
Now that we have TaskSchedule, we don't need to expose these any
longer.
2022-04-12 09:04:10 -04:00
Nick Mathewson 3d5276a9cc circmgr: Report CircProvenance from AbstractCircMgr.
This feature is similar to ChanProvenance from ChanMgr, except that
we don't yet need to report it outside the crate.  I'm going to use
it to distinguish newly created circuits from existing circuits in
the preemptive circuit builder.
2022-04-12 08:41:32 -04:00
Nick Mathewson 11a9091602 arti-client: Report clock skew when it is noteworthy
(Also, blame clock skew when it is an explanation of why we cannot
finish a connection.)
2022-04-12 08:03:49 -04:00
Nick Mathewson 5f946b8d45 chanmgr: expose whether we are failing because of expired certs. 2022-04-12 08:03:49 -04:00
Nick Mathewson 72f00daf12 circmgr: re-export clock skew estimates. 2022-04-12 08:03:49 -04:00
Nick Mathewson 5f5cbdc08e GuardMgr: publish skew estimates.
Instead of just having a function that recalculates the latest clock
skew, instead recalculate the clock skew when it may have changed,
and notify other processes via a postage::watch.
2022-04-12 08:03:49 -04:00
eta 5c1e7db01e Merge branch 'guardmgr_test_fix' into 'main'
guardmgr: fix a unit test panic.

See merge request tpo/core/arti!454
2022-04-11 18:40:14 +00:00
Dimitris Apostolou ea283584f5
Fix typos 2022-04-11 21:21:17 +03:00
Nick Mathewson 61080dcaec guardmgr: fix a unit test panic.
Apparently on OSX you are not allowed to construct an Instant that is a
long time before the time when the test is running.

Also, fix the length of a year in this test.
2022-04-11 14:13:17 -04:00
Nick Mathewson 9f7a80b5f2 Merge branch 'record-skew-v3' into 'main'
Collect and analyze clock skew information

See merge request tpo/core/arti!450
2022-04-11 17:27:14 +00:00
Nick Mathewson 4efe45ce6e handshake.rs: Document the time for clock skew authentication. 2022-04-11 12:34:16 -04:00
Nick Mathewson c909926302 Fold FallbackStatus into Entry.
This simplifies the code a lot.
2022-04-11 12:34:16 -04:00
Nick Mathewson 452e1c0935 Add a couple of TODO items to clock-skew estimator. 2022-04-11 12:34:16 -04:00
Nick Mathewson cf362fac9f Implement a better clock skew estimator.
This time, our estimator discards outliers, takes the mean of what's
left, and uses the standard deviation to try to figure out how
seriously to take our report of skew/not-skew.

These estimates are still not actually used.
2022-04-11 12:34:16 -04:00
Nick Mathewson adb94f8047 Merge branch 'cargo-audit' into 'main'
fix maint/cargo_audit not propagating error and add temporary exceptions

See merge request tpo/core/arti!452
2022-04-08 15:55:05 +00:00