gpg: allow setting passphrase from environment variable

as done by TREZOR's client library
This commit is contained in:
Roman Zeyde
2018-02-20 09:59:15 +02:00
parent 34ce1005fd
commit 7803026f61
2 changed files with 9 additions and 0 deletions

View File

@@ -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)