Skip to main content

DirectReader

Struct DirectReader 

Source
pub struct DirectReader { /* private fields */ }
Expand description

Opens the file itself and makes the checks sshd makes of authorized_keys.

On Unix, from the account’s real home down, one component at a time:

  • the path must lie under the account’s home; no directory on the way and not the file may be a symlink, or on another file system than the home;
  • the home, every directory below it on the path, and the file must be owned by the account’s uid (its uid attribute) or by root and must not be writable by group or others;
  • the file is opened without following a link and without blocking (O_NOFOLLOW, O_NONBLOCK), and what is read is the opened file, checked again: a regular file, the one the walk saw, of at most MAX_FILE_BYTES.

The walk and the read run on a thread the reader waits on for timeout (READ_TIMEOUT unless set), so a file system that never answers (a network or FUSE mount, a pipe put where the file should be) costs the caller that long and a refusal. The thread itself stays stuck until the file system answers. A reader lets one read wait per account (a hung mount in one person’s home stops that person, not the others) and at most max_waiting in all, and refuses further reads until some finish.

There is a gap no portable call closes: a directory above the file may be swapped between the walk and the open by someone who owns it (only the account, or root) and who is not the person being signed in. The checks make the account’s own writable paths the only ones that can be abused. Elsewhere than Unix it refuses everything, as those checks have no meaning there.

Implementations§

Source§

impl DirectReader

Source

pub fn new() -> Self

A reader with the default READ_TIMEOUT and MOST_WAITING.

Source

pub fn timeout(self, timeout: Duration) -> Self

How long one read waits on the file system before it is refused.

Source

pub fn max_waiting(self, most: usize) -> Self

How many reads may be stuck on the file system at once before further ones are refused without being tried.

Trait Implementations§

Source§

impl Clone for DirectReader

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DirectReader

Source§

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

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

impl Default for DirectReader

Source§

fn default() -> Self

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

impl PinFileReader for DirectReader

Source§

fn read(&self, account: &Person, path: &Path) -> Result<FileRead, ReadFailure>

The text of path, or why it may not be used.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.