aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/shim
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-10-13 16:56:10 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-10-13 16:56:10 +0900
commit77f2c320a6b1d5290c7596d2c8f8b6ba358b5de9 (patch)
treec11e647db81d465905bcf3ac6087342e09dc3c03 /internal/shim
parentb47094191145277319b81feb6d1a7f0e3e20b906 (diff)
shim: re-exec self on startup
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/shim')
-rw-r--r--internal/shim/main.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/shim/main.go b/internal/shim/main.go
index e5bca6fd..5b3303b4 100644
--- a/internal/shim/main.go
+++ b/internal/shim/main.go
@@ -7,6 +7,7 @@ import (
"fmt"
"net"
"os"
+ "path"
"strconv"
"syscall"
@@ -18,6 +19,14 @@ import (
// proceed with caution!
func shim(socket string) {
+ // re-exec
+ if len(os.Args) > 0 && os.Args[0] != "fortify" && path.IsAbs(os.Args[0]) {
+ if err := syscall.Exec(os.Args[0], []string{"fortify", "shim"}, os.Environ()); err != nil {
+ fmt.Println("fortify-shim: cannot re-exec self:", err)
+ // continue anyway
+ }
+ }
+
verbose.Prefix = "fortify-shim:"
// dial setup socket