Skip to content

Commit

Permalink
libct/system: rm Fexecve
Browse files Browse the repository at this point in the history
This helper was added for runc-dmz in commit dac4171, but runc-dmz was
later removed in commit 871057d, which forgot to remove the helper.

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Jan 3, 2025
1 parent 06a4a78 commit 83350c2
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 83350c2

Please sign in to comment.