diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-21 01:49:36 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-21 01:49:36 +0900 |
| commit | 766dd89ffa198a315b043230f904636461c41efe (patch) | |
| tree | 163290a35109da0cae36c6453fc4b56529cf4d54 /cmd/hsu/main.go | |
| parent | 699c19e972a3cbcc714403aedffcb5ff74386cfc (diff) | |
internal: clean up build strings
These names are less ambiguous and should be understandable without reading the source code.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/hsu/main.go')
| -rw-r--r-- | cmd/hsu/main.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/cmd/hsu/main.go b/cmd/hsu/main.go index 27b97b5c..5901087c 100644 --- a/cmd/hsu/main.go +++ b/cmd/hsu/main.go @@ -26,6 +26,11 @@ const ( identityMax = 9999 ) +// hakureiPath is the absolute path to Hakurei. +// +// This is set by the linker. +var hakureiPath string + func main() { log.SetFlags(0) log.SetPrefix("hsu: ") @@ -43,13 +48,18 @@ func main() { log.Fatal("this program must not be started by root") } + if !path.IsAbs(hakureiPath) { + log.Fatal("this program is compiled incorrectly") + return + } + var toolPath string pexe := path.Join("/proc", strconv.Itoa(os.Getppid()), "exe") if p, err := os.Readlink(pexe); err != nil { log.Fatalf("cannot read parent executable path: %v", err) } else if strings.HasSuffix(p, " (deleted)") { log.Fatal("hakurei executable has been deleted") - } else if p != mustCheckPath(hmain) { + } else if p != hakureiPath { log.Fatal("this program must be started by hakurei") } else { toolPath = p |
