Skip to content

Commit

Permalink
[CM] Fix enroll under Windows (elastic#12799)
Browse files Browse the repository at this point in the history
Enrolling of a Beat to Central Management was failing under Windows
because the Beat tries to create a configuration backup file that has
a colon character in its name, which is not allowed under Windows.

Fixes elastic#12797
  • Loading branch information
adriansr authored Jul 9, 2019
1 parent 427d0ce commit 4eb411b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
processor (or by any code utilizing `PutValue()` on a `beat.Event`).
- Fix leak in script processor when using Javascript functions in a processor chain. {pull}12600[12600]
- Add additional nil pointer checks to Docker client code to deal with vSphere Integrated Containers {pull}12628[12628]
- Fix Central Management enroll under Windows {issue}12797[12797] {pull}12799[12799]

*Auditbeat*

Expand Down
8 changes: 7 additions & 1 deletion x-pack/libbeat/management/enroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ func Enroll(

ts := time.Now()

// This timestamp format is a variation of RFC3339 replacing colons with
// slashes so that it can be used as part of a filename in all OSes.
// (Colon is not a valid character for filenames in Windows).
// Also removed the TZ-offset as that can cause a plus sign to be output.
const fsSafeTimestamp = "2006-01-02T15-04-05"

// backup current settings:
backConfigFile := configFile + "." + ts.Format(time.RFC3339) + ".bak"
backConfigFile := configFile + "." + ts.Format(fsSafeTimestamp) + ".bak"
fmt.Println("Saving a copy of current settings to " + backConfigFile)
err = file.SafeFileRotate(backConfigFile, configFile)
if err != nil {
Expand Down

0 comments on commit 4eb411b

Please sign in to comment.