diff --git a/pkg/declarative/helpers.go b/pkg/declarative/helpers.go index e865e591..59493983 100644 --- a/pkg/declarative/helpers.go +++ b/pkg/declarative/helpers.go @@ -112,3 +112,15 @@ func SymlinkSyscall(oldpath string, newpath string) error { func LinkSyscall(oldpath string, newpath string) error { return unix.Link(oldpath, newpath) } + +func DupSyscall(oldfd int) (int, error) { + newfd, err := unix.Dup(oldfd) + if err != nil { + return -1, err + } + return newfd, nil +} + +func PtraceSyscall(pid int, signal int) error { + return unix.PtraceSyscall(pid, signal) +} diff --git a/pkg/declarative/host.go b/pkg/declarative/host.go index 5ce61b9d..d38f6b65 100644 --- a/pkg/declarative/host.go +++ b/pkg/declarative/host.go @@ -75,6 +75,16 @@ func (r *Hostrunner) ExecuteStep(ctx context.Context, test Test) error { if err != nil { return fmt.Errorf("link syscall failed with error: %v", err) } + case "dup": + _, err := DupSyscall(*step.Args.Oldfd) + if err != nil { + return fmt.Errorf("dup syscall failed with error: %v", err) + } + case "ptrace": + err := PtraceSyscall(*step.Args.Pid, *step.Args.Ptracesignal) + if err != nil { + return fmt.Errorf("ptrace syscall failed with error: %v", err) + } default: return fmt.Errorf("unsupported syscall: %s", step.Syscall) } diff --git a/pkg/declarative/yamltypes.go b/pkg/declarative/yamltypes.go index 7e94a33e..0f1ffed2 100644 --- a/pkg/declarative/yamltypes.go +++ b/pkg/declarative/yamltypes.go @@ -42,6 +42,13 @@ type Args struct { // For symlink and link syscalls Oldpath *string `yaml:"oldpath,omitempty"` Newpath *string `yaml:"newpath,omitempty"` + + // For dup syscall + Oldfd *int `yaml:"oldfd,omitempty"` + + // For ptrace syscall + Pid *int `yaml:"pid,omitempty"` + Ptracesignal *int `yaml:"ptracesignal,omitempty"` } type SyscallStep struct {