-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport] Revert "unbundle agent and remove associated code (#31228)" (
#31796) (#32160) Co-authored-by: Alex Lopez <[email protected]>
- Loading branch information
Showing
12 changed files
with
352 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
|
||
#ifndef DD_AGENT_PATH | ||
#error DD_AGENT_PATH must be defined | ||
#endif | ||
|
||
#ifndef DD_AGENT | ||
#define DD_AGENT "agent" | ||
#endif | ||
|
||
int main(int argc, char **argv) { | ||
if (argc > 1) { | ||
argv[0] = DD_AGENT; | ||
} else { | ||
argv = malloc(sizeof(char *) * 2); | ||
argv[0] = DD_AGENT; | ||
argv[1] = NULL; | ||
} | ||
|
||
if (strlen(DD_AGENT_PATH) == 0) { | ||
fprintf(stderr, "Cannot determine agent location\n"); | ||
exit(1); | ||
} | ||
|
||
setenv("DD_BUNDLED_AGENT", DD_AGENT, 0); | ||
|
||
execvp(DD_AGENT_PATH, argv); | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
//go:build !linux | ||
|
||
package main | ||
|
||
// nolint: deadcode, unused | ||
func setProcessName(_ string) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
//go:build linux && cgo | ||
|
||
package main | ||
|
||
/* | ||
#include <errno.h> | ||
#include <sys/prctl.h> | ||
#include <stdlib.h> | ||
int prctl_err = 0; | ||
int set_process_name () __attribute__((constructor)); | ||
int set_process_name() | ||
{ | ||
const char *name = getenv("DD_BUNDLED_AGENT"); | ||
if (name != NULL) { | ||
int ret = prctl(PR_SET_NAME, name, 0, 0); | ||
if (!ret) { | ||
prctl_err = errno; | ||
} | ||
return ret; | ||
} | ||
return 0; | ||
} | ||
*/ | ||
import ( | ||
"C" | ||
) | ||
import "syscall" | ||
|
||
func setProcessName(_ string) error { | ||
if C.prctl_err == 0 { | ||
return nil | ||
} | ||
return syscall.Errno(C.prctl_err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
//go:build linux && !cgo | ||
|
||
package main | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
func setProcessName(process string) error { | ||
processName := make([]byte, len(process)+1) | ||
copy(processName, process) | ||
_, _, err := syscall.AllThreadsSyscall(unix.SYS_PRCTL, unix.PR_SET_NAME, uintptr(unsafe.Pointer(&processName[0])), 0) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
//go:build !windows && bundle_process_agent | ||
|
||
// Main package for the agent binary | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
processcommand "github.com/DataDog/datadog-agent/cmd/process-agent/command" | ||
processsubcommands "github.com/DataDog/datadog-agent/cmd/process-agent/subcommands" | ||
"github.com/DataDog/datadog-agent/pkg/util/flavor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
registerAgent([]string{"process-agent"}, func() *cobra.Command { | ||
flavor.SetFlavor(flavor.ProcessAgent) | ||
os.Args = processcommand.FixDeprecatedFlags(os.Args, os.Stdout) | ||
return processcommand.MakeCommand(processsubcommands.ProcessAgentSubcommands(), processcommand.UseWinParams, processcommand.RootCmdRun) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
//go:build !windows && bundle_security_agent | ||
|
||
// Main package for the agent binary | ||
package main | ||
|
||
import ( | ||
seccommand "github.com/DataDog/datadog-agent/cmd/security-agent/command" | ||
secsubcommands "github.com/DataDog/datadog-agent/cmd/security-agent/subcommands" | ||
"github.com/DataDog/datadog-agent/pkg/util/flavor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
registerAgent([]string{"security-agent"}, func() *cobra.Command { | ||
flavor.SetFlavor(flavor.SecurityAgent) | ||
return seccommand.MakeCommand(secsubcommands.SecurityAgentSubcommands()) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
//go:build !windows && bundle_system_probe | ||
|
||
// Main package for the agent binary | ||
package main | ||
|
||
import ( | ||
sysprobecommand "github.com/DataDog/datadog-agent/cmd/system-probe/command" | ||
sysprobesubcommands "github.com/DataDog/datadog-agent/cmd/system-probe/subcommands" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
registerAgent([]string{"system-probe"}, func() *cobra.Command { | ||
rootCmd := sysprobecommand.MakeCommand(sysprobesubcommands.SysprobeSubcommands()) | ||
sysprobecommand.SetDefaultCommandIfNonePresent(rootCmd) | ||
return rootCmd | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
//go:build !windows && bundle_trace_agent | ||
|
||
// Main package for the agent binary | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
tracecommand "github.com/DataDog/datadog-agent/cmd/trace-agent/command" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
registerAgent([]string{"trace-agent"}, func() *cobra.Command { | ||
os.Args = tracecommand.FixDeprecatedFlags(os.Args, os.Stdout) | ||
return tracecommand.MakeRootCommand() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.