Skip to content

Commit

Permalink
merge #4576 into opencontainers/runc:main
Browse files Browse the repository at this point in the history
Kir Kolyshkin (1):
  libct/system: rm Fexecve

LGTMs: lifubang cyphar
  • Loading branch information
cyphar committed Jan 4, 2025
2 parents 06a4a78 + 83350c2 commit 1c32d39
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions libcontainer/system/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"fmt"
"io"
"os"
"strconv"
"syscall"
"unsafe"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -43,49 +41,6 @@ func Exec(cmd string, args []string, env []string) error {
}
}

func execveat(fd uintptr, pathname string, args []string, env []string, flags int) error {
pathnamep, err := syscall.BytePtrFromString(pathname)
if err != nil {
return err
}

argvp, err := syscall.SlicePtrFromStrings(args)
if err != nil {
return err
}

envp, err := syscall.SlicePtrFromStrings(env)
if err != nil {
return err
}

_, _, errno := syscall.Syscall6(
unix.SYS_EXECVEAT,
fd,
uintptr(unsafe.Pointer(pathnamep)),
uintptr(unsafe.Pointer(&argvp[0])),
uintptr(unsafe.Pointer(&envp[0])),
uintptr(flags),
0,
)
return errno
}

func Fexecve(fd uintptr, args []string, env []string) error {
var err error
for {
err = execveat(fd, "", args, env, unix.AT_EMPTY_PATH)
if err != unix.EINTR { // nolint:errorlint // unix errors are bare
break
}
}
if err == unix.ENOSYS { // nolint:errorlint // unix errors are bare
// Fallback to classic /proc/self/fd/... exec.
return Exec("/proc/self/fd/"+strconv.Itoa(int(fd)), args, env)
}
return os.NewSyscallError("execveat", err)
}

func SetParentDeathSignal(sig uintptr) error {
if err := unix.Prctl(unix.PR_SET_PDEATHSIG, sig, 0, 0, 0); err != nil {
return err
Expand Down

0 comments on commit 1c32d39

Please sign in to comment.