pub use std::iter::repeat_with;
pub use std::marker::PhantomData;
pub use std::num::{NonZeroUsize, TryFromIntError, Wrapping};
-pub use std::os::linux::fs::MetadataExt; // todo why linux for st_mode??
+pub use std::os::linux::fs::MetadataExt as _; // todo why linux for st_mode??
pub use std::os::unix;
pub use std::os::unix::ffi::OsStrExt;
-pub use std::os::unix::fs::OpenOptionsExt;
+pub use std::os::unix::fs::{MetadataExt, OpenOptionsExt};
pub use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
pub use std::os::unix::net::UnixStream;
pub use std::os::unix::process::{CommandExt, ExitStatusExt};
};
(||{
- let f = match File::open(path) {
+ let mut f = match File::open(path) {
Err(e) if e.kind() == ErrorKind::NotFound => return Ok(()),
x => x,
}.context("open")?;
- let l = BufReader::new(f).lines().next()
+ let l = BufReader::new(&mut f).lines().next()
.ok_or_else(|| anyhow!("no first line!"))?
.context("read first line")?;
if l == MAGIC_BANNER {
return Ok(());
}
+ if let Some(staticf) = &staticf {
+ let devino = |f: &File| f.metadata().map(|m| (m.dev(), m.ino()));
+ if devino(staticf).context("fstat static auth keys")? ==
+ devino(&f).context("fstat existing auth keys")? {
+ return Ok(());
+ }
+ }
Err(anyhow!(
"first line is not as expected (manually written/edited?)"
))