aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/password-store.sh
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-08-01 04:12:04 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-08-01 04:12:04 +0200
commit44f54f0b02b567d621764a50b0920c87c245e4c9 (patch)
tree70d7e478dc86e48a26f7a750bef651d7d04adf82 /src/password-store.sh
parentAdd custom bash completion for extensions (diff)
downloadpassword-store-44f54f0b02b567d621764a50b0920c87c245e4c9.tar.xz
password-store-44f54f0b02b567d621764a50b0920c87c245e4c9.zip
show: do not store binary data in bash vars
Instead we're forced to base64 it, like we do with the clipboard.
Diffstat (limited to 'src/password-store.sh')
-rwxr-xr-xsrc/password-store.sh14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index 55a1aea..1d26a1a 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -156,12 +156,12 @@ clip() {
# trailing new lines.
local sleep_argv0="password store sleep on display $DISPLAY"
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
- local before="$(xclip -o -selection "$X_SELECTION" 2>/dev/null | base64)"
+ local before="$(xclip -o -selection "$X_SELECTION" 2>/dev/null | $BASE64)"
echo -n "$1" | xclip -selection "$X_SELECTION" || die "Error: Could not copy data to the clipboard"
(
( exec -a "$sleep_argv0" bash <<<"trap 'kill %1' TERM; sleep '$CLIP_TIME' & wait" )
- local now="$(xclip -o -selection "$X_SELECTION" | base64)"
- [[ $now != $(echo -n "$1" | base64) ]] && before="$now"
+ local now="$(xclip -o -selection "$X_SELECTION" | $BASE64)"
+ [[ $now != $(echo -n "$1" | $BASE64) ]] && before="$now"
# It might be nice to programatically check to see if klipper exists,
# as well as checking for other common clipboard managers. But for now,
@@ -172,7 +172,7 @@ clip() {
# so we axe it here:
qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory &>/dev/null
- echo "$before" | base64 -d | xclip -selection "$X_SELECTION"
+ echo "$before" | $BASE64 -d | xclip -selection "$X_SELECTION"
) >/dev/null 2>&1 & disown
echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."
}
@@ -224,6 +224,7 @@ tmpdir() {
}
GETOPT="getopt"
SHRED="shred -f -z"
+BASE64="base64"
source "$(dirname "$0")/platform/$(uname | cut -d _ -f 1 | tr '[:upper:]' '[:lower:]').sh" 2>/dev/null # PLATFORM_FUNCTION_FILE
@@ -363,8 +364,8 @@ cmd_show() {
check_sneaky_paths "$path"
if [[ -f $passfile ]]; then
if [[ $clip -eq 0 && $qrcode -eq 0 ]]; then
- pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile")" || exit $?
- echo "$pass"
+ pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | $BASE64)" || exit $?
+ echo "$pass" | $BASE64 -d
else
[[ $selected_line =~ ^[0-9]+$ ]] || die "Clip location '$selected_line' is not a number."
pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +${selected_line} | head -n 1)" || exit $?
@@ -474,7 +475,6 @@ cmd_edit() {
tmpdir #Defines $SECURE_TMPDIR
local tmp_file="$(mktemp -u "$SECURE_TMPDIR/XXXXXX")-${path//\//-}.txt"
-
local action="Add"
if [[ -f $passfile ]]; then
$GPG -d -o "$tmp_file" "${GPG_OPTS[@]}" "$passfile" || exit 1