From 2af75c3b3e6e9fcdbcd6baad9d30bb6dd2f26cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20CORTIER?= Date: Tue, 8 Oct 2024 19:16:57 +0900 Subject: [PATCH] ci: update the tested and built feature set --- .github/workflows/build-native.yml | 10 +++++----- .github/workflows/ci.yml | 22 ++++++++++++++++++---- ffi/Cargo.toml | 2 +- ffi/src/winscard/pcsc_lite/mod.rs | 13 ++++++++++--- ffi/src/winscard/system_scard/mod.rs | 5 +++-- 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-native.yml b/.github/workflows/build-native.yml index 0be9e83e..53278541 100644 --- a/.github/workflows/build-native.yml +++ b/.github/workflows/build-native.yml @@ -135,7 +135,7 @@ jobs: - name: Update runner if: ${{ matrix.os == 'linux' }} - run: sudo apt update + run: sudo apt-get update # We need a newer version of GCC because aws-lc-rs rejects versions affected # by this bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189 @@ -143,7 +143,7 @@ jobs: - name: Install GCC 10.x if: ${{ matrix.os == 'linux' }} run: | - sudo apt install gcc-10 + sudo apt-get install gcc-10 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 - name: Build sspi (${{matrix.os}}-${{matrix.arch}}) (${{matrix.build}}) @@ -185,7 +185,7 @@ jobs: } if ($RustTarget -eq 'aarch64-unknown-linux-gnu') { - sudo apt install gcc-aarch64-linux-gnu + sudo apt-get install gcc-aarch64-linux-gnu $Env:RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc" } @@ -205,14 +205,14 @@ jobs: } if ($DotNetOs -Eq 'win') { - $CargoArgs += @('--features', 'scard,tsssp') + $CargoArgs += @('--features', 'tsssp') } # No pregenerated Android bindings are provided for aws-lc-sys at this time. # See: https://github.com/aws/aws-lc-rs/tree/main/aws-lc-sys#pregenerated-bindings-availability # For simplicity, we’re using the ring crypto backend. if ($DotNetOs -Eq 'android') { - $CargoArgs += @('--no-default-features', '--features', 'ring') + $CargoArgs += @('--no-default-features', '--features', 'scard,ring') } $CargoCmd = $(@('cargo') + $CargoArgs) -Join ' ' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24f4eb20..dbd19f1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: include: - os: win runner: windows-2022 - additional-args: --features tsssp,scard + additional-args: --features tsssp - os: osx runner: macos-12 - os: linux @@ -67,14 +67,28 @@ jobs: crate-name: sspi - manifest: ffi/Cargo.toml crate-name: sspi-ffi + - os: win runner: windows-2022 - additional-args: --features tsssp,scard - os: osx runner: macos-12 - os: linux runner: ubuntu-20.04 + - os: win + manifest: Cargo.toml + additional-args: --features network_client,dns_resolver,scard,tsssp + - os: osx + manifest: Cargo.toml + additional-args: --features network_client,dns_resolver,scard + - os: linux + manifest: Cargo.toml + additional-args: --features network_client,dns_resolver,scard + + - os: win + manifest: ffi/Cargo.toml + additional-args: --features tsssp + steps: - uses: actions/checkout@v4 @@ -99,7 +113,7 @@ jobs: rustup override set nightly - name: Test - run: cargo miri test --manifest-path ffi/Cargo.toml + run: cargo miri test --manifest-path ffi/Cargo.toml --no-default-features --features ring wasm: name: WASM target @@ -110,7 +124,7 @@ jobs: - uses: actions/checkout@v4 - name: Prepare runner - run: sudo apt install wabt + run: sudo apt-get install wabt - name: Check shell: pwsh diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml index 8745e98a..a71f0e14 100644 --- a/ffi/Cargo.toml +++ b/ffi/Cargo.toml @@ -13,7 +13,7 @@ name = "sspi" crate-type = ["cdylib"] [features] -default = ["aws-lc-rs"] +default = ["aws-lc-rs", "scard"] tsssp = ["sspi/tsssp"] scard = ["sspi/scard", "dep:ffi-types", "dep:winscard", "dep:bitflags", "dep:picky-asn1-x509", "dep:picky"] aws-lc-rs = ["sspi/aws-lc-rs"] diff --git a/ffi/src/winscard/pcsc_lite/mod.rs b/ffi/src/winscard/pcsc_lite/mod.rs index cf313747..2638188d 100644 --- a/ffi/src/winscard/pcsc_lite/mod.rs +++ b/ffi/src/winscard/pcsc_lite/mod.rs @@ -148,11 +148,18 @@ pub fn initialize_pcsc_lite_api() -> WinScardResult { macro_rules! load_fn { ($func_name:literal) => {{ let fn_name = CString::new($func_name).expect("CString creation should not fail"); - // SAFETY: The `handle` is initialized and checked above. The function name should be correct - // because it's hardcoded in the code. + + // SAFETY: The `handle` is initialized and checked above. + // The function name should be correct because it's hardcoded in the code. let fn_ptr = unsafe { dlsym(handle, fn_name.as_ptr()) }; debug!(?fn_ptr, $func_name); - unsafe { std::mem::transmute(fn_ptr) } + + // SAFETY: FFI. We have to trust that we defined the signatures correctly. + unsafe { + // Not great to silent, but mostly fine in this context. + #[expect(clippy::missing_transmute_annotations)] + std::mem::transmute::<*mut libc::c_void, _>(fn_ptr) + } }}; } diff --git a/ffi/src/winscard/system_scard/mod.rs b/ffi/src/winscard/system_scard/mod.rs index 7130ba04..90982b34 100644 --- a/ffi/src/winscard/system_scard/mod.rs +++ b/ffi/src/winscard/system_scard/mod.rs @@ -79,10 +79,11 @@ pub fn init_scard_api_table() -> WinScardResult { macro_rules! load_fn { ($func_name:literal) => {{ - // SAFETY: This function is safe to call because we've checked the `winscard_mofule` + // SAFETY: This function is safe to call because we've checked the `winscard_module` // handle above and the `$func_name` is correct and hardcoded in the code. unsafe { - #[expect(clippy::missing_transmute_annotations)] // Not great to silent, but mostly fine. + // Not great to silent, but mostly fine in this context. + #[expect(clippy::missing_transmute_annotations)] transmute::(GetProcAddress(winscard_module, s!($func_name))) } }};