Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Live): Improve interactive root password services #1358

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[Unit]
Description=Generate issue file for Agama SSL certificate
Before=systemd-user-sessions.service

[Service]
Type=oneshot
Expand Down
19 changes: 13 additions & 6 deletions live/root/etc/systemd/system/live-password-dialog.service
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,28 @@ Before=serial-getty@ttyS1.service
Before=serial-getty@ttyS2.service
Before=serial-getty@ttysclp0.service

# start at the end to avoid overwriting the screen with systemd messages
After=agama.service
After=modprobe@drm.service

# kernel command line option
ConditionKernelCommandLine=live.password_dialog

[Service]
Type=oneshot
Environment=TERM=linux

# disable the kernel output on the console
ExecStartPre=dmesg --console-off
# disable the systemd status messages on the console
ExecStartPre=kill -SIGRTMIN+21 1

ExecStart=live-password --dialog

# reset the console state after closing the dialog otherwise the dialog
# content would stay on the screen
ExecStartPost=reset
# enable back the kernel output on the console
ExecStartPost=dmesg --console-on
TTYReset=yes
TTYVHangup=yes
# enable back the systemd status messages on the console
ExecStartPost=kill -SIGRTMIN+20 1

StandardInput=tty
RemainAfterExit=true
TimeoutSec=0
Expand Down
14 changes: 10 additions & 4 deletions live/root/etc/systemd/system/live-password-systemd.service
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,24 @@ Before=serial-getty@ttyS1.service
Before=serial-getty@ttyS2.service
Before=serial-getty@ttysclp0.service

# start at the end to avoid overwriting the screen with systemd messages
After=agama.service
After=modprobe@drm.service

# kernel command line option
ConditionKernelCommandLine=live.password_systemd

[Service]
Type=oneshot

# disable the kernel output on the console
ExecStartPre=dmesg --console-off
# disable the systemd status messages on the console
ExecStartPre=kill -SIGRTMIN+21 1

ExecStart=live-password --systemd

# enable back the kernel output on the console
ExecStartPost=dmesg --console-on
# enable back the systemd status messages on the console
ExecStartPost=kill -SIGRTMIN+20 1

StandardOutput=tty
RemainAfterExit=true
TimeoutSec=0
Expand Down
9 changes: 5 additions & 4 deletions live/root/usr/bin/live-password
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ TITLE="Set Login Password"

# functions for entering the password in an interactive dialog
confirm_exit() {
if dialog --backtitle "$BTITLE" --defaultno --yesno "Are you sure you want to cancel?" 5 40; then
# --keep-tite is not a misspelling of "title"
if dialog --keep-tite --backtitle "$BTITLE" --defaultno --yesno "Are you sure you want to cancel?" 5 40; then
lslezak marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi
}

msg_box() {
dialog --backtitle "$BTITLE" --msgbox "$1" 6 30
dialog --keep-tite --backtitle "$BTITLE" --msgbox "$1" 6 30
}

ask_password() {
if ! PWD1=$(dialog --title "$TITLE" --backtitle "$BTITLE" --stdout --insecure --passwordbox "Password:" 8 40); then
if ! PWD1=$(dialog --keep-tite --title "$TITLE" --backtitle "$BTITLE" --stdout --insecure --passwordbox "Password:" 8 40); then
confirm_exit
ask_password
fi

if ! PWD2=$(dialog --title "$TITLE" --backtitle "$BTITLE" --stdout --insecure --passwordbox "Verify Password:" 8 40); then
if ! PWD2=$(dialog --keep-tite --title "$TITLE" --backtitle "$BTITLE" --stdout --insecure --passwordbox "Verify Password:" 8 40); then
confirm_exit
ask_password
fi
Expand Down