SDImporter class in pkcs11-daemon/sd_import.cpp monitors up to three SD card mount points and is intended to automatically import keys from removable media into the vault.
How it works
TheSDImporter constructor takes a Vault reference, which it stores for use during import once that is implemented:
watch_ports() method polls three fixed paths every 10 seconds:
| Mount point | Port index |
|---|---|
/media/sdcard0 | 0 |
/media/sdcard1 | 1 |
/media/sdcard2 | 2 |
Thread integration
The daemon spawns the watcher on a background thread at startup, alongside vault initialization:Intended workflow (planned)
Once the import logic is implemented, the workflow will be:- An SD card mounts at
/media/sdcard0(orsdcard1,sdcard2) watch_ports()detects the path exists on the next poll cycle- The watcher reads a key file from the SD card
- The key material is passed to
vault.store_key(label, type, data) - The key is available in
vault.dbfor use by the daemon
Testing detection
You can verify that the watcher correctly detects mount points without physical hardware by creating the directory manually.Wait for the next poll cycle
The watcher sleeps 10 seconds between polls. After up to 10 seconds, the daemon should print:
Detection confirms the polling loop and
filesystem::exists check are working. No key data is read or written to the vault during this test — that code path is not yet implemented.