@@ -31,7 +31,7 @@ const (
3131
3232// SSHCmdDialer implements socket.Dialer interface for go-libvirt
3333// It uses the command-line ssh tool for communication, which automatically
34- // respects OpenSSH config settings in ~/.ssh/config
34+ // respects OpenSSH config settings in ~/.ssh/config.
3535type SSHCmdDialer struct {
3636 // Connection details
3737 hostname string
@@ -183,7 +183,7 @@ func (d *SSHCmdDialer) applyURIOptions(uri *url.URL) {
183183 // TODO mode parameter
184184}
185185
186- // Dial implements the socket.Dialer interface to enable using this dialer with go-libvirt
186+ // Dial implements the socket.Dialer interface to enable using this dialer with go-libvirt.
187187func (d * SSHCmdDialer ) Dial () (net.Conn , error ) {
188188 args := d .buildSSHArgs ()
189189
@@ -192,6 +192,7 @@ func (d *SSHCmdDialer) Dial() (net.Conn, error) {
192192 stdinReader , stdinWriter := io .Pipe ()
193193 stdoutReader , stdoutWriter := io .Pipe ()
194194
195+ //nolint:gosec
195196 cmd := exec .Command (d .sshBin , args ... )
196197 cmd .Stdin = stdinReader
197198 cmd .Stdout = stdoutWriter
@@ -227,7 +228,9 @@ func (d *SSHCmdDialer) Dial() (net.Conn, error) {
227228 <- ctx .Done ()
228229 // Process monitoring is done, clean up
229230 if cmd .Process != nil {
230- cmd .Process .Kill ()
231+ if err := cmd .Process .Kill ();err != nil {
232+ log .Printf ("[ERROR] Failed to kill ssh command: %v" , err )
233+ }
231234 }
232235 }()
233236
@@ -325,7 +328,7 @@ func (d *SSHCmdDialer) buildSSHArgs() []string {
325328 return args
326329}
327330
328- // sshCmdConn implements net.Conn to communicate with the ssh process
331+ // sshCmdConn implements net.Conn to communicate with the ssh process.
329332type sshCmdConn struct {
330333 cmd * exec.Cmd
331334 stdin io.WriteCloser
0 commit comments