summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJohannes Schneider <johannes.schneider@leica-geosystems.com>2022-08-02 11:40:19 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-12 15:46:49 +0100
commit54dd5c56fc76390bcc02b4d91eec2d8c45b7ae77 (patch)
tree51e935a5ab9330a308e9a7634229eac5b54c1d75 /meta
parent39197039e90313f66cf9aa1e6631b5678f04325d (diff)
downloadpoky-54dd5c56fc76390bcc02b4d91eec2d8c45b7ae77.tar.gz
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 (From OE-Core rev: 01b3cb46405f814e27cab5290118211786cd63a0) Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes-recipe/core-image.bbclass1
-rw-r--r--meta/classes-recipe/image.bbclass2
-rw-r--r--meta/classes-recipe/rootfs-postcommands.bbclass20
-rw-r--r--meta/recipes-core/sysvinit/sysvinit-inittab/start_getty3
4 files changed, 24 insertions, 2 deletions
diff --git a/meta/classes-recipe/core-image.bbclass b/meta/classes-recipe/core-image.bbclass
index 7ef7d07390..4b5f2c99c4 100644
--- a/meta/classes-recipe/core-image.bbclass
+++ b/meta/classes-recipe/core-image.bbclass
@@ -31,6 +31,7 @@
31# - allow-empty-password 31# - allow-empty-password
32# - allow-root-login 32# - allow-root-login
33# - post-install-logging 33# - post-install-logging
34# - serial-autologin-root - with 'empty-root-password': autologin 'root' on the serial console
34# - dev-pkgs - development packages (headers, etc.) for all installed packages in the rootfs 35# - dev-pkgs - development packages (headers, etc.) for all installed packages in the rootfs
35# - dbg-pkgs - debug symbol packages for all installed packages in the rootfs 36# - dbg-pkgs - debug symbol packages for all installed packages in the rootfs
36# - lic-pkgs - license packages for all installed pacakges in the rootfs, requires 37# - lic-pkgs - license packages for all installed pacakges in the rootfs, requires
diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass
index 433172378a..e387645503 100644
--- a/meta/classes-recipe/image.bbclass
+++ b/meta/classes-recipe/image.bbclass
@@ -39,7 +39,7 @@ INHIBIT_DEFAULT_DEPS = "1"
39# IMAGE_FEATURES may contain any available package group 39# IMAGE_FEATURES may contain any available package group
40IMAGE_FEATURES ?= "" 40IMAGE_FEATURES ?= ""
41IMAGE_FEATURES[type] = "list" 41IMAGE_FEATURES[type] = "list"
42IMAGE_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" 42IMAGE_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"
43 43
44# Generate companion debugfs? 44# Generate companion debugfs?
45IMAGE_GEN_DEBUGFS ?= "0" 45IMAGE_GEN_DEBUGFS ?= "0"
diff --git a/meta/classes-recipe/rootfs-postcommands.bbclass b/meta/classes-recipe/rootfs-postcommands.bbclass
index d40adf5f0e..bf1e992bb2 100644
--- a/meta/classes-recipe/rootfs-postcommands.bbclass
+++ b/meta/classes-recipe/rootfs-postcommands.bbclass
@@ -13,6 +13,9 @@ ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'deb
13# Allow dropbear/openssh to accept root logins if debug-tweaks or allow-root-login is enabled 13# Allow dropbear/openssh to accept root logins if debug-tweaks or allow-root-login is enabled
14ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'allow-root-login' ], "ssh_allow_root_login; ", "",d)}' 14ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'allow-root-login' ], "ssh_allow_root_login; ", "",d)}'
15 15
16# Autologin the root user on the serial console, if empty-root-password and serial-autologin-root are active
17ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", [ 'empty-root-password', 'serial-autologin-root' ], "serial_autologin_root; ", "",d)}'
18
16# Enable postinst logging if debug-tweaks or post-install-logging is enabled 19# Enable postinst logging if debug-tweaks or post-install-logging is enabled
17ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'post-install-logging' ], "postinst_enable_logging; ", "",d)}' 20ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'post-install-logging' ], "postinst_enable_logging; ", "",d)}'
18 21
@@ -201,6 +204,23 @@ ssh_allow_root_login () {
201 fi 204 fi
202} 205}
203 206
207#
208# Autologin the 'root' user on the serial terminal,
209# if empty-root-password' AND 'serial-autologin-root are enabled
210#
211serial_autologin_root () {
212 if ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then
213 # add autologin option to util-linux getty only
214 sed -i 's/options="/&--autologin root /' \
215 "${IMAGE_ROOTFS}${base_bindir}/start_getty"
216 elif ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", d)}; then
217 if [ -e ${IMAGE_ROOTFS}${systemd_system_unitdir}/serial-getty@.service ]; then
218 sed -i '/^\s*ExecStart\b/ s/getty /&--autologin root /' \
219 "${IMAGE_ROOTFS}${systemd_system_unitdir}/serial-getty@.service"
220 fi
221 fi
222}
223
204python sort_passwd () { 224python sort_passwd () {
205 import rootfspostcommands 225 import rootfspostcommands
206 rootfspostcommands.sort_passwd(d.expand('${IMAGE_ROOTFS}${sysconfdir}')) 226 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
9 if [ -x "/usr/bin/setsid" ] ; then 9 if [ -x "/usr/bin/setsid" ] ; then
10 setsid="/usr/bin/setsid" 10 setsid="/usr/bin/setsid"
11 fi 11 fi
12 options=""
12 ;; 13 ;;
13esac 14esac
14 15
15if [ -e /sys/class/tty/$2 -a -c /dev/$2 ]; then 16if [ -e /sys/class/tty/$2 -a -c /dev/$2 ]; then
16 ${setsid:-} ${getty} -L $1 $2 $3 17 ${setsid:-} ${getty} ${options:-} -L $1 $2 $3
17fi 18fi