diff options
-rw-r--r-- | util/pinentry/pinentry.lisp | 27 | ||||
-rwxr-xr-x | util/pinentry/stumpwm-pinentry | 2 |
2 files changed, 11 insertions, 18 deletions
diff --git a/util/pinentry/pinentry.lisp b/util/pinentry/pinentry.lisp index ae83c51..74d9798 100644 --- a/util/pinentry/pinentry.lisp +++ b/util/pinentry/pinentry.lisp @@ -1,22 +1,15 @@ (defpackage #:pinentry - (:use #:cl)) + (:use #:cl) + (:export #:getpin)) (in-package #:pinentry) -(defun main (stream) +(defun getpin (description prompt) (ignore-errors - (let ((description (percent:decode (read-line stream))) - (prompt (read-line stream))) - (format stream - (percent:encode - (or (stumpwm:read-one-line (stumpwm:current-screen) - (format nil "~a~%~a " description prompt) - :password t) - "")))))) - -(handler-case (usocket:socket-server "127.0.0.1" 22222 #'main nil - :in-new-thread t - :multi-threading t) - ;; Probably already running: - (usocket:address-in-use-error ()) - (usocket:address-not-available-error ())) + (let ((description (percent:decode description)) + (prompt (percent:decode prompt))) + (percent:encode + (or (stumpwm:read-one-line (stumpwm:current-screen) + (format nil "~a~%~a " description prompt) + :password t) + ""))))) diff --git a/util/pinentry/stumpwm-pinentry b/util/pinentry/stumpwm-pinentry index 1f2c4b3..e0aff38 100755 --- a/util/pinentry/stumpwm-pinentry +++ b/util/pinentry/stumpwm-pinentry @@ -12,7 +12,7 @@ while IFS="\n" read -r command; do elif [[ "$command" == SETPROMPT* ]]; then prompt=${command:10} elif [ "$command" == GETPIN ]; then - password=$(printf "%s\n%s\n" "$description" "$prompt" | nc 127.0.0.1 22222) + password=$(stumpish eval "(pinentry:getpin \"$description\" \"$prompt\")" | cut -d '""' -f 2) if [ -z "$password" ]; then echo S close_button fi |