From a2a291791c6447528d3b1abc1ec57c7b213730b6 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 15 Sep 2025 02:30:47 +0900 Subject: internal/sys: separate hsu uid cache This begins the effort of the removal of the sys package. Signed-off-by: Ophestra --- cmd/hakurei/command.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'cmd') diff --git a/cmd/hakurei/command.go b/cmd/hakurei/command.go index c3b9d85d..eaefb893 100644 --- a/cmd/hakurei/command.go +++ b/cmd/hakurei/command.go @@ -2,6 +2,7 @@ package main import ( "context" + "errors" "fmt" "io" "log" @@ -20,6 +21,7 @@ import ( "hakurei.app/internal/app" "hakurei.app/internal/app/state" "hakurei.app/internal/hlog" + "hakurei.app/internal/sys" "hakurei.app/system" "hakurei.app/system/dbus" ) @@ -272,20 +274,19 @@ func runApp(config *hst.Config) { // fatal prints the error message according to [container.GetErrorMessage], or fallback // prepended to err if an error message is not available, followed by a call to [os.Exit](1). func fatal(fallback string, err error) { - m, ok := container.GetErrorMessage(err) - if !ok { - log.Fatal(fallback, err) - return - } - // this indicates the error message has already reached stderr, outside the current process's control; - // this is only reached when hsu fails for any reason, as we do not want a second error message following hsu - // TODO(ophestra): handle the hsu error here instead of relying on a magic string - if m == "\x00" { + // this is only reached when hsu fails for any reason, as a second error message following hsu is confusing + if errors.Is(err, sys.ErrHsuAccess) { hlog.Verbose("*"+fallback, err) os.Exit(1) return } + m, ok := container.GetErrorMessage(err) + if !ok { + log.Fatalln(fallback, err) + return + } + log.Fatal(m) } -- cgit v1.3.1