[2/4] hood file: Use different files for www and for checksum comparison

Submitted by Adrian Schmutzler on June 13, 2018, 2:36 p.m.

Details

Message ID 1528900566-9555-3-git-send-email-freifunk@adrianschmutzler.de
State Superseded
Headers show

Commit Message

Adrian Schmutzler June 13, 2018, 2:36 p.m.
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
 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(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
index b0c43ed..baee487 100755
--- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
+++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
@@ -89,7 +89,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
 			rm -f "$sectorfilewww" # always delete: no broadcast for isolated device
 			rm -f "$sectorfiletmp"
 
@@ -134,7 +135,7 @@  if [ -s "$hoodfiletmp" ]; then
 	fi
 
 	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 " ")
 
@@ -213,6 +214,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"
 		[ -s "$sectorfiletmp" ] && cp "$sectorfiletmp" "$sectorfilewww"
 
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..40ebe4f 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"
+	if [ -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

Comments

Fabian Blaese June 24, 2018, 9:24 a.m.
Hallo

eine Anmerkung inline, ansonsten

Reviewed-by: Fabian Bläse <fabian@blaese.de>

Fabian

> On 13. Jun 2018, at 16:36, Adrian Schmutzler <freifunk@adrianschmutzler.de> wrote:
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> ---
> 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 b0c43ed..baee487 100755
> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> @@ -89,7 +89,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
> 			rm -f "$sectorfilewww" # always delete: no broadcast for isolated device
> 			rm -f "$sectorfiletmp"
> 
> @@ -134,7 +135,7 @@ if [ -s "$hoodfiletmp" ]; then
> 	fi
> 
> 	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 " ")
> 
> @@ -213,6 +214,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"
> 		[ -s "$sectorfiletmp" ] && cp "$sectorfiletmp" "$sectorfilewww"
> 
> 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..40ebe4f 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"
> +	if [ -s "$hoodfileref" ] ; then
> +		jsonfile="$hoodfileref”

Wollen wir wirklich jedes x-beliebige gerade rumfliegende Hoodfile für das Auswerten von Daten (fürs WebUI) hernehmen?

> 	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
> --
> 2.7.4
>
Adrian Schmutzler June 24, 2018, 6 p.m.
Hallo Fabian,

siehe unten.

> -----Original Message-----
> From: Fabian Bläse [mailto:fabian@blaese.de]
> Sent: Sonntag, 24. Juni 2018 11:24
> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> Cc: franken-dev <franken-dev@freifunk.net>
> Subject: Re: [PATCH 2/4] hood file: Use different files for www and for
> checksum comparison
> 
> Hallo
> 
> eine Anmerkung inline, ansonsten
> 
> Reviewed-by: Fabian Bläse <fabian@blaese.de>
> 
> Fabian
> 
> > On 13. Jun 2018, at 16:36, Adrian Schmutzler
> <freifunk@adrianschmutzler.de> wrote:
> >
> > Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> > ---
> > 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 b0c43ed..baee487 100755
> > --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> > +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> > @@ -89,7 +89,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
> > 			rm -f "$sectorfilewww" # always delete: no broadcast
> for isolated device
> > 			rm -f "$sectorfiletmp"
> >
> > @@ -134,7 +135,7 @@ if [ -s "$hoodfiletmp" ]; then
> > 	fi
> >
> > 	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 " ")
> >
> > @@ -213,6 +214,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"
> > 		[ -s "$sectorfiletmp" ] && cp "$sectorfiletmp"
> "$sectorfilewww"
> >
> > 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..40ebe4f 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"
> > +	if [ -s "$hoodfileref" ] ; then
> > +		jsonfile="$hoodfileref”
> 
> Wollen wir wirklich jedes x-beliebige gerade rumfliegende Hoodfile für das
> Auswerten von Daten (fürs WebUI) hernehmen?

Ja. Das tut uns nicht weh und dann muss man nicht siebzehnmal überlegen, welches wann da ist.

Grüße

Adrian

> 
> > 	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
> > --
> > 2.7.4
> >