From 4ade82e26fc2eca2e7054ea2a0f68c1a9998e7fb Mon Sep 17 00:00:00 2001 From: Maarten <9350991+mjkl-gh@users.noreply.github.com> Date: Sat, 15 Jan 2022 16:21:37 +0100 Subject: [PATCH 1/8] chmod before moving file make file executable before moving to the windows folder to prevent weird permissions problem --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 1b47fcb..1916224 100755 --- a/install.sh +++ b/install.sh @@ -91,8 +91,8 @@ fi set +x echo_stage "Installing Windows component of WSL-Hello-sudo..." set -x +chmod +x build/WindowsHelloBridge.exe cp build/WindowsHelloBridge.exe "$PAM_WSL_HELLO_WINPATH/" -chmod +x "$PAM_WSL_HELLO_WINPATH/WindowsHelloBridge.exe" set +x echo_stage "Installing PAM module to the Linux system..." From 15501eff1cddf20f3351ac5b403f8ba8553897bf Mon Sep 17 00:00:00 2001 From: bri <284789+b-@users.noreply.github.com> Date: Tue, 10 Jan 2023 19:14:55 -0500 Subject: [PATCH 2/8] Update default install path in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 680230f..2a4504b 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ $ ./install.sh Although you don't have to care about the detailed installation process, `install.sh` does following things. -1. Copy a small Windows CLI app that launches Windows Hello to `C:\Users\your_account\pam_wsl_hello` (default location) +1. Copy a small Windows CLI app that launches Windows Hello to `C:\Users\your_account\AppData\Local\Programs\wsl-hello-sudo` (default location) 2. Install a PAM module to your WSL system. 3. Create config files in `/etc/pam_wsl_hello/` 4. Create a pam-configs entry in `/usr/share/pam-configs/` for automatic PAM configuration From 099eacf073c0e8e96b0ecc99c1f71d91588f9ae0 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 31 Jan 2023 19:47:17 -0400 Subject: [PATCH 3/8] Make install script architecture-agnostic --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 1b47fcb..0db473a 100755 --- a/install.sh +++ b/install.sh @@ -96,7 +96,7 @@ chmod +x "$PAM_WSL_HELLO_WINPATH/WindowsHelloBridge.exe" set +x echo_stage "Installing PAM module to the Linux system..." -SECURITY_PATH="/lib/x86_64-linux-gnu/security" +SECURITY_PATH="/lib/$(uname -m)-linux-gnu/security" if ! check_pam_directory "${SECURITY_PATH}"; then echo "PAM directory was not found in '/lib/x86_64-linux-gnu/security/'. It looks like you're not running Ubuntu nor Debian." echo "Checking '/lib/security/'..." From f08e42e932d06d0e6719c0d38d6d99d3e25de18e Mon Sep 17 00:00:00 2001 From: Evan <35814742+evanphilip@users.noreply.github.com> Date: Sun, 21 May 2023 11:44:57 +0200 Subject: [PATCH 4/8] Delete Cargo.lock --- Cargo.lock | 271 ----------------------------------------------------- 1 file changed, 271 deletions(-) delete mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 29cff2b..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,271 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "cc" -version = "1.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.85" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3" - -[[package]] -name = "openssl" -version = "0.10.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "lazy_static", - "libc", - "openssl-sys", -] - -[[package]] -name = "openssl-src" -version = "111.16.0+1.1.1l" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab2173f69416cf3ec12debb5823d244127d23a9b127d5a5189aa97c5fa2859f" -dependencies = [ - "cc", -] - -[[package]] -name = "openssl-sys" -version = "0.9.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6" -dependencies = [ - "autocfg", - "cc", - "libc", - "openssl-src", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "pkg-config" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" - -[[package]] -name = "rand" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" -dependencies = [ - "libc", - "rand 0.4.6", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "serde" -version = "1.0.123" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" - -[[package]] -name = "toml" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -dependencies = [ - "serde", -] - -[[package]] -name = "uuid" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc7e3b898aa6f6c08e5295b6c89258d1331e9ac578cc992fb818759951bdc22" -dependencies = [ - "rand 0.3.23", -] - -[[package]] -name = "vcpkg" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" - -[[package]] -name = "win_hello_bridge" -version = "1.4.0" -dependencies = [ - "windows", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebbc80318ebf919219a113c41deae34aa90198e4a15e93c810a9ea1aaa4c1a78" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "windows-sys" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39cae116ee11e4bce7c0a0425f2b0c866a91d86d209624b7707a7deea52da786" -dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_msvc" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7d1649bbab232cde71148c6ef7bbe647f214d2154dd66347fada60de40cda7" - -[[package]] -name = "windows_i686_gnu" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4eb20b59b93fc302839f3b0df3e61de7e9606b44cb54cbeb68d71cf137309fa" - -[[package]] -name = "windows_i686_msvc" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40331d8ef3e4dcdc8982eb7de16e1f09b86f5384626a56b3a99c2a51b88ff98e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5937d290e39c3308147d9b877c5fa741c50f4121ea78d2d20c4a138ad365464a" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee1b76aec4e2bead4758a181b663c37af0de7ec56fe6837c10215b8d6a1635f" - -[[package]] -name = "wsl_hello_pam" -version = "1.4.0" -dependencies = [ - "libc", - "openssl", - "toml", - "uuid", -] From 6442da6b0ad1bf03262ab861e95392a14059f37a Mon Sep 17 00:00:00 2001 From: Evan <35814742+evanphilip@users.noreply.github.com> Date: Sun, 21 May 2023 12:05:47 +0200 Subject: [PATCH 5/8] Update dependencies --- .github/workflows/cicd.yaml | 60 ++++++++++++++++----------- Makefile | 6 +-- win_hello_bridge/Cargo.toml | 2 +- win_hello_bridge/src/authenticator.rs | 1 - win_hello_bridge/src/main.rs | 2 +- wsl_hello_pam/Cargo.toml | 2 +- wsl_hello_pam/src/auth.rs | 2 +- 7 files changed, 40 insertions(+), 35 deletions(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index a1462dc..bc09e50 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -16,16 +16,30 @@ env: CARGO_TERM_COLOR: always jobs: - lint: - name: "Run linters" + lint-rust: + name: "Run Rust linter" - runs-on: ubuntu-latest + runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + + - name: Enable Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Run cargo clippy + run: cargo clippy -- -D warnings + + lint-bash: + name: "Run bash linter" - - name: Run linters - run: make lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Run shellcheck + run: shellcheck install.sh build-pam-module: name: "Build PAM module" @@ -33,17 +47,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - default: true - override: true - + - uses: actions/checkout@v3 + - name: Enable Rust cache - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2 - name: Install libpam run: sudo apt-get install libpam0g-dev @@ -51,7 +58,7 @@ jobs: - name: Build run: make clean build/pam_wsl_hello.so - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 name: Upload artifact with: name: "PAM module" @@ -64,12 +71,15 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 - + - uses: actions/checkout@v3 + + - name: Enable Rust cache + uses: Swatinem/rust-cache@v2 + - name: Build run: make clean build/WindowsHelloBridge.exe - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 name: Upload artifacts with: name: "Windows Binary" @@ -84,14 +94,14 @@ jobs: needs: [build-pam-module, build-windows-binary] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: "Windows Binary" path: build - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: "PAM module" path: build @@ -115,9 +125,9 @@ jobs: release_name: release run: | make -d release RELEASE="$release_name" - echo "::set-output name=release_asset::$release_name.tar.gz" + echo "release_asset=$release_name.tar.gz" >> $GITHUB_OUTPUT - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 if: ${{ github.event.inputs.should_publish != 'yes' }} name: Upload the release asset (CI) with: diff --git a/Makefile b/Makefile index 7237023..3353f3c 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ RELEASE := release WIN_CARGO="cargo.exe" -.PHONY: all clean cleanall cleanrelease install release lint +.PHONY: all clean cleanall cleanrelease install release all: build/pam_wsl_hello.so build/WindowsHelloBridge.exe @@ -39,7 +39,3 @@ release: all cp -R build $(RELEASE)/ cp install.sh pam-config $(RELEASE)/ tar cvzf $(RELEASE).tar.gz $(RELEASE) - -lint: - shellcheck install.sh - cargo clippy -- -D warnings diff --git a/win_hello_bridge/Cargo.toml b/win_hello_bridge/Cargo.toml index b9020f2..0a6f77c 100644 --- a/win_hello_bridge/Cargo.toml +++ b/win_hello_bridge/Cargo.toml @@ -11,4 +11,4 @@ name = "WindowsHelloBridge" path = "src/main.rs" [dependencies] -windows = { version = "0.27", features = ["alloc", "Foundation", "Security_Credentials", "Security_Cryptography", "Storage_Streams", "UI_Popups", "Win32_Foundation", "Win32_UI_WindowsAndMessaging"] } \ No newline at end of file +windows = { version = "0.32", features = ["alloc", "Foundation", "Security_Credentials", "Security_Cryptography", "Storage_Streams", "UI_Popups", "Win32_Foundation", "Win32_UI_WindowsAndMessaging"] } \ No newline at end of file diff --git a/win_hello_bridge/src/authenticator.rs b/win_hello_bridge/src/authenticator.rs index fdf91d8..8264807 100644 --- a/win_hello_bridge/src/authenticator.rs +++ b/win_hello_bridge/src/authenticator.rs @@ -2,7 +2,6 @@ use crate::FailureReason; use std::sync::mpsc; use std::time::Duration; use windows::{ - core::Handle, Security::{Credentials::KeyCredentialManager, Cryptography::CryptographicBuffer}, Win32::{ Foundation::PWSTR, diff --git a/win_hello_bridge/src/main.rs b/win_hello_bridge/src/main.rs index a6e4651..4f55e96 100644 --- a/win_hello_bridge/src/main.rs +++ b/win_hello_bridge/src/main.rs @@ -60,7 +60,7 @@ fn main() { let pem_key = creator::create_public_key(key_name)?; let file_name = format!("./{}.pem", key_name); println!("file name: {}", file_name); - std::fs::write(&file_name, &pem_key).unwrap(); + std::fs::write(&file_name, pem_key).unwrap(); println!( "Done. The public credential key is written in '{}'", file_name diff --git a/wsl_hello_pam/Cargo.toml b/wsl_hello_pam/Cargo.toml index d7aebd5..fba8a5a 100644 --- a/wsl_hello_pam/Cargo.toml +++ b/wsl_hello_pam/Cargo.toml @@ -9,6 +9,6 @@ crate-type = ["dylib"] [dependencies] libc = "0.2.0" -openssl = { version = "0.10.29", features = ["vendored"] } +openssl = { version = "0.10.48", features = ["vendored"] } toml = "0.4" uuid = { version = "0.5", features = ["v4"] } diff --git a/wsl_hello_pam/src/auth.rs b/wsl_hello_pam/src/auth.rs index 8c67cf6..84fa103 100644 --- a/wsl_hello_pam/src/auth.rs +++ b/wsl_hello_pam/src/auth.rs @@ -216,7 +216,7 @@ fn authenticate_via_hello(pamh: *mut pam_handle_t) -> Result Date: Sun, 21 May 2023 12:13:34 +0200 Subject: [PATCH 6/8] Fix UNC path warning --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 1b47fcb..1cb1e23 100755 --- a/install.sh +++ b/install.sh @@ -60,7 +60,7 @@ if [[ ! -e "${MNT}" ]]; then read -r MNT fi -WINUSER=$("${MNT}/Windows/System32/cmd.exe" /C "echo | set /p dummy=%username%") # Hacky. Get Windows's user name without new line +WINUSER=$("${MNT}/Windows/System32/whoami.exe"|tr -dc '[:print:]'|awk -F \\ '{print $2}') # Hacky. Get Windows user name DEF_PAM_WSL_HELLO_WINPATH="${MNT}/Users/$WINUSER/AppData/Local/Programs/wsl-hello-sudo" OLD_DEF_PAM_WSL_HELLO_WINPATH="${MNT}/Users/$WINUSER/pam_wsl_hello" From 9eb0f6170ab102e15d73d0c95b1d83b4409bd7a8 Mon Sep 17 00:00:00 2001 From: Evan <35814742+evanphilip@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:26:01 +0200 Subject: [PATCH 7/8] Update upload/download-artifact version --- .github/workflows/cicd.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index bc09e50..21be196 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -58,7 +58,7 @@ jobs: - name: Build run: make clean build/pam_wsl_hello.so - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 name: Upload artifact with: name: "PAM module" @@ -79,7 +79,7 @@ jobs: - name: Build run: make clean build/WindowsHelloBridge.exe - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 name: Upload artifacts with: name: "Windows Binary" @@ -96,12 +96,12 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: "Windows Binary" path: build - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: "PAM module" path: build @@ -127,7 +127,7 @@ jobs: make -d release RELEASE="$release_name" echo "release_asset=$release_name.tar.gz" >> $GITHUB_OUTPUT - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: ${{ github.event.inputs.should_publish != 'yes' }} name: Upload the release asset (CI) with: From 64a1705a43300abf07c916204dd58a408fe0f1f9 Mon Sep 17 00:00:00 2001 From: Evan <35814742+evanphilip@users.noreply.github.com> Date: Fri, 6 Sep 2024 10:27:26 +0200 Subject: [PATCH 8/8] Linting --- wsl_hello_pam/src/auth.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wsl_hello_pam/src/auth.rs b/wsl_hello_pam/src/auth.rs index 84fa103..00a8e64 100644 --- a/wsl_hello_pam/src/auth.rs +++ b/wsl_hello_pam/src/auth.rs @@ -65,6 +65,7 @@ fn get_user(pamh: *mut pam_handle_t, prompt: Option<&str>) -> Result, i } #[derive(Debug)] +#[allow(dead_code)] enum ConfigError { Io(io::Error), Toml(toml::de::Error), @@ -126,6 +127,7 @@ fn get_win_mnt() -> Result { } #[derive(Debug)] +#[allow(dead_code)] enum HelloAuthenticationError { GetUserError(i32), ConfigError(ConfigError), @@ -232,7 +234,7 @@ fn authenticate_via_hello(pamh: *mut pam_handle_t) -> Result { /* Success */ } + Some(0) => { /* Success */ } Some(_) => { return Err(HelloAuthenticationError::HelloAuthenticationFail( String::from_utf8(auth_res.stdout)