usersock

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT, MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package usersock serves a unix socket only the user's own processes may use: it lives in a 0700 directory, and a peer whose SO_PEERCRED uid is another is refused before it is heard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path(env xdg.Env, name string) (string, error)

Path is $XDG_RUNTIME_DIR/lys-secrets/name as env resolves it, so a process may find a socket of a session other than its own; an error when XDG_RUNTIME_DIR holds no absolute path, since there is no other place the user's session agrees on.

Types

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

Listener accepts the user's own connections on a socket.

func Listen

func Listen(path string) (*Listener, error)

Listen binds the socket at path in a 0700 directory, replacing a stale socket a dead server left, and refusing one a live server holds.

func (*Listener) Close

func (l *Listener) Close() error

Close stops listening and removes the socket.

func (*Listener) Serve

func (l *Listener) Serve(ctx context.Context, name string, handle func(*net.UnixConn))

Serve hands each connection of the user's own processes to handle, in a goroutine of its own that closes it afterwards, until ctx ends; name says whose socket it is in the log.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL