diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-09-04 01:20:12 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-09-04 01:20:12 +0900 |
| commit | d8f76f3b2594db4687c0203c4f2be8d3e4ef7740 (patch) | |
| tree | b1d8bfb5250d71094e397f8afa87710de1f1ca2f /launcher.go | |
| parent | 7e6eb82195c650bc34829e5cca2d2296e78c0707 (diff) | |
rename to fortify and restructure
More sandbox features will be added and this will no longer track ego's features and behaviour.
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'launcher.go')
| -rw-r--r-- | launcher.go | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/launcher.go b/launcher.go deleted file mode 100644 index 68d2cb80..00000000 --- a/launcher.go +++ /dev/null @@ -1,72 +0,0 @@ -package main - -import ( - "bytes" - "encoding/base64" - "encoding/gob" - "fmt" - "os" - "strings" - "syscall" -) - -const ( - // hidden path for main to act as a launcher - egoLauncher = "EGO_LAUNCHER" -) - -// hidden launcher path -func tryLauncher() { - if printVersion { - if r, ok := os.LookupEnv(egoLauncher); ok { - // egoLauncher variable contains launcher payload - dec := base64.NewDecoder(base64.StdEncoding, strings.NewReader(r)) - - var argv []string - if err := gob.NewDecoder(dec).Decode(&argv); err != nil { - fmt.Println("Error decoding launcher payload:", err) - os.Exit(1) - } - - if err := os.Unsetenv(egoLauncher); err != nil { - fmt.Println("Error unsetting launcher payload:", err) - // not fatal, do not fail - } - - var p string - - if len(argv) > 0 { - if p, ok = which(argv[0]); !ok { - fmt.Printf("Did not find '%s' in PATH\n", argv[0]) - os.Exit(1) - } - } else { - if p, ok = os.LookupEnv("SHELL"); !ok { - fmt.Println("No command was specified and $SHELL was unset") - os.Exit(1) - } - } - - if err := syscall.Exec(p, argv, os.Environ()); err != nil { - fmt.Println("Error executing launcher payload:", err) - os.Exit(1) - } - - // unreachable - os.Exit(1) - return - } - } -} - -func launcherPayloadEnv() string { - r := &bytes.Buffer{} - enc := base64.NewEncoder(base64.StdEncoding, r) - - if err := gob.NewEncoder(enc).Encode(command); err != nil { - fatal("Error encoding launcher payload:", err) - } - - _ = enc.Close() - return egoLauncher + "=" + r.String() -} |
