Skip to content

Commit

Permalink
ci: update the tested and built feature set
Browse files Browse the repository at this point in the history
  • Loading branch information
CBenoit committed Oct 8, 2024
1 parent 96dcecf commit 2af75c3
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ 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
# These lines can be safely removed once we switch to ubuntu-22.04 runner.
- 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}})
Expand Down Expand Up @@ -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"
}
Expand All @@ -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 ' '
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
13 changes: 10 additions & 3 deletions ffi/src/winscard/pcsc_lite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,18 @@ pub fn initialize_pcsc_lite_api() -> WinScardResult<PcscLiteApiFunctionTable> {
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)
}
}};
}

Expand Down
5 changes: 3 additions & 2 deletions ffi/src/winscard/system_scard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ pub fn init_scard_api_table() -> WinScardResult<SCardApiFunctionTable> {

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::<windows_sys::Win32::Foundation::FARPROC, _>(GetProcAddress(winscard_module, s!($func_name)))
}
}};
Expand Down

0 comments on commit 2af75c3

Please sign in to comment.