retry bad passwords on backups; add note that backups are not abortable

Because we unmount the PDDB and put the system in a semi-shutdown
state, backups are not abortable if you type in the wrong root password.
This patch retries the root password forever, but also adds a note
at the beginning of the process that the process cannot be stopped
once started.
This commit is contained in:
bunnie 2022-10-09 17:44:46 +08:00
parent b2048d0066
commit 2a440f6409
4 changed files with 38 additions and 2 deletions

View file

@ -12,10 +12,10 @@
"en-tts": "Would you like to verify that you wrote the backup key down correctly by re-entering it now?"
},
"rootkeys.backup_badpass": {
"en": "Password incorrect. Aborting backup!",
"en": "Password incorrect.\n\nPlease try again, or reboot by inserting a paperclip in the hard reset hole.",
"ja": "正しくないパスワード。 バックアップを中止します!",
"zh": "密码错误。 中止备份!",
"en-tts": "Password incorrect. Aborting backup!"
"en-tts": "Password incorrect.\n\nPlease try again, or reboot by inserting a paperclip in the hard reset hole."
},
"rootkeys.restore_badpass": {
"en": "BIP-39 entry was not valid. Aborting restore!",

View file

@ -1411,6 +1411,7 @@ fn main() -> ! {
continue;
}
checksums = ipc.checksums;
keys.set_ux_password_type(Some(PasswordType::Update));
password_action.set_action_opcode(Opcode::UxCreateBackupPwReturn.to_u32().unwrap());
rootkeys_modal.modify(
@ -1491,6 +1492,20 @@ fn main() -> ! {
}
} else {
modals.show_notification(t!("rootkeys.backup_badpass", xous::LANG), None).ok();
// Prompt the user again for the password. It will do this until a correct password is entered.
// maybe it would be thoughtful to add a yes/no box for rebooting in case someone decides they
// don't want to run the backup right now. But I think this is an edge case that few will run into.
keys.set_ux_password_type(Some(PasswordType::Update));
password_action.set_action_opcode(Opcode::UxCreateBackupPwReturn.to_u32().unwrap());
rootkeys_modal.modify(
Some(ActionType::TextEntry(password_action.clone())),
Some(t!("rootkeys.get_update_password_backup", xous::LANG)), false,
None, true, None
);
#[cfg(feature="tts")]
tts.tts_blocking(t!("rootkeys.get_update_password_backup", xous::LANG)).unwrap();
log::info!("{}ROOTKEY.UPDPW,{}", xous::BOOKEND_START, xous::BOOKEND_END);
rootkeys_modal.activate();
}
}
Some(Opcode::DoRestore) => {

View file

@ -29,6 +29,12 @@
"zh": "无法卸载 PDDB 以准备备份。 备份中止。",
"en-tts": "Couldn't unmount PDDB in preparation for backup. Backup aborted."
},
"backup.confirm": {
"ja": "PDDB とルート キーのバックアップの準備をしますか?\n\nプロセスは、いったん開始すると中止できません。",
"en": "Prepare for PDDB and root key backup?\n\nThe process cannot be aborted once started.",
"zh": "准备 PDDB 和根密钥备份吗?\n\n进程一旦启动就不能中止。",
"en-tts": "Prepare for PDDB and root key backup?\n\nThe process cannot be aborted once started."
},
"ecup.invalid": {
"ja": "ECファームウェアパッケージが破損しているか無効です: ",
"en": "EC firmware package is corrupted or invalid: ",

View file

@ -1061,6 +1061,21 @@ fn wrapped_main() -> ! {
com.set_backlight(0, 0).expect("cannot set backlight off");
},
Some(StatusOpcode::PrepareBackup) => {
log::info!("{}BACKUP.CONFIRM,{}", xous::BOOKEND_START, xous::BOOKEND_END);
modals.add_list_item(t!("rootkeys.gwup.yes", xous::LANG)).expect("couldn't build radio item list");
modals.add_list_item(t!("rootkeys.gwup.no", xous::LANG)).expect("couldn't build radio item list");
match modals.get_radiobutton(t!("backup.confirm", xous::LANG)) {
Ok(response) => {
if response.as_str() == t!("rootkeys.gwup.yes", xous::LANG) {
{}
} else {
// abort the flow now by returning to the main dispatch handler
continue;
}
}
_ => (),
}
// disconnect from the network, so that incoming network packets don't trigger any processes that
// could write to the PDDB.
netmgr.connection_manager_wifi_off_and_stop().ok();