Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gethostname = "1.1.0"
hex = "0.4.3"
libc = "0.2.186"
log = "0.4.31"
pam-bindings = "0.1.2"
pam-bindings = "0.2.1"
serde = "1.0.228"
serde_json = "1.0.150"
whoami = "2.1.0"
4 changes: 2 additions & 2 deletions pam/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub fn authenticate_impl(
"failed to send prompt"
) {
Some(password) => match password.to_str() {
Ok(t) => t,
Ok(t) => t.to_owned(),
Err(_) => {
log::warn!("failed to convert password");
return PamResultCode::PAM_AUTH_ERR;
Expand Down Expand Up @@ -102,7 +102,7 @@ pub fn authenticate_impl(
log::debug!("Token authentication");
let raw_token = password
.strip_prefix(PW_PREFIX)
.unwrap_or(password)
.unwrap_or(&password)
.to_string();
let decoded = match decode_pb::<SshTokenAuthentication>(raw_token) {
Ok(t) => t,
Expand Down
26 changes: 15 additions & 11 deletions pam/src/auth/fido.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,29 @@ pub fn fido2(raw: String, conv: &Conv<'_>) -> Result<FidoResponse, Box<dyn Error
up: true,
};

if req.uv {
let pin_cstring: Option<std::ffi::CString> = if req.uv {
match conv.send(PAM_PROMPT_ECHO_OFF, "Input Security key PIN: ") {
Ok(c) => match c {
Some(c) => match c.to_str() {
Ok(cc) => {
assertion_args.pin = Some(cc);
assertion_args.uv = None;
}
Err(e) => return Err(Box::from(e)),
},
Some(c) => Some(c),
None => {
log::warn!("Failed to get PIN");
return Err(Box::from("failed to get pin"));
}
},
Err(_) => {
return Err(Box::from("failed to get pin"));
Err(_) => return Err(Box::from("failed to get pin")),
}
} else {
None
};

if let Some(ref pc) = pin_cstring {
match pc.to_str() {
Ok(cc) => {
assertion_args.pin = Some(cc);
assertion_args.uv = None;
}
};
Err(e) => return Err(Box::from(e)),
}
}

pam_print_user(conv, "Touch your security key...");
Expand Down
4 changes: 2 additions & 2 deletions pam/src/auth/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub fn auth_interactive(
let credential = match conv.send(style, &challenge.prompt) {
Ok(c) => match c {
Some(c) => match c.to_str() {
Ok(cc) => cc,
Ok(cc) => cc.to_owned(),
Err(_) => {
log::warn!("failed to convert PAM Conversation response to string");
return Err(PamResultCode::PAM_ABORT);
Expand All @@ -152,7 +152,7 @@ pub fn auth_interactive(
return Err(e);
}
};
req_inner.value = credential.to_owned();
req_inner.value = credential;
}
Err(_) => {
log::warn!(
Expand Down
Loading