1
0
Fork 0

fix: check client is not nil before closing

timestamps
dump_stack() 2023-05-24 19:36:54 +00:00
parent bf9a43c1b8
commit 94285cd94d
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
1 changed files with 7 additions and 1 deletions

View File

@ -408,7 +408,13 @@ func (q System) Command(user, cmd string) (output string, err error) {
flog.Debug().Err(err).Msg("ssh connection")
return
}
defer client.Close()
defer func() {
if client != nil {
client.Close()
} else {
log.Debug().Msg("why client is nil?")
}
}()
session, err := client.NewSession()
if err != nil {