Merge pull request #1697 from zcash/1686-zcb-tor-dir-perms
zcash_client_backend: Allow disabling Tor directory permissions tightening
This commit is contained in:
commit
ad503f7219
|
@ -6158,6 +6158,7 @@ dependencies = [
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"document-features",
|
"document-features",
|
||||||
"dynosaur",
|
"dynosaur",
|
||||||
|
"fs-mistrust",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"group",
|
"group",
|
||||||
"gumdrop",
|
"gumdrop",
|
||||||
|
|
|
@ -158,6 +158,7 @@ incrementalmerkletree-testing = "0.3"
|
||||||
# failure due to incompatible `libsqlite3-sys` versions.
|
# failure due to incompatible `libsqlite3-sys` versions.
|
||||||
arti-client = { version = "0.23", default-features = false, features = ["compression", "rustls", "tokio"] }
|
arti-client = { version = "0.23", default-features = false, features = ["compression", "rustls", "tokio"] }
|
||||||
dynosaur = "0.1.1"
|
dynosaur = "0.1.1"
|
||||||
|
fs-mistrust = "0.8"
|
||||||
tokio = "1"
|
tokio = "1"
|
||||||
tor-rtcompat = "0.23"
|
tor-rtcompat = "0.23"
|
||||||
tower = "0.4"
|
tower = "0.4"
|
||||||
|
|
|
@ -11,6 +11,9 @@ and this library adheres to Rust's notion of
|
||||||
- MSRV is now 1.81.0.
|
- MSRV is now 1.81.0.
|
||||||
- Migrated to `bip32 =0.6.0-pre.1`, `nonempty 0.11`, `incrementalmerkletree 0.8`,
|
- Migrated to `bip32 =0.6.0-pre.1`, `nonempty 0.11`, `incrementalmerkletree 0.8`,
|
||||||
`shardtree 0.6`.
|
`shardtree 0.6`.
|
||||||
|
- `zcash_client_backend::tor`:
|
||||||
|
- `tor::Client::create` now takes an optional `with_permissions` argument for
|
||||||
|
configuring `fs_mistrust::Mistrust`.
|
||||||
- `zcash_client_backend::wallet::Recipient` has changed:
|
- `zcash_client_backend::wallet::Recipient` has changed:
|
||||||
- The `Recipient::External` variant is now a structured variant.
|
- The `Recipient::External` variant is now a structured variant.
|
||||||
- The `Recipient::EphemeralTransparent` variant is now only available if
|
- The `Recipient::EphemeralTransparent` variant is now only available if
|
||||||
|
|
|
@ -120,6 +120,7 @@ crossbeam-channel.workspace = true
|
||||||
rayon.workspace = true
|
rayon.workspace = true
|
||||||
|
|
||||||
# - Tor
|
# - Tor
|
||||||
|
fs-mistrust = { workspace = true, optional = true }
|
||||||
tokio = { workspace = true, optional = true, features = ["fs"] }
|
tokio = { workspace = true, optional = true, features = ["fs"] }
|
||||||
tor-rtcompat = { workspace = true, optional = true }
|
tor-rtcompat = { workspace = true, optional = true }
|
||||||
tower = { workspace = true, optional = true }
|
tower = { workspace = true, optional = true }
|
||||||
|
@ -201,6 +202,7 @@ sync = [
|
||||||
tor = [
|
tor = [
|
||||||
"dep:arti-client",
|
"dep:arti-client",
|
||||||
"dep:dynosaur",
|
"dep:dynosaur",
|
||||||
|
"dep:fs-mistrust",
|
||||||
"dep:futures-util",
|
"dep:futures-util",
|
||||||
"dep:http-body-util",
|
"dep:http-body-util",
|
||||||
"dep:hyper",
|
"dep:hyper",
|
||||||
|
|
|
@ -24,20 +24,33 @@ impl Client {
|
||||||
/// Preserving the contents of this directory will speed up subsequent calls to
|
/// Preserving the contents of this directory will speed up subsequent calls to
|
||||||
/// `Client::create`.
|
/// `Client::create`.
|
||||||
///
|
///
|
||||||
|
/// If `with_permissions` is `None`, the default from [`arti_client`] will be used
|
||||||
|
/// (enable permissions checks unless the `ARTI_FS_DISABLE_PERMISSION_CHECKS` env
|
||||||
|
/// variable is set).
|
||||||
|
///
|
||||||
/// Returns an error if `tor_dir` does not exist, or if bootstrapping fails.
|
/// Returns an error if `tor_dir` does not exist, or if bootstrapping fails.
|
||||||
pub async fn create(tor_dir: &Path) -> Result<Self, Error> {
|
pub async fn create(
|
||||||
|
tor_dir: &Path,
|
||||||
|
with_permissions: Option<impl FnOnce(&mut fs_mistrust::MistrustBuilder)>,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
let runtime = PreferredRuntime::current()?;
|
let runtime = PreferredRuntime::current()?;
|
||||||
|
|
||||||
if !tokio::fs::try_exists(tor_dir).await? {
|
if !tokio::fs::try_exists(tor_dir).await? {
|
||||||
return Err(Error::MissingTorDirectory);
|
return Err(Error::MissingTorDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = TorClientConfigBuilder::from_directories(
|
let mut config_builder = TorClientConfigBuilder::from_directories(
|
||||||
tor_dir.join("arti-data"),
|
tor_dir.join("arti-data"),
|
||||||
tor_dir.join("arti-cache"),
|
tor_dir.join("arti-cache"),
|
||||||
)
|
);
|
||||||
.build()
|
|
||||||
.expect("all required fields initialized");
|
if let Some(f) = with_permissions {
|
||||||
|
f(config_builder.storage().permissions());
|
||||||
|
}
|
||||||
|
|
||||||
|
let config = config_builder
|
||||||
|
.build()
|
||||||
|
.expect("all required fields initialized");
|
||||||
|
|
||||||
let client_builder = TorClient::with_runtime(runtime).config(config);
|
let client_builder = TorClient::with_runtime(runtime).config(config);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue