Commit 3f90b873 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner

pkg: Use sha256 for config hashes

Opkg switched to it (reportedly for security reasons, which makes no
sense), so stay compatible.

Also, use internal hash computation instead of calling external scripts.
parent d4242232
...@@ -37,6 +37,8 @@ local stat = stat ...@@ -37,6 +37,8 @@ local stat = stat
local mkdir = mkdir local mkdir = mkdir
local move = move local move = move
local ls = ls local ls = ls
local md5 = md5
local sha256 = sha256
local DBG = DBG local DBG = DBG
local WARN = WARN local WARN = WARN
local utils = require "utils" local utils = require "utils"
...@@ -441,12 +443,12 @@ function pkg_examine(dir) ...@@ -441,12 +443,12 @@ function pkg_examine(dir)
local conffiles = {} local conffiles = {}
if cidx then if cidx then
for l in cidx:lines() do for l in cidx:lines() do
local fname = l:match("^%s*/(.*%S)%s*") local fname = l:match("^%s*(/.*%S)%s*")
local function get_hash(text) local content, err = utils.slurp(data_dir .. fname)
local hash = text:match("[0-9a-fA-F]+") if not content then
conffiles["/" .. fname] = hash error(err)
end end
launch(get_hash, "/usr/bin/md5sum", fname) conffiles[fname] = sha256(content)
end end
cidx:close() cidx:close()
end end
......
...@@ -324,7 +324,7 @@ function test_pkg_unpack() ...@@ -324,7 +324,7 @@ function test_pkg_unpack()
/usr/share/updater/keys /usr/share/updater/keys
/usr/bin]]), dirs) /usr/bin]]), dirs)
assert_table_equal({ assert_table_equal({
["/etc/config/updater"] = "30843ef73412c8f6b4212c00724a1cc8" ["/etc/config/updater"] = "b5cf279732a87011eadfe522a0c163b98682bef2919afc4f96330f9f103a3230"
}, conffiles) }, conffiles)
-- We want to take it out, the time changes every time -- We want to take it out, the time changes every time
assert_not_nil(control["Installed-Time"]) assert_not_nil(control["Installed-Time"])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment