jailfs

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 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 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 remove once the jailed process terminates.
	Run 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.

Jump to

Keyboard shortcuts

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