From 70b31d8dc0de0d01d7fa58ef4e347ca51d858237 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 25 May 2025 09:57:46 +0200 Subject: [PATCH] Adding upstream version 0.5.8. Signed-off-by: Daniel Baumann --- .cargo_vcs_info.json | 2 +- CHANGELOG | 4 ++++ Cargo.lock | 2 +- Cargo.toml | 8 ++++---- Cargo.toml.orig | 2 +- src/default_prompt.rs | 6 +++--- src/lib.rs | 5 ++++- src/prompter.rs | 7 ------- src/ssh_key.rs | 1 + 9 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 139ee7f..c8741d8 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "527e6ada07ae24ab2f4811d8b0d6e9146c94bfe0" + "sha1": "3ba94e6efe2c59a4ffd2e6beb4bc96e958998979" }, "path_in_vcs": "" } \ No newline at end of file diff --git a/CHANGELOG b/CHANGELOG index 7d2601a..a578778 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +# Version 0.5.8 - 2025-05-23 +- [fix][minor] Fix loading of default ECDSA key. +- [add][patch] Log a warning when processing a private key in unknown format. + # Version 0.5.7 - 2025-02-13 - [change][patch] Update internal dependencies. diff --git a/Cargo.lock b/Cargo.lock index 5014254..3133e3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,7 +87,7 @@ dependencies = [ [[package]] name = "auth-git2" -version = "0.5.7" +version = "0.5.8" dependencies = [ "assert2", "clap", diff --git a/Cargo.toml b/Cargo.toml index c98cad7..4fa3500 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2021" name = "auth-git2" -version = "0.5.7" +version = "0.5.8" authors = ["Maarten de Vries "] build = false publish = ["crates-io"] @@ -35,6 +35,9 @@ categories = ["authentication"] license = "BSD-2-Clause" repository = "https://github.com/de-vri-es/auth-git2-rs" +[features] +log = ["dep:log"] + [lib] name = "auth_git2" path = "src/lib.rs" @@ -73,6 +76,3 @@ version = "0.11.6" [dev-dependencies.git2] version = ">=0.14, <21.0" - -[features] -log = ["dep:log"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index f575cba..d13bfad 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "auth-git2" -version = "0.5.7" +version = "0.5.8" description = "Authentication for `git2`" license = "BSD-2-Clause" authors = ["Maarten de Vries "] diff --git a/src/default_prompt.rs b/src/default_prompt.rs index 0b1641c..d7679f5 100644 --- a/src/default_prompt.rs +++ b/src/default_prompt.rs @@ -47,7 +47,7 @@ pub enum Error { AskpassExitStatus(AskpassExitStatusError), /// Password contains invalid UTF-8. - InvalidUtf8(std::string::FromUtf8Error), + InvalidUtf8, /// Failed to open a handle to the main terminal of the process. OpenTerminal(std::io::Error), @@ -153,7 +153,7 @@ fn askpass_prompt(program: &Path, prompt: &str) -> Result { .map_err(Error::AskpassCommand)?; if output.status.success() { let password = String::from_utf8(output.stdout) - .map_err(Error::InvalidUtf8)?; + .map_err(|_| Error::InvalidUtf8)?; Ok(password) } else { // Do not keep stdout, it could contain a password D: @@ -169,7 +169,7 @@ impl std::fmt::Display for Error { match self { Self::AskpassCommand(e) => write!(f, "Failed to run askpass command: {e}"), Self::AskpassExitStatus(e) => write!(f, "{e}"), - Self::InvalidUtf8(_) => write!(f, "User response contains invalid UTF-8"), + Self::InvalidUtf8 => write!(f, "User response contains invalid UTF-8"), Self::OpenTerminal(e) => write!(f, "Failed to open terminal: {e}"), Self::ReadWriteTerminal(e) => write!(f, "Failed to read/write to terminal: {e}"), } diff --git a/src/lib.rs b/src/lib.rs index 20f91c0..fbe1388 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -349,7 +349,7 @@ impl GitAuthenticator { let candidates = [ "id_rsa", - "id_ecdsa,", + "id_ecdsa", "id_ecdsa_sk", "id_ed25519", "id_ed25519_sk", @@ -615,6 +615,9 @@ impl PrivateKeyFile { None }, Ok(key_info) => { + if key_info.format == ssh_key::KeyFormat::Unknown { + warn!("Unknown key format for key: {}", self.private_key.display()); + } if key_info.encrypted { prompter.prompt_ssh_key_passphrase(&self.private_key, git_config) } else { diff --git a/src/prompter.rs b/src/prompter.rs index ef3c277..342b951 100644 --- a/src/prompter.rs +++ b/src/prompter.rs @@ -33,9 +33,6 @@ pub(crate) trait ClonePrompter: Prompter { /// Clone the `Box`. fn dyn_clone(&self) -> Box; - /// Get `self` as plain `Prompter`. - fn as_prompter(&self) -> &dyn Prompter; - /// Get `self` as plain `Prompter`. fn as_prompter_mut(&mut self) -> &mut dyn Prompter; } @@ -49,10 +46,6 @@ where Box::new(self.clone()) } - fn as_prompter(&self) -> &dyn Prompter { - self - } - fn as_prompter_mut(&mut self) -> &mut dyn Prompter { self } diff --git a/src/ssh_key.rs b/src/ssh_key.rs index b3a4428..5cdd49a 100644 --- a/src/ssh_key.rs +++ b/src/ssh_key.rs @@ -22,6 +22,7 @@ pub enum Error { } /// The format of a key file. +#[derive(Copy, Clone, Eq, PartialEq)] pub enum KeyFormat { /// We don't know what format it is. Unknown,