Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions tomb
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ ask_password() {
return 1
}

print "$password"
print -R -n - "$password"
return 0
}

Expand Down Expand Up @@ -1152,12 +1152,12 @@ _load_key() {
# contains tweaks for different gpg versions
# support both symmetric and asymmetric encryption
gpg_decrypt() {
# fix for gpg 1.4.11 where the --status-* options don't work ;^/
# gpg version check necessary for <2.1.x (although those aren't supported anymore)
local gpgver=$(gpg --version --no-permission-warning | awk '/^gpg/ {print $3}')
local gpgpass="$1\n$TOMBKEY"
local gpgpass="$1"
local tmpres ret
typeset -a gpgopt
gpgpopt=(--batch --no-tty --passphrase-fd 0 --no-options)
gpgpopt=(--batch --no-tty --no-options --no-mdc-warning --no-permission-warning --no-secmem-warning)

{ option_is_set -g } && {
gpgpass="$TOMBKEY"
Expand All @@ -1174,29 +1174,18 @@ gpg_decrypt() {
}
}

[[ $gpgver == "1.4.11" ]] && {
_verbose "GnuPG is version 1.4.11 - adopting status fix."
TOMBSECRET=`print - "$gpgpass" | \
gpg --decrypt ${gpgpopt[@]}`
ret=$?
unset gpgpass
return $ret
}

_tmp_create
tmpres=$TOMBTMP
TOMBSECRET=`print - "$gpgpass" | \
gpg --decrypt ${gpgpopt[@]} \
--status-fd 2 --no-mdc-warning --no-permission-warning \
--no-secmem-warning 2> $tmpres`
TOMBSECRET=`print - "$TOMBKEY" | \
gpg --decrypt ${gpgpopt[@]} --status-fd 2 \
--passphrase-file <(print -R -n - "$gpgpass") 2> $tmpres`
unset gpgpass
ret=1
for i in ${(f)"$(cat $tmpres)"}; do
_verbose "$i"
[[ "$i" =~ "DECRYPTION_OKAY" ]] && ret=0;
done
return $ret

}


Expand Down Expand Up @@ -1538,18 +1527,16 @@ gen_key() {
print $header >> "$1"

# Set gpg inputs and options
gpgpass="${tombpass}\n$TOMBSECRET"
gpgopt=(--passphrase-fd 0 --symmetric --no-options)
opt='-n'
fi

_tmp_create
local tmpres=$TOMBTMP
print $opt - "$gpgpass" \
print $opt - "$TOMBSECRET" \
| gpg --openpgp --force-mdc --cipher-algo ${algo} \
--batch --no-tty ${gpgopt} \
--batch --no-tty ${gpgopt} --passphrase-file <(print -R -n - "$tombpass") \
--status-fd 2 -o - --armor 2> $tmpres >> "$1"
unset gpgpass
# check result of gpg operation
for i in ${(f)"$(cat $tmpres)"}; do
_verbose "$i"
Expand Down