Skip to content

Commit

Permalink
fix(scanner): fix socket file name length of SSH ControlPath (#1714)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaineK00n authored Sep 22, 2023
1 parent dea9ed7 commit 4a28722
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scanner/executil.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scanner
import (
"bytes"
"fmt"
"hash/fnv"
"io"
ex "os/exec"
"path/filepath"
Expand Down Expand Up @@ -213,7 +214,12 @@ func sshExecExternal(c config.ServerInfo, cmdstr string, sudo bool) (result exec
return
}

controlPath := filepath.Join(home, ".vuls", `controlmaster-%r-`+c.ServerName+`.%p`)
controlPath := filepath.Join(home, ".vuls", "cm-%C")
h := fnv.New32()
if _, err := h.Write([]byte(c.ServerName)); err == nil {
controlPath = filepath.Join(home, ".vuls", fmt.Sprintf("cm-%x-%%C", h.Sum32()))
}

args = append(args,
"-o", "ControlMaster=auto",
"-o", fmt.Sprintf("ControlPath=%s", controlPath),
Expand Down

0 comments on commit 4a28722

Please sign in to comment.