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
Force restic to ask the password when adding a key. #1133
Conversation
As `restic key add` uses the same `ReadPasswordTwice()` as the rest of restic, it is sensitive to the environment variable RESTIC_PASSWORD or --password-file= override. When asking for the new key, temporary remove these 2 overrides, forcing the password to be asked.
Codecov Report
@@ Coverage Diff @@
## master #1133 +/- ##
=========================================
- Coverage 52.84% 49.5% -3.35%
=========================================
Files 121 121
Lines 11397 11406 +9
=========================================
- Hits 6023 5646 -377
- Misses 4667 5078 +411
+ Partials 707 682 -25
Continue to review full report at Codecov.
|
Instead of determining the password lazily during ReadPassword(), do so now in cobra.PersistentPreRunE() so we can store the result in the globalOptions and reuse/override when applicable without having to worry about the environment or flag options interfering.
Sounds like this solution will not allow non-interactive invocation of this subcommand. Possibly a more universal solution would be to use a different environment variable and a different command line option for password that is added by |
Can you please file a new feature request for this? I'm just trying to fix the broken existing behavior (==bug) here and would be happy to discuss (and share my concerns ^^) on your feature request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
Force restic to ask the password when adding a key.
As
restic key add
uses the sameReadPasswordTwice()
as therest of restic, it is sensitive to the environment variable
RESTIC_PASSWORD or --password-file= override.
When asking for the new key, temporary remove these 2 overrides, forcing
the password to be asked.
Closes #1132