-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #522 from cbosdo/proxy-selinux-config
Relabel proxy configuration files on SELinux
- Loading branch information
Showing
4 changed files
with
58 additions
and
4 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
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,14 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package podman | ||
|
||
import "github.com/rs/zerolog" | ||
|
||
// IsSELinuxEnabled reports whether SELinux is enabled or not. | ||
// It relies on selinuxenabled tool. | ||
func IsSELinuxEnabled() bool { | ||
_, err := runCmdOutput(zerolog.DebugLevel, "selinuxenabled") | ||
return err == 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,34 @@ | ||
// SPDX-FileCopyrightText: 2024 SUSE LLC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package podman | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/rs/zerolog" | ||
"github.com/uyuni-project/uyuni-tools/shared/testutils" | ||
) | ||
|
||
func TestIsSELinuxEnabled(t *testing.T) { | ||
type testType struct { | ||
err error | ||
expected bool | ||
} | ||
|
||
cases := []testType{ | ||
{nil, true}, | ||
{errors.New("no such program selinuxenabled"), false}, | ||
} | ||
|
||
for i, testCase := range cases { | ||
runCmdOutput = func(_ zerolog.Level, _ string, _ ...string) ([]byte, error) { | ||
return []byte(""), testCase.err | ||
} | ||
caseString := fmt.Sprintf("case %d: ", i) | ||
testutils.AssertEquals(t, caseString+"unexpected return value", testCase.expected, IsSELinuxEnabled()) | ||
} | ||
} |
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 @@ | ||
- Relabel proxy config files on SELinux (bsc#1235658) |