Struct fs_mistrust::Mistrust

source ·
pub struct Mistrust { /* private fields */ }
Expand description

Configuration for verifying that a file or directory is really “private”.

By default, we mistrust everything that we can: we assume that every directory on the filesystem is potentially misconfigured. This object can be used to change that.

Once you have a working Mistrust, you can call its “check_*” methods directly, or use verifier() to configure a more complicated check.

See the crate documentation for more information.

§TODO

  • support more kinds of trust configuration, including more trusted users, trusted groups, multiple trusted directories, etc?

Implementations§

source§

impl Mistrust

source

pub fn builder() -> MistrustBuilder

Return a new MistrustBuilder.

source

pub fn new() -> Self

Initialize a new default Mistrust.

By default:

  • we will inspect all directories that are used to resolve any path that is checked.
source

pub fn new_dangerously_trust_everyone() -> Self

Construct a new Mistrust that trusts all users and all groups.

(In effect, this Mistrust will have all of its permissions checks disabled, since if all users and groups are trusted, it doesn’t matter what the permissions on any file and directory are.)

source

pub fn verifier(&self) -> Verifier<'_>

Create a new Verifier with this configuration, to perform a single check.

source

pub fn check_directory<P: AsRef<Path>>(&self, dir: P) -> Result<()>

Verify that dir is a directory that only trusted users can read from, list the files in, or write to.

If it is, and we can verify that, return Ok(()). Otherwise, return the first problem that we encountered when verifying it.

m.check_directory(dir) is equivalent to m.verifier().require_directory().check(dir). If you need different behavior, see Verifier for more options.

source

pub fn make_directory<P: AsRef<Path>>(&self, dir: P) -> Result<()>

As check_directory, but create the directory if needed.

m.check_directory(dir) is equivalent to m.verifier().make_directory(dir). If you need different behavior, see Verifier for more options.

Trait Implementations§

source§

impl Clone for Mistrust

source§

fn clone(&self) -> Mistrust

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Mistrust

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Mistrust

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for Mistrust

source§

fn eq(&self, other: &Mistrust) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Mistrust

source§

impl StructuralPartialEq for Mistrust

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.