Skip to content

Commit

Permalink
[Elastic Agent] Fix agent control socket path to always be less than …
Browse files Browse the repository at this point in the history
…107 characters (elastic#20426)

* Fix agent control socket path to always be less than 107 characters.

* Use os.TempDir.

* Don't use os.TempDir.
  • Loading branch information
blakerouse authored and melchiormoulin committed Oct 14, 2020
1 parent 963851e commit d41587c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions x-pack/elastic-agent/pkg/agent/control/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
package control

import (
"crypto/sha256"
"fmt"
"path/filepath"

"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/paths"
)

// Address returns the address to connect to Elastic Agent daemon.
func Address() string {
data := paths.Data()
return fmt.Sprintf("unix://%s", filepath.Join(data, "agent.sock"))
// entire string cannot be longer than 107 characters, this forces the
// length to always be 88 characters (but unique per data path)
return fmt.Sprintf(`unix:///tmp/elastic-agent-%x.sock`, sha256.Sum256([]byte(data)))
}

0 comments on commit d41587c

Please sign in to comment.