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

Initialize a new default Mistrust.

By default:

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

Set a path as an “ignored prefix” for all of our checks.

Any path that is a part of this prefix will be assumed to have valid permissions and ownership. For example, if you call ignore_prefix("/u1/users"), then we will not check /, /u1, or /u1/users.

A typical use of this function is to ignore ${HOME}/...

If this directory cannot be found or resolved, this function will return an error.

Configure this Mistrust to trust every user and every group.

With this option set, every file and directory is treated as having valid permissions: even world-writeable files are allowed. File-type checks are still performed.

This option is mainly useful to handle cases where you want to make these checks optional, and still use CheckedDir without having to implement separate code paths for the “checking on” and “checking off” cases.

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

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.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.