Skip to content
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

PIN/Passphrase input for trezorctl doesn't work in some environments #1737

Closed
vietnamese-chowder opened this issue Jul 27, 2021 · 3 comments · Fixed by #1959 or #2023
Closed

PIN/Passphrase input for trezorctl doesn't work in some environments #1737

vietnamese-chowder opened this issue Jul 27, 2021 · 3 comments · Fixed by #1959 or #2023
Assignees
Labels
low hanging fruit Simple, quick task.

Comments

@vietnamese-chowder
Copy link

vietnamese-chowder commented Jul 27, 2021

Describe the bug
I'm trying to run trezorctl to sign a Qtum transaction built in Java alongside a Trezor device, by creating a process through ProcessBuilder that runs the command trezorctl sign-tx <name_of_file>.json. After running it, I'm feeding it the PIN (corresponding to the layout) that I acquire from the user on the frontend.

I am inputting the PIN to the process using a BufferedWriter(OutputStreamWriter(proc.getOutputStream())) by calling write(pin), then newLine(), then flush(). Everything works on Linux and on Mac when running the program through Intellij, but when I build the jar file and run that, it doesn't. trezorctl doesn't receive the input and my program hangs at the next stdInput.next(). On Windows this behaviour also occurs on Intellij, and on Git Bash.

When I run trezorctl on the command line on Windows, it works on cmd, but not on Git Bash, exhibiting the same behaviour. I've also tried running my program with sudo, so I don't think it's a permission issue. I'm pretty sure this is an issue with trezorctl's IO and not my application, because I tested the exact same method on a dummy Python script I wrote and it worked, even on Windows.

Firmware version and revision
1.10.2

Desktop/smartphone setup (please complete the following information):

  • Wallet software: trezorctl
  • OS: Windows
  • Browser: None, Git Bash
  • Version: 0.12.2

To Reproduce
Steps to reproduce the behavior:

  1. Make sure your Trezor has either PIN or Passphrase enabled
  2. Open Git Bash on Windows
  3. Type any trezorctl command i.e. trezorctl get-address -n "m/49'/0'/0'/0/0"
  4. Try typing your PIN/Passphrase (according to the layout) and press enter

Expected behavior
The mask doesn't work, so you'll see what you're typing, and pressing enter does nothing.

Screenshots
image

@vietnamese-chowder vietnamese-chowder added the bug Something isn't working as expected label Jul 27, 2021
@vietnamese-chowder vietnamese-chowder changed the title PIN/Passphrase input doesn't work in some environments PIN/Passphrase input for trezorctl doesn't work in some environments Jul 27, 2021
@matejcik
Copy link
Contributor

This seems to be an issue either with the click library, or with Python itself.

possibly related: #1682

please try manually upgrading click: pip install --upgrade click and see if the problem goes away afterwards

@matejcik
Copy link
Contributor

The issue is actually a bug in Python's getpass function, which does not work correctly on Windows unless you're using a real terminal.

(Weirdly enough, Git Bash is using MinTTY which is not actually a real terminal. It can be fixed by enabling winpty while installing Git for Windows.)

I suppose we could explicitly detect the condition and fall back to reading non-hidden input.

I'm also wondering if we should do something more advanced, e.g., like HWI does, for separating PIN entry and subsequent actions, for usage in scripts.

@alex-jerechinsky alex-jerechinsky moved this from 📥 Inbox to 🐛 Bug in Firmware · Backlog 🗂 Oct 5, 2021
@tsusanka tsusanka moved this from 🐛 Bug to 👨‍💻 Code in Firmware · Backlog 🗂 Oct 5, 2021
@tsusanka tsusanka added low hanging fruit Simple, quick task. and removed bug Something isn't working as expected labels Oct 7, 2021
@matejcik matejcik added the LOW label Oct 7, 2021
@alex-jerechinsky alex-jerechinsky added this to 📽 Product in Backlog 🗂 Oct 22, 2021
@alex-jerechinsky alex-jerechinsky moved this from 📽 Product to 💻 Code in Backlog 🗂 Oct 22, 2021
@alex-jerechinsky alex-jerechinsky removed this from 💻 Code in Firmware · Backlog 🗂 Oct 22, 2021
@alex-jerechinsky alex-jerechinsky removed this from 💻 Code in Backlog 🗂 Nov 18, 2021
@alex-jerechinsky alex-jerechinsky added this to 🎯 To do in Nov 18 - Dec 2 via automation Nov 18, 2021
@grdddj grdddj linked a pull request Nov 30, 2021 that will close this issue
Nov 18 - Dec 2 automation moved this from 🎯 To do to 🤝 Needs QA Dec 1, 2021
@alex-jerechinsky alex-jerechinsky removed this from 🤝 Needs QA in Nov 18 - Dec 2 Dec 2, 2021
@alex-jerechinsky alex-jerechinsky added this to 🎯 To do in ❄️ Dec 2 - Dec 30 via automation Dec 2, 2021
@grdddj grdddj moved this from 🎯 To do to 🏃‍♀️ In progress in ❄️ Dec 2 - Dec 30 Dec 14, 2021
@hynek-jina hynek-jina removed this from 🏃‍♀️ In progress in ❄️ Dec 2 - Dec 30 Jan 3, 2022
@hynek-jina hynek-jina added this to 🎯 To do in Dec 30 - Jan 13 via automation Jan 3, 2022
@hynek-jina hynek-jina moved this from 🎯 To do to 🏃‍♀️ In progress in Dec 30 - Jan 13 Jan 3, 2022
@grdddj grdddj linked a pull request Jan 11, 2022 that will close this issue
Dec 30 - Jan 13 automation moved this from 🏃‍♀️ In progress to 🤝 Needs QA Jan 12, 2022
@matejcik
Copy link
Contributor

@vietnamese-chowder please have a look at the new --script option to trezorctl for your usecase

@matejcik matejcik moved this from 🤝 Needs QA to ✅ Approved in Dec 30 - Jan 13 Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low hanging fruit Simple, quick task.
Projects
No open projects
Dec 30 - Jan 13
✅ Approved
5 participants