ScanOptions: add disable_keydb to skip all keydb lookup
A caller that resolves Unit Keys out-of-band can now set disable_keydb
so the scan consults no keydb at all — neither an explicit keydb_path
nor the standard search locations. Without it, a keydb that merely sits
in a default location ('~/.config/...') silently shadows the out-of-band
path. unit_key still takes precedence over everything.
This commit is contained in:
@@ -951,11 +951,21 @@ pub struct ScanOptions {
|
|||||||
/// obtains the key however it likes; libfreemkv stays free of any network
|
/// obtains the key however it likes; libfreemkv stays free of any network
|
||||||
/// dependency.
|
/// dependency.
|
||||||
pub unit_key: Option<[u8; 16]>,
|
pub unit_key: Option<[u8; 16]>,
|
||||||
|
/// Disable KEYDB entirely: skip both the explicit `keydb_path` and the
|
||||||
|
/// standard-location search, so no keydb is loaded for this scan. A caller
|
||||||
|
/// that resolves keys out-of-band (e.g. a remote key service) sets this so
|
||||||
|
/// a keydb that merely happens to sit in a default location does not shadow
|
||||||
|
/// the out-of-band path. `unit_key` still takes precedence over everything.
|
||||||
|
pub disable_keydb: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ScanOptions {
|
impl ScanOptions {
|
||||||
/// Resolve KEYDB path: explicit path first, then standard locations.
|
/// Resolve KEYDB path: explicit path first, then standard locations.
|
||||||
|
/// Returns `None` when `disable_keydb` is set — no keydb is consulted.
|
||||||
fn resolve_keydb(&self) -> Option<std::path::PathBuf> {
|
fn resolve_keydb(&self) -> Option<std::path::PathBuf> {
|
||||||
|
if self.disable_keydb {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
if let Some(p) = &self.keydb_path {
|
if let Some(p) = &self.keydb_path {
|
||||||
if p.exists() {
|
if p.exists() {
|
||||||
return Some(p.clone());
|
return Some(p.clone());
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ pub fn input(url: &str, opts: &InputOptions) -> io::Result<Box<dyn crate::pes::S
|
|||||||
let scan_opts = crate::disc::ScanOptions {
|
let scan_opts = crate::disc::ScanOptions {
|
||||||
keydb_path: opts.keydb_path.as_ref().map(Into::into),
|
keydb_path: opts.keydb_path.as_ref().map(Into::into),
|
||||||
unit_key: opts.unit_key,
|
unit_key: opts.unit_key,
|
||||||
|
..Default::default()
|
||||||
};
|
};
|
||||||
// FileSectorSource is the sole file-backed sector source.
|
// FileSectorSource is the sole file-backed sector source.
|
||||||
// It carries the platform-tuned SEQUENTIAL fadvise hint
|
// It carries the platform-tuned SEQUENTIAL fadvise hint
|
||||||
|
|||||||
Reference in New Issue
Block a user