feat!: winscard: remove scars cache seed and make it global - #755
Pavlo Myroniuk (TheBestTvarynka) wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Cache entries are not isolated by card identifier, initialization can overwrite shared state, and raw cache payloads are logged.
Review effort: Balanced
Findings: 2
Open (3)
What changed in this PR
Makes smart-card caching process-global while removing cache seeding for system-provided cards.
Changes:
- Adds a synchronized global cache with freshness handling.
- Injects the cache into emulated contexts.
- Simplifies system-card context initialization.
| File | Description |
|---|---|
ffi/src/winscard/system_scard/context.rs |
Uses the global cache on non-Windows systems. |
ffi/src/winscard/scard_context.rs |
Injects the global cache and adds write diagnostics. |
ffi/src/winscard/piv.rs |
Updates system-context construction. |
ffi/src/winscard/mod.rs |
Registers the cache module. |
ffi/src/winscard/cache.rs |
Implements global cache storage and tests. |
crates/winscard/src/scard_context.rs |
Accepts a cache implementation and seeds it. |
crates/winscard/src/lib.rs |
Exports the cache abstraction. |
crates/winscard/src/cache.rs |
Defines the public cache trait. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| #[derive(Default)] | ||
| struct ScardCache { | ||
| items: BTreeMap<String, CacheItem>, |
There was a problem hiding this comment.
First, I decided to support only one smart card per system. But then I found out that I needed to support multiple smart cards. It turned out it wasn't as hard as I thought. Done in ffaf9ba
Now we support multiple system-provided smart cards.
Pay attention: we still support only one smart card per system for emulated smart cards.
…rd cache seedable;
… write Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
ffaf9ba to
8598962
Compare
|
Benoît Cortier (@CBenoit), I addressed Copilot's comments and resolved merge conflicts |


Hi,
I fixed the scard logon for system-provided smart cards in this PR. Overall, this PR introduces two major changes: