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)

View File

@@ -20,6 +20,7 @@ setup(
'python-daemon>=2.1.2',
'ecdsa>=0.13',
'ed25519>=1.4',
'mnemonic>=0.18',
'pymsgbox>=1.0.6',
'semver>=2.2',
'unidecode>=0.4.20',