trezor-agent icon indicating copy to clipboard operation
trezor-agent copied to clipboard

GPG initialization with bracket in name fails

Open slush0 opened this issue 3 years ago • 5 comments

trezor-gpg init "Example (example) <[email protected]>" -v --time=0

ends with error:

Traceback (most recent call last):
  File "/home/marekp/.local/bin/trezor-gpg", line 8, in <module>
    sys.exit(gpg_tool())
  File "/home/marekp/.local/bin/trezor_agent.py", line 6, in <lambda>
    gpg_tool = lambda: libagent.gpg.main(DeviceType)
  File "/home/marekp/.local/lib/python3.8/site-packages/libagent/gpg/__init__.py", line 320, in main
    return args.func(device_type=device_type, args=args)
  File "/home/marekp/.local/lib/python3.8/site-packages/libagent/gpg/__init__.py", line 198, in run_init
    check_call(keyring.gpg_command(['--homedir', homedir,
  File "/home/marekp/.local/lib/python3.8/site-packages/libagent/gpg/__init__.py", line 104, in check_call
    subprocess.check_call(args=args, stdin=stdin, env=env)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/gpg', '--homedir', '/home/marekp/.gnupg/trezor', '--list-secret-keys', 'Example (example) <[email protected]>']' returned non-zero exit status 2.

Initialization without a simple brackets "(example)" works as expected.

slush0 avatar Apr 11 '22 11:04 slush0

Ok, now it looks like any special character in name actually fails. I tried it with asterisks and I got the same result. The same apply for three words in the name.

slush0 avatar Apr 11 '22 11:04 slush0

Oh, found out that this doesn't apply to latest version built from git. Closing.

slush0 avatar Apr 11 '22 11:04 slush0

It looks like the error is back and now it is not caused by brackets.

$ trezor-gpg init --time=0 "test"
2022-06-07 23:24:47,078 WARNING      This GPG tool is still in EXPERIMENTAL mode, so please note that the API and features may change without backwards compatibility! [__init__.py:118]
2022-06-07 23:24:47,095 WARNING      NOTE: in order to re-generate the exact same GPG key later, run this command with "--time=0" commandline flag (to set the timestamp of the GPG key manually). [__init__.py:33]
gpg: inserting ownertrust of 6
gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: error reading key: No secret key
Traceback (most recent call last):
  File "/home/marekp/.local/bin/trezor-gpg", line 11, in <module>
    load_entry_point('trezor-agent', 'console_scripts', 'trezor-gpg')()
  File "/home/marekp/projekty/trezor/trezor-agent/agents/trezor/trezor_agent.py", line 6, in <lambda>
    gpg_tool = lambda: gpg.main(DeviceType)
  File "/home/marekp/projekty/trezor/trezor-agent/libagent/gpg/__init__.py", line 331, in main
    return args.func(device_type=device_type, args=args)
  File "/home/marekp/projekty/trezor/trezor-agent/libagent/gpg/__init__.py", line 198, in run_init
    check_call(keyring.gpg_command(['--homedir', homedir,
  File "/home/marekp/projekty/trezor/trezor-agent/libagent/gpg/__init__.py", line 104, in check_call
    subprocess.check_call(args=args, stdin=stdin, env=env)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/gpg', '--homedir', '/home/marekp/.gnupg/trezor', '--list-secret-keys', 'test']' returned non-zero exit status 2.

trezor==0.13, trezor-agent=0.11.0 libagent=0.14.4 (built from github master), gpg 2.2.19

I have no clue what's going wrong and why "--list-secret-keys" is called at first place. Any advice, please?

slush0 avatar Jun 07 '22 22:06 slush0

I have added a call to gpg --list-secret-keys (which uses gpg-agent to list the available signing keys) as a sanity test - to make sure the installation worked.

I do remember that once it a while gpg failed to connect to the agent during this step though... but usually it wasn't a persistent issue.

romanz avatar Jun 08 '22 17:06 romanz

BTW, does the issue reproduce?

If so, could you please try with the latest master branch (both of libagent & trezor-agent packages)? You can also add -vvv to the trezor-gpg init command to see more verbose logs.

romanz avatar Jun 08 '22 17:06 romanz