Use return variables for Goodsig and Signers

This commit is contained in:
root 2012-12-02 00:41:09 -02:00
parent 6e90c21c87
commit d6d8d565c9

View file

@ -27,8 +27,6 @@ Extension_list=
Repack_limit=25 Repack_limit=25
Recipients= Recipients=
Signers=
Goodsig=
# compat/utility functions # compat/utility functions
xecho() xecho()
@ -272,15 +270,16 @@ PRIVENCRYPT()
addsignkeyparam gpg --compress-algo none -se $1 addsignkeyparam gpg --compress-algo none -se $1
} }
# $1 is the match for good signature, $2 is the textual signers list
PRIVDECRYPT() PRIVDECRYPT()
{ {
local status_= local status_=
exec 4>&1 && exec 4>&1 &&
status_=$(gpg --status-fd 3 -q -d 3>&1 1>&4) && status_=$(gpg --status-fd 3 -q -d 3>&1 1>&4) &&
xecho "$status_" | grep "^\[GNUPG:\] ENC_TO " >/dev/null && xecho "$status_" | grep "^\[GNUPG:\] ENC_TO " >/dev/null &&
(xecho "$status_" | grep -e "$Goodsig" >/dev/null || { (xecho "$status_" | grep -e "$1" >/dev/null || {
echo_info "Failed to verify manifest signature!" && echo_info "Failed to verify manifest signature!" &&
echo_info "Only accepting signatories: ${Signers:-(none)}" && echo_info "Only accepting signatories: ${2:-(none)}" &&
return 1 return 1
}) })
} }
@ -327,9 +326,10 @@ make_new_repo()
} }
# $1 return var for goodsig match, $2 return var for signers text
read_config() read_config()
{ {
local recp_= key_line= cap_= conf_keyring= conf_part= local recp_= key_line= cap_= conf_keyring= conf_part= good_sig= signers_=
Conf_signkey=$(git config --path user.signingkey || :) Conf_signkey=$(git config --path user.signingkey || :)
conf_keyring=$(git config --path gcrypt.keyring || :) conf_keyring=$(git config --path gcrypt.keyring || :)
conf_part=$(git config --get "remote.$NAME.gcrypt-participants" '.+' || conf_part=$(git config --get "remote.$NAME.gcrypt-participants" '.+' ||
@ -346,9 +346,11 @@ read_config()
if isnull "$conf_part" || iseq "$conf_part" simple if isnull "$conf_part" || iseq "$conf_part" simple
then then
Signers="(default keyring)" signers_="(default keyring)"
Recipients="--throw-keyids --default-recipient-self" Recipients="--throw-keyids --default-recipient-self"
Goodsig="^\[GNUPG:\] GOODSIG " good_sig="^\[GNUPG:\] GOODSIG "
setvar "$1" "$good_sig"
setvar "$2" "$signers_"
return 0 return 0
fi fi
@ -358,8 +360,8 @@ read_config()
keyid_=$(xecho "$key_line" | cut -f 5 -d :) keyid_=$(xecho "$key_line" | cut -f 5 -d :)
isnonnull "$keyid_" && isnonnull "$keyid_" &&
Signers="$Signers $keyid_" && signers_="$signers_ $keyid_" &&
Goodsig=$(append "$Goodsig" "^\[GNUPG:\] GOODSIG $keyid_") || { good_sig=$(append "$good_sig" "^\[GNUPG:\] GOODSIG $keyid_") || {
echo_info "WARNING: Skipping missing key $recp_" echo_info "WARNING: Skipping missing key $recp_"
continue continue
} }
@ -375,18 +377,20 @@ read_config()
echo_info " git config gcrypt.participants YOURKEYID" echo_info " git config gcrypt.participants YOURKEYID"
exit 1 exit 1
fi fi
setvar "$1" "$good_sig"
setvar "$2" "$signers_"
} }
ensure_connected() ensure_connected()
{ {
local manifest_= rcv_repoid= r_name= url_frag= local manifest_= rcv_repoid= r_name= url_frag= good_sig= signers_=
if isnonnull "$Did_find_repo" if isnonnull "$Did_find_repo"
then then
return return
fi fi
Did_find_repo=no Did_find_repo=no
read_config read_config good_sig signers_
iseq "${NAME#gcrypt::}" "$URL" || r_name=$NAME iseq "${NAME#gcrypt::}" "$URL" || r_name=$NAME
@ -446,7 +450,7 @@ ensure_connected()
Did_find_repo=yes Did_find_repo=yes
echo_info "Decrypting manifest" echo_info "Decrypting manifest"
manifest_=$(PRIVDECRYPT < "$TmpManifest_Enc") && manifest_=$(PRIVDECRYPT "$good_sig" "$signers_" < "$TmpManifest_Enc") &&
isnonnull "$manifest_" || isnonnull "$manifest_" ||
echo_die "Failed to decrypt manifest!" echo_die "Failed to decrypt manifest!"
rm -f "$TmpManifest_Enc" rm -f "$TmpManifest_Enc"