-
Notifications
You must be signed in to change notification settings - Fork 73
Live ISO: set the root password from boot command line or interactively #1288
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
live/root/etc/systemd/system/agama-password-cmdline.service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| [Unit] | ||
| Description=Set the Agama/root password from kernel command line | ||
| # before starting the SSH and Agama server so they use the new password | ||
| Before=sshd.service | ||
| Before=agama-web-server.service | ||
|
|
||
| # plain text password or encrypted password passed via kernel command line | ||
| ConditionKernelCommandLine=|agama.password | ||
| ConditionKernelCommandLine=|agama.password_hash | ||
|
|
||
| [Service] | ||
| ExecStart=agama-password --kernel | ||
| Type=oneshot | ||
|
|
||
| [Install] | ||
| WantedBy=default.target |
45 changes: 45 additions & 0 deletions
45
live/root/etc/systemd/system/agama-password-dialog.service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| [Unit] | ||
| Description=Interactively set the Agama/root password in a dialog | ||
|
|
||
| # before starting the SSH and Agama server so they use the new password | ||
| Before=sshd.service | ||
| Before=agama-web-server.service | ||
| # before X11 because it switches the terminal to VT7 | ||
| Before=x11-autologin.service | ||
|
|
||
| # copied from YaST2-Second-Stage.service | ||
| Before=getty@tty1.service | ||
| Before=getty@tty2.service | ||
| Before=getty@tty3.service | ||
| Before=getty@tty4.service | ||
| Before=getty@tty5.service | ||
| Before=getty@tty6.service | ||
| Before=serial-getty@hvc0.service | ||
| Before=serial-getty@sclp_line0.service | ||
| Before=serial-getty@ttyAMA0.service | ||
| Before=serial-getty@ttyS0.service | ||
| 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=agama.password_dialog | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| Environment=TERM=linux | ||
| ExecStartPre=dmesg --console-off | ||
| ExecStart=agama-password --dialog | ||
| ExecStartPost=dmesg --console-on | ||
| TTYReset=yes | ||
| TTYVHangup=yes | ||
| StandardInput=tty | ||
| RemainAfterExit=true | ||
| TimeoutSec=0 | ||
|
|
||
| [Install] | ||
| WantedBy=default.target | ||
42 changes: 42 additions & 0 deletions
42
live/root/etc/systemd/system/agama-password-systemd.service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| [Unit] | ||
| Description=Interactively set the Agama/root password | ||
|
|
||
| # before starting the SSH and Agama server so they use the new password | ||
| Before=sshd.service | ||
| Before=agama-web-server.service | ||
| # before X11 because it switches the terminal to VT7 | ||
| Before=x11-autologin.service | ||
|
|
||
| # copied from YaST2-Second-Stage.service | ||
| Before=getty@tty1.service | ||
| Before=getty@tty2.service | ||
| Before=getty@tty3.service | ||
| Before=getty@tty4.service | ||
| Before=getty@tty5.service | ||
| Before=getty@tty6.service | ||
| Before=serial-getty@hvc0.service | ||
| Before=serial-getty@sclp_line0.service | ||
| Before=serial-getty@ttyAMA0.service | ||
| Before=serial-getty@ttyS0.service | ||
| 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=agama.password_systemd | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStartPre=dmesg --console-off | ||
| ExecStart=agama-password --systemd | ||
| ExecStartPost=dmesg --console-on | ||
| StandardOutput=tty | ||
| RemainAfterExit=true | ||
| TimeoutSec=0 | ||
|
|
||
| [Install] | ||
| WantedBy=default.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #!/usr/bin/sh | ||
|
|
||
| # Helper script wich sets the root (Agama) pasword from several sources | ||
| # - Kernel boot command line (use --kernel option) | ||
| # - Systemd ask password tool (use --systemd option) | ||
| # - Interactively using a dialog (use --dialog option) | ||
|
|
||
| MYDIR=$(realpath "$(dirname "$0")") | ||
| export DIALOGRC="$MYDIR/../share/agama/misc/dialog.conf" | ||
|
|
||
| # dialog titles | ||
| BTITLE="Agama Configuration (Press Ctrl+L to refresh the screen)" | ||
| 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 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| msg_box() { | ||
| dialog --backtitle "$BTITLE" --msgbox "$1" 6 30 | ||
| } | ||
|
|
||
| ask_password() { | ||
| if ! PWD1=$(dialog --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 | ||
| confirm_exit | ||
| ask_password | ||
| fi | ||
|
|
||
| if [ "$PWD1" != "$PWD2" ]; then | ||
| msg_box "Passwords do not match.\nPlease try again." | ||
| ask_password | ||
| elif [ -z "$PWD1" ]; then | ||
| msg_box "Password cannot be empty.\nPlease try again." | ||
| ask_password | ||
| else | ||
| echo "$PWD1" | passwd --stdin | ||
| exit 0 | ||
| fi | ||
| } | ||
|
|
||
| # functions for entering the password using the "systemd-ask-password" tool | ||
| ask_password_systemd() { | ||
| if ! PWD1=$(systemd-ask-password --timeout=0 "Set login password: "); then | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! PWD2=$(systemd-ask-password --timeout=0 "Verify password: "); then | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$PWD1" != "$PWD2" ]; then | ||
| echo "Passwords do not match, please try again." | ||
| ask_password_systemd | ||
| elif [ -z "$PWD1" ]; then | ||
| echo "Password cannot be empty, please try again. To skip the password configuration press Ctrl+C." | ||
| ask_password_systemd | ||
| else | ||
| echo "$PWD1" | passwd --stdin | ||
| exit 0 | ||
| fi | ||
| } | ||
|
|
||
| if [ "$1" = "--kernel" ]; then | ||
| # get the password from the kernel command line | ||
| PWD=$(awk -F 'agama.password=' '{sub(/ .*$/, "", $2); print $2}' < /proc/cmdline) | ||
| if [ -n "$PWD" ]; then | ||
| echo "$PWD" | passwd --stdin | ||
| fi | ||
|
|
||
| PWD=$(awk -F 'agama.password_hash=' '{sub(/ .*$/, "", $2); print $2}' < /proc/cmdline) | ||
| if [ -n "$PWD" ]; then | ||
| usermod -p "$PWD" root | ||
| fi | ||
| elif [ "$1" = "--dialog" ]; then | ||
| ask_password | ||
| elif [ "$1" = "--systemd" ]; then | ||
| ask_password_systemd | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # | ||
| # Configuration file for the "dialog" tool | ||
| # | ||
| # To generate a full template with all options run: | ||
| # | ||
| # dialog --create-rc dialog.conf | ||
| # | ||
|
|
||
| # Background screen color | ||
| screen_color = (WHITE,CYAN,ON) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: I would try to be consistent with the style in
agama-password-cmdline.serviceand use:or
Whatever you prefer, but the same.