aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/hsu.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-18 20:45:42 +0900
committerOphestra <cat@gensokyo.uk>2025-10-18 20:45:42 +0900
commita103c4a7c70f67faa33665cd886545ddc7e09c89 (patch)
tree6bcefae7da52c2aa89ee059f84085cfbc149a413 /internal/app/hsu.go
parent67ec82ae1b60c9f9db0f15dd06e0246312343bea (diff)
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 <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/hsu.go')
-rw-r--r--internal/app/hsu.go12
1 files changed, 6 insertions, 6 deletions
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 }