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
uidattribute) 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 mostMAX_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
impl DirectReader
Sourcepub fn new() -> Self
pub fn new() -> Self
A reader with the default READ_TIMEOUT and MOST_WAITING.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
How long one read waits on the file system before it is refused.
Sourcepub fn max_waiting(self, most: usize) -> Self
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.