[PATCH 1/2] fff-hoods: let sha256sum read file directly

mail at adrianschmutzler.de mail at adrianschmutzler.de
Sa Aug 1 12:11:05 CEST 2020


Beide applied.

> -----Original Message-----
> From: franken-dev [mailto:franken-dev-bounces at freifunk.net] On Behalf
> Of Adrian Schmutzler
> Sent: Samstag, 1. August 2020 01:29
> To: franken-dev at freifunk.net
> Subject: [PATCH 1/2] fff-hoods: let sha256sum read file directly
> 
> This removes two useless cat as found by shellcheck:
> 
>   sumnew=$(cat "$hoodfiletmp" 2>/dev/null | sha256sum | cut -f1 -d " ")
>                ^-- SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..'
> instead.
> 
> While not functionally relevant in our case, note that
> 
>   cat <non-existant-file> | sha256sum
> 
> actually returns a hash code, while
> 
>   sha256sum <non-existant-file>
> 
> does not return anything on stdout.
> 
> Since we check the existance of $hoodfiletmp before calling sha256sum,
> though, we always have a hash value for at least one file, so two empty
> checksum won't happen at that point.
> 
> Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
> ---
>  src/packages/fff/fff-hoods/Makefile                     | 2 +-
>  src/packages/fff/fff-hoods/files/usr/sbin/configurehood | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/packages/fff/fff-hoods/Makefile b/src/packages/fff/fff-
> hoods/Makefile
> index d48e7b27..e166666a 100644
> --- a/src/packages/fff/fff-hoods/Makefile
> +++ b/src/packages/fff/fff-hoods/Makefile
> @@ -1,7 +1,7 @@
>  include $(TOPDIR)/rules.mk
> 
>  PKG_NAME:=fff-hoods
> -PKG_RELEASE:=13
> +PKG_RELEASE:=14
> 
>  PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
> 
> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> index 1df6e2a5..99f0fce4 100755
> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> @@ -78,8 +78,8 @@ if [ -s "$hoodfiletmp" ]; then
>  	# https://pw.freifunk-franken.de/patch/205/
>  	# but without signature, every hood file we get is valid!
> 
> -	sumnew=$(cat "$hoodfiletmp" 2>/dev/null | sha256sum | cut -f1 -d "
> ")
> -	sumold=$(cat "$hoodfileref" 2>/dev/null | sha256sum | cut -f1 -d " ")
> +	sumnew=$(sha256sum "$hoodfiletmp" 2>/dev/null | cut -f1 -d " ")
> +	sumold=$(sha256sum "$hoodfileref" 2>/dev/null | cut -f1 -d " ")
> 
>  	json_load "$(cat "$hoodfiletmp")"
> 
> --
> 2.20.1
-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : openpgp-digital-signature.asc
Dateityp    : application/pgp-signature
Dateigröße  : 834 bytes
Beschreibung: nicht verfügbar
URL         : <https://lists.freifunk.net/pipermail/franken-dev-freifunk.net/attachments/20200801/f687d2bf/attachment.sig>


Mehr Informationen über die Mailingliste franken-dev