summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill A. Korinsky <kirill@korins.ky>2024-03-22 14:06:27 +0100
committerKirill A. Korinsky <kirill@korins.ky>2024-03-22 14:10:07 +0100
commit816d67f73ee782ab85239779b8f0384ac11839ca (patch)
tree347cb4961bd65c4b4174acc29991569c0e52d86b
parentbfb815c776f2ad3af89729eb1a7aafd7b8773c7e (diff)
Move pinentry to stumpish
Instead using nc and dedicated thread which lock current screen, use stumpish to run the function. It is a bit slower, but way stable than old way.
-rw-r--r--util/pinentry/pinentry.lisp27
-rwxr-xr-xutil/pinentry/stumpwm-pinentry2
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