luci-mod-admin-full: show also sha256 checksum for sysupgrade images
authorHannu Nyman <hannu.nyman@iki.fi>
Fri, 19 Aug 2016 07:59:52 +0000 (10:59 +0300)
committerHannu Nyman <hannu.nyman@iki.fi>
Fri, 19 Aug 2016 08:08:24 +0000 (11:08 +0300)
Show also the sha256 checksum in addition to MD5 checksum to enable
image verification also for builds with only sha256 checksums.

If the 'sha256sum' command is not present in the system, the value
remains empty.

Note: The easiest way to get the 'sha256sum' command is to compile it
into busybox.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
modules/luci-mod-admin-full/luasrc/controller/admin/system.lua
modules/luci-mod-admin-full/luasrc/view/admin_system/upgrade.htm

index fd6dda1c804cca7e333115036ecc557a47f1fb75..cf8cfb5d2dd5749d25a91ceb20b5ea00107925fb 100644 (file)
@@ -185,6 +185,10 @@ local function image_checksum(image)
        return (luci.sys.exec("md5sum %q" % image):match("^([^%s]+)"))
 end
 
+local function image_sha256_checksum(image)
+       return (luci.sys.exec("sha256sum %q" % image):match("^([^%s]+)"))
+end
+
 local function supports_sysupgrade()
        return nixio.fs.access("/lib/upgrade/platform.sh")
 end
@@ -268,6 +272,7 @@ function action_sysupgrade()
                if image_supported(image_tmp) then
                        luci.template.render("admin_system/upgrade", {
                                checksum = image_checksum(image_tmp),
+                               sha256ch = image_sha256_checksum(image_tmp),
                                storage  = storage_size(),
                                size     = (fs.stat(image_tmp, "size") or 0),
                                keep     = (not not http.formvalue("keep"))
index 5ca0398e13a0f3b94e078a94d1712332ba2d1a9c..279af575c1d797e464603be27143ee94b8be9ff7 100644 (file)
@@ -24,7 +24,8 @@
 
 <fieldset class="cbi-section">
        <ul>
-               <li><%:Checksum%>: <code><%=checksum%></code></li>
+               <li><%:Checksum MD5%>: <code><%=checksum%></code></li>
+               <li><%:Checksum SHA256%>: <code><%=sha256ch%></code></li>
                <li><%:Size%>: <%
                        local w = require "luci.tools.webadmin"
                        write(w.byte_format(size))