handleConnect handles the connect(2) syscall.
(n *seccomp.Notif, fd int, addrPtr uintptr, addrSize int)
| 370 | |
| 371 | // handleConnect handles the connect(2) syscall. |
| 372 | func (p *Process) handleConnect(n *seccomp.Notif, fd int, addrPtr uintptr, addrSize int) error { |
| 373 | s, ok := p.getSocket(fd) |
| 374 | if !ok { |
| 375 | return n.Skip() |
| 376 | } |
| 377 | |
| 378 | peer, errno, err := p.vmReadSockaddr(n, addrPtr, addrSize) |
| 379 | if err != nil { |
| 380 | return fmt.Errorf("read peer addr: %w", err) |
| 381 | } |
| 382 | if errno != 0 { |
| 383 | return n.Return(0, errno) |
| 384 | } |
| 385 | |
| 386 | errno, err = s.Connect(peer) |
| 387 | if err != nil { |
| 388 | return fmt.Errorf("connect socket: %w", err) |
| 389 | } |
| 390 | return n.Return(0, errno) |
| 391 | } |
| 392 | |
| 393 | // handleListen handles the listen(2) syscall. |
| 394 | func (p *Process) handleListen(n *seccomp.Notif, fd int, backlog int) error { |