aboutsummaryrefslogtreecommitdiffstats
path: root/pinentry-rofi.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2023-05-18 14:53:50 +0200
committerMatěj Cepl <mcepl@cepl.eu>2023-08-11 11:59:01 +0200
commit53aabece0f1d465872ae8e9ff21b8c545f1e0566 (patch)
treec7adcb3a555b6c32aafb08d2b1c2780f87ea0a8e /pinentry-rofi.py
parenta67f3096128ff26b0a58e4eb09ae57756d6fd97c (diff)
downloadpinentry-rofi-53aabece0f1d465872ae8e9ff21b8c545f1e0566.tar.gz
fix: remove unnecessary stuff and some more debugging to the Python version.
Diffstat (limited to 'pinentry-rofi.py')
-rwxr-xr-xpinentry-rofi.py53
1 files changed, 45 insertions, 8 deletions
diff --git a/pinentry-rofi.py b/pinentry-rofi.py
index e2266e6..9d267ba 100755
--- a/pinentry-rofi.py
+++ b/pinentry-rofi.py
@@ -1,7 +1,14 @@
#!/usr/bin/env python3
+
+# SPDX-FileCopyrightText: 2016 Quentin "Sardem FF7" Glidic
+# SPDX-FileCopyrightText: 2018-2023 Fredrik Salomonsson <plattfot@posteo.net>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
# Some documentation
# https://info2html.sourceforge.net/cgi-bin/info2html-demo/info2html?(pinentry)Protocol
# https://superuser.com/a/1655428
+# TODO https://superuser.com/questions/1457167/i-want-to-make-pinentry-use-gui-locally-and-cli-on-ssh
# Although it is called a PIN-Entry, it does allow to enter reasonably
# long strings (at least 2048 characters are supported by every
@@ -15,6 +22,7 @@
# percent-escape them (i.e. a line feed is encoded as `%0A', the
# percent sign itself is encoded as `%25').
+__version__="0.0.1"
import io
import os
@@ -41,6 +49,34 @@ win_title = "Prompt for password"
win_prompt = "Password"
win_mesg = ''
+# gpg-agent[676]: DBG: chan_9 -> OK Pleased to meet you, process 3073
+# gpg-agent[676]: DBG: chan_9 <- RESET
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- OPTION ttyname=/dev/pts/0
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- OPTION ttytype=xterm-256color
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- OPTION display=:0
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- OPTION putenv=WAYLAND_DISPLAY=wayland-1
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- OPTION putenv=XDG_SESSION_TYPE=wayland
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- OPTION putenv=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- OPTION lc-ctype=en_US.UTF-8
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- OPTION lc-messages=cs_CZ.utf8
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- GETINFO version
+# gpg-agent[676]: DBG: chan_9 -> D 2.3.8
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- OPTION allow-pinentry-notify
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- OPTION agent-awareness=2.1.0
+# gpg-agent[676]: DBG: chan_9 -> OK
+# gpg-agent[676]: DBG: chan_9 <- KEYINFO 8EA96F4B4BD616DA44A2E297F31C0448A74B9D33
+
while True:
line = input()
log.debug(f'line = {line}')
@@ -52,11 +88,15 @@ while True:
# OPTION lc-messages=C
assuan_send('OK')
elif line.startswith("GETINFO"):
- info = line.split()[1].strip()
- # case ( info )
- # when 'pid'
- # assuan_send "D #{Process.pid}"
- # end
+ # https://www.gnupg.org/documentation/manuals/gnupg/Agent-GETINFO.html
+ # version or pid of this script?
+ # gpg-agent --version works but it must be filtered
+ subcommand = line.split(' ')[1]
+ log.debug(f'subcommand = {subcommand}')
+ if subcommand == 'version':
+ assuan_send(f'D {__version__}')
+ elif subcommand == 'pid':
+ assuan_send(f'D {os.getpid()}')
assuan_send('OK')
elif line.startswith("SETKEYINFO"):
# TODO SETKEYINFO s/FINGERPRINT
@@ -106,6 +146,3 @@ while True:
else:
assuan_send("BYE")
exit(1)
-
- if ok:
- break