From 8a3746d71661df97615d004c353a183408c3e910 Mon Sep 17 00:00:00 2001 From: Lena Date: Sun, 23 Aug 2026 00:00:00 +0000 Subject: rsh: pass the resolved port to dial Both callers already read and used RSH_PORT before dialling. Reading it a third time inside dial hid the data flow and duplicated the error path. --- rsh/main.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'rsh/main.go') diff --git a/rsh/main.go b/rsh/main.go index 9906966..d75a9c7 100644 --- a/rsh/main.go +++ b/rsh/main.go @@ -138,7 +138,7 @@ func transport(args []string, in io.Reader, out, errw io.Writer) error { // an unknown or changed key still fails loud, just after the dial. algos = scanAlgos } - client, err := dial(user, host, cb, algos) + client, err := dial(user, host, port, cb, algos) if err != nil { return err } @@ -189,7 +189,7 @@ func scan(target string, out io.Writer) error { hostKey = key return nil } - client, err := dial(user, host, capture, algos) + client, err := dial(user, host, port, capture, algos) if err != nil { return err } @@ -314,15 +314,11 @@ func loadSigner() (ssh.Signer, error) { // dial opens an SSH connection authenticated with the configured key, verifying // the host key with hostKey and offering only the host-key algorithms in algos. -func dial(user, host string, hostKey ssh.HostKeyCallback, algos []string) (*ssh.Client, error) { +func dial(user, host string, port int, hostKey ssh.HostKeyCallback, algos []string) (*ssh.Client, error) { signer, err := loadSigner() if err != nil { return nil, err } - port, err := sshPort() - if err != nil { - return nil, err - } timeout, err := dialTimeout() if err != nil { return nil, err -- cgit v1.2.3