diff options
author | Fredrik Salomonsson <plattfot@gmail.com> | 2020-04-21 13:25:58 -0700 |
---|---|---|
committer | Fredrik Salomonsson <plattfot@gmail.com> | 2020-04-21 13:25:58 -0700 |
commit | 3aa7741db05aa5334b67e9bf52ca482291f5598a (patch) | |
tree | 9b23dbccbdb4ee014768cd168b2e709c64490fe8 | |
parent | a69f12768f38b662fd5c6eb2365694d98309cbe2 (diff) | |
download | pinentry-rofi-3aa7741db05aa5334b67e9bf52ca482291f5598a.tar.gz |
Added support to ask password again if it's wrong (#3)0.5.0
SETERROR was missing so it was just bailing out when it saw that
command.
-rwxr-xr-x | pinentry-rofi.scm | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/pinentry-rofi.scm b/pinentry-rofi.scm index a669c79..5afb98f 100755 --- a/pinentry-rofi.scm +++ b/pinentry-rofi.scm @@ -31,7 +31,7 @@ (ice-9 regex) (ice-9 getopt-long)) -(define pinentry-rofi-guile-version "0.4.0") +(define pinentry-rofi-guile-version "0.5.0") (when (equal? (system-file-name-convention) 'windows) (format #t "Only support posix systems!") @@ -44,7 +44,8 @@ (prompt pinentry-prompt set-pinentry-prompt!) (desc pinentry-desc set-pinentry-desc!) (visibility pinentry-visibility set-pinentry-visibility!) - (display pinentry-display set-pinentry-display!)) + (display pinentry-display set-pinentry-display!) + (error pinentry-error set-pinentry-error!)) (define-syntax-rule (set-and-return! val expr) "Set val to expr and return val" @@ -115,6 +116,15 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent" (set-pinentry-desc! pinentry mesg))) regex-match)) +(define (pinentry-seterror pinentry line) + "SETERROR MESSAGE" + (let ((seterror-re (make-regexp "^SETERROR (.+)$")) + (regex-match #f)) + (when (set-and-return! regex-match (regexp-exec seterror-re line)) + (let ((mesg (hex->char (html-< (match:substring regex-match 1))))) + (set-pinentry-error! pinentry mesg)) + regex-match))) + (define (pinentry-setprompt pinentry line) "SETPROMPT Passphrase:" (let ((setprompt-re (make-regexp "^SETPROMPT (.+)$")) @@ -138,7 +148,11 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent" "-lines" "1" (if (pinentry-visibility pinentry) "" "-password") "-p" (pinentry-prompt pinentry) - "-mesg" (pinentry-desc pinentry))) + "-mesg" (if (pinentry-error pinentry) + (format #f "~a\n~a" + (pinentry-error pinentry) + (pinentry-desc pinentry)) + (pinentry-desc pinentry)))) (pass (get-string-all pipe)) (status (close-pipe pipe))) (if (equal? (status:exit-val status) 0) @@ -168,6 +182,7 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent" ((pinentry-setdesc pinentry line)) ((pinentry-setprompt pinentry line)) ((pinentry-getpin pinentry line)) + ((pinentry-seterror pinentry line)) ((pinentry-bye pinentry line)) (#t (begin (format #t "BYE\n") |