=================================================================== RCS file: /cvs/openbsd/fw_update/fw_install.sh,v retrieving revision 1.115 retrieving revision 1.120 diff -u -r1.115 -r1.120 --- openbsd/fw_update/fw_install.sh 2021/12/23 21:43:04 1.115 +++ openbsd/fw_update/fw_install.sh 2021/12/24 01:41:54 1.120 @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: fw_install.sh,v 1.115 2021/12/23 21:43:04 afresh1 Exp $ +# $OpenBSD: fw_install.sh,v 1.120 2021/12/24 01:41:54 afresh1 Exp $ # # Copyright (c) 2021 Andrew Hewus Fresh # @@ -67,10 +67,10 @@ "$VERBOSE" && flags=-vm if [ -x /usr/bin/su ]; then exec /usr/bin/su -s /bin/ksh "$_user" -c \ - "/usr/bin/ftp -D 'Get/Verify' $flags -o- '$_src'" > "$_dst" + "/usr/bin/ftp -N '${0##/}' -D 'Get/Verify' $flags -o- '$_src'" > "$_dst" else exec /usr/bin/doas -u "$_user" \ - /usr/bin/ftp -D 'Get/Verify' $flags -o- "$_src" > "$_dst" + /usr/bin/ftp -N "${0##/}" -D 'Get/Verify' $flags -o- "$_src" > "$_dst" fi ) & _pid=$! set +o monitor @@ -173,7 +173,7 @@ local _tmpdir="$( tmpdir "${DESTDIR}/var/db/pkg/.firmware" )" local flags=-VM "$VERBOSE" && flags=-vm - ftp -D "Install" "$flags" -o- "file:${1}" | + ftp -N "${0##/}" -D "Install" "$flags" -o- "file:${1}" | tar -s ",^\+,${_tmpdir}/+," \ -s ",^firmware,${DESTDIR}/etc/firmware," \ -C / -zxphf - "+*" "firmware/*" @@ -277,11 +277,9 @@ CFILE="$LOCALSRC/$CFILE" -if "$INSTALL" || "$DELETE"; then - if [ -x /usr/bin/id ] && [ "$(/usr/bin/id -u)" != 0 ]; then - echo "need root privileges" >&2 - exit 1 - fi +if [ -x /usr/bin/id ] && [ "$(/usr/bin/id -u)" != 0 ]; then + echo "need root privileges" >&2 + exit 1 fi set -A devices -- "$@" @@ -338,9 +336,15 @@ [ "${devices[*]:-}" ] || exit if "$DOWNLOAD"; then + set +o noclobber # we want to get the latest CFILE fetch "$CFILE" + set -o noclobber ! signify -qVep "$FWPUB_KEY" -x "$CFILE" -m "$CFILE" && echo "Signature check of SHA256.sig failed" >&2 && exit 1 +elif [ ! -e "$CFILE" ]; then + # TODO: We shouldn't need a CFILE if all arguments are files. + echo "${0##*/}: $CFILE: No such file or directory" >&2 + exit 2 fi added='' @@ -374,11 +378,13 @@ if "$DOWNLOAD"; then "$VERBOSE" && echo "Verify existing ${f##*/}" verify "$f" || continue + "$INSTALL" || kept="$kept,$d" # else assume it was verified when downloaded fi elif "$DOWNLOAD"; then fetch "$f" || continue verify "$f" || continue + "$INSTALL" || added="$added,$d" elif "$INSTALL"; then echo "Cannot install ${f##*/}, not found" >&2 continue @@ -406,4 +412,8 @@ added="${added:#,}" updated="${updated:#,}" kept="${kept:#,}" -echo "${0##*/}: added ${added:-none}; updated ${updated:-none}; kept ${kept:-none}" +if "$INSTALL"; then + echo "${0##*/}: added ${added:-none}; updated ${updated:-none}; kept ${kept:-none}" +else + echo "${0##*/}: downloaded ${added:-none}; kept ${kept:-none}" +fi