Skip to content

Commit 7ca442b

Browse files
committed
address comments, remove progress prompts
1 parent 194fecc commit 7ca442b

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

orbit/pkg/luks/luks_linux.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ func (lr *LuksRunner) Run(oc *fleet.OrbitConfig) error {
5959
if keyslot != nil {
6060
salt, err := getSaltforKeySlot(ctx, devicePath, *keyslot)
6161
if err != nil {
62+
if err := removeKeySlot(ctx, devicePath, *keyslot); err != nil {
63+
log.Error().Err(err).Msgf("failed to remove key slot %d", *keyslot)
64+
}
6265
return fmt.Errorf("Failed to get salt for key slot: %w", err)
6366
}
6467
response.Salt = salt
@@ -105,9 +108,6 @@ func (lr *LuksRunner) getEscrowKey(ctx context.Context, devicePath string) ([]by
105108
return nil, nil, fmt.Errorf("Failed to show passphrase entry prompt: %w", err)
106109
}
107110

108-
cancelProgress := lr.progressPrompt(ctx, "Validating passphrase")
109-
defer cancelProgress()
110-
111111
// Validate the passphrase
112112
for {
113113
valid, err := lr.passphraseIsValid(ctx, device, devicePath, passphrase)
@@ -119,25 +119,17 @@ func (lr *LuksRunner) getEscrowKey(ctx context.Context, devicePath string) ([]by
119119
break
120120
}
121121

122-
cancelProgress()
123-
124122
passphrase, err = lr.entryPrompt(ctx, entryDialogTitle, retryEntryDialogText)
125123
if err != nil {
126124
return nil, nil, fmt.Errorf("Failed re-prompting for passphrase: %w", err)
127125
}
128-
129-
cancelProgress = lr.progressPrompt(ctx, "Validating passphrase")
130126
}
131127

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

137-
cancelProgress()
138-
cancelProgress = lr.progressPrompt(ctx, "Key escrow in progress")
139-
defer cancelProgress()
140-
141133
escrowPassphrase, err := generateRandomPassphrase()
142134
if err != nil {
143135
return nil, nil, fmt.Errorf("Failed to generate random passphrase: %w", err)
@@ -166,6 +158,15 @@ func (lr *LuksRunner) getEscrowKey(ctx context.Context, devicePath string) ([]by
166158
break
167159
}
168160

161+
valid, err := lr.passphraseIsValid(ctx, device, devicePath, escrowPassphrase)
162+
if err != nil {
163+
return nil, nil, fmt.Errorf("Error while validating escrow passphrase: %w", err)
164+
}
165+
166+
if !valid {
167+
return nil, nil, errors.New("Failed to validate escrow passphrase")
168+
}
169+
169170
return escrowPassphrase, &keySlot, nil
170171
}
171172

@@ -174,7 +175,7 @@ func (lr *LuksRunner) passphraseIsValid(ctx context.Context, device *luksdevice.
174175
return false, nil
175176
}
176177

177-
valid, err := device.CheckKey(ctx, devicePath, encryption.NewKey(0, passphrase))
178+
valid, err := device.CheckKey(ctx, devicePath, encryption.NewKey(userKeySlot, passphrase))
178179
if err != nil {
179180
return false, fmt.Errorf("Error validating passphrase: %w", err)
180181
}

0 commit comments

Comments
 (0)