From 25098b5a637c1708408c98a57a79b528fb5e00ee Mon Sep 17 00:00:00 2001 From: "Fabien F." <8136686+lostmind84@users.noreply.github.com> Date: Sun, 4 Oct 2026 09:53:48 +0200 Subject: [PATCH] fix: a Docker server is never offered or given the repack's updates Found by installing a server through the new screen: the update check of a Docker server read the Windows "stable" channel and offered "0.261003.17 (you have 0.261003.1)". Applying it would have put the repack's executables, MySQL and launcher into a Linux server folder. Refused in the core (update::preview, apply and rollback), so no caller can do it. The Settings tab says that updates are not available for Docker servers yet; the background check stays quiet, as for any failed check. A test applies the same update package to the same folder with and without Settings/docker.json: refused and untouched with it, committed without it. --- crates/coa-core/src/update.rs | 33 +++++++++++++++++++++++++++++++++ docs/ARCHITECTURE.md | 3 +++ 2 files changed, 36 insertions(+) diff --git a/crates/coa-core/src/update.rs b/crates/coa-core/src/update.rs index ab83667..c90711f 100644 --- a/crates/coa-core/src/update.rs +++ b/crates/coa-core/src/update.rs @@ -283,12 +283,22 @@ pub enum DatabaseAccess { OnlyIfRunning, } +/// The update packages are those of the Windows repack (executables, a bundled MySQL, a launcher): applying one to a Docker +/// server would put Windows files in a Linux server folder. Updating a Docker server is separate work. +fn refuse_for_docker(root: &Path) -> Result<()> { + if crate::docker::is_docker(root) { + return Err(Error::Invalid("Updates are not available for Docker servers yet.".into())); + } + Ok(()) +} + /// Describe the update; a managed launcher may need a one-time authenticated payload check. pub fn preview(root: &Path, meta: &InstallMeta, source: &Source, trusted_key: &str, resolutions: &BTreeMap) -> Result { preview_with(root, meta, source, trusted_key, resolutions, DatabaseAccess::Start) } pub fn preview_with(root: &Path, meta: &InstallMeta, source: &Source, trusted_key: &str, resolutions: &BTreeMap, access: DatabaseAccess) -> Result { + refuse_for_docker(root)?; let meta_dir = crate::registry::metadata_dir_for(root)?; let _lock = operation_lock(&meta_dir)?; ensure_recovered(&meta_dir)?; @@ -396,6 +406,7 @@ fn step(report: &dyn Fn(&str, u8), name: &str, pct: u8) { /// Run the whole update. On failure before the new build is validated the files are rolled back automatically; /// a build that is applied but unhealthy is left in `NeedsDecision` so the owner chooses. pub fn apply(p: &Params, report: &dyn Fn(&str, u8)) -> Result { + refuse_for_docker(p.root)?; let (root, meta_dir) = (p.root, p.meta_dir); let _lock = operation_lock(meta_dir)?; ensure_recovered(meta_dir)?; @@ -700,6 +711,7 @@ fn restore_files(root: &Path, before: &Path, txn: &mut Txn) -> Result<()> { /// Restore the database recovery point first, then restore binaries and configuration. pub fn rollback(root: &Path, meta_dir: &Path, id: &str, env: &dyn Env) -> Result { + refuse_for_docker(root)?; let _lock = operation_lock(meta_dir)?; let mut txn = load(meta_dir, id)?; if matches!(txn.state, State::Committed | State::RolledBack) { @@ -1142,6 +1154,27 @@ mod tests { assert_eq!(read(&w, "Core/worldserver.exe"), b"world-v1"); } + #[test] + fn a_docker_server_is_never_given_the_repack_files() { + // Found by trying the installer: the update check of a Docker server read the Windows channel and offered its files. + let w = world(&[], false); + write(&w.root, "Settings/docker.json", br#"{"project":"t1"}"#); + let before = read(&w, "Core/worldserver.exe"); + let meta = InstallMeta::new(InstallKind::New, &w.root); + + let err = preview(&w.root, &meta, &Source::Dir(w.pkg.clone()), &w.key, &BTreeMap::new()).unwrap_err(); + assert!(err.to_string().contains("Docker"), "{err}"); + let err = run(&w, &Fake::ok(), BTreeMap::new(), None).unwrap_err(); + assert!(err.to_string().contains("Docker"), "{err}"); + assert!(rollback(&w.root, &w.meta, "any", &Fake::ok()).is_err()); + assert_eq!(read(&w, "Core/worldserver.exe"), before, "nothing was touched"); + assert!(!w.root.join("Core/newfile.dll").exists()); + + // The same package is applied to the same folder once it is not a Docker server. + fs::remove_file(w.root.join("Settings/docker.json")).unwrap(); + assert_eq!(run(&w, &Fake::ok(), BTreeMap::new(), None).unwrap().txn.state, State::Committed); + } + #[test] fn happy_path_replaces_creates_merges_and_records_ownership() { let w = world(&[], false); diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index bef72b0..885a89c 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -408,6 +408,9 @@ hand over to `coa_core::docker`; nothing else needed to change for start, stop, the package, and there is no default package address until a signed Linux package is published. Packages are checked with the embedded key; only a debug build (`tauri dev`) accepts another one, named in `COA_DEV_TRUSTED_KEY`, to try the installer on a package signed with a throwaway key. +* **Updates are refused for a Docker server, never half done.** `update::preview`, `apply` and `rollback` refuse it: the + update packages are the repack's (executables, a bundled MySQL, a launcher) and applying one would put Windows files in a + Linux folder. Found by installing a server with the screen: the update check had read the Windows channel and offered one. * **Not done yet**: downloading the game data, updates, port conflict detection, the firewall and exposure checks, the Wildcard realm profiles, and the client under Wine/Proton.