Documentation
¶
Overview ¶
Package sysconf reads the machine-wide locksql setup that separates the console from the agent: the console runs as a dedicated account (locksql, used in its own login session) that alone holds the database credentials, and the agent's account reaches it through a socket that a group grants access to. The kernel enforces the boundary.
The file is written by `locksql install` and must be owned by root and writable by root only: an agent that could edit it could point clients at a console of its own or widen the socket's access.
Index ¶
Constants ¶
const ( DisplayWayland = "wayland" DisplayX11 = "x11" DisplayTTY = "tty" // no graphical session (a text console or SSH) DisplayQuartz = "quartz" // macOS DisplayUnknown = "unknown" )
Display kinds.
const ( DefaultServiceUser = "locksql" DefaultClientGroup = "locksql-clients" )
Defaults written by locksql install.
const ( X11Warn = "warn" X11Refuse = "refuse" )
X11 policies.
Variables ¶
var Path = "/etc/locksql/system.toml"
Path is the system configuration file. Tests may point it elsewhere.
var SkipOwnerCheck = false
SkipOwnerCheck disables the root-ownership check (tests only).
Functions ¶
func DefaultSocketDir ¶
func DefaultSocketDir() string
DefaultSocketDir is where shared sockets live.
func InGroup ¶
InGroup reports whether the account uid belongs to group (as its primary group or a supplementary one).
func LegacyTIOCSTI ¶
func LegacyTIOCSTI() (on, known bool)
LegacyTIOCSTI reports whether the kernel still lets a process push characters into the input of a terminal it can open (TIOCSTI). It is off by default since Linux 6.2 (dev.tty.legacy_tiocsti = 0).
func LoginUID ¶
LoginUID returns the account that opened the login session of the process (Linux audit loginuid), which sudo and su do not change. A console running as locksql whose loginuid is another account was started from that account's session: it shares its terminal and display.
func PtraceScope ¶
PtraceScope is the Yama ptrace scope (0: any process of the same user may attach to another), when the kernel has Yama.
Types ¶
type Config ¶
type Config struct {
// ServiceUser is the account the console runs as.
ServiceUser string `toml:"service_user"`
// ClientGroup's members may connect to the console sockets.
ClientGroup string `toml:"client_group"`
// SocketDir holds the sockets: owned by ServiceUser, group
// ClientGroup, mode 0710 or 0750, setgid on Linux.
SocketDir string `toml:"socket_dir"`
// AllowedUIDs may connect besides the group's members.
AllowedUIDs []int `toml:"allowed_uids"`
// X11 is what the console does in an X11 session, where any client can
// read the keyboard and the screen of the others: "warn" (the default)
// or "refuse". Production profiles always refuse.
X11 string `toml:"x11"`
}
Config is the system setup.
func Load ¶
Load reads the system configuration. It returns nil and no error when the file does not exist (same-user mode).
func (*Config) ClientAllowed ¶
ClientAllowed reports whether uid may connect: listed in AllowedUIDs or a member of the client group.
func (*Config) ServiceUID ¶
ServiceUID returns the uid of the service account.
type Display ¶
Display is the graphical session a process runs in.
func DetectDisplay ¶
func DetectDisplay() Display
DetectDisplay reports the graphical session of the current process. On Linux an X11 session (or an X display without Wayland) lets any client read the keyboard and the screen of every other client, and send them synthetic input; Wayland isolates clients from each other.