summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes-recipe/rootfs-postcommands.bbclass30
1 files changed, 17 insertions, 13 deletions
diff --git a/meta/classes-recipe/rootfs-postcommands.bbclass b/meta/classes-recipe/rootfs-postcommands.bbclass
index 215e38e33d..74601f0829 100644
--- a/meta/classes-recipe/rootfs-postcommands.bbclass
+++ b/meta/classes-recipe/rootfs-postcommands.bbclass
@@ -22,7 +22,7 @@ ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'deb
22# Create /etc/timestamp during image construction to give a reasonably sane default time setting 22# Create /etc/timestamp during image construction to give a reasonably sane default time setting
23ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp; " 23ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp; "
24 24
25# Tweak the mount options for rootfs in /etc/fstab if read-only-rootfs is enabled 25# Tweak files in /etc if read-only-rootfs is enabled
26ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "read_only_rootfs_hook; ", "",d)}' 26ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "read_only_rootfs_hook; ", "",d)}'
27 27
28# We also need to do the same for the kernel boot parameters, 28# We also need to do the same for the kernel boot parameters,
@@ -111,20 +111,24 @@ read_only_rootfs_hook () {
111 # If we're using openssh and the /etc/ssh directory has no pre-generated keys, 111 # If we're using openssh and the /etc/ssh directory has no pre-generated keys,
112 # we should configure openssh to use the configuration file /etc/ssh/sshd_config_readonly 112 # we should configure openssh to use the configuration file /etc/ssh/sshd_config_readonly
113 # and the keys under /var/run/ssh. 113 # and the keys under /var/run/ssh.
114 if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then 114 # If overlayfs-etc is used this is not done as /etc is treated as writable
115 if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then 115 # If stateless-rootfs is enabled this is always done as we don't want to save keys then
116 echo "SYSCONFDIR=\${SYSCONFDIR:-/etc/ssh}" >> ${IMAGE_ROOTFS}/etc/default/ssh 116 if ${@ 'true' if not bb.utils.contains('IMAGE_FEATURES', 'overlayfs-etc', True, False, d) or bb.utils.contains('IMAGE_FEATURES', 'stateless-rootfs', True, False, d) else 'false'}; then
117 echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh 117 if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then
118 else 118 if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then
119 echo "SYSCONFDIR=\${SYSCONFDIR:-/var/run/ssh}" >> ${IMAGE_ROOTFS}/etc/default/ssh 119 echo "SYSCONFDIR=\${SYSCONFDIR:-/etc/ssh}" >> ${IMAGE_ROOTFS}/etc/default/ssh
120 echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> ${IMAGE_ROOTFS}/etc/default/ssh 120 echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh
121 else
122 echo "SYSCONFDIR=\${SYSCONFDIR:-/var/run/ssh}" >> ${IMAGE_ROOTFS}/etc/default/ssh
123 echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> ${IMAGE_ROOTFS}/etc/default/ssh
124 fi
121 fi 125 fi
122 fi
123 126
124 # Also tweak the key location for dropbear in the same way. 127 # Also tweak the key location for dropbear in the same way.
125 if [ -d ${IMAGE_ROOTFS}/etc/dropbear ]; then 128 if [ -d ${IMAGE_ROOTFS}/etc/dropbear ]; then
126 if [ ! -e ${IMAGE_ROOTFS}/etc/dropbear/dropbear_rsa_host_key ]; then 129 if [ ! -e ${IMAGE_ROOTFS}/etc/dropbear/dropbear_rsa_host_key ]; then
127 echo "DROPBEAR_RSAKEY_DIR=/var/lib/dropbear" >> ${IMAGE_ROOTFS}/etc/default/dropbear 130 echo "DROPBEAR_RSAKEY_DIR=/var/lib/dropbear" >> ${IMAGE_ROOTFS}/etc/default/dropbear
131 fi
128 fi 132 fi
129 fi 133 fi
130 134