[v2] upgrade.html: Rename uploaded firmware before sysupgrade

Submitted by Adrian Schmutzler on May 25, 2019, 6:02 p.m.

Details

Message ID 20190525180240.43216-1-freifunk@adrianschmutzler.de
State Accepted
Headers show

Commit Message

Adrian Schmutzler May 25, 2019, 6:02 p.m.
At the moment sysupgrade via WebUI is broken on many devices.
This is reproducible: While the (few) status messages seem
normal, the device boots again with the old firmware.
Sysupgrade via SSH always works.

The sysupgrade call in upgrade.html directly uses the path of
the uploaded firmware file as argument. From several tests and
based on caught stdout/stderr from this line, it looks like haserl
deletes the uploaded firmware file due to a hidden trigger before
or even while it is processed by sysupgrade.

The easiest way to work around that is to just rename the file
before using it as argument to sysupgrade. This will preserve the
file DURING sysupgrade. If sysupgrade fails explicitly (status
code != 0), remove the file to provide sufficient memory for
another upload.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

---

Changes in v2:
- Remove file on exit-code != 0
- Adjust commit message to that change
---
 src/packages/fff/fff-web/Makefile                           | 2 +-
 src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-web/Makefile b/src/packages/fff/fff-web/Makefile
index 9bb10f71..819644a5 100644
--- a/src/packages/fff/fff-web/Makefile
+++ b/src/packages/fff/fff-web/Makefile
@@ -1,7 +1,7 @@ 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fff-web
-PKG_RELEASE:=7
+PKG_RELEASE:=8
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
 
diff --git a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html
index 96199c22..e2b0a57f 100755
--- a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html
+++ b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html
@@ -72,8 +72,9 @@  elif [ "$do_sysupgrade" = "1" ] ; then
 	echo "<pre>"
 	echo "# Freeing caches ..."
 	echo 3 > /proc/sys/vm/drop_caches
-	echo "# sysupgrade $args $HASERL_firmware_path"
-	sysupgrade $args $HASERL_firmware_path
+	echo "# sysupgrade $args /tmp/uploadedfw.bin"
+	mv -f "$HASERL_firmware_path" /tmp/uploadedfw.bin
+	sysupgrade $args /tmp/uploadedfw.bin || rm /tmp/uploadedfw.bin
 	echo "</pre>"
 fi
 %>

Comments

Fabian Blaese May 25, 2019, 6:07 p.m.
Gefällt mir so besser.

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

Fabian
Robert Langhammer May 31, 2019, 9:35 a.m.
Hallo Adrian,

Reviewed-by: Robert Langhammer <rlanghammer@web.de>

Am 25.05.19 um 20:02 schrieb Adrian Schmutzler:
> At the moment sysupgrade via WebUI is broken on many devices.
> This is reproducible: While the (few) status messages seem
> normal, the device boots again with the old firmware.
> Sysupgrade via SSH always works.
>
> The sysupgrade call in upgrade.html directly uses the path of
> the uploaded firmware file as argument. From several tests and
> based on caught stdout/stderr from this line, it looks like haserl
> deletes the uploaded firmware file due to a hidden trigger before
> or even while it is processed by sysupgrade.
>
> The easiest way to work around that is to just rename the file
> before using it as argument to sysupgrade. This will preserve the
> file DURING sysupgrade. If sysupgrade fails explicitly (status
> code != 0), remove the file to provide sufficient memory for
> another upload.
>
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
>
> ---
>
> Changes in v2:
> - Remove file on exit-code != 0
> - Adjust commit message to that change
> ---
>  src/packages/fff/fff-web/Makefile                           | 2 +-
>  src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html | 5 +++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/packages/fff/fff-web/Makefile b/src/packages/fff/fff-web/Makefile
> index 9bb10f71..819644a5 100644
> --- a/src/packages/fff/fff-web/Makefile
> +++ b/src/packages/fff/fff-web/Makefile
> @@ -1,7 +1,7 @@
>  include $(TOPDIR)/rules.mk
>
>  PKG_NAME:=fff-web
> -PKG_RELEASE:=7
> +PKG_RELEASE:=8
>
>  PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
>
> diff --git a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html
> index 96199c22..e2b0a57f 100755
> --- a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html
> +++ b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/upgrade.html
> @@ -72,8 +72,9 @@ elif [ "$do_sysupgrade" = "1" ] ; then
>  	echo "<pre>"
>  	echo "# Freeing caches ..."
>  	echo 3 > /proc/sys/vm/drop_caches
> -	echo "# sysupgrade $args $HASERL_firmware_path"
> -	sysupgrade $args $HASERL_firmware_path
> +	echo "# sysupgrade $args /tmp/uploadedfw.bin"
> +	mv -f "$HASERL_firmware_path" /tmp/uploadedfw.bin
> +	sysupgrade $args /tmp/uploadedfw.bin || rm /tmp/uploadedfw.bin
>  	echo "</pre>"
>  fi
>  %>
Fabian Blaese May 31, 2019, 3:36 p.m.
applied.