aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDale Phurrough <dale@hidale.com>2018-02-09 03:29:45 +0100
committerDale Phurrough <dale@hidale.com>2018-02-13 16:07:20 +0100
commit4c8f768494377f8d1f18623519c9c42d9eec37ca (patch)
tree871c3f89bfb9ad053d3398d16d2faf00cf5d2d46
parent8355b07e1a87e01381676b81343c8c0c6c76ca93 (diff)
downloadpinentry-rofi-4c8f768494377f8d1f18623519c9c42d9eec37ca.tar.gz
get keyid as user from dialog description
-rw-r--r--pinentry-wsl-ps1.sh18
1 files changed, 14 insertions, 4 deletions
diff --git a/pinentry-wsl-ps1.sh b/pinentry-wsl-ps1.sh
index 87f8b70..85844ca 100644
--- a/pinentry-wsl-ps1.sh
+++ b/pinentry-wsl-ps1.sh
@@ -5,7 +5,8 @@ TIMEOUT="0"
DESCRIPTION="Enter password for GPG key"
PROMPT="Password:"
TITLE="GPG Key Credentials"
-CACHEPREFIX="gpgcache://"
+CACHEPREFIX="gpgcache:"
+CACHEUSER=""
KEYINFO=""
OKBUTTON="&OK"
CANCELBUTTON="&Cancel"
@@ -47,10 +48,15 @@ assuan_result() {
}
getpassword() {
+ if [ -n $CACHEUSER ]; then
+ local creduser="$CACHEUSER"
+ else
+ local creduser="$KEYINFO"
+ fi
local cmd_prompt=$(cat <<-DLM
\$cred = \$Host.ui.PromptForCredential("$TITLE",
"$PINERROR$DESCRIPTION",
- "$KEYINFO",
+ "$creduser",
"",
"Generic",
"None,ReadOnlyUserName")
@@ -62,7 +68,7 @@ DLM
local cmd_repeat=$(cat <<-DLM
\$cred = \$Host.ui.PromptForCredential("$TITLE",
"$REPEATDESCRIPTION",
- "$KEYINFO",
+ "$creduser",
"",
"Generic",
"None,ReadOnlyUserName")
@@ -81,7 +87,7 @@ DLM
local cmd_store=$(cat <<-DLM
\$pw = \$Input | Select-Object -First 1
\$securepw = ConvertTo-SecureString \$pw -AsPlainText -Force
- New-StoredCredential -Target "$CACHEPREFIX$KEYINFO" -Type GENERIC -UserName "$KEYINFO" -SecurePassword \$securepw -Persist LocalMachine |
+ New-StoredCredential -Target "$CACHEPREFIX$KEYINFO" -Type GENERIC -UserName "$creduser" -SecurePassword \$securepw -Persist LocalMachine |
out-null
DLM
)
@@ -203,6 +209,10 @@ setdescription() {
local prep2="${prep1//%/\\x}" # convert hex encoding style
local decode="$(echo -en "$prep2")" # decode hex
DESCRIPTION="${decode//\"/\`\"}" # escape double quotes for powershell
+ local searchfor='ID ([[:xdigit:]]{16})' # hack to search for first gpg key id in description
+ if [[ "$1" =~ $searchfor ]]; then
+ CACHEUSER="${BASH_REMATCH[1]}"
+ fi
echo "OK"
}