Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecUnsandboxed ¶ added in v0.720.2
func ExecUnsandboxed(ctx context.Context, dir, command string, timeoutMs int) (string, string, int, bool, error)
ExecUnsandboxed runs command once, outside the host sandbox, as `<shell> -c command` in dir with Pando's own (unscrubbed) environment. It is the bash tool's escalation path after the user approved it: the persistent shell (sandboxed, with its state) is not used, so nothing the command does to shell state (cd, exports) persists.
The result mirrors PersistentShell.Exec: stdout, stderr, exit code, whether the command was interrupted (timeout or ctx), and an error only when the command could not be started. timeoutMs <= 0 means no timeout besides ctx.
func ResetForTests ¶ added in v0.720.2
func ResetForTests()
ResetForTests closes the process-wide shell so the next GetPersistentShell spawns a fresh one. For tests in other packages.
Types ¶
type PersistentShell ¶
type PersistentShell struct {
// contains filtered or unexported fields
}
PersistentShell is the long-lived shell the bash tool (and the host runtime) runs commands in. There is one per process (GetPersistentShell).
When the host sandbox covers bash, the shell is spawned through sandbox.WrapCmd: its environment is scrubbed and the process is confined to the policy that was current at spawn time. That policy's hash is recorded so GetPersistentShell can replace the shell as soon as the policy changes (a settings toggle applies to the next command).
func GetPersistentShell ¶
func GetPersistentShell(workingDir string) *PersistentShell
GetPersistentShell returns the process-wide persistent shell, starting it in workingDir on first use. A new shell replaces the current one when it has died or when the sandbox policy changed since it was spawned (the replacement starts in the old shell's current directory). The old shell of a policy change is retired gracefully: its stdin is closed, so it exits after the command it may be running.
It never returns nil: when the shell cannot be started, the returned placeholder reports the reason from Exec and the next call retries.
func (*PersistentShell) Close ¶
func (s *PersistentShell) Close()
Close terminates the shell (and, where the platform allows, its whole process tree) immediately.
func (*PersistentShell) Cwd ¶ added in v0.720.2
func (s *PersistentShell) Cwd() string
Cwd returns the shell's current working directory (tracked after every command).
func (*PersistentShell) Sandbox ¶ added in v0.720.2
func (s *PersistentShell) Sandbox() SandboxInfo
Sandbox describes how the shell was confined when it was spawned.
type SandboxInfo ¶ added in v0.720.2
type SandboxInfo struct {
// Policy is the policy resolved at spawn time.
Policy sandbox.Policy
// Capability is the backend that wrapped the shell.
Capability sandbox.Capability
// PolicyHash is Policy.Hash(); a mismatch with
// sandbox.CurrentPolicyHash() makes GetPersistentShell re-spawn.
PolicyHash string
}
SandboxInfo describes how the persistent shell was confined when spawned.
func (SandboxInfo) Active ¶ added in v0.720.2
func (i SandboxInfo) Active() bool
Active reports whether the shell really runs confined: the policy covers bash and the backend enforces it.
func (SandboxInfo) AutoAllowBash ¶ added in v0.720.2
func (i SandboxInfo) AutoAllowBash() bool
AutoAllowBash reports whether the shell's policy lets the bash tool skip the permission prompt for commands that are not dangerous. It is only true while the shell is Active and the sandbox gives its full guarantees (sandbox.Guarantees: protected paths and Pando's own ports enforced); a partial sandbox keeps the prompt.