jailfs

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrangeFilesystem

func ArrangeFilesystem(paths *Paths, cfg *config.Config) error

ArrangeFilesystem sets up the jail filesystem hierarchy.

func BaseConfigPath

func BaseConfigPath(homeDir string) string

BaseConfigPath returns path to a base Drop config file which environment specific config files extend by default. If DROP_HOME is set, DROP_HOME/config/base.toml is returned, otherwise XDG specification is followed: the base config is in (XDG_CONFIG_HOME or "~/.config")/drop/base.toml

func ConfigDir

func ConfigDir(homeDir string) string

func CreateEnvDir

func CreateEnvDir(dropHome string, envId string) error

func CwdInSandbox added in v0.2.0

func CwdInSandbox(fsRoot string, cwdCandidates []string) (string, error)

CwdInSandbox returns the working directory of the sandboxed process: the first of the cwdCandidates that exists as a directory that can be entered within the assembled root filesystem (fsRoot).

CwdInSandbox must be called only after ArrangeFilesystem has assembled fsRoot and capabilities have been dropped.

func CwdToEnvId

func CwdToEnvId() (string, error)

func DropHome

func DropHome(homeDir string) (string, error)

DropHome returns the base directory for Drop data (environment dirs, internal files, such as mount points). If DROP_HOME is set, it is used directly, otherwise XDG specification is followed: (XDG_DATA_HOME or "~/.local/share")/drop/ is returned

func EnvConfigPath

func EnvConfigPath(homeDir, envId string) string

func EnvPath

func EnvPath(dropHome, envId string) string

func IsEnvIdValid

func IsEnvIdValid(envId string) bool

func LsEnvs

func LsEnvs(dropHome string) ([]string, error)

func RmEnv

func RmEnv(homeDir, dropHome string, envId string) error

func WriteEtcFiles

func WriteEtcFiles(paths *Paths) error

WriteEtcFiles writes configuration files needed in the jail's /etc directory.

Types

type Paths

type Paths struct {
	// Cwd is the directory where Drop was started.
	Cwd string
	// DropHome is the top-level directory where Drop files are stored
	// (e.g. /home/alice/.local/share/drop).
	DropHome string
	// Env is the entry point for all paths specific to the current
	// environment. For example, if envId is 'project-foo', Env is
	// /home/alice/.local/share/drop/envs/project-foo.
	Env string
	// FsRoot is where the root filesystem is assembled before chroot.
	FsRoot string
	// HostHome is the user's home directory on the host system
	// (e.g. /home/alice).
	HostHome string
	// Home is the directory mounted as the home directory in the jail
	// (e.g. /home/alice/.local/share/drop/envs/project-foo/home).
	Home string
	// Etc is the directory mounted as read-only overlay over /etc in the jail
	// (e.g. /home/alice/.local/share/drop/envs/project-foo/etc).
	Etc string
	// Var is the directory mounted as /var in the jail. The original
	// /var is hidden
	// (e.g. /home/alice/.local/share/drop/envs/project-foo/var).
	Var string
	// Tmp is the directory mounted as /tmp in the jail. It is placed as a
	// subdir of the host $TMPDIR to allow standard cleanup mechanisms.
	Tmp string
	// Run holds temporary files and dirs for the current jail instance.
	// It can be safely removed once the jailed process terminates.
	// Run is located within Paths.DropHome.
	Run string
	// Like Run dir, but located in /tmp/drop-{username}/run/.
	//
	// Stores pasta runtime files (pid and log). This ensures no
	// extra configuration is needed on systems where SELinux
	// or AppArmor configs allow pasta to write files only to /tmp.
	//
	// Stores PtySocket. Has a limited total path length (unlike
	// Paths.Run) to mitigate problems with unix socket path length
	// limit (although these can still be hit with custom TMPDIR or very
	// long username).
	RunInTmp string
	// PtySocket is a path to a named socket that the child uses to send
	// pty to the parent.
	PtySocket string
	// EmptyDir is an empty directory used to hide directories in the jail.
	EmptyDir string
	// EmptyFile is an empty file used to hide files in the jail.
	EmptyFile string
}

Paths contains filesystem paths used to setup the jail.

func NewPaths

func NewPaths(hostHome string, envId string) (*Paths, func(), error)

NewPaths creates Paths object with the relevant paths for the current environment and creates missing dir and files.

On success, the second return value is a cleanup function that should be called when Drop terminates.

func (*Paths) CwdCandidates added in v0.2.0

func (p *Paths) CwdCandidates() []string

CwdCandidates returns the candidates for the working directory to use for the sandboxed process, ordered by preference: the directory Drop was started from, the home dir and "/". The first candidate dir that exists in the sandbox should be used as the sandboxed process CWD.

Jump to

Keyboard shortcuts

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