minor bump

This commit is contained in:
Vivian 2023-12-19 14:59:04 +01:00
parent 3c2daca7aa
commit 84f3dd55ef
4 changed files with 13 additions and 8 deletions

2
Cargo.lock generated
View file

@ -403,7 +403,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]] [[package]]
name = "gnome-autounlock-keyring" name = "gnome-autounlock-keyring"
version = "0.1.1" version = "0.2.0"
dependencies = [ dependencies = [
"base64 0.21.5", "base64 0.21.5",
"clap", "clap",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "gnome-autounlock-keyring" name = "gnome-autounlock-keyring"
version = "0.1.1" version = "0.2.0"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -7,7 +7,7 @@
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml)); cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) stdenv lib; inherit (pkgs) stdenv lib;
in rec { in rec {
@ -75,7 +75,7 @@
script = '' script = ''
${self.packages.${pkgs.system}.default}/bin/gnome-autounlock-keyring unlock ${self.packages.${pkgs.system}.default}/bin/gnome-autounlock-keyring unlock
''; '';
serviceConfig = { Type = "oneshot"; }; serviceConfig.Type = "oneshot";
}; };
}; };
}; };

View file

@ -7,7 +7,6 @@ use std::fs::{read_to_string, File};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::os::unix::net::UnixStream; use std::os::unix::net::UnixStream;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::exit;
use std::thread::sleep; use std::thread::sleep;
use std::time::Duration; use std::time::Duration;
use tpm::tpm_objects::TPM2Config; use tpm::tpm_objects::TPM2Config;
@ -152,10 +151,12 @@ fn main() -> color_eyre::Result<()> {
if token_path.exists() { if token_path.exists() {
let token = read_to_string(token_path)?; let token = read_to_string(token_path)?;
let mut res = ControlResult::NoDaemon;
for _ in 0..tries { for _ in 0..tries {
let password = let password =
tpm::perform_decrypt(token.as_bytes()).map_err(|err| eyre!("{err:?}"))?; 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 { if res == ControlResult::Ok {
break; break;
} else { } else {
@ -164,6 +165,11 @@ fn main() -> color_eyre::Result<()> {
sleep(Duration::from_secs(timeout)); sleep(Duration::from_secs(timeout));
} }
if res != ControlResult::Ok {
bail!("Unlocking failed after {tries}: {res:?}");
}
} else { } else {
bail!("password token file not found") bail!("password token file not found")
} }
@ -173,8 +179,7 @@ fn main() -> color_eyre::Result<()> {
let password = rpassword::prompt_password("Password: ")?; let password = rpassword::prompt_password("Password: ")?;
if unlock_keyring(password.as_bytes())? != ControlResult::Ok { if unlock_keyring(password.as_bytes())? != ControlResult::Ok {
eprintln!("invalid password"); bail!("invalid password");
exit(3);
} }
let token = tpm::perform_encrypt(TPM2Config::default(), password.as_bytes()) let token = tpm::perform_encrypt(TPM2Config::default(), password.as_bytes())