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
local mkdir = mkdir
local move = move
local ls = ls
local md5 = md5
local sha256 = sha256
local DBG = DBG
local WARN = WARN
local utils = require "utils"
......@@ -441,12 +443,12 @@ function pkg_examine(dir)
local conffiles = {}
if cidx then
for l in cidx:lines() do
local fname = l:match("^%s*/(.*%S)%s*")
local function get_hash(text)
local hash = text:match("[0-9a-fA-F]+")
conffiles["/" .. fname] = hash
local fname = l:match("^%s*(/.*%S)%s*")
local content, err = utils.slurp(data_dir .. fname)
if not content then
launch(get_hash, "/usr/bin/md5sum", fname)
conffiles[fname] = sha256(content)
......@@ -324,7 +324,7 @@ function test_pkg_unpack()
/usr/bin]]), dirs)
["/etc/config/updater"] = "30843ef73412c8f6b4212c00724a1cc8"
["/etc/config/updater"] = "b5cf279732a87011eadfe522a0c163b98682bef2919afc4f96330f9f103a3230"
}, conffiles)
-- We want to take it out, the time changes every 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