proc/priv/shim: merge shim into main program
Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -24,7 +24,6 @@ const (
|
||||
|
||||
var (
|
||||
Fmain = compPoison
|
||||
Fshim = compPoison
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -41,17 +40,12 @@ func main() {
|
||||
log.Fatal("this program must not be started by root")
|
||||
}
|
||||
|
||||
var fmain, fshim string
|
||||
var fmain string
|
||||
if p, ok := checkPath(Fmain); !ok {
|
||||
log.Fatal("invalid fortify path, this copy of fsu is not compiled correctly")
|
||||
} else {
|
||||
fmain = p
|
||||
}
|
||||
if p, ok := checkPath(Fshim); !ok {
|
||||
log.Fatal("invalid fshim path, this copy of fsu is not compiled correctly")
|
||||
} else {
|
||||
fshim = p
|
||||
}
|
||||
|
||||
pexe := path.Join("/proc", strconv.Itoa(os.Getppid()), "exe")
|
||||
if p, err := os.Readlink(pexe); err != nil {
|
||||
@@ -142,7 +136,7 @@ func main() {
|
||||
if _, _, errno := syscall.AllThreadsSyscall(syscall.SYS_PRCTL, PR_SET_NO_NEW_PRIVS, 1, 0); errno != 0 {
|
||||
log.Fatalf("cannot set no_new_privs flag: %s", errno.Error())
|
||||
}
|
||||
if err := syscall.Exec(fshim, []string{"fshim"}, []string{envShim + "=" + shimSetupFd}); err != nil {
|
||||
if err := syscall.Exec(fmain, []string{"fortify", "shim"}, []string{envShim + "=" + shimSetupFd}); err != nil {
|
||||
log.Fatalf("cannot start shim: %v", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user