Skip to content

Commit

Permalink
05core/autologin: query journal instead of /run/ignition.json
Browse files Browse the repository at this point in the history
We shouldn't use `/run/ignition.json` to determine whether a user
config was provided since it's implementation details. Instead, use the
new official journal messages that Ignition emits.

This is complicated by the fact that we need to support RHCOS, where the
journal messages haven't been backported. Use the fact that we always
have a base config to key off of whether to use the old behaviour vs the
new one. (More accurately, we'd want to check for
coreos/ignition#1002, but there's no easy way to
do this from the outside. Alternatively we can check the Ignition
version, though that's deeply nested under `/usr/lib/dracut/...`).

Anyway, this should be temporary until RHCOS moves to spec v3.

Closes: #514
  • Loading branch information
jlebon committed Jul 15, 2020
1 parent 963a9a8 commit 613f691
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,22 @@ fi
# If the user supplied an Ignition config, they have the ability to enable
# autologin themselves. Don't automatically render them insecure, since
# they might be running in production and booting via e.g. IPMI.
if [ -e /run/ignition.json ] ; then
exit 0

# This is a hack for RHCOS Ignition which doesn't have
# https://github.com/coreos/ignition/pull/958. This works because right now both
# RHCOS and FCOS unconditionally bake in a base config. Once RHCOS moves to
# Ignition v2, we can drop this and just leave the else block.
ign_basecfg_msg=$(journalctl -q MESSAGE_ID=57124006b5c94805b77ce473e92a8aeb IGNITION_CONFIG_TYPE=base)
if [ -z "${ign_basecfg_msg}" ]; then
if [ -e /run/ignition.json ]; then
exit 0
fi
else
# See https://github.com/coreos/ignition/pull/958 for the MESSAGE_ID source.
ign_usercfg_msg=$(journalctl -q MESSAGE_ID=57124006b5c94805b77ce473e92a8aeb IGNITION_CONFIG_TYPE=user)
if [ -n "${ign_usercfg_msg}" ]; then
exit 0
fi
fi

write_dropin "getty@.service" "--noclear"
Expand Down

0 comments on commit 613f691

Please sign in to comment.