crypto/ssh/keystore: Reduce scope of DirBuilderExt
Directory builder extensions are platform specific and only available on Unix. Move their use into a conditionally compiled block, so that we can build on Windows.
This commit is contained in:
parent
37ea81766e
commit
92d77f9ec3
|
|
@ -1,5 +1,4 @@
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::os::unix::fs::DirBuilderExt;
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::{fs, io};
|
use std::{fs, io};
|
||||||
|
|
||||||
|
|
@ -94,10 +93,18 @@ impl Keystore {
|
||||||
return Err(Error::AlreadyInitialized);
|
return Err(Error::AlreadyInitialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::DirBuilder::new()
|
{
|
||||||
.recursive(true)
|
let mut builder = fs::DirBuilder::new();
|
||||||
.mode(0o700)
|
builder.recursive(true);
|
||||||
.create(&self.path)?;
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
use std::os::unix::fs::DirBuilderExt as _;
|
||||||
|
builder.mode(0o700);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.create(&self.path)?;
|
||||||
|
}
|
||||||
|
|
||||||
secret.write_openssh_file(&path, ssh_key::LineEnding::default())?;
|
secret.write_openssh_file(&path, ssh_key::LineEnding::default())?;
|
||||||
public.write_openssh_file(&path.with_extension("pub"))?;
|
public.write_openssh_file(&path.with_extension("pub"))?;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue