From b6f758c2bd22ec303092c5920e01f88ebc9a1869 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 8 Jan 2024 18:04:58 -0500 Subject: [PATCH] keyfork wizard generate-shard-secret: do not write to terminal --- keyfork/src/cli/wizard.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/keyfork/src/cli/wizard.rs b/keyfork/src/cli/wizard.rs index 90e7a3f..bfde049 100644 --- a/keyfork/src/cli/wizard.rs +++ b/keyfork/src/cli/wizard.rs @@ -1,6 +1,6 @@ use super::Keyfork; use clap::{Parser, Subcommand}; -use std::collections::HashSet; +use std::{collections::HashSet, io::IsTerminal}; use card_backend_pcsc::PcscBackend; use openpgp_card_sequoia::{state::Open, types::KeyType, Card}; @@ -99,6 +99,11 @@ fn generate_shard_secret(threshold: u8, max: u8, keys_per_shard: u8) -> Result<( let mut pm = PromptManager::new(std::io::stdin(), std::io::stderr())?; let mut certs = vec![]; let mut seen_cards: HashSet = HashSet::new(); + let stdout = std::io::stdout(); + assert!( + !stdout.is_terminal(), + "not printing shard to terminal, redirect output" + ); for index in 0..max { let cert = derive_key(&seed, index)?;