Skip to content

Commit 0cd59ae

Browse files
committed
set specific bin_t context on bins dir
1 parent c182dce commit 0cd59ae

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

pkg-new/hostutils/initialize.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,20 @@ func (h *HostUtils) ConfigureHost(ctx context.Context, rc runtimeconfig.RuntimeC
4040
}
4141
}
4242

43-
h.logger.Debugln("checking for restorecon binary in $PATH")
44-
if _, err := exec.LookPath("restorecon"); err != nil {
45-
h.logger.Debugln("restorecon not found")
43+
h.logger.Debugln("checking for semanage binary in $PATH")
44+
if _, err := exec.LookPath("semanage"); err != nil {
45+
h.logger.Debugln("semanage not found")
4646
} else {
47-
out, err := exec.Command("restorecon", "-RvF", rc.EmbeddedClusterHomeDirectory()).CombinedOutput()
47+
48+
// Set selinux fcontext for embedded-cluster binary directory to bin_t
49+
out, err := exec.Command("semanage", "fcontext", "-a", "-s", "system_u", "-t", "bin_t", rc.EmbeddedClusterBinsSubDir()+"(.*)?").CombinedOutput()
50+
if err != nil {
51+
h.logger.Debugf("unable to set contexts on binary directory: %v", err)
52+
h.logger.Debugln(out)
53+
}
54+
55+
// Relabel whole embedded-cluster data directory since it's created with unconfined_u
56+
out, err = exec.Command("restorecon", "-RvF", rc.EmbeddedClusterHomeDirectory()).CombinedOutput()
4857
if err != nil {
4958
h.logger.Debugf("unable to run restorecon: %v", err)
5059
h.logger.Debugln(out)

0 commit comments

Comments
 (0)