chiark / gitweb /
sshkeys: Allow the creation of a fresh auth keys file
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 1 Jun 2021 20:45:37 +0000 (21:45 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 1 Jun 2021 20:57:43 +0000 (21:57 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/sshkeys.rs

index 7ddacc8d3d8c20e4ef38355dc6e5c75d019a2bd0..c1e07314b0b4f6ef09429d59d66b31a1df0e5e91 100644 (file)
@@ -468,7 +468,10 @@ impl Global {
     let tmp = format!("{}.tmp", &path);
 
     (||{
-      let f = File::open(path).context("open")?;
+      let 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()
         .ok_or_else(|| anyhow!("no first line!"))?
         .context("read first line")?;