Files
zip/files_other.go
T
zeekayandHanzo Dev 02f2e3da97 Carry file descriptors over unix connections
A descriptor is not data: its number is an index into a table the peer does not
share, so a byte stream cannot hand over a pipe, a console, or an already-open
file. SCM_RIGHTS is the kernel doing that translation, and it rides the same
unix connection peerOf already reads SO_PEERCRED from.

Needed to carry a sandbox control plane. gVisor's urpc passes Files on 20 of
its 22 call sites — exec's stdio, checkpoint restore, the memory file — so a
transport without this cannot replace it at all.

Refuses rather than half-delivering: an empty body would let the kernel discard
a control-only message and lose the descriptors while the call reports success,
and a non-unix connection would deliver the bytes without the files.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-08 23:57:32 -07:00

21 lines
654 B
Go

//go:build !linux && !darwin
package zip
import (
"errors"
"net"
"os"
)
// ErrNoFilePassing reports a host with no SCM_RIGHTS. It is the same error the
// unix build returns for a non-unix connection, so a caller has one condition
// to handle rather than one per platform.
var ErrNoFilePassing = errors.New("zip: file passing needs a unix connection")
// SendFiles refuses rather than dropping the files and delivering the bytes.
func SendFiles(net.Conn, []byte, []*os.File) error { return ErrNoFilePassing }
// RecvFiles refuses for the same reason.
func RecvFiles(net.Conn, []byte) (int, []*os.File, error) { return 0, nil, ErrNoFilePassing }