feat: v1.3.3, remove dependency lazy_static
This commit is contained in:
@@ -16,13 +16,10 @@ use ssh_agent::proto::message::{self, Message};
|
||||
use ssh_agent::proto::public_key::PublicKey;
|
||||
|
||||
use crate::digest::{copy_sha256, copy_sha512};
|
||||
use crate::sshutil::with_sign;
|
||||
|
||||
lazy_static! {
|
||||
static ref CARD: Mutex<Option<PcscBackend>> = Mutex::new(None);
|
||||
}
|
||||
use crate::sshutil::{generate_ssh_string, with_sign};
|
||||
|
||||
struct SshAgent {
|
||||
card: Mutex<PcscBackend>,
|
||||
use_sign: bool,
|
||||
pin: String,
|
||||
public_key: PublicKey,
|
||||
@@ -54,13 +51,10 @@ impl SshAgent {
|
||||
n: with_sign(n.to_vec()),
|
||||
});
|
||||
let comment = format!("pgp-card:{}:{}", iff!(use_sign, "sign", "auth"), serial);
|
||||
(public_key, comment.clone(), crate::sshutil::generate_ssh_string(e, n, &comment))
|
||||
(public_key, comment.clone(), generate_ssh_string(e, n, &comment))
|
||||
};
|
||||
{
|
||||
let mut card_mutex = CARD.lock().unwrap();
|
||||
*card_mutex = Some(card);
|
||||
}
|
||||
Ok(Self {
|
||||
card: Mutex::new(card),
|
||||
use_sign,
|
||||
pin,
|
||||
public_key,
|
||||
@@ -104,12 +98,8 @@ impl SshAgent {
|
||||
};
|
||||
|
||||
information!("SSH request, algorithm: {}", algorithm);
|
||||
let mut card_mutex = CARD.lock().unwrap();
|
||||
let card_mut = match card_mutex.as_mut() {
|
||||
Some(card) => card,
|
||||
None => return Err(From::from("Illegal card status: none")),
|
||||
};
|
||||
let mut pgp = OpenPgp::new(card_mut);
|
||||
let mut card_mut = self.card.lock().unwrap();
|
||||
let mut pgp = OpenPgp::new(&mut *card_mut);
|
||||
let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}");
|
||||
let sig = if self.use_sign {
|
||||
debugging!("User pin verify for pw1 sign, use sign: {}", self.use_sign);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#[macro_use]
|
||||
extern crate rust_util;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
use clap::{App, AppSettings, ArgMatches};
|
||||
use rust_util::util_clap::{Command, CommandError};
|
||||
|
||||
Reference in New Issue
Block a user