* [meta-oe][PATCH v4] classes: rootfs-postcommands: autologin root on serial-getty
@ 2022-08-02 9:40 Johannes Schneider
2022-08-02 9:45 ` SCHNEIDER Johannes
2022-08-02 10:01 ` [OE-core] " Luca Ceresoli
0 siblings, 2 replies; 3+ messages in thread
From: Johannes Schneider @ 2022-08-02 9:40 UTC (permalink / raw)
To: openembedded-core; +Cc: Johannes Schneider
when empty-root-password AND serial-autologin-root 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 console after each
and every reboot
this is done 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/core-image.bbclass | 1 +
meta/classes/image.bbclass | 2 +-
meta/classes/rootfs-postcommands.bbclass | 20 +++++++++++++++++++
.../sysvinit/sysvinit-inittab/start_getty | 3 ++-
4 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/meta/classes/core-image.bbclass b/meta/classes/core-image.bbclass
index 84fd3eeb38..6764035729 100644
--- a/meta/classes/core-image.bbclass
+++ b/meta/classes/core-image.bbclass
@@ -29,6 +29,7 @@
# - allow-empty-password
# - allow-root-login
# - post-install-logging
+# - serial-autologin-root - with 'empty-root-password': autologin 'root' on the serial console
# - dev-pkgs - development packages (headers, etc.) for all installed packages in the rootfs
# - dbg-pkgs - debug symbol packages for all installed packages in the rootfs
# - lic-pkgs - license packages for all installed pacakges in the rootfs, requires
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 2139a7e576..fe32cdefd5 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -34,7 +34,7 @@ INHIBIT_DEFAULT_DEPS = "1"
# IMAGE_FEATURES may contain any available package group
IMAGE_FEATURES ?= ""
IMAGE_FEATURES[type] = "list"
-IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs read-only-rootfs-delayed-postinsts stateless-rootfs empty-root-password allow-empty-password allow-root-login post-install-logging overlayfs-etc"
+IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs read-only-rootfs-delayed-postinsts stateless-rootfs empty-root-password allow-empty-password allow-root-login serial-autologin-root post-install-logging overlayfs-etc"
# Generate companion debugfs?
IMAGE_GEN_DEBUGFS ?= "0"
diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index a8a952f31d..3dadba6047 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 empty-root-password and serial-autologin-root are active
+ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", [ 'empty-root-password', 'serial-autologin-root' ], "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,23 @@ ssh_allow_root_login () {
fi
}
+#
+# Autologin the 'root' user on the serial terminal,
+# if empty-root-password' AND 'serial-autologin-root are enabled
+#
+serial_autologin_root () {
+ if ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then
+ # add autologin option to util-linux getty only
+ sed -i 's/options="/&--autologin root /' \
+ "${IMAGE_ROOTFS}${base_bindir}/start_getty"
+ elif ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", d)}; then
+ 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
+ fi
+}
+
python sort_passwd () {
import rootfspostcommands
rootfspostcommands.sort_passwd(d.expand('${IMAGE_ROOTFS}${sysconfdir}'))
diff --git a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
index 699a1ead1a..7106fb72fb 100644
--- a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
+++ b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
@@ -9,9 +9,10 @@ case $(readlink -f "${getty}") in
if [ -x "/usr/bin/setsid" ] ; then
setsid="/usr/bin/setsid"
fi
+ options=""
;;
esac
if [ -e /sys/class/tty/$2 -a -c /dev/$2 ]; then
- ${setsid:-} ${getty} -L $1 $2 $3
+ ${setsid:-} ${getty} ${options:-} -L $1 $2 $3
fi
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [meta-oe][PATCH v4] classes: rootfs-postcommands: autologin root on serial-getty
2022-08-02 9:40 [meta-oe][PATCH v4] classes: rootfs-postcommands: autologin root on serial-getty Johannes Schneider
@ 2022-08-02 9:45 ` SCHNEIDER Johannes
2022-08-02 10:01 ` [OE-core] " Luca Ceresoli
1 sibling, 0 replies; 3+ messages in thread
From: SCHNEIDER Johannes @ 2022-08-02 9:45 UTC (permalink / raw)
To: openembedded-core@lists.openembedded.org, Luca Ceresoli,
Marta Rybczynska, ross.burton@arm.com
[-- Attachment #1: Type: text/plain, Size: 5601 bytes --]
Hi,
v4 adds a variant for sysv - when/if using util-linux getty, since busybox does not seem to support an autologin option
also adds some documentation to the bbclass
regards
________________________________
From: Johannes Schneider <johannes.schneider@leica-geosystems.com>
Sent: Tuesday, August 2, 2022 11:40
To: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org>
Cc: SCHNEIDER Johannes <johannes.schneider@leica-geosystems.com>
Subject: [meta-oe][PATCH v4] classes: rootfs-postcommands: autologin root on serial-getty
when empty-root-password AND serial-autologin-root 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 console after each
and every reboot
this is done 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/core-image.bbclass | 1 +
meta/classes/image.bbclass | 2 +-
meta/classes/rootfs-postcommands.bbclass | 20 +++++++++++++++++++
.../sysvinit/sysvinit-inittab/start_getty | 3 ++-
4 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/meta/classes/core-image.bbclass b/meta/classes/core-image.bbclass
index 84fd3eeb38..6764035729 100644
--- a/meta/classes/core-image.bbclass
+++ b/meta/classes/core-image.bbclass
@@ -29,6 +29,7 @@
# - allow-empty-password
# - allow-root-login
# - post-install-logging
+# - serial-autologin-root - with 'empty-root-password': autologin 'root' on the serial console
# - dev-pkgs - development packages (headers, etc.) for all installed packages in the rootfs
# - dbg-pkgs - debug symbol packages for all installed packages in the rootfs
# - lic-pkgs - license packages for all installed pacakges in the rootfs, requires
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 2139a7e576..fe32cdefd5 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -34,7 +34,7 @@ INHIBIT_DEFAULT_DEPS = "1"
# IMAGE_FEATURES may contain any available package group
IMAGE_FEATURES ?= ""
IMAGE_FEATURES[type] = "list"
-IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs read-only-rootfs-delayed-postinsts stateless-rootfs empty-root-password allow-empty-password allow-root-login post-install-logging overlayfs-etc"
+IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs read-only-rootfs-delayed-postinsts stateless-rootfs empty-root-password allow-empty-password allow-root-login serial-autologin-root post-install-logging overlayfs-etc"
# Generate companion debugfs?
IMAGE_GEN_DEBUGFS ?= "0"
diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index a8a952f31d..3dadba6047 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 empty-root-password and serial-autologin-root are active
+ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", [ 'empty-root-password', 'serial-autologin-root' ], "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,23 @@ ssh_allow_root_login () {
fi
}
+#
+# Autologin the 'root' user on the serial terminal,
+# if empty-root-password' AND 'serial-autologin-root are enabled
+#
+serial_autologin_root () {
+ if ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then
+ # add autologin option to util-linux getty only
+ sed -i 's/options="/&--autologin root /' \
+ "${IMAGE_ROOTFS}${base_bindir}/start_getty"
+ elif ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", d)}; then
+ 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
+ fi
+}
+
python sort_passwd () {
import rootfspostcommands
rootfspostcommands.sort_passwd(d.expand('${IMAGE_ROOTFS}${sysconfdir}'))
diff --git a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
index 699a1ead1a..7106fb72fb 100644
--- a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
+++ b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
@@ -9,9 +9,10 @@ case $(readlink -f "${getty}") in
if [ -x "/usr/bin/setsid" ] ; then
setsid="/usr/bin/setsid"
fi
+ options=""
;;
esac
if [ -e /sys/class/tty/$2 -a -c /dev/$2 ]; then
- ${setsid:-} ${getty} -L $1 $2 $3
+ ${setsid:-} ${getty} ${options:-} -L $1 $2 $3
fi
--
2.25.1
[-- Attachment #2: Type: text/html, Size: 9417 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [OE-core] [meta-oe][PATCH v4] classes: rootfs-postcommands: autologin root on serial-getty
2022-08-02 9:40 [meta-oe][PATCH v4] classes: rootfs-postcommands: autologin root on serial-getty Johannes Schneider
2022-08-02 9:45 ` SCHNEIDER Johannes
@ 2022-08-02 10:01 ` Luca Ceresoli
1 sibling, 0 replies; 3+ messages in thread
From: Luca Ceresoli @ 2022-08-02 10:01 UTC (permalink / raw)
To: Johannes Schneider via lists.openembedded.org
Cc: johannes.schneider, openembedded-core
Hi Johannes,
On Tue, 2 Aug 2022 11:40:19 +0200
"Johannes Schneider via lists.openembedded.org"
<johannes.schneider=leica-geosystems.com@lists.openembedded.org> wrote:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
As you can see above, your sender address is getting mangled. This is
not your fault, but it makes applying your patches annoying.
Can you please try to work around that by setting the sendemail.from
parameter in your git config?
You can read the details in this discussion:
https://lists.openembedded.org/g/openembedded-core/message/166515?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Acreated%2C0%2Crootfs.py%3A+find+.ko.zst+kernel+modules%2C20%2C2%2C0%2C91453338
Thank you very much!
However you don't need to resend this patch just for this. I fixed it
manually while applying to my testing branch.
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-02 10:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-02 9:40 [meta-oe][PATCH v4] classes: rootfs-postcommands: autologin root on serial-getty Johannes Schneider
2022-08-02 9:45 ` SCHNEIDER Johannes
2022-08-02 10:01 ` [OE-core] " Luca Ceresoli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox