Skip to content

Commit 75120fd

Browse files
committed
fix issue with disk encryption banner (#21385)
for #21381 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [x] Orbit runs on macOS, Linux and Windows. Check if the orbit feature/bugfix should only apply to one platform (`runtime.GOOS`). - [ ] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - [x] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)).
1 parent 97f9fee commit 75120fd

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

orbit/changes/21381-fv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Fixed an issue that would display a disk encryption modal with MDM configured and FileVault enabled if the user hadn't escrowed the key in the past.

orbit/cmd/orbit/orbit.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,12 @@ func main() {
12241224
if orbitClient.GetServerCapabilities().Has(fleet.CapabilityEscrowBuddy) {
12251225
orbitClient.RegisterConfigReceiver(update.NewEscrowBuddyRunner(updateRunner, 5*time.Minute))
12261226
} else {
1227-
orbitClient.RegisterConfigReceiver(update.ApplyDiskEncryptionRunnerMiddleware())
1227+
orbitClient.RegisterConfigReceiver(
1228+
update.ApplyDiskEncryptionRunnerMiddleware(
1229+
orbitClient.GetServerCapabilities,
1230+
orbitClient.TriggerOrbitRestart,
1231+
),
1232+
)
12281233
}
12291234
}
12301235

orbit/pkg/update/disk_encryption.go

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package update
22

33
import (
4+
"errors"
45
"sync/atomic"
56

67
"github.com/fleetdm/fleet/v4/orbit/pkg/useraction"
@@ -11,16 +12,37 @@ import (
1112
const maxRetries = 2
1213

1314
type DiskEncryptionRunner struct {
14-
isRunning atomic.Bool
15+
isRunning atomic.Bool
16+
capabilitiesFetcher func() fleet.CapabilityMap
17+
triggerOrbitRestart func(reason string)
1518
}
1619

17-
func ApplyDiskEncryptionRunnerMiddleware() fleet.OrbitConfigReceiver {
18-
return &DiskEncryptionRunner{}
20+
func ApplyDiskEncryptionRunnerMiddleware(
21+
capabilitiesFetcher func() fleet.CapabilityMap,
22+
triggerOrbitRestart func(reason string),
23+
) fleet.OrbitConfigReceiver {
24+
return &DiskEncryptionRunner{
25+
capabilitiesFetcher: capabilitiesFetcher,
26+
triggerOrbitRestart: triggerOrbitRestart,
27+
}
1928
}
2029

2130
func (d *DiskEncryptionRunner) Run(cfg *fleet.OrbitConfig) error {
2231
log.Debug().Msgf("running disk encryption fetcher middleware, notification: %v, isIdle: %v", cfg.Notifications.RotateDiskEncryptionKey, d.isRunning.Load())
2332

33+
if d.capabilitiesFetcher == nil {
34+
return errors.New("disk encryption runner needs a capabilitites fetcher configured")
35+
}
36+
37+
if d.triggerOrbitRestart == nil {
38+
return errors.New("disk encryption runner needs a function to trigger orbit restarts configured")
39+
}
40+
41+
if d.capabilitiesFetcher().Has(fleet.CapabilityEscrowBuddy) {
42+
d.triggerOrbitRestart("server has Escrow Buddy capability but old disk encryption fetcher was running")
43+
return nil
44+
}
45+
2446
if cfg.Notifications.RotateDiskEncryptionKey && !d.isRunning.Swap(true) {
2547
go func() {
2648
defer d.isRunning.Store(false)

0 commit comments

Comments
 (0)