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

Fix handling of empty user input in pinentry module #178

Closed
wants to merge 2 commits into from

Conversation

d-e-s-o
Copy link
Owner

@d-e-s-o d-e-s-o commented May 2, 2021

As it turns out, the pinentry program responds slightly differently to a
request to enter a password/PIN when the user enters one vs. when he/she
just continues, leaving the input empty, as is illustrated here:

When the user enters 'hello':

$ gpg-connect-agent 'GET_PASSPHRASE --data cacheid errormsg prompt description' '/bye'
D hello
OK

When the user enters nothing:

$ gpg-connect-agent 'GET_PASSPHRASE --data cacheid errormsg prompt description' '/bye'
OK

So far we always expected a two line response, with the first line
containing the 'D ' prefix, which prevents us from handling empty input
properly.
This change fixes this shortcoming by adding a case for it.

Fixes #176

As it turns out, the pinentry program responds slightly differently to a
request to enter a password/PIN when the user enters one vs. when he/she
just continues, leaving the input empty, as is illustrated here:

When the user enters 'hello':
  > $ gpg-connect-agent 'GET_PASSPHRASE --data cacheid errormsg prompt description' '/bye'
  > D hello
  > OK

When the user enters nothing:
  > $ gpg-connect-agent 'GET_PASSPHRASE --data cacheid errormsg prompt description' '/bye'
  > OK

So far we always expected a two line response, with the first line
containing the 'D ' prefix, which prevents us from handling empty input
properly.
This change fixes this shortcoming by adding a case for it.

Fixes #176
@d-e-s-o d-e-s-o requested a review from robinkrahl May 2, 2021 17:57
Copy link
Collaborator

@robinkrahl robinkrahl left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to me!

@d-e-s-o d-e-s-o closed this May 3, 2021
@d-e-s-o d-e-s-o deleted the topic/empty-input branch May 3, 2021 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Unexpected response: OK" if empty password is entred via pinentry
2 participants