Documentation
¶
Overview ¶
Package control is the delivery daemon's control socket: a Unix socket in a directory only its owner can open, which accepts a connection only when the kernel reports that the peer runs as the same OS user. When the peer's user can't be read, the connection is refused. It implements the delivery package's Control port.
Index ¶
- Constants
- Variables
- func Allow(want, got int, readErr error) error
- func CheckDir(dir string) error
- func Dial(ctx context.Context, path string) (net.Conn, error)
- func Path(stateDir string) string
- func PeerUID(c *net.UnixConn) (int, error)
- func PrepareDir(dir string) error
- func SelfTest() error
- type Listener
Constants ¶
const SocketName = "daemon.sock"
SocketName is the socket's file name in the state directory.
Variables ¶
var ErrPeerRefused = errors.New("control connection refused")
ErrPeerRefused means a connection came from another user, or its user couldn't be read.
var ErrUnsafe = errors.New("socket directory is not private")
ErrUnsafe means the socket's directory can be opened by other users or belongs to someone else.
Functions ¶
func Allow ¶
Allow decides whether a peer may talk to the daemon: only when its user was read and matches. It fails closed.
func Path ¶
Path returns where the daemon's socket lives for a state directory: in the directory itself, or, when that path is too long for a socket, in a directory of this user's own under /tmp named after a hash of the state directory.
func PrepareDir ¶
PrepareDir creates the socket's directory with mode 0700 if needed and checks that it belongs to this user and that nobody else can open it.
Types ¶
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener accepts control connections from this OS user only.
func Listen ¶
Listen creates the socket at path, replacing a stale one, readable only by its owner. The caller must hold the daemon lock, so no live daemon's socket is removed.