diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-09-15 02:30:47 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-09-15 02:30:47 +0900 |
| commit | a2a291791c6447528d3b1abc1ec57c7b213730b6 (patch) | |
| tree | 4d4515976d798b461d8df358c272364c5cf0b2e1 /cmd | |
| parent | 8690419c2d577a27efe3cfcafc39c05b7646926b (diff) | |
internal/sys: separate hsu uid cache
This begins the effort of the removal of the sys package.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/hakurei/command.go | 19 |
1 files changed, 10 insertions, 9 deletions
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) } |
