minor bump
This commit is contained in:
parent
84a674f998
commit
db96c4a4eb
4 changed files with 13 additions and 8 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -403,7 +403,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
|||
|
||||
[[package]]
|
||||
name = "gnome-autounlock-keyring"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"base64 0.21.5",
|
||||
"clap",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "gnome-autounlock-keyring"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
|
||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs) stdenv lib;
|
||||
in rec {
|
||||
|
@ -75,7 +75,7 @@
|
|||
script = ''
|
||||
${self.packages.${pkgs.system}.default}/bin/gnome-autounlock-keyring unlock
|
||||
'';
|
||||
serviceConfig = { Type = "oneshot"; };
|
||||
serviceConfig.Type = "oneshot";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -7,7 +7,6 @@ use std::fs::{read_to_string, File};
|
|||
use std::io::{Read, Write};
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::path::PathBuf;
|
||||
use std::process::exit;
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
use tpm::tpm_objects::TPM2Config;
|
||||
|
@ -152,10 +151,12 @@ fn main() -> color_eyre::Result<()> {
|
|||
if token_path.exists() {
|
||||
let token = read_to_string(token_path)?;
|
||||
|
||||
let mut res = ControlResult::NoDaemon;
|
||||
|
||||
for _ in 0..tries {
|
||||
let password =
|
||||
tpm::perform_decrypt(token.as_bytes()).map_err(|err| eyre!("{err:?}"))?;
|
||||
let res = unlock_keyring(password.as_slice())?;
|
||||
res = unlock_keyring(password.as_slice())?;
|
||||
if res == ControlResult::Ok {
|
||||
break;
|
||||
} else {
|
||||
|
@ -164,6 +165,11 @@ fn main() -> color_eyre::Result<()> {
|
|||
|
||||
sleep(Duration::from_secs(timeout));
|
||||
}
|
||||
|
||||
if res != ControlResult::Ok {
|
||||
bail!("Unlocking failed after {tries}: {res:?}");
|
||||
}
|
||||
|
||||
} else {
|
||||
bail!("password token file not found")
|
||||
}
|
||||
|
@ -173,8 +179,7 @@ fn main() -> color_eyre::Result<()> {
|
|||
let password = rpassword::prompt_password("Password: ")?;
|
||||
|
||||
if unlock_keyring(password.as_bytes())? != ControlResult::Ok {
|
||||
eprintln!("invalid password");
|
||||
exit(3);
|
||||
bail!("invalid password");
|
||||
}
|
||||
|
||||
let token = tpm::perform_encrypt(TPM2Config::default(), password.as_bytes())
|
||||
|
|
Loading…
Reference in a new issue