shim: re-exec self on startup
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
parent
b470941911
commit
77f2c320a6
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
@ -18,6 +19,14 @@ import (
|
||||||
// proceed with caution!
|
// proceed with caution!
|
||||||
|
|
||||||
func shim(socket string) {
|
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:"
|
verbose.Prefix = "fortify-shim:"
|
||||||
|
|
||||||
// dial setup socket
|
// dial setup socket
|
||||||
|
|
Loading…
Reference in New Issue