internal: beforeExit before reachable fatal calls
All checks were successful
Test / Create distribution (push) Successful in 18s
Test / Run NixOS test (push) Successful in 47s

These are the only two calls to log.Fatal* reachable during suspended output. Call fmsg.BeforeExit here to catch that.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-02-16 19:02:52 +09:00
parent 29c38caac8
commit 468696f611
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
2 changed files with 5 additions and 0 deletions

View File

@ -4,6 +4,8 @@ import (
"log" "log"
"os" "os"
"sync" "sync"
"git.gensokyo.uk/security/fortify/internal/fmsg"
) )
var ( var (
@ -13,6 +15,7 @@ var (
func copyExecutable() { func copyExecutable() {
if name, err := os.Executable(); err != nil { if name, err := os.Executable(); err != nil {
fmsg.BeforeExit()
log.Fatalf("cannot read executable path: %v", err) log.Fatalf("cannot read executable path: %v", err)
} else { } else {
executable = name executable = name

View File

@ -13,6 +13,7 @@ import (
"syscall" "syscall"
"git.gensokyo.uk/security/fortify/internal" "git.gensokyo.uk/security/fortify/internal"
"git.gensokyo.uk/security/fortify/internal/fmsg"
) )
// Std implements System using the standard library. // Std implements System using the standard library.
@ -73,6 +74,7 @@ func (s *Std) Uid(aid int) (int, error) {
u.uid = -1 u.uid = -1
if fsu, ok := internal.Check(internal.Fsu); !ok { if fsu, ok := internal.Check(internal.Fsu); !ok {
fmsg.BeforeExit()
log.Fatal("invalid fsu path, this copy of fortify is not compiled correctly") log.Fatal("invalid fsu path, this copy of fortify is not compiled correctly")
// unreachable // unreachable
return 0, syscall.EBADE return 0, syscall.EBADE