Commit 90974a47 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

communicator/ssh: fix panic when client is nil on reconnect

parent 656de901
......@@ -205,9 +205,14 @@ func (c *comm) Download(string, io.Writer) error {
panic("not implemented yet")
}
func (c *comm) newSession() (*ssh.Session, error) {
func (c *comm) newSession() (session *ssh.Session, err error) {
log.Println("opening new ssh session")
session, err := c.client.NewSession()
if c.client == nil {
err = errors.New("client not available")
} else {
session, err = c.client.NewSession()
}
if err != nil {
log.Printf("ssh session open error: '%s', attempting reconnect", err)
if err := c.reconnect(); err != nil {
......@@ -225,6 +230,10 @@ func (c *comm) reconnect() (err error) {
c.conn.Close()
}
// Set the conn and client to nil since we'll recreate it
c.conn = nil
c.client = nil
log.Printf("reconnecting to TCP connection for SSH")
c.conn, err = c.config.Connection()
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment