Name update
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
use crate::entry::{BootEntry, BootKind, KernelArgs};
|
||||
use crate::introspect::{introspect, DistroFamily, IntrospectionReport};
|
||||
use bytes::Bytes;
|
||||
use parking_lot::RwLock;
|
||||
use openpxe_core::{Error, Result};
|
||||
use parking_lot::RwLock;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::collections::HashMap;
|
||||
@@ -170,7 +170,9 @@ impl IsoStore {
|
||||
let mut entries = tokio::fs::read_dir(self.iso_dir.as_path()).await?;
|
||||
while let Some(e) = entries.next_entry().await? {
|
||||
let p = e.path();
|
||||
if p.extension().and_then(|s| s.to_str()) != Some("json") { continue; }
|
||||
if p.extension().and_then(|s| s.to_str()) != Some("json") {
|
||||
continue;
|
||||
}
|
||||
if !p
|
||||
.file_name()
|
||||
.and_then(|s| s.to_str())
|
||||
@@ -276,7 +278,10 @@ impl IsoStore {
|
||||
/// share or unmount the NFS share entirely.
|
||||
pub async fn delete(&self, id: &str) -> Result<()> {
|
||||
let meta = self.get(id);
|
||||
let is_local = matches!(meta.as_ref().map(|m| &m.source), Some(IsoSource::Local) | None);
|
||||
let is_local = matches!(
|
||||
meta.as_ref().map(|m| &m.source),
|
||||
Some(IsoSource::Local) | None
|
||||
);
|
||||
if is_local {
|
||||
let iso = self.iso_path(id);
|
||||
let meta_path = self.meta_path(id);
|
||||
@@ -319,9 +324,9 @@ impl IsoStore {
|
||||
/// to clean out stale entries.
|
||||
pub fn drop_external_source(&self, mount_id: &str) {
|
||||
let mut g = self.inner.write();
|
||||
g.isos.retain(|_, m| {
|
||||
!matches!(&m.source, IsoSource::Nfs { mount_id: mid, .. } if mid == mount_id)
|
||||
});
|
||||
g.isos.retain(
|
||||
|_, m| !matches!(&m.source, IsoSource::Nfs { mount_id: mid, .. } if mid == mount_id),
|
||||
);
|
||||
}
|
||||
|
||||
/// Set or clear an ISO's boot password.
|
||||
@@ -371,7 +376,7 @@ impl IsoStore {
|
||||
|
||||
/// Verify a candidate password against the stored bcrypt hash.
|
||||
/// Returns:
|
||||
/// - `Ok(true)` — match (or the ISO has no password set; gate is open)
|
||||
/// - `Ok(true)` — match (or the ISO has no password set; boot is open)
|
||||
/// - `Ok(false)` — mismatch
|
||||
/// - `Err(_)` — id not found, or bcrypt error
|
||||
pub fn verify_password(&self, id: &str, candidate: &str) -> Result<bool> {
|
||||
@@ -427,7 +432,10 @@ pub fn generate_boot_entries_for(
|
||||
/// Build `BootEntry`s from the introspection report. URLs are relative —
|
||||
/// the HTTP layer rewrites them with the public base URL per request.
|
||||
fn generate_boot_entries(id: &str, filename: &str, r: &IntrospectionReport) -> Vec<BootEntry> {
|
||||
let title = r.volume_label.clone().unwrap_or_else(|| filename.to_string());
|
||||
let title = r
|
||||
.volume_label
|
||||
.clone()
|
||||
.unwrap_or_else(|| filename.to_string());
|
||||
match r.family {
|
||||
DistroFamily::WindowsPe if r.has_boot_wim => {
|
||||
// Standard wimboot chain. Paths are in-ISO; the HTTP layer maps
|
||||
@@ -451,12 +459,22 @@ fn generate_boot_entries(id: &str, filename: &str, r: &IntrospectionReport) -> V
|
||||
fam if r.kernel_path.is_some() => {
|
||||
let base = format!("iso/{id}");
|
||||
let kernel_url = format!("{base}{}", r.kernel_path.as_deref().unwrap_or(""));
|
||||
let initrd_urls = r.initrd_paths.iter().map(|p| format!("{base}{p}")).collect();
|
||||
let args = KernelArgs { cmdline: linux_cmdline(fam, id) };
|
||||
let initrd_urls = r
|
||||
.initrd_paths
|
||||
.iter()
|
||||
.map(|p| format!("{base}{p}"))
|
||||
.collect();
|
||||
let args = KernelArgs {
|
||||
cmdline: linux_cmdline(fam, id),
|
||||
};
|
||||
vec![BootEntry {
|
||||
id: format!("{id}-linux"),
|
||||
title,
|
||||
kind: BootKind::LinuxKernel { kernel_url, initrd_urls, args },
|
||||
kind: BootKind::LinuxKernel {
|
||||
kernel_url,
|
||||
initrd_urls,
|
||||
args,
|
||||
},
|
||||
}]
|
||||
}
|
||||
_ => {
|
||||
@@ -465,7 +483,9 @@ fn generate_boot_entries(id: &str, filename: &str, r: &IntrospectionReport) -> V
|
||||
vec![BootEntry {
|
||||
id: format!("{id}-sanboot"),
|
||||
title: format!("{title} (SAN boot — may fail for >1GiB ISOs)"),
|
||||
kind: BootKind::SanBootIso { iso_url: format!("iso/{id}.iso") },
|
||||
kind: BootKind::SanBootIso {
|
||||
iso_url: format!("iso/{id}.iso"),
|
||||
},
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -536,7 +556,11 @@ mod tests {
|
||||
let dir = tempdir().unwrap();
|
||||
let store = IsoStore::new(dir.path().to_path_buf());
|
||||
store.ensure_dirs().await.unwrap();
|
||||
store.inner.write().isos.insert("alpha".into(), fake_meta("alpha"));
|
||||
store
|
||||
.inner
|
||||
.write()
|
||||
.isos
|
||||
.insert("alpha".into(), fake_meta("alpha"));
|
||||
|
||||
// No password set — verify_password returns Ok(true) for any input.
|
||||
assert!(store.verify_password("alpha", "anything").unwrap());
|
||||
|
||||
Reference in New Issue
Block a user