From f59713b7ce6563fde7a7bce7f8ffa7606815f3aa Mon Sep 17 00:00:00 2001
From: Dante Catalfamo <43040593+dantecatalfamo@users.noreply.github.com>
Date: Wed, 16 Apr 2025 12:25:41 -0400
Subject: [PATCH] Removed indicator for background LUKS validation (#28218)
#25700
---
changes/25700-luks-escrow-longtime | 1 +
.../CreateLinuxKeyModal.tsx | 4 ++
orbit/changes/25700-luks-escrow-longtime | 1 +
orbit/pkg/dialog/dialog.go | 3 --
orbit/pkg/kdialog/kdialog.go | 17 --------
orbit/pkg/kdialog/kdialog_test.go | 39 -----------------
orbit/pkg/luks/luks_linux.go | 42 +++----------------
orbit/pkg/zenity/zenity.go | 28 -------------
orbit/pkg/zenity/zenity_test.go | 35 ----------------
tools/dialog/main.go | 15 -------
10 files changed, 12 insertions(+), 173 deletions(-)
create mode 100644 changes/25700-luks-escrow-longtime
create mode 100644 orbit/changes/25700-luks-escrow-longtime
diff --git a/changes/25700-luks-escrow-longtime b/changes/25700-luks-escrow-longtime
new file mode 100644
index 0000000000..601a76260a
--- /dev/null
+++ b/changes/25700-luks-escrow-longtime
@@ -0,0 +1 @@
+- Changed LUKS escrow instrucitons
diff --git a/frontend/pages/hosts/details/DeviceUserPage/CreateLinuxKeyModal/CreateLinuxKeyModal.tsx b/frontend/pages/hosts/details/DeviceUserPage/CreateLinuxKeyModal/CreateLinuxKeyModal.tsx
index 4d231f4ee5..8c783a14bb 100644
--- a/frontend/pages/hosts/details/DeviceUserPage/CreateLinuxKeyModal/CreateLinuxKeyModal.tsx
+++ b/frontend/pages/hosts/details/DeviceUserPage/CreateLinuxKeyModal/CreateLinuxKeyModal.tsx
@@ -24,6 +24,10 @@ const CreateLinuxKeyModal = ({
In the pop-up, enter the passphrase used to encrypt your device during
setup.
+
+ Wait for Fleet to create a new key. This process may take up to 10
+ minutes.
+
Close this window and select Refetch on your My device{" "}
page. This shares the new key with your organization.
diff --git a/orbit/changes/25700-luks-escrow-longtime b/orbit/changes/25700-luks-escrow-longtime
new file mode 100644
index 0000000000..1c793cfbe9
--- /dev/null
+++ b/orbit/changes/25700-luks-escrow-longtime
@@ -0,0 +1 @@
+- Removed popup loading indicator for LUKS key escrow
diff --git a/orbit/pkg/dialog/dialog.go b/orbit/pkg/dialog/dialog.go
index b0155c269b..f41747d7ba 100644
--- a/orbit/pkg/dialog/dialog.go
+++ b/orbit/pkg/dialog/dialog.go
@@ -23,9 +23,6 @@ type Dialog interface {
// ShowInfo displays a dialog that displays information. It returns an error if the dialog
// could not be displayed.
ShowInfo(opts InfoOptions) error
- // Progress displays a dialog that shows progress. It waits until the
- // context is cancelled.
- ShowProgress(opts ProgressOptions) (cancelFunc func() error, err error)
}
// EntryOptions represents options for a dialog that accepts end user input.
diff --git a/orbit/pkg/kdialog/kdialog.go b/orbit/pkg/kdialog/kdialog.go
index c688b8f60a..590e7a782b 100644
--- a/orbit/pkg/kdialog/kdialog.go
+++ b/orbit/pkg/kdialog/kdialog.go
@@ -50,23 +50,6 @@ func (k *KDialog) ShowEntry(opts dialog.EntryOptions) ([]byte, error) {
return output, nil
}
-func (k *KDialog) ShowProgress(opts dialog.ProgressOptions) (func() error, error) {
- args := []string{"--msgbox"}
- if opts.Text != "" {
- args = append(args, opts.Text)
- }
- if opts.Title != "" {
- args = append(args, "--title", opts.Title)
- }
-
- cancel, err := k.cmdWithCancel(args...)
- if err != nil {
- return nil, err
- }
-
- return cancel, nil
-}
-
func (k *KDialog) ShowInfo(opts dialog.InfoOptions) error {
args := []string{"--msgbox"}
if opts.Text != "" {
diff --git a/orbit/pkg/kdialog/kdialog_test.go b/orbit/pkg/kdialog/kdialog_test.go
index 17cd4444d4..f9ac199023 100644
--- a/orbit/pkg/kdialog/kdialog_test.go
+++ b/orbit/pkg/kdialog/kdialog_test.go
@@ -30,16 +30,6 @@ func (m *mockExecCmd) runWithOutput(timeout time.Duration, args ...string) ([]by
return m.output, m.exitCode, nil
}
-func (m *mockExecCmd) runWithCancel(args ...string) (cancelFunc func() error, err error) {
- m.capturedArgs = append(m.capturedArgs, args...)
-
- if m.err != nil {
- return nil, m.err
- }
-
- return nil, nil
-}
-
func TestShowEntryArgs(t *testing.T) {
testCases := []struct {
name string
@@ -164,32 +154,3 @@ func TestShowInfoError(t *testing.T) {
})
}
}
-
-func TestShowProgressArgs(t *testing.T) {
- testCases := []struct {
- name string
- opts dialog.ProgressOptions
- expectedArgs []string
- }{
- {
- name: "Basic Progress",
- opts: dialog.ProgressOptions{
- Title: "A Title",
- Text: "Some text",
- },
- expectedArgs: []string{"--msgbox", "Some text", "--title", "A Title"},
- },
- }
-
- for _, tt := range testCases {
- t.Run(tt.name, func(t *testing.T) {
- mock := &mockExecCmd{}
- k := &KDialog{
- cmdWithCancel: mock.runWithCancel,
- }
- _, err := k.ShowProgress(tt.opts)
- assert.NoError(t, err)
- assert.Equal(t, tt.expectedArgs, mock.capturedArgs)
- })
- }
-}
diff --git a/orbit/pkg/luks/luks_linux.go b/orbit/pkg/luks/luks_linux.go
index a8a8892f63..2c23580257 100644
--- a/orbit/pkg/luks/luks_linux.go
+++ b/orbit/pkg/luks/luks_linux.go
@@ -33,7 +33,7 @@ const (
retryEntryDialogText = "Passphrase incorrect. Please try again."
infoTitle = "Disk encryption"
infoFailedText = "Failed to escrow key. Please try again later."
- infoSuccessText = "Success! Now, return to your browser window and follow the instructions to verify disk encryption."
+ infoSuccessText = "Disk encryption key created! Now, return to your browser window and follow the instructions to verify."
timeoutMessage = "Please visit Fleet Desktop > My device and click Create key"
maxKeySlots = 8
userKeySlot = 0 // Key slot 0 is assumed to be the location of the user's passphrase
@@ -145,21 +145,9 @@ func (lr *LuksRunner) getEscrowKey(ctx context.Context, devicePath string) ([]by
return nil, nil, nil
}
- cancelProgress, err := lr.notifier.ShowProgress(dialog.ProgressOptions{
- Title: infoTitle,
- Text: "Validating passphrase...",
- })
- if err != nil {
- log.Error().Err(err).Msg("failed to show progress dialog")
- }
- defer func() {
- if err := cancelProgress(); err != nil {
- log.Debug().Err(err).Msg("failed to cancel progress dialog")
- }
- }()
-
// Validate the passphrase
for {
+ log.Debug().Msg("Validating disk passphrase")
valid, err := lr.passphraseIsValid(ctx, device, devicePath, passphrase, userKeySlot)
if err != nil {
return nil, nil, fmt.Errorf("Failed validating passphrase: %w", err)
@@ -181,45 +169,27 @@ func (lr *LuksRunner) getEscrowKey(ctx context.Context, devicePath string) ([]by
}
- if err := cancelProgress(); err != nil {
- log.Error().Err(err).Msg("failed to cancel progress dialog")
- }
-
- cancelProgress, err = lr.notifier.ShowProgress(dialog.ProgressOptions{
- Title: infoTitle,
- Text: "Escrowing key...",
- })
- if err != nil {
- log.Error().Err(err).Msg("failed to show progress dialog")
- }
-
- defer func() {
- if err := cancelProgress(); err != nil {
- log.Error().Err(err).Msg("failed to cancel progress dialog")
- }
- }()
-
- log.Debug().Msg("generating random disk encryption passphrase")
+ log.Debug().Msg("Generating random disk encryption passphrase")
escrowPassphrase, err := generateRandomPassphrase()
if err != nil {
return nil, nil, fmt.Errorf("Failed to generate random passphrase: %w", err)
}
+ log.Debug().Msg("Getting the next available keyslot")
keySlot, err := getNextAvailableKeySlot(ctx, devicePath)
if err != nil {
return nil, nil, fmt.Errorf("finding available keyslot: %w", err)
}
- log.Debug().Msgf("found available keyslot: %d", keySlot)
+ log.Debug().Msgf("Found available keyslot: %d", keySlot)
userKey := encryption.NewKey(userKeySlot, passphrase)
escrowKey := encryption.NewKey(int(keySlot), escrowPassphrase) // #nosec G115
- log.Debug().Msgf("adding new key to keyslot %d", keySlot)
if err := device.AddKey(ctx, devicePath, userKey, escrowKey); err != nil {
return nil, nil, fmt.Errorf("Failed to add key: %w", err)
}
- log.Debug().Msg("validating newly inserted key")
+ log.Debug().Msg("Validating newly inserted key")
valid, err := lr.passphraseIsValid(ctx, device, devicePath, escrowPassphrase, keySlot)
if err != nil {
return nil, nil, fmt.Errorf("Error while validating escrow passphrase: %w", err)
diff --git a/orbit/pkg/zenity/zenity.go b/orbit/pkg/zenity/zenity.go
index 5887a3bf4d..c98475b5a5 100644
--- a/orbit/pkg/zenity/zenity.go
+++ b/orbit/pkg/zenity/zenity.go
@@ -85,34 +85,6 @@ func (z *Zenity) ShowInfo(opts dialog.InfoOptions) error {
return nil
}
-// ShowProgress starts a Zenity pulsating progress dialog with the given options.
-// It returns a cancel function that can be used to cancel the dialog.
-func (z *Zenity) ShowProgress(opts dialog.ProgressOptions) (func() error, error) {
- args := []string{"--progress"}
- if opts.Title != "" {
- args = append(args, fmt.Sprintf("--title=%s", opts.Title))
- }
- if opts.Text != "" {
- args = append(args, fmt.Sprintf("--text=%s", opts.Text))
- }
-
- // --pulsate shows a pulsating progress bar
- args = append(args, "--pulsate")
-
- // --no-cancel disables the cancel button
- args = append(args, "--no-cancel")
-
- // --auto-close automatically closes the dialog when stdin is closed
- args = append(args, "--auto-close")
-
- cancel, err := z.cmdWithCancel(args...)
- if err != nil {
- return nil, fmt.Errorf("failed to start progress dialog: %w", err)
- }
-
- return cancel, nil
-}
-
func execCmdWithOutput(args ...string) ([]byte, int, error) {
var opts []execuser.Option
for _, arg := range args {
diff --git a/orbit/pkg/zenity/zenity_test.go b/orbit/pkg/zenity/zenity_test.go
index b38381b6ee..6f3decd8ee 100644
--- a/orbit/pkg/zenity/zenity_test.go
+++ b/orbit/pkg/zenity/zenity_test.go
@@ -27,12 +27,6 @@ func (m *mockExecCmd) runWithOutput(args ...string) ([]byte, int, error) {
return m.output, m.exitCode, nil
}
-func (m *mockExecCmd) runWithStdin(args ...string) (func() error, error) {
- m.capturedArgs = append(m.capturedArgs, args...)
-
- return nil, nil
-}
-
func TestShowEntryArgs(t *testing.T) {
testCases := []struct {
name string
@@ -191,32 +185,3 @@ func TestShowInfoError(t *testing.T) {
})
}
}
-
-func TestProgressArgs(t *testing.T) {
- testCases := []struct {
- name string
- opts dialog.ProgressOptions
- expectedArgs []string
- }{
- {
- name: "Basic Entry",
- opts: dialog.ProgressOptions{
- Title: "A Title",
- Text: "Some text",
- },
- expectedArgs: []string{"--progress", "--title=A Title", "--text=Some text", "--pulsate", "--no-cancel", "--auto-close"},
- },
- }
-
- for _, tt := range testCases {
- t.Run(tt.name, func(t *testing.T) {
- mock := &mockExecCmd{}
- z := &Zenity{
- cmdWithCancel: mock.runWithStdin,
- }
- _, err := z.ShowProgress(tt.opts)
- assert.NoError(t, err)
- assert.Equal(t, tt.expectedArgs, mock.capturedArgs)
- })
- }
-}
diff --git a/tools/dialog/main.go b/tools/dialog/main.go
index 90d59e93d3..04c66a93eb 100644
--- a/tools/dialog/main.go
+++ b/tools/dialog/main.go
@@ -38,21 +38,6 @@ func main() {
panic(err)
}
- cancelProgress, err := prompt.ShowProgress(dialog.ProgressOptions{
- Title: "Zenity Test Progress Title",
- Text: "Zenity Test Progress Text",
- })
- if err != nil {
- fmt.Println("Err ShowProgress")
- panic(err)
- }
-
- time.Sleep(2 * time.Second)
- if err := cancelProgress(); err != nil {
- fmt.Println("Err cancelProgress")
- panic(err)
- }
-
err = prompt.ShowInfo(dialog.InfoOptions{
Title: "Zenity Test Info Title",
Text: "Result: " + string(output),