-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathsynthexec_linux.go
31 lines (26 loc) · 1.02 KB
/
synthexec_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.
//go:build linux || synthetics
package synthexec
import (
"os"
"golang.org/x/sys/unix"
"github.com/elastic/beats/v7/heartbeat/security"
"github.com/elastic/elastic-agent-libs/logp"
)
func init() {
platformCmdMutate = func(cmd *SynthCmd) {
logp.L().Warn("invoking node as:", security.NodeChildProcCred, " from: ", os.Getenv("HOME"))
// Note that while cmd.SysProcAtr takes a syscall.SysProcAttr object
// we are passing in a unix.SysProcAttr object
// this is equivalent, but the unix package is not considered deprecated
// as the syscall package is
cmd.SysProcAttr = &unix.SysProcAttr{
// Ensure node subprocesses are killed if this process dies (linux only)
Pdeathsig: unix.SIGKILL,
// Apply restricted user if available
Credential: security.NodeChildProcCred,
}
}
}