Skip to content

Commit 2e19d44

Browse files
committed
CORS-3446: Add instructions for obtaining correct binary
Update the warning message from the hostcrypt check to give more specific instructions on how to obtain the correct binary and where to run it.
1 parent ac3ac89 commit 2e19d44

File tree

3 files changed

+46
-8
lines changed

3 files changed

+46
-8
lines changed

pkg/hostcrypt/dynamic.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//go:build libvirt
2+
// +build libvirt
3+
4+
package hostcrypt
5+
6+
import "fmt"
7+
8+
func allowFIPSCluster() error {
9+
fipsEnabled, err := hostFIPSEnabled()
10+
if err != nil {
11+
return err
12+
}
13+
if fipsEnabled {
14+
return nil
15+
}
16+
return fmt.Errorf("enable FIPS mode on the host")
17+
}

pkg/hostcrypt/hostcrypt.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,27 @@ func VerifyHostTargetState(fips bool) error {
1818
if !fips {
1919
return nil
2020
}
21+
22+
if err := allowFIPSCluster(); err != nil {
23+
return fmt.Errorf("target cluster is in FIPS mode, %w", err)
24+
}
25+
return nil
26+
}
27+
28+
func hostFIPSEnabled() (bool, error) {
2129
if runtime.GOOS != "linux" {
22-
return fmt.Errorf("target cluster is in FIPS mode, operation requires a Linux client")
30+
return false, fmt.Errorf("operation requires a Linux client")
2331
}
2432

2533
hostFIPSData, err := os.ReadFile(fipsFile)
2634
if err != nil {
27-
return fmt.Errorf("target cluster is in FIPS mode, but failed to read client FIPS state %s: %w", fipsFile, err)
35+
return false, fmt.Errorf("failed to read client FIPS state %s: %w", fipsFile, err)
2836
}
2937

3038
hostFIPS, err := strconv.ParseBool(strings.TrimSuffix(string(hostFIPSData), "\n"))
3139
if err != nil {
32-
return fmt.Errorf("target cluster is in FIPS mode, but failed to parse client FIPS state %s: %w", fipsFile, err)
33-
}
34-
35-
if !hostFIPS {
36-
return fmt.Errorf("target cluster is in FIPS mode, operation requires a FIPS enabled client")
40+
return false, fmt.Errorf("failed to parse client FIPS state %s: %w", fipsFile, err)
3741
}
3842

39-
return nil
43+
return hostFIPS, nil
4044
}

pkg/hostcrypt/static.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//go:build !libvirt
2+
// +build !libvirt
3+
4+
package hostcrypt
5+
6+
import "fmt"
7+
8+
const binaryInstructions = "To obtain a suitable binary, download the openshift-install-rhel8 archive from the client mirror, or extract the openshift-install-fips command from the release payload."
9+
10+
func allowFIPSCluster() error {
11+
hostMsg := ""
12+
if fipsEnabled, err := hostFIPSEnabled(); err != nil || !fipsEnabled {
13+
hostMsg = " on a host with FIPS enabled"
14+
}
15+
return fmt.Errorf("use the FIPS-capable installer binary for RHEL 8%s.\n%s",
16+
hostMsg, binaryInstructions)
17+
}

0 commit comments

Comments
 (0)