loginshell

package
v0.6.13 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package loginshell keeps an image's PATH in the login shells toolboxd runs.

Images put their tools on PATH with ENV (the golang image adds /usr/local/go/bin, rust /usr/local/cargo/bin), and toolboxd starts with that PATH. A login shell reads /etc/profile first, and on Alpine and Debian alike that file overwrites PATH with a fixed default, so the image's own directories vanish and `go` or `cargo` is "not found". Login shells stay, because some images set tools up through the profile (conda, nix, sdkman in /etc/profile.d); what changes is that the image's PATH is put back in front once the profile has run.

toolboxd records the PATH it started with in Env, inherited by every child, and runs Restore after the profile: prefixed to every command it hands a login shell (Prefix, Argv), written first to a stdin-fed login session, and installed as an /etc/profile.d script (InstallProfileHook) for the interactive terminals no command reaches.

Index

Constants

View Source
const Env = "AEROLVM_IMAGE_PATH"

Env names the variable holding the PATH login shells put back: the one toolboxd started with, or the one a request set.

View Source
const ProfileDir = "/etc/profile.d"

ProfileDir is where login shells on Alpine and Debian source drop-in scripts, after /etc/profile has set PATH.

View Source
const Restore = `` /* 157-byte string literal not displayed */

Restore is POSIX shell that puts $AEROLVM_IMAGE_PATH back at the front of PATH unless it is already there, keeping whatever the profile added after it. It does nothing when the variable is unset, so it is harmless outside aerolvm.

Variables

This section is empty.

Functions

func Argv

func Argv(argv []string) []string

Argv returns argv with the PATH restore prefixed to its command when argv runs a login shell with -c (an E2B command is /bin/bash -l -c ...). Anything else is returned unchanged.

func EnvFor

func EnvFor(env map[string]string) []string

EnvFor is the extra environment for a child started with a request's env: a PATH the request sets is the one its login shells keep.

func InstallProfileHook

func InstallProfileHook(dir string) (bool, error)

InstallProfileHook writes the PATH restore as a profile.d script in dir, for the interactive login shells no command reaches (terminals). It reports whether the hook is in place. A missing dir means no profile sources drop-ins, and nothing is written; an unwritable one (a non-root image, a read-only root) is an error the caller logs.

func LoginWithoutCommand

func LoginWithoutCommand(argv []string) bool

LoginWithoutCommand reports whether argv starts a login shell that reads its commands from stdin (or a terminal) rather than -c.

func Prefix

func Prefix(command string) string

Prefix returns a command for a login shell's -c that restores the PATH first. It is a separate line, so the command is unchanged.

func Record

func Record()

Record notes the PATH toolboxd started with, for every child to inherit. A value already set (by the runtime) is kept.

Types

This section is empty.

Jump to

Keyboard shortcuts

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