Message ID | 20220726085139.464795-1-johannes.schneider@leica-geosystems.com |
---|---|
State | New |
Headers | show |
Series | classes: rootfs-postcommands: autologin root on serial-getty | expand |
On Tue, 2022-07-26 at 10:51 +0200, Johannes Schneider via lists.openembedded.org wrote: > when debug-tweaks or empty-root-password are part of the > IMAGE_FEATURES, save some of the developers time by not having to type > the (then still sole) 'root' username on the serial consoleafter each > and every reboot > > by inserting '--autologin root' into the command line of the > responsible 'getty' service > > Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com> > --- > meta/classes/rootfs-postcommands.bbclass | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass > index a8a952f31d..39992b101e 100644 > --- a/meta/classes/rootfs-postcommands.bbclass > +++ b/meta/classes/rootfs-postcommands.bbclass > @@ -8,6 +8,9 @@ ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'deb > # Allow dropbear/openssh to accept root logins if debug-tweaks or allow-root-login is enabled > ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'allow-root-login' ], "ssh_allow_root_login; ", "",d)}' > > +# Autologin the root user on the serial console, if debug-tweaks or empty-root-password are active > +ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'empty-root-password' ], "serial_autologin_root; ", "",d)}' > + > # Enable postinst logging if debug-tweaks or post-install-logging is enabled > ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'post-install-logging' ], "postinst_enable_logging; ", "",d)}' > I really want to remove debug-tweaks as an image feature as it isn't clear to the user enabling it what they're signing up to. I'd suggest we name this feature specific to what it actually is (serial-autologin) and then ask users to specifically select it if they want it rather than making things too magic. Cheers, Richard
diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass index a8a952f31d..39992b101e 100644 --- a/meta/classes/rootfs-postcommands.bbclass +++ b/meta/classes/rootfs-postcommands.bbclass @@ -8,6 +8,9 @@ ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'deb # Allow dropbear/openssh to accept root logins if debug-tweaks or allow-root-login is enabled ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'allow-root-login' ], "ssh_allow_root_login; ", "",d)}' +# Autologin the root user on the serial console, if debug-tweaks or empty-root-password are active +ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'empty-root-password' ], "serial_autologin_root; ", "",d)}' + # Enable postinst logging if debug-tweaks or post-install-logging is enabled ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'post-install-logging' ], "postinst_enable_logging; ", "",d)}' @@ -196,6 +199,18 @@ ssh_allow_root_login () { fi } +# +# Autologin the 'root' user on the serial terminal, +# if empty-root-password is enabled +# +serial_root_autologin () { + if [ -e ${IMAGE_ROOTFS}${systemd_system_unitdir}/serial-getty@.service ]; then + sed -i '/^\s*ExecStart\b/ s/getty /&--autologin root /' \ + "${IMAGE_ROOTFS}${systemd_system_unitdir}/serial-getty@.service" + fi +} + + python sort_passwd () { import rootfspostcommands rootfspostcommands.sort_passwd(d.expand('${IMAGE_ROOTFS}${sysconfdir}'))
when debug-tweaks or empty-root-password are part of the IMAGE_FEATURES, save some of the developers time by not having to type the (then still sole) 'root' username on the serial consoleafter each and every reboot by inserting '--autologin root' into the command line of the responsible 'getty' service Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com> --- meta/classes/rootfs-postcommands.bbclass | 15 +++++++++++++++ 1 file changed, 15 insertions(+)