Cleanup manifest verification, require a non-empty manifest

This commit is contained in:
root 2013-02-14 00:00:00 +00:00
parent 08ad287a0c
commit 9efc5d82bf

View file

@ -239,20 +239,21 @@ ensure_connected()
DID_FIND_REPO=no DID_FIND_REPO=no
return return
fi fi
MANIFESTDATA="$(GET_OR_EMPTY "$URL" manifest | DECRYPT)" MANIFESTDATA="$(GET "$URL" manifest | DECRYPT)"
if [ -n "$MANIFESTDATA" -a \( "$CONF_REQUIRE_SIGN" = true -o \ if [ "$CONF_REQUIRE_SIGN" = true -o -z "${MANIFESTDATA##-----BEGIN*}" ]
-z "${MANIFESTDATA##-----BEGIN*}" \) ]
then then
# Use gpg to verify and strip the signature # Use gpg to verify and strip the signature
echo_info "Verifying manifest signature" echo_info "Verifying manifest signature"
STRIPDATA=$(printf "%s" "$MANIFESTDATA" | gpg --batch || { STRIPDATA="$(printf "%s" "$MANIFESTDATA" | gpg --batch || {
echo_info "WARNING: Failed to verify signature from $URL" echo_info "WARNING: Failed to verify signature from $URL"
[ "$CONF_REQUIRE_SIGN" = "true" ] && \ if [ "$CONF_REQUIRE_SIGN" = "true" ] ; then
echo_info "Exiting per gcrypt.requiresign" && exit 1 echo_info "Exiting per gcrypt.requiresign" && exit 1
} fi
) }
[ -n "$STRIPDATA" ] && MANIFESTDATA=$STRIPDATA )"
[ -n "$STRIPDATA" ] && MANIFESTDATA=$STRIPDATA || :
fi fi
[ -n "$MANIFESTDATA" ] || exit 1
BRANCHLIST=$(printf "%s\n" "$MANIFESTDATA" | xgrep -E '^[0-9a-f]{40}') BRANCHLIST=$(printf "%s\n" "$MANIFESTDATA" | xgrep -E '^[0-9a-f]{40}')
PACKLIST=$(printf "%s\n" "$MANIFESTDATA" | xgrep "^$PACKPFX") PACKLIST=$(printf "%s\n" "$MANIFESTDATA" | xgrep "^$PACKPFX")
} }
@ -346,6 +347,7 @@ do_push()
# file's hash. The manifest is updated with the pack id. # file's hash. The manifest is updated with the pack id.
# The manifest is encrypted. # The manifest is encrypted.
local REMOTEHAS local REMOTEHAS
local SIGNMANIFEST
local REMOTEWANT local REMOTEWANT
local prefix_ local prefix_
local suffix_ local suffix_
@ -395,8 +397,8 @@ do_push()
fi fi
# Put new manifest # Put new manifest
printf "%s\n%s\n" "$BRANCHLIST" "$PACKLIST" | \ SIGNMANIFEST=$(printf "%s\n%s\n" "$BRANCHLIST" "$PACKLIST" | CLEARSIGN)
CLEARSIGN | ENCRYPT | PUT "$URL" "manifest" printf "%s\n" "$SIGNMANIFEST" | ENCRYPT | PUT "$URL" "manifest"
PUT_FINAL "$URL" PUT_FINAL "$URL"