diff --git a/crates/alkane-gui/src/credentials.rs b/crates/alkane-gui/src/credentials.rs index 99803c41..f0a6fe51 100644 --- a/crates/alkane-gui/src/credentials.rs +++ b/crates/alkane-gui/src/credentials.rs @@ -106,6 +106,9 @@ pub fn clear_credentials() -> std::io::Result<()> { /// duplicated here; a firmware absent from this table defaults to blank. pub fn firmware_default_creds() -> &'static [(&'static str, &'static str, &'static str)] { &[ + // Alkane OS ships with this control-board login, so restore-to-stock on + // an alkane board authenticates with no operator setup (issue #51). + ("Alkane", "root", "alkane"), ("AntMiner Stock", "root", "root"), ("WhatsMiner Stock", "admin", "admin"), ("Braiins", "root", "root"), @@ -134,6 +137,18 @@ pub fn firmware_default_for(name: &str) -> (String, String) { .unwrap_or_default() } +/// The login to use for a board running `firmware`: the operator's saved +/// per-firmware override if any, else the shipped default. This is how install +/// (a stock target) and restore (an alkane target) each pick the right login +/// automatically, without a password field in the dialog (issues #46, #51). +pub fn cred_for(firmware: &str) -> (String, String) { + load_firmware_credentials() + .get(firmware) + .cloned() + .filter(|(_, p)| !p.is_empty()) + .unwrap_or_else(|| firmware_default_for(firmware)) +} + /// Load the operator's per-firmware credential overrides, keyed by firmware /// Display name. Malformed lines are skipped. pub fn load_firmware_credentials() -> HashMap { diff --git a/crates/alkane-gui/src/ui.rs b/crates/alkane-gui/src/ui.rs index 027e232b..2de48f3a 100644 --- a/crates/alkane-gui/src/ui.rs +++ b/crates/alkane-gui/src/ui.rs @@ -3070,10 +3070,14 @@ impl App { ) }; let allow_unsigned = self.install_unsigned_check.is_checked(); - // Board login from Settings; empty -> the firmware's shipped default - // applies inside the engine (issue #46). - let password = credentials::load_ssh_credentials() - .map(|(_, p)| p) + // The STOCK board's shipped login (overridable per-firmware in Settings), + // so install authenticates with no password field (issues #46, #51). The + // target is on stock, so its firmware's default (e.g. AntMiner root/root) + // is correct -- not a saved alkane login. + let password = self + .selected_rows() + .first() + .map(|r| credentials::cred_for(&r.firmware).1) .filter(|p| !p.is_empty()); let ips = std::mem::take(&mut self.install_ips); if ips.is_empty() { @@ -3138,9 +3142,10 @@ impl App { // Credentials come from Settings (the alkane root login), not this dialog // (issue #46). Probe each selected board for a restorable on-board stock // backup so the on-board option can be offered or greyed out (#48). - let cred = credentials::load_ssh_credentials() - .map(|(_, p)| p) - .filter(|p| !p.is_empty()); + let cred = { + let p = credentials::cred_for(crate::alkane_detect::FIRMWARE).1; + (!p.is_empty()).then_some(p) + }; let onboard_ok = ips .iter() .all(|ip| stock_ops::onboard_backup_present(ip, cred.as_deref())); @@ -3255,11 +3260,12 @@ impl App { return; } } - // Alkane root credential comes from Settings; empty -> the method's - // shipped default applies (issue #46, #51). - let password = credentials::load_ssh_credentials() - .map(|(_, p)| p) - .filter(|p| !p.is_empty()); + // The ALKANE board's shipped login (overridable per-firmware in + // Settings), so restore authenticates with no password field (#46, #51). + let password = { + let p = credentials::cred_for(crate::alkane_detect::FIRMWARE).1; + (!p.is_empty()).then_some(p) + }; let ips = std::mem::take(&mut self.uninstall_ips); if ips.is_empty() { self.uninstall_dialog.close(0);