Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feature/beats-tes…
Browse files Browse the repository at this point in the history
…ter-commit

* upstream/master:
  [Ingest Manager] Use ML_SYSTEM to detect if agent is running as a service (elastic#21884)
  Prevent log input from sending duplicate messages due to file renaming (elastic#21911)
  • Loading branch information
v1v committed Oct 21, 2020
2 parents 9aa0feb + 374467e commit 5f6f7db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions filebeat/input/log/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ func (p *Input) harvestExistingFile(newState file.State, oldState file.State) {
logp.Debug("input", "Updating state for renamed file: %s -> %s, Current offset: %v", oldState.Source, newState.Source, oldState.Offset)
// Update state because of file rotation
oldState.Source = newState.Source
oldState.TTL = newState.TTL
err := p.updateState(oldState)
if err != nil {
logp.Err("File rotation state update error: %s", err)
Expand Down
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Fix issue where inputs without processors defined would panic {pull}21628[21628]
- Prevent reporting ecs version twice {pull}21616[21616]
- Partial extracted beat result in failure to spawn beat {issue}21718[21718]
- Use ML_SYSTEM to detect if agent is running as a service {pull}21884[21884]
- Use local temp instead of system one {pull}21883[21883]
- Rename monitoring index from `elastic.agent` to `elastic_agent` {pull}21932[21932]
- Fix issue with named pipes on Windows 7 {pull}21931[21931]
Expand Down
8 changes: 6 additions & 2 deletions x-pack/elastic-agent/pkg/agent/install/svc_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ import (
"golang.org/x/sys/windows"
)

const (
ML_SYSTEM_RID = 0x4000
)

// RunningUnderSupervisor returns true when executing Agent is running under
// the supervisor processes of the OS.
func RunningUnderSupervisor() bool {
serviceSid, err := allocSid(windows.SECURITY_SERVICE_RID)
serviceSid, err := allocSid(ML_SYSTEM_RID)
if err != nil {
return false
}
Expand All @@ -40,7 +44,7 @@ func RunningUnderSupervisor() bool {

func allocSid(subAuth0 uint32) (*windows.SID, error) {
var sid *windows.SID
err := windows.AllocateAndInitializeSid(&windows.SECURITY_NT_AUTHORITY,
err := windows.AllocateAndInitializeSid(&windows.SECURITY_MANDATORY_LABEL_AUTHORITY,
1, subAuth0, 0, 0, 0, 0, 0, 0, 0, &sid)
if err != nil {
return nil, err
Expand Down

0 comments on commit 5f6f7db

Please sign in to comment.