Skip to contentSkip to conversation

image.bbclass: improve sed expressions for ssh_allow_empty_password()

PATCH New Jonathan Liu 1 participant 1 message Apr 10, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 image.bbclass: improve sed expressions for ssh_allow_empty_password()

The sed expression was also replacing documentation text containing PermitRootLogin in the line so "PermitRootLogin yes" was specified twice.

---
 meta/classes/image.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/image.bbclass +2 -2
index 32df01d..79de5a2 100644
@@ -285,8 +285,8 @@ 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#.*PermitRootLogin.*#PermitRootLogin yes#' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
-		sed -i 's#.*PermitEmptyPasswords.*#PermitEmptyPasswords yes#' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+		sed -i 's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
+		sed -i 's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
 	fi
 
 	if [ -e ${IMAGE_ROOTFS}${sbindir}/dropbear ] ; then
Signature · 1 line
1.9.1