crypto.lua: sha256sum not available on OpenBSD/FreeBSD #10

Closed
opened 2026-03-18 13:55:11 +01:00 by michael · 0 comments
Owner

Problem

crypto.hash_file() and crypto.hash_string() use sha256sum which is a
GNU coreutils tool. It is not available on OpenBSD or FreeBSD by default.

On OpenBSD/FreeBSD the native command is sha256 (with -r flag for
sha256sum-compatible output format).

Impact

steurjan verify-period uses crypto.hash_file and crypto.hash_string
for manifest integrity checks. Fails on OpenBSD without GNU coreutils port.

Fix

Detect available command once at module load time (cached):

  • sha256sum present -> use it (Linux/GNU)
  • otherwise -> use sha256 -r (OpenBSD/FreeBSD)

hash_string writes content to a temp file to avoid shell pipe
differences between platforms.

Acceptance criteria

  • crypto.hash_file() works on Linux, OpenBSD, FreeBSD
  • crypto.hash_string() works on Linux, OpenBSD, FreeBSD
  • No new external dependencies
  • Existing tests pass

Refs

Used by DAW/steurjan#19 (verify-period)

## Problem `crypto.hash_file()` and `crypto.hash_string()` use `sha256sum` which is a GNU coreutils tool. It is not available on OpenBSD or FreeBSD by default. On OpenBSD/FreeBSD the native command is `sha256` (with `-r` flag for sha256sum-compatible output format). ## Impact `steurjan verify-period` uses `crypto.hash_file` and `crypto.hash_string` for manifest integrity checks. Fails on OpenBSD without GNU coreutils port. ## Fix Detect available command once at module load time (cached): - `sha256sum` present -> use it (Linux/GNU) - otherwise -> use `sha256 -r` (OpenBSD/FreeBSD) `hash_string` writes content to a temp file to avoid shell pipe differences between platforms. ## Acceptance criteria - `crypto.hash_file()` works on Linux, OpenBSD, FreeBSD - `crypto.hash_string()` works on Linux, OpenBSD, FreeBSD - No new external dependencies - Existing tests pass ## Refs Used by DAW/steurjan#19 (verify-period)
michael 2026-03-18 14:00:24 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/daw-lua-common#10
No description provided.