diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2023-08-03 10:16:19 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2023-08-11 11:59:01 +0200 |
commit | 7a460a11a6a2ffe806fb3090a6c5adc72ee281ea (patch) | |
tree | b5f8a79b43a11949448bd076f5019a3161111ecc /pinentry-rofi.sh | |
parent | 642a3da6c3b1811b272223b8c903737b5e3f2d25 (diff) | |
download | pinentry-rofi-7a460a11a6a2ffe806fb3090a6c5adc72ee281ea.tar.gz |
fix: just add more documentation and more working commands.
Diffstat (limited to 'pinentry-rofi.sh')
-rwxr-xr-x | pinentry-rofi.sh | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/pinentry-rofi.sh b/pinentry-rofi.sh index 661152e..45e8d4e 100755 --- a/pinentry-rofi.sh +++ b/pinentry-rofi.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -eu # SPDX-FileCopyrightText: 2016 Quentin "Sardem FF7" Glidic # SPDX-FileCopyrightText: 2018-2023 Fredrik Salomonsson <plattfot@posteo.net> @@ -9,6 +10,8 @@ # 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 +# Even better +# https://github.com/gpg/libassuan/blob/master/doc/assuan.texi # Although it is called a PIN-Entry, it does allow to enter reasonably # long strings (at least 2048 characters are supported by every @@ -30,7 +33,6 @@ log_debug() { rofi_cmd="rofi -dmenu -input /dev/null -password" - assuan_send() { log_debug "assuan_send: $*" echo "$@" @@ -42,6 +44,8 @@ win_title="Prompt for password" win_prompt="Password" win_mesg="" +keyinfo="" + # 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 @@ -73,6 +77,12 @@ win_mesg="" while : ; do read -r line log_debug "line=$line" + # Set options for the connection. The syntax of such a line is + # OPTION name [ [=] value ] + # Leading and trailing spaces around name and value are + # allowed but should be ignored. For compatibility reasons, name + # may be prefixed with two dashes. The use of the equal sign + # is optional but suggested if value is given. if [[ "$line" =~ ^OPTION ]] ; then # OPTION grab # OPTION ttyname=/dev/pts/1 @@ -92,13 +102,41 @@ while : ; do assuan_send f"D {os.getpid()}" fi assuan_send "OK" + # This command is reserved for future extensions. + # True NOOP + elif [[ "$line" =~ ^CANCEL ]] ; then + assuan_send "OK" + # This command is reserved for future extensions. Not yet + # specified as we don't implement it in the first phase. See + # Werner's mail to gpa-dev on 2001-10-25 about the rationale + # for measurements against local attacks. + # True NOOP + elif [[ "$line" =~ ^AUTH ]] ; then + assuan_send "OK" + # And this actually is NOOP + elif [[ "$line" =~ ^NOP ]] ; then + assuan_send "OK" + elif [[ "$line" =~ ^KEYINFO ]] ; then + assuan_send "${keyinfo}" + assuan_send "OK" elif [[ "$line" =~ ^SETKEYINFO ]] ; then - # TODO SETKEYINFO s/FINGERPRINT + IFS=" " read -ra line_arr <<< "$line" + unset "line_arr[0]" + if [[ "${line_arr[0]}" =~ ^--clear ]] ; then + keyinfo="" + else + keyinfo="${line_arr[*]}" + fi assuan_send "OK" elif [[ "$line" =~ ^SETOK|^SETNOTOK|^SETERROR|^SETCANCEL|^SETTIMEOUT|^SETQUALITYBAR|^SETGENPIN ]] ; then assuan_send "OK" elif [[ "$line" =~ ^CONFIRM|^MESSAGE ]] ; then assuan_send "OK" + # Reset the connection but not any existing authentication. + # The server should release all resources associated with the + # connection. + elif [[ "$line" =~ ^RESET ]] ; then + assuan_send "OK" elif [[ "$line" =~ ^SETDESC ]] ; then #SETDESC Please enter the passphrase for the ssh key%0A ke:yf:in:ge:rp:ri:nt # rofi << "-mesg" << $1.gsub("<", "<").gsub(/%([0-9A-Fa-f]{2})/) { $1.to_i(16).chr } @@ -129,7 +167,7 @@ while : ; do if [[ -n "${win_mesg}" ]] ; then rofi_cmd+=" -mesg ${win_mesg}" fi - passw="$(eval ${rofi_cmd})" + passw="$(eval "${rofi_cmd}")" passw_err=$? if [[ ${passw_err} -ne 0 ]] ; then # assuan_send "ERR 83886179 Operation cancelled <rofi>" @@ -141,6 +179,7 @@ while : ; do fi fi assuan_send "OK" + # Close the connection. The server will respond with OK. elif [[ ${line} =~ ^BYE ]] ; then exit 0 else |