Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

systemd: configure emergency.service to autologin if set on kernel co… #213

Merged
merged 1 commit into from Jul 19, 2016

Conversation

mischief
Copy link
Contributor

…mmandline

@@ -52,6 +65,8 @@ autologin() {
overlay_unit "getty@.service"
overlay_unit "serial-getty@.service"
fi

emergency_autologin "emergency.service"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unnecessary for this to be an argument.

@@ -52,6 +64,8 @@ autologin() {
overlay_unit "getty@.service"
overlay_unit "serial-getty@.service"
fi

emergency_autologin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be on the safe side, lets pass "${arg}" as an argument, the function should then exit early if arg is not empty but doesn't exist in /sys/class/tty/console/active

that way we don't open up a tty in emergency mode that wouldn't otherwise be open.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that multiple consoles may be listed but only the first is going to be applicable (only one can be stdin) so something like:

if [[ -n "$1" ]]; then
    egrep -q "^$1( |$)" /sys/class/tty/console/active || return
fi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

er, wait, or is it the last one? damnit... I always forget.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last one, so can be simplified to merely: grep -q "$1$" /sys/class/tty/console/active || return if "$1" is blank it'll still match so no need for the extra if.

@mischief
Copy link
Contributor Author

fixes coreos/bugs#1433

@marineam
Copy link
Contributor

LGTM

@mischief mischief merged commit f315ee8 into coreos:master Jul 19, 2016
@mischief mischief deleted the emergency-autologin branch July 19, 2016 21:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants