From 56038c33672d12f1b5ff73ecfe7c7c43d59fd76a Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Thu, 12 Oct 2023 08:51:57 -0700 Subject: sign-autobuilds: fix variable name-induced confusion bugs in files being signed Signed-off-by: Robin H. Johnson --- sign-autobuilds.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/sign-autobuilds.sh b/sign-autobuilds.sh index 5d40fd0..adf2848 100755 --- a/sign-autobuilds.sh +++ b/sign-autobuilds.sh @@ -119,28 +119,32 @@ unsigned="$(comm -23 <(echo "$files" |sort) <(echo "$sigs" | sed -e 's,.asc$,,g' #$VERBOSEP echo "=== ARCH: $a" -for dgst in $unsigned ; do - if [ ! -f ${dgst}.asc ]; then - $VERBOSEP echo "Signing $dgst" - signone $dgst +for src in ${unsigned} ; do + dgst=${src}.asc + if [[ -f "$src" ]] && [[ ! -f "${dgst}" ]]; then + $VERBOSEP echo "Signing $src" + signone "$src" fi done for dgst in ${sigs}; do - dgst=${dgst%.asc} - if [ -f ${dgst}.asc -a ${dgst} -nt ${dgst}.asc ]; then + src=${dgst%.asc} + # If both the source & signature are files, not symlinks, and the source is + # newer, then resign. Need to check both for being files, in case we are in + # a symlink location. + if [[ -f "${src}" ]] && [[ -f "${dgst}" ]] && [[ "${src}" -nt "${dgst}" ]]; then $VERBOSEP echo "Resigning $dgst" - rm -f ${dgst}.asc - signone $dgst + rm -f "${dgst}" + signone "$src" fi done #echo "Text helper files:" unsigned="$( "${find_unsigned_helper_cmd[@]}" )" -for dgst in $unsigned ; do - $VERBOSEP echo "Signing (inline/cleartext) $dgst" - signone_clearsign $dgst +for src in $unsigned ; do + $VERBOSEP echo "Signing (inline/cleartext) $src" + signone_clearsign "$src" done cleanup -- cgit v1.2.3-65-gdbad