From ba5fa16cc120aeacb78abd654db4f4bc00b18100 Mon Sep 17 00:00:00 2001 From: Michael Pfaff Date: Fri, 9 Jun 2023 09:31:17 -0400 Subject: [PATCH] Use upstream pam_client on non-macos platforms --- Cargo.lock | 17 ++++++++++++++++- Cargo.toml | 7 ++++++- src/main.rs | 7 ++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c695ae..67abc94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -517,6 +517,20 @@ dependencies = [ "serde", ] +[[package]] +name = "pam-client" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bd776116a7ada5ebbe31f54cdc5b1030ed7265686cf7c8a21c057a2f8dab9a" +dependencies = [ + "bitflags", + "enum-repr", + "libc", + "pam-sys", + "rustversion", + "serde", +] + [[package]] name = "pam-sys" version = "1.0.0-alpha4" @@ -677,7 +691,8 @@ dependencies = [ "flume", "libc", "nix", - "pam-client", + "pam-client 0.5.0", + "pam-client 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot", "pin-project-lite", "quinn", diff --git a/Cargo.toml b/Cargo.toml index ed5c8e3..8981b35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ fast-hex = { git = "https://git.pfaff.dev/michael/fast-hex.git", version = "0.1. flume = "0.10.14" libc = "0.2.145" nix = "0.26.2" -pam-client = { version = "0.5.0", path = "../../../../../Users/michael/b/rust-pam-client", default-features = false, features = ["serde"] } parking_lot = "0.12.1" pin-project-lite = "0.2.9" quinn = "0.10.1" @@ -29,3 +28,9 @@ tokio = { version = "1.28.2", default-features = false, features = ["rt-multi-th tracing = "0.1.37" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } triggered = "0.1.2" + +[target.'cfg(not(target_os = "macos"))'.dependencies] +pam-client = { version = "0.5.0", default-features = false, features = ["serde"] } + +[target.'cfg(target_os = "macos")'.dependencies] +pam-client-macos = { package = "pam-client", version = "0.5.0", path = "../../../../../Users/michael/b/rust-pam-client", default-features = false, features = ["serde"] } diff --git a/src/main.rs b/src/main.rs index 1ccd5c3..82ecde3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,9 @@ mod pty; mod terminfo; mod user_info; +#[cfg(target_os = "macos")] +use pam_client_macos as pam_client; + use std::ffi::{CStr, CString}; use std::fmt; use std::future::Future; @@ -119,7 +122,7 @@ struct ClientConfig { async fn run_server() -> Result<()> { let cfg = { let opt_listen = std::env::var("BIND_ADDR") - .unwrap_or_else(|_| "127.0.0.1:8022".to_owned()) + .expect("BIND_ADDR not specified") .parse()?; &*Box::leak(ServerConfig { listen: opt_listen }.into()) @@ -786,6 +789,8 @@ async fn greet_conn(cfg: &'static ServerConfig, conn: quinn::Connecting) -> Resu } mod auth { + use super::pam_client; + use std::ffi::CString; #[derive(Debug, Serialize, Deserialize)]