Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
crypto/ssh/keystore: Reduce scope of DirBuilderExt
Lorenz Leutgeb committed 11 months ago
commit b2932dd121bcdcfecbd4e7b853d4552806298cb6
parent fe6a11d0db4e8547c0bbfeadd91f7563f5098f2b
1 file changed +12 -5
modified crates/radicle-crypto/src/ssh/keystore.rs
@@ -1,5 +1,4 @@
use std::ops::Deref;
-
use std::os::unix::fs::DirBuilderExt;
use std::path::{Path, PathBuf};
use std::{fs, io};

@@ -94,10 +93,18 @@ impl Keystore {
            return Err(Error::AlreadyInitialized);
        }

-
        fs::DirBuilder::new()
-
            .recursive(true)
-
            .mode(0o700)
-
            .create(&self.path)?;
+
        {
+
            let mut builder = fs::DirBuilder::new();
+
            builder.recursive(true);
+

+
            #[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())?;
        public.write_openssh_file(&path.with_extension("pub"))?;