diff mbox

rootfs-postcommands.bbclass: Filter out dangling symlinks in ssh_allow_empty_password()

Message ID 20170809164518.35834-1-raj.khem@gmail.com
State Superseded
Headers show

Commit Message

Khem Raj Aug. 9, 2017, 4:45 p.m. UTC
In images built with pam in DISTRO_FEATURES, we end up with dangling symlinks
if su is not packaged into image

$ ls /mnt/a/oe/build/tmp/work/raspberrypi3-bec-linux-gnueabi/core-image-minimal/1.0-r0/rootfs/etc/pam.d/su-l -l
lrwxrwxrwx 1 kraj users 2 Aug  9 07:56 /mnt/a/oe/build/tmp/work/raspberrypi3-bec-linux-gnueabi/core-image-minimal/1.0-r0/rootfs/etc/pam.d/su-l -> su

This causes image do_rootfs to fail

| sed: can't read /mnt/a/oe/build/tmp/work/raspberrypi3-bec-linux-gnueabi/core-image-minimal/1.0-r0/rootfs/etc/pam.d/s
u-l: No such file or directory
| WARNING: /mnt/a/oe/build/tmp/work/raspberrypi3-bec-linux-gnueabi/core-image-minimal/1.0-r0/temp/run.ssh_allow_empty_
password.19238:1 exit 2 from 'sed -i 's/nullok_secure/nullok/' /mnt/a/oe/build/tmp/work/raspberrypi3-bec-linux-gnueabi
/core-image-minimal/1.0-r0/rootfs/etc/pam.d/*'

Therefore we need to filter out dangling symlinks before sed'ing
things out

Signed-off-by: Khem Raj <raj.khem@gmail.com>

---
 meta/classes/rootfs-postcommands.bbclass | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

-- 
2.14.0

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Comments

Richard Purdie Aug. 14, 2017, 8:30 a.m. UTC | #1
On Wed, 2017-08-09 at 09:45 -0700, Khem Raj wrote:
> In images built with pam in DISTRO_FEATURES, we end up with dangling
> symlinks
> if su is not packaged into image
> 
> $ ls /mnt/a/oe/build/tmp/work/raspberrypi3-bec-linux-gnueabi/core-
> image-minimal/1.0-r0/rootfs/etc/pam.d/su-l -l
> lrwxrwxrwx 1 kraj users 2 Aug  9 07:56
> /mnt/a/oe/build/tmp/work/raspberrypi3-bec-linux-gnueabi/core-image-
> minimal/1.0-r0/rootfs/etc/pam.d/su-l -> su
> 
> This causes image do_rootfs to fail
> 
> > 
> > sed: can't read /mnt/a/oe/build/tmp/work/raspberrypi3-bec-linux-
> > gnueabi/core-image-minimal/1.0-r0/rootfs/etc/pam.d/s
> u-l: No such file or directory
> > 
> > WARNING: /mnt/a/oe/build/tmp/work/raspberrypi3-bec-linux-
> > gnueabi/core-image-minimal/1.0-r0/temp/run.ssh_allow_empty_
> password.19238:1 exit 2 from 'sed -i 's/nullok_secure/nullok/'
> /mnt/a/oe/build/tmp/work/raspberrypi3-bec-linux-gnueabi
> /core-image-minimal/1.0-r0/rootfs/etc/pam.d/*'
> 
> Therefore we need to filter out dangling symlinks before sed'ing
> things out
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  meta/classes/rootfs-postcommands.bbclass | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

This caused all rootfs sanity tests to fail in lsb images (for all
arches):

https://autobuilder.yocto.io/builders/nightly-x86-lsb/builds/410
https://autobuilder.yocto.io/builders/nightly-x86-64-lsb/builds/408
https://autobuilder.yocto.io/builders/nightly-ppc-lsb/builds/407
https://autobuilder.yocto.io/builders/nightly-mips-lsb/builds/394
https://autobuilder.yocto.io/builders/nightly-arm-lsb/builds/406

(I've confirmed dropping this patch made this issue go away)

Cheers,

Richard
diff mbox

Patch

diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index 78f7c55933..e26aa90d73 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -158,7 +158,10 @@  ssh_allow_empty_password () {
 	fi
 
 	if [ -d ${IMAGE_ROOTFS}${sysconfdir}/pam.d ] ; then
-		sed -i 's/nullok_secure/nullok/' ${IMAGE_ROOTFS}${sysconfdir}/pam.d/*
+		for f in `find ${IMAGE_ROOTFS}${sysconfdir}/pam.d -type l -exec test -e {} \; -print`
+		do
+			sed -i 's/nullok_secure/nullok/' $f
+		done
 	fi
 }