From a3c913dec62cb098b3234bfaec22492ba8979119 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 15 Jul 2022 12:46:50 -0300 Subject: Fix(xclip): avoid 'Error: target STRING not available' (2) --- lib/keyringer/actions/xclip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/keyringer/actions/xclip b/lib/keyringer/actions/xclip index f63fdb5..0e36dae 100755 --- a/lib/keyringer/actions/xclip +++ b/lib/keyringer/actions/xclip @@ -20,7 +20,7 @@ clip() { # Avoid "Error: target STRING not available" # https://github.com/astrand/xclip/issues/38 - echo "$RANDOM" | $xclip + echo "$RANDOM" | $xclip &> /dev/null # Copy text into clipboard echo -n "$1" | $xclip -- cgit v1.2.3 From aac16ab2cbd31d783f98a1ffe814a363886f74f4 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 19 Aug 2022 11:17:15 -0300 Subject: Fix re-encryption when the secret hass NULL bytes --- ChangeLog | 4 +++ lib/keyringer/actions/recrypt | 59 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b6fae2..0c39eb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2022-08-19 - unreleased - Silvio Rhatto + + Fix re-encryption when the secret hass NULL bytes + 2022-06-07 - 0.5.7 - Silvio Rhatto New upstream URLs diff --git a/lib/keyringer/actions/recrypt b/lib/keyringer/actions/recrypt index 0e2f6a0..5542bfc 100755 --- a/lib/keyringer/actions/recrypt +++ b/lib/keyringer/actions/recrypt @@ -9,33 +9,66 @@ source "$LIB" readwrite $* || exit 1 # Recrypt a single secret function keyringer_recrypt { - # Get file keyringer_get_file "$1" # Set recipients file keyringer_set_recipients "$FILE" - # Decrypt - decrypted="$($GPG --use-agent -d "$KEYDIR/$FILE")" + # Verbosity + echo "Processing $FILE..." - if [ "$?" != "0" ]; then - echo "Decryption error on $1." - exit 1 - fi + # Recrypt in stages. This approach will fail for secrets that have NULL bytes, since + # bash can't hold those as variables. + # + # In that case, it would lead to the following warning: + # + # lib/keyringer/actions/recrypt: line 20: warning: command substitution: ignored null byte in input + # + # See https://stackoverflow.com/a/42493691 + # + ## Decrypt + #decrypted="$($GPG --use-agent -d "$KEYDIR/$FILE")" + + #if [ "$?" != "0" ]; then + # echo "Decryption error on $1." + # exit 1 + #fi + + ## Recrypt + #recrypted="`echo "$decrypted" | $GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE")`" + + #if [ "$?" != "0" ]; then + # echo "Recryption error on $1." + # exit 1 + #fi - # Recrypt - recrypted="`echo "$decrypted" | $GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE")`" + #unset decrypted + #echo "$recrypted" > "$KEYDIR/$FILE" + + # As we can't use variables as the secret material can contain NULL bytes, we + # use a temporary file instead + set -o pipefail + mkdir -p -m 700 "$TMPWORK/`dirname $FILE`" + $GPG --use-agent -d "$KEYDIR/$FILE" | $GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") -o "$TMPWORK/$FILE.recrypted" if [ "$?" != "0" ]; then echo "Recryption error on $1." + + if [ -e "$TMPWORK/$FILE.recrypted" ]; then + keyringer_shred "$TMPWORK/$FILE.recrypted" + fi + exit 1 fi - unset decrypted - echo "$recrypted" > "$KEYDIR/$FILE" + # Move the re-encrypted secret only if there was no error + mv "$TMPWORK/$FILE.recrypted" "$KEYDIR/$FILE" } +# Set a tmp file +keyringer_set_tmpfile recrypt -d + # Syntax check and dispatcher if [ ! -z "$2" ]; then keyringer_recrypt $2 @@ -46,3 +79,7 @@ else fi done fi + +# Cleanup +rm -rf "$TMPWORK" +trap - EXIT -- cgit v1.2.3 From 0bce87704b1ca134880067942e3eb64f548a0e32 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 19 Aug 2022 12:17:40 -0300 Subject: Keyringer 0.5.8 --- ChangeLog | 4 +++- keyringer | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c39eb4..81e4d25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,9 @@ -2022-08-19 - unreleased - Silvio Rhatto +2022-08-19 - 0.5.8 - Silvio Rhatto Fix re-encryption when the secret hass NULL bytes + Attempt to fix xclip message 'Error: target STRING not available' + 2022-06-07 - 0.5.7 - Silvio Rhatto New upstream URLs diff --git a/keyringer b/keyringer index f28c8f3..878d5d1 100755 --- a/keyringer +++ b/keyringer @@ -140,7 +140,7 @@ function keyringer_dispatch { # Config NAME="keyringer" -KEYRINGER_VERSION="0.5.7" +KEYRINGER_VERSION="0.5.8" CONFIG_VERSION="0.1" CONFIG_BASE="$HOME/.$NAME" CONFIG="$CONFIG_BASE/config" -- cgit v1.2.3