From 08d81c992c5a4695e23dcfbccdb2a838a6ccb777 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Tue, 27 Feb 2018 11:17:53 +0200 Subject: [PATCH] trezor: split pinentry tool into a separate file --- libagent/device/trezor.py | 4 +--- libagent/device/ui/__init__.py | 1 + libagent/device/ui/simple.py | 6 ++++++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 libagent/device/ui/__init__.py create mode 100644 libagent/device/ui/simple.py diff --git a/libagent/device/trezor.py b/libagent/device/trezor.py index 0dc3d5b..f1a2861 100644 --- a/libagent/device/trezor.py +++ b/libagent/device/trezor.py @@ -16,9 +16,7 @@ log = logging.getLogger(__name__) def _message_box(label, sp=subprocess): """Launch an external process for PIN/passphrase entry GUI.""" - cmd = ('import sys, pymsgbox; ' - 'sys.stdout.write(pymsgbox.password(sys.stdin.read()))') - args = [sys.executable, '-c', cmd] + args = [sys.executable, '-m', 'libagent.device.ui.simple'] p = sp.Popen(args=args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) out, err = p.communicate(label.encode('ascii')) exitcode = p.wait() diff --git a/libagent/device/ui/__init__.py b/libagent/device/ui/__init__.py new file mode 100644 index 0000000..4313f96 --- /dev/null +++ b/libagent/device/ui/__init__.py @@ -0,0 +1 @@ +"""UIs for PIN/passphrase entry.""" diff --git a/libagent/device/ui/simple.py b/libagent/device/ui/simple.py new file mode 100644 index 0000000..7c59b79 --- /dev/null +++ b/libagent/device/ui/simple.py @@ -0,0 +1,6 @@ +"""Simple, cross-platform UI for entering a PIN/passhprase.""" +import sys + +import pymsgbox + +sys.stdout.write(pymsgbox.password(sys.stdin.read()))