From a103c4a7c70f67faa33665cd886545ddc7e09c89 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 18 Oct 2025 20:45:42 +0900 Subject: internal/app/hsu: check behaviour The stub exec.ExitError is hairy as usual, but internal/app is not cross-platform, so this is okay. Signed-off-by: Ophestra --- internal/app/hsu.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'internal/app/hsu.go') diff --git a/internal/app/hsu.go b/internal/app/hsu.go index e53d9f3d..cae56c88 100644 --- a/internal/app/hsu.go +++ b/internal/app/hsu.go @@ -62,8 +62,8 @@ func (h *Hsu) ID() (int, error) { } else if errors.As(h.idErr, &exitError) && exitError != nil && exitError.ExitCode() == 1 { // hsu prints an error message in this case h.idErr = &hst.AppError{Step: step, Err: ErrHsuAccess} - } else if os.IsNotExist(h.idErr) { - h.idErr = &hst.AppError{Step: step, Err: os.ErrNotExist, + } else if errors.Is(h.idErr, os.ErrNotExist) { + h.idErr = &hst.AppError{Step: step, Err: h.idErr, Msg: fmt.Sprintf("the setuid helper is missing: %s", hsuPath)} } }) @@ -84,16 +84,16 @@ func (h *Hsu) MustID(msg message.Msg) int { msg.Verbose("*"+fallback, err) } os.Exit(1) - return -0xdeadbeef + return -0xdeadbeef // not reached } else if m, ok := message.GetMessage(err); ok { log.Fatal(m) - return -0xdeadbeef + return -0xdeadbeef // not reached } else { log.Fatalln(fallback, err) - return -0xdeadbeef + return -0xdeadbeef // not reached } } // HsuUid returns target uid for the stable hsu uid format. -// No bounds check is performed, a value retrieved from hsu is expected. +// No bounds check is performed, a value retrieved by [Hsu] is expected. func HsuUid(id, identity int) int { return 1000000 + id*10000 + identity } -- cgit v1.3.1