summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle2025-03-30 23:32:50 +0000
committerDaniel Golle2025-04-21 15:12:42 +0000
commit5175d0a62301ebb2fec6fa83b04946026ce91475 (patch)
tree6cba844c1966e7e8ac4dac25f2d2d9a9ab7a98e1
parent370a9d55868981609f2b6ad510fd2f2fb4416e51 (diff)
downloadopenwrt-5175d0a62301ebb2fec6fa83b04946026ce91475.tar.gz
base-files: allow platform_check_image to prevent --force
Introduce special handling for return code 74 (EBADMSG) of platform_check_image which will mark the image as broken and hence not allow the user to override the check using the --force option. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rwxr-xr-xpackage/base-files/files/sbin/sysupgrade3
-rwxr-xr-xpackage/base-files/files/usr/libexec/validate_firmware_image12
2 files changed, 13 insertions, 2 deletions
diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index 9b993a72f2..75817d178a 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -384,8 +384,9 @@ json_load "$(/usr/libexec/validate_firmware_image "$IMAGE")" || {
exit 1
}
json_get_var valid "valid"
+json_get_var forceable "forceable"
[ "$valid" -eq 0 ] && {
- if [ $FORCE -eq 1 ]; then
+ if [ $FORCE -eq 1 ] && [ "$forceable" -eq 1 ]; then
echo "Image check failed but --force given - will update anyway!" >&2
else
echo "Image check failed." >&2
diff --git a/package/base-files/files/usr/libexec/validate_firmware_image b/package/base-files/files/usr/libexec/validate_firmware_image
index f85fb9e4b4..870d9beda5 100755
--- a/package/base-files/files/usr/libexec/validate_firmware_image
+++ b/package/base-files/files/usr/libexec/validate_firmware_image
@@ -56,7 +56,17 @@ json_init
# Call platform_check_image() here so it can add its test
# results and still mark image properly.
json_set_namespace $old_ns
- platform_check_image "$1" >&2 || notify_firmware_invalid
+ platform_check_image "$1" >&2
+ case "$?" in
+ 0)
+ ;;
+ 74)
+ notify_firmware_broken
+ ;;
+ *)
+ notify_firmware_invalid
+ ;;
+ esac
json_set_namespace validate_firmware_image old_ns
json_close_object
json_add_boolean valid "$VALID"