]> code.ossystems Code Review - openembedded-core.git/commitdiff
image.bbclass: when building a readonly rootfs, tweak ssh settings regardless of...
authorAlexander Kanavin <alexander.kanavin@linux.intel.com>
Wed, 30 Sep 2015 12:53:15 +0000 (15:53 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 1 Oct 2015 06:40:36 +0000 (07:40 +0100)
Previously it was done only if sysvinit was in DISTRO_FEATURES.

Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/image.bbclass

index 7e6822cac50fc64041e69c0380e5d8923d72eda4..9fbdce583cc31994b0921a2d24098578a2f7448e 100644 (file)
@@ -239,6 +239,18 @@ read_only_rootfs_hook () {
        # Tweak the mount option and fs_passno for rootfs in fstab
        sed -i -e '/^[#[:space:]]*\/dev\/root/{s/defaults/ro/;s/\([[:space:]]*[[:digit:]]\)\([[:space:]]*\)[[:digit:]]$/\1\20/}' ${IMAGE_ROOTFS}/etc/fstab
 
+       # If we're using openssh and the /etc/ssh directory has no pre-generated keys,
+       # we should configure openssh to use the configuration file /etc/ssh/sshd_config_readonly
+       # and the keys under /var/run/ssh.
+       if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then
+               if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then
+                       echo "SYSCONFDIR=/etc/ssh" >> ${IMAGE_ROOTFS}/etc/default/ssh
+                       echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh
+               else
+                       echo "SYSCONFDIR=/var/run/ssh" >> ${IMAGE_ROOTFS}/etc/default/ssh
+                       echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> ${IMAGE_ROOTFS}/etc/default/ssh
+               fi
+       fi
        if ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then
                # Change the value of ROOTFS_READ_ONLY in /etc/default/rcS to yes
                if [ -e ${IMAGE_ROOTFS}/etc/default/rcS ]; then
@@ -249,18 +261,6 @@ read_only_rootfs_hook () {
                if [ -x ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
                        ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
                fi
-               # If we're using openssh and the /etc/ssh directory has no pre-generated keys,
-               # we should configure openssh to use the configuration file /etc/ssh/sshd_config_readonly
-               # and the keys under /var/run/ssh.
-               if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then
-                       if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then
-                               echo "SYSCONFDIR=/etc/ssh" >> ${IMAGE_ROOTFS}/etc/default/ssh
-                               echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh
-                       else
-                               echo "SYSCONFDIR=/var/run/ssh" >> ${IMAGE_ROOTFS}/etc/default/ssh
-                               echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> ${IMAGE_ROOTFS}/etc/default/ssh
-                       fi
-               fi
        fi
 
        if ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", d)}; then