Skip to content

Commit

Permalink
pkg/pinentry: Support OPTION call for pinentry (#1469)
Browse files Browse the repository at this point in the history
RELEASE_NOTES=[FEATURE] Pinentry API: support OPTION API call

For example, to allow storing passwords in keychain, the option `allow-external-password-cache` must be set (together with `SETKEYINFO [keyname]`).

Thus, we support the `OPTION` API call, as for example described in http://info2html.sourceforge.net/cgi-bin/info2html-demo/info2html?(pinentry)Protocol .

Fixes: #1470
Signed-off-by: Sebastian Kurfürst <sebastian.kurfuerst@sandstorm.de>
  • Loading branch information
skurfuerst authored Jul 23, 2020
1 parent 55b7134 commit 11660a1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/pinentry/pinentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ func (c *Client) Set(key, value string) error {
return nil
}

// Option sets an option, e.g. "default-cancel=Abbruch" or "allow-external-password-cache"
func (c *Client) Option(value string) error {
val := "OPTION " + value + "\n"
if _, err := c.in.Write([]byte(val)); err != nil {
return err
}
line, _, _ := c.out.ReadLine()
if string(line) != "OK" {
return errors.Errorf("error: %s", line)
}
return nil
}

// GetPin asks for the pin
func (c *Client) GetPin() ([]byte, error) {
if _, err := c.in.Write([]byte("GETPIN\n")); err != nil {
Expand Down

0 comments on commit 11660a1

Please sign in to comment.