remote

package
v0.149.5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolFlagBeforeDash

func BoolFlagBeforeDash(args []string, long, shorthand string) bool

BoolFlagBeforeDash mirrors pflag's boolean forms closely enough to choose the SSH TTY mode before the remote Cobra command parses the arguments. Repeated flags use the last value, and agent arguments after -- are never inspected.

func ConfiguredRemote

func ConfiguredRemote(dir, name string) (config.Remote, error)

func ProfileArgs added in v0.149.4

func ProfileArgs(profile config.Remote) []string

ProfileArgs is literal local CLI argv; RunRemoteInvocation alone quotes it for the receiving POSIX shell. Labels and remote paths never become shell source.

func RunRemoteInvocation

func RunRemoteInvocation(ctx context.Context, invocation Invocation, streams IO) error

func ShellQuote

func ShellQuote(value string) string

ShellQuote quotes one argument for the remote user's POSIX shell. OpenSSH combines the remote command into a shell string even when local argv is safe.

func ValidateRemoteCommand

func ValidateRemoteCommand(args []string) error

func ValidateRemoteState

func ValidateRemoteState(state string) error

ValidateRemoteState accepts only a POSIX absolute path for the remote host. It deliberately avoids filepath.Abs, Clean, and EvalSymlinks: the client's filesystem says nothing about the remote one, and the receiving executable applies its own overlap, alias, and channel-marker checks before any write.

As with --remote-binary, NUL cannot reach an environment value, and CR or LF would split the one-line remote command for SSH logs and non-POSIX login shells. Every other byte, including tab and other control bytes, is legal in a POSIX path and stays inert inside the single-quoted assignment, so it is passed through literally.

func ValidateRemoteTarget

func ValidateRemoteTarget(target string) error

Types

type IO

type IO struct {
	In        io.Reader
	Out       io.Writer
	ErrOut    io.Writer
	StdinTTY  bool
	StdoutTTY bool
	SSHPath   string
}

func ProcessIO

func ProcessIO() IO

func Streams

func Streams(ctx context.Context) IO

type IOContextKey

type IOContextKey struct{}

type Invocation

type Invocation struct {
	Target      string
	Binary      string
	CWD         string
	State       string
	Args        []string
	AllocateTTY bool
	// NonInteractive prevents SSH from prompting via /dev/tty in background work.
	NonInteractive bool
}

Invocation.State is a lexical absolute path on the remote host. It is never resolved locally: the receiving executable owns its own state checks.

func ParseRemoteInvocation

func ParseRemoteInvocation(argv []string, interactive bool, newRootCommand func() *cobra.Command) (Invocation, bool, error)

func ProfileInvocation added in v0.149.4

func ProfileInvocation(profile config.Remote, args []string) Invocation

ProfileInvocation preserves the saved host, executable and remote state. The receiving binary still applies the channel guard and attachment authorization.

Jump to

Keyboard shortcuts

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