-
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.
[NPM-3662] Add sestatus to agent flare
- Loading branch information
Showing
5 changed files
with
61 additions
and
3 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,29 @@ | ||
// 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 2024-present Datadog, Inc. | ||
|
||
//go:build linux | ||
|
||
// Package debug contains handlers for debug information global to all of system-probe | ||
package debug | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"net/http" | ||
"os/exec" | ||
) | ||
|
||
// HandleSelinuxSestatus reports the output of sestatus as an http result | ||
func HandleSelinuxSestatus(w http.ResponseWriter, _ *http.Request) { | ||
cmd := exec.Command("sestatus") | ||
output, err := cmd.CombinedOutput() | ||
// don't report ExitErrors since we are using the combined output which will already include stderr | ||
if err != nil && !errors.Is(err, &exec.ExitError{}) { | ||
fmt.Fprintf(w, "sestatus command failed: %s", err) | ||
return | ||
} | ||
|
||
w.Write(output) | ||
} |
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,21 @@ | ||
// 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 2024-present Datadog, Inc. | ||
|
||
//go:build !linux | ||
|
||
// Package debug contains handlers for debug information global to all of system-probe | ||
package debug | ||
|
||
import ( | ||
"io" | ||
"net/http" | ||
) | ||
|
||
// HandleSelinuxSestatus is not supported | ||
func HandleSelinuxSestatus(w http.ResponseWriter, _ *http.Request) { | ||
io.WriteString(w, "HandleSelinuxSestatus is not supported on this platform") | ||
w.WriteHeader(500) | ||
return | ||
} |
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
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