]> code.ossystems Code Review - openembedded-core.git/commitdiff
rootfs-postcommands: fix ssh_allow_empty_password checking
authorJonathan Liu <net147@gmail.com>
Fri, 26 Feb 2016 09:12:21 +0000 (20:12 +1100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 28 Feb 2016 11:32:41 +0000 (11:32 +0000)
The ssh_allow_empty_password function doesn't check if
sshd_config_readonly exists before running sed which can result in an
error if sshd_config exists but sshd_config_readonly doesn't.

Signed-off-by: Jonathan Liu <net147@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/classes/rootfs-postcommands.bbclass

index f5d6147b4d11b17c0f5d7674ac91b288d8e48d83..e184667f67a59947cc877fb39006935c03834f08 100644 (file)
@@ -112,10 +112,12 @@ zap_empty_root_password () {
 # allow dropbear/openssh to accept root logins and logins from accounts with an empty password string
 #
 ssh_allow_empty_password () {
-       if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
-               sed -i 's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config_readonly
-               sed -i 's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config_readonly
-       fi
+       for config in sshd_config sshd_config_readonly; do
+               if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config ]; then
+                       sed -i 's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
+                       sed -i 's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config
+               fi
+       done
 
        if [ -e ${IMAGE_ROOTFS}${sbindir}/dropbear ] ; then
                if grep -q DROPBEAR_EXTRA_ARGS ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear 2>/dev/null ; then