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

Allow the user to configure a pinentry #202

Closed
wants to merge 14 commits into from

Conversation

rendaw
Copy link
Contributor

@rendaw rendaw commented Feb 22, 2018

(and optionally a passphrase entry).

It uses pinentry by default, which should be available if gpg is installed, then falls back to the existing builtin pinentry. I also had to parse the options passed to the agent to pass them to the pinentry - this communicates things like the X11 display and user's current TTY so the pinentry can communicate properly.

(and optionally a passphrase entry).
It uses `pinentry` by default, which should
be available if gpg is installed.  It looks
roughly similar to the existing pinentry.
encoding='utf-8',
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
)
except OSError as e:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Py2 specific. How would you handle compatibility in this case? Catch both? Wrap subprocess?

@@ -255,6 +266,8 @@ def main(device_type):
p.add_argument('-t', '--time', type=int, default=int(time.time()))
p.add_argument('-v', '--verbose', default=0, action='count')
p.add_argument('-s', '--subkey', default=False, action='store_true')
p.add_argument('-p', '--pinentry')
p.add_argument('-pa', '--passentry')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these would be better as long options only.

@rendaw
Copy link
Contributor Author

rendaw commented Feb 22, 2018

I noticed I missed SSH config. Any suggestions on how to access the config there? Should that just read gpg-agent.conf?

Will fix remaining lint issues tomorrow.

Edit: I have SSH load the gpg-agent.conf to get the pinentry programs and it also uses the log level configured there now.

@romanz
Copy link
Owner

romanz commented Feb 22, 2018

@rendaw Please let me know when I can review this PR :)

@rendaw
Copy link
Contributor Author

rendaw commented Feb 22, 2018

Ah, please review it when you are available! :) I've tested the GPG portion and added the SSH config, and the linting passes. I think it's complete at this point.

I haven't switched over to using trezor-agent keys yet though for day to day work, so I'd like to do that.

@rendaw
Copy link
Contributor Author

rendaw commented Feb 22, 2018

Found this regarding default pinentry program logic: https://github.com/gpg/gnupg/blob/660eafa3a9f68e116e9b0597edc317d8ff90f9b2/common/homedir.c#L932 - so there's more that could be done to come up with fallback names for Windows. At the moment though it will still use the builtin pinentry so it shouldn't cause problems at least.

@rendaw
Copy link
Contributor Author

rendaw commented Feb 22, 2018

I just figured out that SSH operation is completely separate from the GPG setup and ring, so the configuration files might not be there. Do you have any suggestions how to handle the pinentry/passphrase entry configuration for SSH in that case?

Edit: On second thought, since this is by default a GPG pinentry program and protocol maybe it's reasonable to ask them to complete the GPG setup first.

@rendaw
Copy link
Contributor Author

rendaw commented Feb 23, 2018

@romanz I made the pinentry SSH config a normal command line argument which seems to be working alright, although I think there's an issue with configargparse (bw2/ConfigArgParse#114) which makes the config file unusable.

I don't think there's anything left to do prior to review, and I've tested it for both SSH and GPG usage locally (seems to work well).

In the meantime if I'll continue to use it myself and fix issues if I find any.

Copy link
Owner

@romanz romanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all - many thanks for effort adding the needed functionality, and sorry for taking so long to review it...

I've understood that my original design of the PIN/passphrase entry is not extensible enough - so I've opened #211 - which should make the integration with trezor-gpg-pinentry-tk much easier.
Could you please take a look at #211?

@rendaw
Copy link
Contributor Author

rendaw commented Mar 8, 2018

Closing in favor of #211

@rendaw rendaw closed this Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants