Skip to content

Commit b8560c5

Browse files
committed
explicitly check for restorecon binary
1 parent a00a23e commit b8560c5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pkg-new/hostutils/initialize.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,23 @@ func (h *HostUtils) ConfigureHost(ctx context.Context, rc runtimeconfig.RuntimeC
4242

4343
h.logger.Debugln("checking for semanage binary in $PATH")
4444
if _, err := exec.LookPath("semanage"); err != nil {
45-
h.logger.Debugln("semanage not found")
45+
h.logger.Debugln("semanage not found in $PATH")
4646
} else {
47-
4847
// Set selinux fcontext for embedded-cluster binary directory to bin_t
4948
out, err := exec.Command("semanage", "fcontext", "-a", "-s", "system_u", "-t", "bin_t", rc.EmbeddedClusterBinsSubDir()+"(/.*)?").CombinedOutput()
5049
if err != nil {
5150
h.logger.Debugf("unable to set contexts on binary directory: %v", err)
5251
h.logger.Debugln(out)
5352
}
5453

54+
}
55+
56+
h.logger.Debugln("checking for restorecon binary in $PATH")
57+
if _, err := exec.LookPath("restorecon"); err != nil {
58+
h.logger.Debugln("restorecon not found in $PATH")
59+
} else {
5560
// Relabel whole embedded-cluster data directory since it's created with unconfined_u
56-
out, err = exec.Command("restorecon", "-RvF", rc.EmbeddedClusterHomeDirectory()).CombinedOutput()
61+
out, err := exec.Command("restorecon", "-RvF", rc.EmbeddedClusterHomeDirectory()).CombinedOutput()
5762
if err != nil {
5863
h.logger.Debugf("unable to run restorecon: %v", err)
5964
h.logger.Debugln(out)

0 commit comments

Comments
 (0)