detached 62374aa

fix(encryption): add escape mechanism for password prompt loop

- check gum exit code for Ctrl+C (exit 130)
- allow empty password to abort installation
- show user instruction: Ctrl+C or empty to cancel
- remove unreachable empty password check after loop
commit
62374aa835c8a909e12bfd815917c54fe7282e38
author
bnema · · 2025-10-26 11:29 UTC
parent
10025b2
signature
unsigned
1 file · +20 -6
M install/partitioning/format.sh +20 -6
@@ -31,28 +31,42 @@ if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then
3131 echo
3232 gum style --foreground 6 --padding "0 0 0 $PADDING_LEFT" "Disk Encryption Password"
3333 gum style --padding "0 0 0 $PADDING_LEFT" "Enter a password to encrypt your disk (different from your account password)"
34+ gum style --foreground 8 --padding "0 0 0 $PADDING_LEFT" "Press Ctrl+C to cancel or leave empty to abort"
3435
3536 while true; do
3637 LUKS_PASSWORD=$(gum input --password --placeholder "Enter encryption password" \
3738 --prompt "Password: " \
3839 --padding "0 0 0 $PADDING_LEFT")
3940
41+ # Check if gum was cancelled (Ctrl+C returns exit code 130)
42+ if [ $? -ne 0 ]; then
43+ echo "Installation cancelled by user" >> "$ARCHUP_INSTALL_LOG_FILE"
44+ exit 130
45+ fi
46+
47+ # Allow empty password to abort
48+ if [ -z "$LUKS_PASSWORD" ]; then
49+ gum style --foreground 3 --padding "1 0 1 $PADDING_LEFT" "Installation aborted by user"
50+ echo "Installation aborted: empty encryption password" >> "$ARCHUP_INSTALL_LOG_FILE"
51+ exit 1
52+ fi
53+
4054 LUKS_PASSWORD_CONFIRM=$(gum input --password --placeholder "Confirm encryption password" \
4155 --prompt "Confirm: " \
4256 --padding "0 0 0 $PADDING_LEFT")
4357
58+ # Check if confirmation was cancelled
59+ if [ $? -ne 0 ]; then
60+ echo "Installation cancelled by user" >> "$ARCHUP_INSTALL_LOG_FILE"
61+ exit 130
62+ fi
63+
4464 if [ "$LUKS_PASSWORD" = "$LUKS_PASSWORD_CONFIRM" ]; then
4565 break
4666 else
4767 gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "Passwords do not match. Try again."
4868 fi
4969 done
50-
51- if [ -z "$LUKS_PASSWORD" ]; then
52- gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "ERROR: Encryption password not set!"
53- echo "ERROR: Encryption password is empty during LUKS setup" >> "$ARCHUP_INSTALL_LOG_FILE"
54- exit 1
55- fi
5670 fi
5771
5872 # Wipe any existing signatures on root partition to avoid conflicts
@@ -31,28 +31,42 @@ if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then
31 echo31 echo
32 gum style --foreground 6 --padding "0 0 0 $PADDING_LEFT" "Disk Encryption Password"32 gum style --foreground 6 --padding "0 0 0 $PADDING_LEFT" "Disk Encryption Password"
33 gum style --padding "0 0 0 $PADDING_LEFT" "Enter a password to encrypt your disk (different from your account password)"33 gum style --padding "0 0 0 $PADDING_LEFT" "Enter a password to encrypt your disk (different from your account password)"
34+ gum style --foreground 8 --padding "0 0 0 $PADDING_LEFT" "Press Ctrl+C to cancel or leave empty to abort"
34 35
35 while true; do36 while true; do
36 LUKS_PASSWORD=$(gum input --password --placeholder "Enter encryption password" \37 LUKS_PASSWORD=$(gum input --password --placeholder "Enter encryption password" \
37 --prompt "Password: " \38 --prompt "Password: " \
38 --padding "0 0 0 $PADDING_LEFT")39 --padding "0 0 0 $PADDING_LEFT")
39 40
41+ # Check if gum was cancelled (Ctrl+C returns exit code 130)
42+ if [ $? -ne 0 ]; then
43+ echo "Installation cancelled by user" >> "$ARCHUP_INSTALL_LOG_FILE"
44+ exit 130
45+ fi
46+
47+ # Allow empty password to abort
48+ if [ -z "$LUKS_PASSWORD" ]; then
49+ gum style --foreground 3 --padding "1 0 1 $PADDING_LEFT" "Installation aborted by user"
50+ echo "Installation aborted: empty encryption password" >> "$ARCHUP_INSTALL_LOG_FILE"
51+ exit 1
52+ fi
53+
40 LUKS_PASSWORD_CONFIRM=$(gum input --password --placeholder "Confirm encryption password" \54 LUKS_PASSWORD_CONFIRM=$(gum input --password --placeholder "Confirm encryption password" \
41 --prompt "Confirm: " \55 --prompt "Confirm: " \
42 --padding "0 0 0 $PADDING_LEFT")56 --padding "0 0 0 $PADDING_LEFT")
43 57
58+ # Check if confirmation was cancelled
59+ if [ $? -ne 0 ]; then
60+ echo "Installation cancelled by user" >> "$ARCHUP_INSTALL_LOG_FILE"
61+ exit 130
62+ fi
63+
44 if [ "$LUKS_PASSWORD" = "$LUKS_PASSWORD_CONFIRM" ]; then64 if [ "$LUKS_PASSWORD" = "$LUKS_PASSWORD_CONFIRM" ]; then
45 break65 break
46 else66 else
47 gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "Passwords do not match. Try again."67 gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "Passwords do not match. Try again."
48 fi68 fi
49 done69 done
50-
51- if [ -z "$LUKS_PASSWORD" ]; then
52- gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "ERROR: Encryption password not set!"
53- echo "ERROR: Encryption password is empty during LUKS setup" >> "$ARCHUP_INSTALL_LOG_FILE"
54- exit 1
55- fi
56 fi70 fi
57 71
58 # Wipe any existing signatures on root partition to avoid conflicts72 # Wipe any existing signatures on root partition to avoid conflicts

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close