mounthelper

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 14 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 mounthelper is gitd-mount: the one process that may mount, so that gitd needs no privilege at all. It runs as root, answers on a Unix socket only the user its configuration names, and does two things only — mount an overlay workspace and unmount one — inside directories that configuration fixes. The configuration is root's: gitd cannot widen what it may ask for.

Every directory is opened with openat2(RESOLVE_NO_SYMLINKS) and the mount made through that descriptor, so a directory swapped for a symbolic link between the checks and the mount changes nothing: what was checked is what is mounted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(config Config, uid int, request Request) error

Do carries a request out for the caller uid, within config, or says why not.

func Serve

func Serve(listener *net.UnixListener, config Config) error

Serve answers on listener until it closes: one request per connection, from a caller the kernel names by its credentials, never by anything it says.

Types

type Answer

type Answer struct {
	Error string `json:"error,omitempty"`
}

Answer is the outcome: empty Error when done.

type Client

type Client struct {
	Socket string
}

Client is gitd's side: a strategy.Mounter that asks gitd-mount on its socket.

func (Client) MountOverlay

func (client Client) MountOverlay(lowers []string, upper, work, target string) error

MountOverlay asks for target to be mounted as the overlay of upper on lowers, the topmost first, which travel as one field joined by colons, as overlayfs names them.

func (Client) Unmount

func (client Client) Unmount(target string) error

Unmount asks for the overlay at target to be unmounted.

type Config

type Config struct {
	UID       int
	Templates []string
	Layers    []string
	Roots     []string
}

Config is who may ask, and where: templates are the only lower layers, layers the only place for upper and work directories, and roots the only places a workspace is mounted. Each may be given more than once: a gitd with tenants has templates, layers and roots for each.

func Load

func Load(path string) (Config, error)

Load reads the configuration at path, which must be root's and writable by root only: whoever could write it could mount anywhere.

user gitd
templates /var/lib/gitd/templates
layers /var/lib/gitd/layers
root /var/lib/gitd/workspaces

So must every directory above it, or whoever could write one could put another file in its place. The file is opened once, without following a link, and checked as opened.

type Request

type Request struct {
	Op     string `json:"op"`
	Lower  string `json:"lower,omitempty"`
	Upper  string `json:"upper,omitempty"`
	Work   string `json:"work,omitempty"`
	Target string `json:"target"`
}

Request is what gitd asks: Op "mount", with all four directories, or "unmount", with the target only. Lower is one template, or a warm layer and its template joined by a colon, the topmost first; each is checked on its own.

Jump to

Keyboard shortcuts

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