-
Notifications
You must be signed in to change notification settings - Fork 6
Resolve selinux installation issues #2394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9cca82c
run restorecon after materialising files
hedge-sparrow c182dce
don't care about selinux enforcing
hedge-sparrow 0cd59ae
set specific bin_t context on bins dir
hedge-sparrow bbbd686
path
hedge-sparrow 7eace5f
Correct match group
hedge-sparrow f10bebc
add selinux preflight
hedge-sparrow d805f95
message formatting
hedge-sparrow a00a23e
Merge remote-tracking branch 'origin/main' into ash/restorecon
hedge-sparrow b8560c5
explicitly check for restorecon binary
hedge-sparrow ba74d7b
Merge remote-tracking branch 'origin/main' into ash/restorecon
hedge-sparrow f5b7038
Merge remote-tracking branch 'origin/main' into ash/restorecon
hedge-sparrow 4267708
Add selinux test
hedge-sparrow 88736bd
Merge remote-tracking branch 'origin/main' into ash/restorecon
hedge-sparrow c7f1109
bump troubleshoot tag
hedge-sparrow f188f1e
Merge remote-tracking branch 'origin/main' into ash/restorecon
hedge-sparrow 9b932da
remove path env from sudo prefix
hedge-sparrow c873ce6
move selinux setup to hostutils interface
hedge-sparrow 29dfa65
mock
hedge-sparrow 4406ae8
Revert "remove path env from sudo prefix"
hedge-sparrow 6d90fba
Merge remote-tracking branch 'origin/main' into ash/restorecon
hedge-sparrow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,50 @@ | ||
package hostutils | ||
|
||
import ( | ||
"os/exec" | ||
|
||
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig" | ||
) | ||
|
||
func (h *HostUtils) ConfigureSELinuxFcontext(rc runtimeconfig.RuntimeConfig) error { | ||
h.logger.Debugln("checking for semanage binary in $PATH") | ||
if _, err := exec.LookPath("semanage"); err != nil { | ||
h.logger.Debugln("semanage not found in $PATH") | ||
return nil | ||
} | ||
|
||
h.logger.Debugf("setting selinux fcontext for embedded-cluster binary directory to bin_t") | ||
args := []string{ | ||
"fcontext", | ||
"-a", | ||
"-s", | ||
"system_u", | ||
"-t", | ||
"bin_t", | ||
rc.EmbeddedClusterBinsSubDir() + "(/.*)?", | ||
} | ||
out, err := exec.Command("semanage", args...).CombinedOutput() | ||
if err != nil { | ||
h.logger.Debugf("unable to set contexts on binary directory: %v", err) | ||
h.logger.Debugln(string(out)) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (h *HostUtils) RestoreSELinuxContext(rc runtimeconfig.RuntimeConfig) error { | ||
h.logger.Debugln("checking for restorecon binary in $PATH") | ||
if _, err := exec.LookPath("restorecon"); err != nil { | ||
h.logger.Debugln("restorecon not found in $PATH") | ||
return nil | ||
} | ||
|
||
h.logger.Debugf("relabeling embedded-cluster data directory with restorecon") | ||
out, err := exec.Command("restorecon", "-RvF", rc.EmbeddedClusterHomeDirectory()).CombinedOutput() | ||
if err != nil { | ||
h.logger.Debugf("unable to run restorecon: %v", err) | ||
h.logger.Debugln(string(out)) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is adding
/usr/local/bin
here necessary if it's being added toPATH
above?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
during writing these tests I found that any
$PATH
settings would get ignored when we came to actually execute the scripts. I spent days banging my head against the problem and determined that using the absolute path was just simpler than working out where the problem was.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the
$PATH
variable being stripped might actually be because of selinux 😓There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok this does get passed on but only in one place... when running the ec binary. all the
.sh
script calls fail if called with aPATH
lookup 🤔