gpg: allow setting passphrase from environment variable
as done by TREZOR's client library
This commit is contained in:
@@ -6,6 +6,7 @@ import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import mnemonic
|
||||
import semver
|
||||
|
||||
from . import interface
|
||||
@@ -81,6 +82,13 @@ class Trezor(interface.Device):
|
||||
if _is_open_tty(sys.stdin):
|
||||
return cli_handler(msg) # CLI-based PIN handler
|
||||
|
||||
# Reusing environment variable from trezorlib/client.py
|
||||
passphrase = os.getenv("PASSPHRASE")
|
||||
if passphrase is not None:
|
||||
log.info("Using PASSPHRASE environment variable.")
|
||||
return self._defs.PassphraseAck(
|
||||
passphrase=mnemonic.Mnemonic.normalize_string(passphrase))
|
||||
|
||||
passphrase = _message_box('Please enter passphrase:')
|
||||
return self._defs.PassphraseAck(passphrase=passphrase)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user