From 18a8cbec3b4f7bcd41ab0136e79099294c3d9dc3 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Fri, 8 Dec 2023 14:06:01 +0100 Subject: [PATCH] add wrapper for passphrase preseeding --- .bin/pass | 31 +++++++++++++++++++++++++++++++ .gitignore.d/pass | 1 + 2 files changed, 32 insertions(+) create mode 100755 .bin/pass diff --git a/.bin/pass b/.bin/pass new file mode 100755 index 0000000..c15a218 --- /dev/null +++ b/.bin/pass @@ -0,0 +1,31 @@ +#!/bin/sh +set -eu + +real_pass() { + local OLDIFS; OLDIFS="$IFS" + IFS=: + local SELF; SELF="$(realpath $0)" + local CMD; CMD="$(basename "$SELF")" + local ret; ret=127 + for p in $PATH; do + case "$SELF" in ($p/*) continue;; esac + if [ -x "$p/$CMD" ]; then + ${exec:-} "$p/$CMD" "$@" + ret=$? + break + fi + done + IFS="$OLDIFS" + return $ret +} + +KEYGRIP=083F1106EEDD459ED7761C825FDB3E60FA7D8F3F + +gpg-connect-agent "keyinfo $KEYGRIP" /bye | while read a b c d e f g h; do + if [ "$g" != 1 ]; then + real_pass .meta/pass-key | /usr/lib/gnupg/gpg-preset-passphrase -c $KEYGRIP + fi + break +done + +exec=exec real_pass "$@" diff --git a/.gitignore.d/pass b/.gitignore.d/pass index 61a21a1..6d0a468 100644 --- a/.gitignore.d/pass +++ b/.gitignore.d/pass @@ -1,5 +1,6 @@ * !/.bin/genpw-editor +!/.bin/pass !/.gitignore.d/pass !/.zsh/aliases/genpw !/.zsh/aliases/getpw -- 2.39.2