From 0d90eb44ac23052e79d42d7520520ebc0f2d2247 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 1 Oct 2026 13:44:08 +0900 Subject: cmd/mbf: poison open via environment This enables use of non-cache cmd/mbf utils as root. Signed-off-by: Ophestra --- cmd/mbf/cache.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cmd/mbf/cache.go') diff --git a/cmd/mbf/cache.go b/cmd/mbf/cache.go index 0e20ca99..166e1c45 100644 --- a/cmd/mbf/cache.go +++ b/cmd/mbf/cache.go @@ -2,6 +2,7 @@ package main import ( "context" + "errors" "net/http" "os" "path/filepath" @@ -14,6 +15,9 @@ import ( "hakurei.app/pkg" ) +// poisonOpen is whether cache.open is poisoned. This enables running as root. +var _, poisonOpen = os.LookupEnv("MBF_POISON_OPEN") + // cache refers to an instance of [pkg.Cache] that might be open. type cache struct { ctx context.Context @@ -49,6 +53,10 @@ func writeTitle(msg message.Msg, s string) { // open opens the underlying [pkg.Cache]. func (cache *cache) open() (err error) { + if poisonOpen { + return errors.New("attempting to open cache") + } + if cache.c != nil { return os.ErrInvalid } -- cgit v1.3.1