File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
14
14
"runtime"
15
15
"strings"
16
16
"sync"
17
+ "time"
17
18
18
19
"github.com/coreos/go-semver/semver"
19
20
"github.com/lima-vm/lima/pkg/ioutilx"
@@ -277,19 +278,29 @@ func ParseOpenSSHVersion(version []byte) *semver.Version {
277
278
return & semver.Version {}
278
279
}
279
280
281
+ // sshExecutable beyond path also records size and mtime, in the case of ssh upgrades.
282
+ type sshExecutable struct {
283
+ Path string
284
+ Size int64
285
+ ModTime time.Time
286
+ }
287
+
280
288
// sshVersions caches the parsed version of each ssh executable, if it is needed again.
281
- var sshVersions = map [string ]* semver.Version {}
289
+ var sshVersions = map [sshExecutable ]* semver.Version {}
282
290
283
291
func DetectOpenSSHVersion () semver.Version {
284
292
var (
285
293
v semver.Version
294
+ exe sshExecutable
286
295
stderr bytes.Buffer
287
296
)
288
297
path , err := exec .LookPath ("ssh" )
289
298
if err != nil {
290
299
logrus .Warnf ("failed to find ssh executable: %v" , err )
291
300
} else {
292
- if ver := sshVersions [path ]; ver != nil {
301
+ st , _ := os .Stat (path )
302
+ exe = sshExecutable {Path : path , Size : st .Size (), ModTime : st .ModTime ()}
303
+ if ver := sshVersions [exe ]; ver != nil {
293
304
return * ver
294
305
}
295
306
}
@@ -300,7 +311,7 @@ func DetectOpenSSHVersion() semver.Version {
300
311
} else {
301
312
v = * ParseOpenSSHVersion (stderr .Bytes ())
302
313
logrus .Debugf ("OpenSSH version %s detected" , v )
303
- sshVersions [path ] = & v
314
+ sshVersions [exe ] = & v
304
315
}
305
316
return v
306
317
}
You can’t perform that action at this time.
0 commit comments