Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ask user to confirm generated passphrase before invocing pinentry #3035

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/action/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ func (s *Action) initGenerateIdentity(ctx context.Context, crypto backend.Crypto
if pwGenerated {
out.Printf(ctx, color.MagentaString("Passphrase: ")+passphrase)
out.Noticef(ctx, "You need to remember this very well!")

// Prompt to confirm that the user noted their passphrase
if want, err := termio.AskForBool(ctx, "Did you save your passphrase?", true); err != nil || !want {
return fmt.Errorf("user did not confirm saving the passphrase: %w", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that not confirming here would still cause the identity file to have been written in step on Line 184, but not in a useable way: gopass will still consider itself not properly initialized, and next time you run the setup, you will be prompted for that old passphrase that was generated during the failed setup between the steps

$ gopass setup --crypto age
🌟 Welcome to gopass!
🌟 Initializing a new password store ...
<PROMPT FOR THAT PASSPHRASE>
🔐 No useable cryptographic keys. Generating new key pair
<...>

which is a somewhat weird edge case. I don't have a good solution, but maybe we should delete the identity file in case it failed to setup? That shouldn't cause issues for a fully initialized store since these won't even let user go through setup again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea. Let me add that to this PR.

}
}

out.Notice(ctx, "🔐 We need to unlock your newly created private key now! Please enter the passphrase you just generated.")
Expand Down
Loading