Skip to content

Commit 4fc7820

Browse files
committed
chore: golangci-lint
1 parent 0396ef6 commit 4fc7820

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

libvirt/dialers/sshcmd.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
3535
type 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.
187187
func (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.
329332
type sshCmdConn struct {
330333
cmd *exec.Cmd
331334
stdin io.WriteCloser

0 commit comments

Comments
 (0)