Skip to content

Commit

Permalink
Treat passphrase like password in import-recovery-device
Browse files Browse the repository at this point in the history
Closes #8567
  • Loading branch information
FirelightFlagboy committed Oct 4, 2024
1 parent 0b941c7 commit c257ee1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
22 changes: 13 additions & 9 deletions cli/src/commands/device/import_recovery_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ crate::clap_parser_with_shared_opts_builder!(
/// Recovery file
#[arg(short, long)]
input: PathBuf,
/// Passphrase
#[arg(short, long)]
passphrase: String,
}
);

pub async fn main(args: Args) -> anyhow::Result<()> {
let Args {
input,
passphrase,
config_dir,
password_stdin,
} = args;
Expand All @@ -31,12 +27,20 @@ pub async fn main(args: Args) -> anyhow::Result<()> {
config_dir.display(),
);

let mut handle = start_spinner("Loading recovery device file".into());

// TODO this is a recovery device: a new local device must be created
let device = load_recovery_device(&input, passphrase.into()).await?;
let device = {
let passphrase = read_password(if password_stdin {
ReadPasswordFrom::Stdin
} else {
ReadPasswordFrom::Tty {
prompt: "Enter passphrase for the recovery file:",
}
})?;
let mut handle = start_spinner("Loading recovery device file".into());
let res = load_recovery_device(&input, passphrase.into()).await?;

Check failure on line 39 in cli/src/commands/device/import_recovery_device.rs

View workflow job for this annotation

GitHub Actions / rust / 🐧 Linux: 🦀 Rust tests

useless conversion to the same type: `zeroize::Zeroizing<std::string::String>`

handle.stop_with_newline();
handle.stop_with_newline();
res
};

let password = choose_password(if password_stdin {
ReadPasswordFrom::Stdin
Expand Down
6 changes: 2 additions & 4 deletions cli/tests/integration/device/import_recovery_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ async fn import_recovery_device(tmp_path: TmpPath) {
.unwrap();

crate::assert_cmd_success!(
with_password = DEFAULT_DEVICE_PASSWORD,
with_password = format!("{}\n{DEFAULT_DEVICE_PASSWORD}", *passphrase),
"device",
"import-recovery-device",
"--input",
&input.to_string_lossy(),
"--passphrase",
&passphrase
&input.to_string_lossy()
)
.stdout(predicates::str::contains("Saved new device"));
}
1 change: 1 addition & 0 deletions newsfragments/8567.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove passphrase from CLI options of ``device import-recovery-device``, it is now read from the standard input like the password.

0 comments on commit c257ee1

Please sign in to comment.