From 83350c24a979d9982f9c35a9311ef41180d7c4bd Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 3 Jan 2025 13:43:22 -0800 Subject: [PATCH] libct/system: rm Fexecve This helper was added for runc-dmz in commit dac417174, but runc-dmz was later removed in commit 871057d, which forgot to remove the helper. Signed-off-by: Kir Kolyshkin --- libcontainer/system/linux.go | 45 ------------------------------------ 1 file changed, 45 deletions(-) diff --git a/libcontainer/system/linux.go b/libcontainer/system/linux.go index 7bbf92a3d30..e8ce0ecac9d 100644 --- a/libcontainer/system/linux.go +++ b/libcontainer/system/linux.go @@ -6,8 +6,6 @@ import ( "fmt" "io" "os" - "strconv" - "syscall" "unsafe" "github.com/sirupsen/logrus" @@ -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