Skip to content

Commit 5c3d467

Browse files
committed
fix: remove redundant LookPath call in detectOpenSSHInfo
Signed-off-by: Bartek Mucha <muchzill4@gmail.com>
1 parent a0e38e6 commit 5c3d467

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pkg/sshutil/sshutil.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,12 @@ func detectOpenSSHInfo(sshExe SSHExe) openSSHInfo {
374374
exe sshExecutable
375375
stderr bytes.Buffer
376376
)
377-
// TODO: Fix this function to properly handle complex SSH commands like "kitten ssh"
378-
// The current LookPath, os.Stat, and caching logic doesn't work well for multi-word commands
379-
path, err := exec.LookPath(sshExe.Exe)
380-
if err != nil {
381-
logrus.Warnf("failed to find ssh executable: %v", err)
382-
} else {
383-
st, _ := os.Stat(path)
384-
exe = sshExecutable{Path: path, Size: st.Size(), ModTime: st.ModTime()}
377+
// Note: For SSH wrappers like "kitten ssh", os.Stat will check the wrapper
378+
// executable (kitten) instead of the underlying ssh binary. This means
379+
// cache invalidation won't work properly - ssh upgrades won't be detected
380+
// since kitten's size/mtime won't change. This is probably acceptable.
381+
if st, err := os.Stat(sshExe.Exe); err == nil {
382+
exe = sshExecutable{Path: sshExe.Exe, Size: st.Size(), ModTime: st.ModTime()}
385383
openSSHInfosRW.RLock()
386384
info := openSSHInfos[exe]
387385
openSSHInfosRW.RUnlock()

0 commit comments

Comments
 (0)