Skip to content

Commit

Permalink
add progress prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlikelee committed Nov 20, 2024
1 parent bd9b8e3 commit 1cdd864
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
38 changes: 31 additions & 7 deletions orbit/pkg/luks/luks_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,39 @@ func (lr *LuksRunner) getEscrowKey(ctx context.Context, devicePath string) ([]by
return nil, nil, fmt.Errorf("Failed to show passphrase entry prompt: %w", err)
}

cancelProgress := lr.progressPrompt(ctx, "Validating passphrase")
defer cancelProgress()

// Validate the passphrase
for {
valid, err := lr.passphraseIsValid(ctx, device, devicePath, passphrase)
if err != nil {
return nil, nil, fmt.Errorf("Failed validating passphrase: %w", err)
}

if !valid {
passphrase, err = lr.entryPrompt(ctx, entryDialogTitle, retryEntryDialogText)
if err != nil {
return nil, nil, fmt.Errorf("Failed re-prompting for passphrase: %w", err)
}
continue
if valid {
break
}

break
cancelProgress()

passphrase, err = lr.entryPrompt(ctx, entryDialogTitle, retryEntryDialogText)
if err != nil {
return nil, nil, fmt.Errorf("Failed re-prompting for passphrase: %w", err)
}

cancelProgress = lr.progressPrompt(ctx, "Validating passphrase")
}

if len(passphrase) == 0 {
log.Debug().Msg("Passphrase is empty, no password supplied, dialog was canceled, or timed out")
return nil, nil, nil
}

cancelProgress()
cancelProgress = lr.progressPrompt(ctx, "Key escrow in progress")
defer cancelProgress()

escrowPassphrase, err := generateRandomPassphrase()
if err != nil {
return nil, nil, fmt.Errorf("Failed to generate random passphrase: %w", err)
Expand Down Expand Up @@ -231,6 +241,20 @@ func (lr *LuksRunner) infoPrompt(ctx context.Context, title, text string) error
return nil
}

func (lr *LuksRunner) progressPrompt(ctx context.Context, text string) func() {
ctx, cancel := context.WithCancel(ctx)
go func() {
err := lr.notifier.ShowProgress(ctx, dialog.ProgressOptions{
Title: "Disk encryption",
Text: text,
})
if err != nil {
log.Error().Err(err).Msg("failed to show progress dialog")
}
}()
return cancel
}

type LuksDump struct {
Keyslots map[string]Keyslot `json:"keyslots"`
}
Expand Down
2 changes: 1 addition & 1 deletion server/vulnerabilities/msrc/parsed/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (p Products) GetMatchForOS(ctx context.Context, os fleet.OperatingSystem) (
}

if dvMatch == "" && noDvMatch == "" {
return "", ctxerr.Wrap(ctx, ErrNoMatch)
return "", ctxerr.Wrap(ctx, ErrNoMatch, os.Version)
}

if dvMatch == "" {
Expand Down

0 comments on commit 1cdd864

Please sign in to comment.