[PATCH v4 2/5] hood file: Use different files for www and for checksum comparison

Tim Niemeyer tim at tn-x.org
Mi Jul 25 22:50:14 CEST 2018


Moin

Danke, dass du das nochmal formuliert hast.

Ich musste mir trotzdem nochmal alles lokal applien, um das
durchzugehen. Letztlich bin ich nicht glücklich mit der Lösung, weil es
irgendwie ein Hack ist. Eigentlich wollen wir ja nur wissen, ob das
hoodfile nun authoritativ ist oder nicht. Das müsste also eine
Eigenschaft der Datei sein. Der Hack besteht darin, die Eigenschaft
über eine Art "Schatten-Kopie" der Datei bereitzustellen. Dabei hängt
es davon ab, ob die Eingeschaft ausgewertet wird oder nicht, ob und
welche Datei nun verwendet wird. Das ist für mich ein riesen Chaos.

Nun haben wir aber hier eine Lösung, die vermutlich funktioniert.
Leider nicht so gut wartbar. Meiner Meinung nach sollten solche
Lösungen eigentlich nicht den Weg in die Firmware finden, wir waren in
der Vergangenheit leider aber auch sehr lax, was die Anforderungen an
unsere Architektur angeht. Genau das spüren wir derzeit mit Frustration
und Komplexität. Auf der anderen Seite steht die Anforderungen endlich
mal eine überhaupt funktionierende Version zu haben..

Insofern erstmal das etwas unzufriedene:
Reviewed-by: Tim Niemeyer <tim at tn-x.org>

Tim

Am Mittwoch, den 25.07.2018, 15:58 +0200 schrieb Adrian Schmutzler:
> At the moment, we use the same file for detecting changes in a
> new hood file and for broadcasting the hood information to be used
> by mesh routers.
> 
> However, there may be situations where we don't want to broadcast
> an existing hoodfile. We, on the other hand, cannot delete it
> then, as we need the file for checking changes in the temporary
> hoodfile.
> We also cannot just switch the wXconfig state to achieve this
> goal, as we need a trigger to do that (which is the same file we
> are discussing about).
> 
> So, in this patch, we introduce two files, one for the checksum
> comparison and one for the hood info broadcast. Those can now be
> set and deleted (in a later patch) as it is required by their
> respective tasks. This should also improve code clarity to the
> reader ...
> 
> Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
> 
> Reviewed-by: Fabian Bläse <fabian at blaese.de>
> Reviewed-by: Robert Langhammer <rlanghammer at web.de>
> Tested-by: Fabian Bläse <fabian at blaese.de>
> 
> ---
> 
> Changes in v2:
> none
> 
> Changes in v3:
> Rebased
> 
> Changes in v4:
> - Fixed if->elif
> - Added commit description
> ---
>  src/packages/fff/fff-hoods/files/usr/sbin/configurehood           |
> 6 ++++--
>  src/packages/fff/fff-hoodutils/files/lib/functions/fff/keyxchange |
> 3 +++
>  src/packages/fff/fff-web/files/www/ssl/cgi-bin/home.html          |
> 2 +-
>  3 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> index 1a2c12a..b6ba3e3 100755
> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> @@ -83,7 +83,8 @@ else
>  		if ! isGatewayAvailable ; then
>  			#now we haven't a gateway in Range, we
> search for a hidden AP to get a keyxchangev2data file!
>  			#first we delete all wifi settings
> -			rm -f "$hoodfilewww" # delete this, so
> interfaces are recreated if reconnect with unchanged hood file takes
> place
> +			rm -f "$hoodfileref" # delete this, so
> interfaces are recreated if reconnect with unchanged hood file takes
> place
> +			rm -f "$hoodfilewww" # delete this, so wrong
> hood file is not broadcasted anymore
>  
>  			uci -q del "system. at system[0].hood"
>  			uci -q commit system
> @@ -106,7 +107,7 @@ if [ -s "$hoodfiletmp" ]; then
>  	# but without signature, every hood file we get is valid!
>  
>  	catnew="$(cat "$hoodfiletmp" | sed 's/"timestamp”: *"[0-
> 9]*"/"timestamp":0/')"
> -	catold="$(cat "$hoodfilewww" 2>/dev/null | sed
> 's/"timestamp”: *"[0-9]*"/"timestamp":0/')"
> +	catold="$(cat "$hoodfileref" 2>/dev/null | sed
> 's/"timestamp”: *"[0-9]*"/"timestamp":0/')"
>  	sumnew=$(echo "$catnew" | sha256sum | cut -f1 -d " ")
>  	sumold=$(echo "$catold" | sha256sum | cut -f1 -d " ")
>  
> @@ -185,6 +186,7 @@ if [ -s "$hoodfiletmp" ]; then
>  
>  		# copy the file to webroot so that other mesh
> routers can download it;
>  		# copy only after all other steps so IF can be
> reentered if something goes wrong
> +		cp "$hoodfiletmp" "$hoodfileref"
>  		cp "$hoodfiletmp" "$hoodfilewww"
>  
>  		# This is a workaround to enable alfred on devices
> which do not see a configap during initial setup
> diff --git a/src/packages/fff/fff-
> hoodutils/files/lib/functions/fff/keyxchange b/src/packages/fff/fff-
> hoodutils/files/lib/functions/fff/keyxchange
> index 4d624a1..e49f7f8 100644
> --- a/src/packages/fff/fff-
> hoodutils/files/lib/functions/fff/keyxchange
> +++ b/src/packages/fff/fff-
> hoodutils/files/lib/functions/fff/keyxchange
> @@ -5,12 +5,15 @@
>  . /usr/share/libubox/jshn.sh
>  
>  hoodfiletmp="/tmp/hoodfile"
> +hoodfileref="/tmp/hoodfileref"
>  hoodfilewww="/www/hood/keyxchangev2data"
>  
>  getJsonPath() {
>  	jsonfile=""
>  	if [ -s "$hoodfilewww" ] ; then
>  		jsonfile="$hoodfilewww"
> +	elif [ -s "$hoodfileref" ] ; then
> +		jsonfile="$hoodfileref"
>  	elif [ -s "$hoodfiletmp" ] ; then
>  		jsonfile="$hoodfiletmp"
>  	fi
> diff --git a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/home.html 
> b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/home.html
> index ef71eb4..bc15df7 100755
> --- a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/home.html
> +++ b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/home.html
> @@ -8,7 +8,7 @@
>  if [ "$REQUEST_METHOD" == "POST" ] ; then
>  	if [ "$POST_resethood" != "" ] ; then
>  		# reset hood
> -		rm "$hoodfilewww" 2> /dev/null
> +		rm "$hoodfileref" 2> /dev/null
>  		MSG='<span class="green">Hood-Daten werden innerhalb
> von 5 Minuten neu prozessiert.</span>'
>  	fi
>  fi
-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : signature.asc
Dateityp    : application/pgp-signature
Dateigröße  : 488 bytes
Beschreibung: This is a digitally signed message part
URL         : <http://lists.freifunk.net/pipermail/franken-dev-freifunk.net/attachments/20180725/f44f6c24/attachment.sig>


Mehr Informationen über die Mailingliste franken-dev