From 7ce87f20c39c615f4d23a3be23780a36008dcb19 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 23 Jun 2023 08:58:59 +0200 Subject: [PATCH] fix: compare only basename of `os.Args[0]` in machined This makes handling of `exec` more flexible. Signed-off-by: Markus Reiter Signed-off-by: Andrey Smirnov --- internal/app/machined/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/app/machined/main.go b/internal/app/machined/main.go index 0b88b709b..d89fd464f 100644 --- a/internal/app/machined/main.go +++ b/internal/app/machined/main.go @@ -13,6 +13,7 @@ import ( "net/http" "os" "os/signal" + "path/filepath" "syscall" "time" @@ -286,25 +287,25 @@ func run() error { } func main() { - switch os.Args[0] { - case "/apid": + switch filepath.Base(os.Args[0]) { + case "apid": apid.Main() return - case "/trustd": + case "trustd": trustd.Main() return // Azure uses the hv_utils kernel module to shutdown the node in hyper-v by calling perform_shutdown which will call orderly_poweroff which will call /sbin/poweroff. - case "/sbin/poweroff": + case "poweroff": poweroff.Main() return - case "/sbin/wrapperd": + case "wrapperd": wrapperd.Main() return - case "/sbin/dashboard": + case "dashboard": dashboard.Main() return