Skip to main content

tor_config/
mistrust.rs

1//! Helpers for [`fs-mistrust`](fs_mistrust) configuration.
2
3use extend::ext;
4use fs_mistrust::{Mistrust, MistrustBuilder};
5
6use crate::ConfigBuildError;
7
8/// The environment variable we look at when deciding whether to disable FS permissions checking.
9pub const FS_PERMISSIONS_CHECKS_DISABLE_VAR: &str = "ARTI_FS_DISABLE_PERMISSION_CHECKS";
10
11/// Extension trait for `MistrustBuilder` to convert the error type on
12/// build.
13#[ext(name = BuilderExt)]
14pub impl MistrustBuilder {
15    /// Run this builder and convert its error type (if any)
16    fn build_for_arti(&self) -> Result<Mistrust, ConfigBuildError> {
17        self.clone()
18            .controlled_by_env_var_if_not_set(FS_PERMISSIONS_CHECKS_DISABLE_VAR)
19            .build()
20            .map_err(|e| ConfigBuildError::Invalid {
21                field: "permissions".to_string(),
22                problem: e.to_string(),
23            })
24    }
25}