Skip to content

Commit bfc5c02

Browse files
committed
[Elastic Agent]: Reduce allowed socket path length
Length limit is 104 on unix.
1 parent 23efd31 commit bfc5c02

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

x-pack/elastic-agent/pkg/agent/control/addr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ func Address() string {
2222
return paths.SocketPath
2323
}
2424

25-
// unix socket path cannot be longer than 107 characters
25+
// unix socket path must be less than 104 characters
2626
path := fmt.Sprintf("unix://%s.sock", filepath.Join(paths.TempDir(), "elastic-agent-control"))
27-
if len(path) <= 107 {
27+
if len(path) < 104 {
2828
return path
2929
}
3030
// place in global /tmp to ensure that its small enough to fit; current path is way to long

x-pack/elastic-agent/pkg/core/monitoring/beats/monitoring.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ func getMonitoringEndpoint(spec program.Spec, operatingSystem, pipelineID string
3333
if operatingSystem == "windows" {
3434
return fmt.Sprintf(mbEndpointFileFormatWin, pipelineID, spec.Cmd)
3535
}
36-
// unix socket path cannot be longer than 107 characters
36+
// unix socket path must be less than 104 characters
3737
path := fmt.Sprintf("unix://%s.sock", filepath.Join(paths.TempDir(), pipelineID, spec.Cmd, spec.Cmd))
38-
if len(path) <= 107 {
38+
if len(path) < 104 {
3939
return path
4040
}
4141
// place in global /tmp to ensure that its small enough to fit; current path is way to long
@@ -58,9 +58,9 @@ func AgentMonitoringEndpoint(operatingSystem string) string {
5858
if operatingSystem == "windows" {
5959
return agentMbEndpointFileFormatWin
6060
}
61-
// unix socket path cannot be longer than 107 characters
61+
// unix socket path must be less than 104 characters
6262
path := fmt.Sprintf("unix://%s.sock", filepath.Join(paths.TempDir(), "elastic-agent"))
63-
if len(path) <= 107 {
63+
if len(path) < 104 {
6464
return path
6565
}
6666
// place in global /tmp to ensure that its small enough to fit; current path is way to long

0 commit comments

Comments
 (0)