From 60cfe1f9c46539fc4e0d5d685795416cfaec1534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9mi=20V=C3=A1nyi?= Date: Mon, 29 Nov 2021 14:53:26 +0100 Subject: [PATCH 1/2] Use the generic helper for opening file to read Closes #29113 --- filebeat/input/filestream/input.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/filebeat/input/filestream/input.go b/filebeat/input/filestream/input.go index c1ba829d65fb..654938869af1 100644 --- a/filebeat/input/filestream/input.go +++ b/filebeat/input/filestream/input.go @@ -29,6 +29,7 @@ import ( input "github.com/elastic/beats/v7/filebeat/input/v2" "github.com/elastic/beats/v7/libbeat/common" "github.com/elastic/beats/v7/libbeat/common/cleanup" + "github.com/elastic/beats/v7/libbeat/common/file" "github.com/elastic/beats/v7/libbeat/common/match" "github.com/elastic/beats/v7/libbeat/feature" "github.com/elastic/beats/v7/libbeat/logp" @@ -244,7 +245,7 @@ func (inp *filestream) openFile(log *logp.Logger, path string, offset int64) (*o } ok := false - f, err := os.OpenFile(path, os.O_RDONLY, os.FileMode(0)) + f, err := file.ReadOpen(path) if err != nil { return nil, fmt.Errorf("failed opening %s: %s", path, err) } From 4795d99792aed61d140d109bb72aca8c82658d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9mi=20V=C3=A1nyi?= Date: Mon, 29 Nov 2021 15:04:09 +0100 Subject: [PATCH 2/2] add changelog entry --- CHANGELOG.next.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 51e6623bb603..80fead3fb4cc 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -192,6 +192,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Revert usageDetails api version to 2019-01-01. {pull}28995[28995] - Fix in `aws-s3` input regarding provider discovery through endpoint {pull}28963[28963] - Fix `threatintel.misp` filters configuration. {issue}27970[27970] +- Fix opening files on Windows in filestream so open files can be deleted. {issue}29113[29113] {pull}29180[29180] *Heartbeat*