tolerate invalid config
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
shimun 2020-07-23 16:26:01 +02:00
parent 68cd2c581e
commit ec8d3cdb23
Signed by: shimun
GPG Key ID: E81D8382DC2F971B
4 changed files with 25 additions and 9 deletions

2
Cargo.lock generated
View File

@ -395,7 +395,7 @@ dependencies = [
[[package]] [[package]]
name = "pam_fido2" name = "pam_fido2"
version = "0.2.5" version = "0.2.7"
dependencies = [ dependencies = [
"ctap_hmac 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "ctap_hmac 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 3.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 3.1.4 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "pam_fido2" name = "pam_fido2"
version = "0.2.5" version = "0.2.7"
authors = ["shimun <shimun@shimun.net>"] authors = ["shimun <shimun@shimun.net>"]
edition = "2018" edition = "2018"

14
default.nix Normal file
View File

@ -0,0 +1,14 @@
{ pkgs ? import <nixpkgs> { }
, callPackage ? pkgs.callPackage
, name ? "pam_fido2"
}:
let
crate2nix_tools = import "${builtins.fetchTarball { url = "https://github.com/kolloch/crate2nix/archive/0.8.0.tar.gz"; }}/tools.nix" { };
overrides = pkgs.defaultCrateOverrides // {
pam_fido2 = attrs: with pkgs; {
buildInputs = [ linux-pam ];
};
};
project = callPackage (crate2nix_tools.generatedCargoNix { name = name; src = "${./.}"; }) { defaultCrateOverrides = overrides; };
in
project.rootCrate.build

View File

@ -90,13 +90,15 @@ impl Settings {
let re = Regex::new(&pattern).expect(&["Invalid regex pattern:", &pattern].join(" ")); let re = Regex::new(&pattern).expect(&["Invalid regex pattern:", &pattern].join(" "));
if re.is_match(user) { if re.is_match(user) {
let mut parts = cred.split(":"); let mut parts = cred.split(":");
//TODO: use expect match (parts.by_ref().next(), parts.by_ref().next()) {
let id = parts.by_ref().next().unwrap(); (Some(id), Some(key)) => {
let key = parts.by_ref().next().unwrap(); creds.push(ctap::FidoCredential {
creds.push(ctap::FidoCredential { id: hex::decode(id).unwrap(),
id: hex::decode(id).unwrap(), public_key: hex::decode(key).ok(),
public_key: hex::decode(key).ok(), });
}); }
_ => eprintln!("Failed to parse {}", cred),
}
} }
} }
creds creds