Resolve pam services not always having a tty (#3176)

This commit is contained in:
Firstyear 2024-11-05 10:49:33 +10:00 committed by William Brown
parent 770efa80f0
commit 78ced241eb
4 changed files with 6 additions and 5 deletions

View file

@ -106,7 +106,8 @@ pub enum PamAuthRequest {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct PamServiceInfo { pub struct PamServiceInfo {
pub service: String, pub service: String,
pub tty: String, // Somehow SDDM doesn't set this ...
pub tty: Option<String>,
// Only set if it really is a remote host? // Only set if it really is a remote host?
pub rhost: Option<String>, pub rhost: Option<String>,
} }
@ -147,7 +148,7 @@ impl ClientRequest {
"PamAuthenticateInit{{ account_id={} tty={} pam_secvice{} rhost={} }}", "PamAuthenticateInit{{ account_id={} tty={} pam_secvice{} rhost={} }}",
account_id, account_id,
info.service, info.service,
info.tty, info.tty.as_deref().unwrap_or(""),
info.rhost.as_deref().unwrap_or("") info.rhost.as_deref().unwrap_or("")
), ),
ClientRequest::PamAuthenticateStep(_) => "PamAuthenticateStep".to_string(), ClientRequest::PamAuthenticateStep(_) => "PamAuthenticateStep".to_string(),

View file

@ -256,7 +256,7 @@ impl PamHandle {
tracing::debug!(?maybe_tty, ?maybe_rhost, ?maybe_service); tracing::debug!(?maybe_tty, ?maybe_rhost, ?maybe_service);
match (maybe_tty, maybe_rhost, maybe_service) { match (maybe_tty, maybe_rhost, maybe_service) {
(Some(tty), rhost, Some(service)) => Ok(PamServiceInfo { (tty, rhost, Some(service)) => Ok(PamServiceInfo {
service, service,
tty, tty,
rhost, rhost,

View file

@ -67,7 +67,7 @@ async fn main() -> ExitCode {
account_id: account_id.clone(), account_id: account_id.clone(),
info: PamServiceInfo { info: PamServiceInfo {
service: "kanidm-unix".to_string(), service: "kanidm-unix".to_string(),
tty: "/dev/null".to_string(), tty: None,
rhost: None, rhost: None,
}, },
}; };

View file

@ -1086,7 +1086,7 @@ impl Resolver {
let pam_info = PamServiceInfo { let pam_info = PamServiceInfo {
service: "kanidm-unix-test".to_string(), service: "kanidm-unix-test".to_string(),
tty: "/dev/null".to_string(), tty: Some("/dev/null".to_string()),
rhost: None, rhost: None,
}; };