aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/fpkg/proc.go
blob: 6cda73466c6952e1a8394e81b94f2dad89cfe3f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import (
	"context"
	"os"

	"git.gensokyo.uk/security/fortify/fst"
	"git.gensokyo.uk/security/fortify/internal/app/setuid"
	"git.gensokyo.uk/security/fortify/internal/fmsg"
)

func mustRunApp(ctx context.Context, config *fst.Config, beforeFail func()) {
	rs := new(fst.RunState)
	a := setuid.MustNew(ctx, std)

	var code int
	if sa, err := a.Seal(config); err != nil {
		fmsg.PrintBaseError(err, "cannot seal app:")
		code = 1
	} else {
		code = setuid.PrintRunStateErr(rs, sa.Run(rs))
	}

	if code != 0 {
		beforeFail()
		os.Exit(code)
	}
}