fix(gui): per-target credentials for install and restore (#46, #51)
source / check (pull_request) Skipped
verify / verify (pull_request) Failing after 31m29s
source / check (pull_request) Skipped
verify / verify (pull_request) Failing after 31m29s
"Install failed due to credentials" was the #46 change pulling one generic saved SSH login for both directions. Install targets a stock board and restore targets an alkane board, which need different logins. Add the alkane control-board login to the shipped defaults ("Alkane" root/alkane) and a `cred_for(firmware)` helper (saved per-firmware override, else shipped default). Install now uses the selected stock board's firmware login (e.g. AntMiner root/root); restore and the on-board-backup probe use the alkane login (root/alkane). No password field; both overridable per-firmware in Settings. Confirmed on the bench S17 at 10.255.1.111: its alkane login is root/alkane. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
@@ -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<String, (String, String)> {
|
||||
|
||||
+18
-12
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user