Documentation
¶
Overview ¶
Package initcmd resolves the entrypoint command passed to machineproxy and derives the local_commands entries that should accompany it.
Two concerns live together here because they share inputs:
- LookPath performs a PATH-style lookup that can skip arbitrary directories. It is used to resolve the entrypoint without consulting the FUSE-backed path-stub directory, which serves remote ELFs that the local kernel cannot load.
- DeriveLocalCommands inspects the resolved entrypoint for a #!-shebang and returns the chain of paths (and, for env-style interpreters, the env target name) that should be added to local_commands so the tracer allows them to run locally.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeriveLocalCommands ¶
DeriveLocalCommands returns local_commands entries that describe the initial executable absPath and, if it is a #!-script, the chain of helpers the kernel will invoke to run it.
The result always begins with absPath. If absPath starts with "#!", the interpreter is appended as an absolute-path rule. When the interpreter is env-like (basename "env"), the first non-flag token in the shebang argument is appended as a basename rule so the actual language runtime is also whitelisted.
Errors reading the file are non-fatal; the function returns the entries it could derive plus the error so the caller can log it. log must be non-nil; the shebang outcome is recorded at trace level (whether a shebang was found, its interpreter, and whether the env-target branch fired).
func LookPath ¶
func LookPath(ctx context.Context, log *slog.Logger, name, pathEnv string, skipDirs ...string) (string, error)
LookPath resolves name to an absolute, executable path by searching pathEnv (a colon-separated PATH-style string), skipping any directory listed in skipDirs. Behavior mirrors exec.LookPath with one addition: directories whose cleaned form matches an entry in skipDirs are transparently bypassed.
If name contains a slash, PATH is not consulted; the path is stat'd directly and converted to its absolute form against the current working directory.
log must be non-nil; the search emits trace-level diagnostics for every PATH entry inspected and for the final hit, so callers can see which $PATH segment served the resolution.
Types ¶
This section is empty.