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