potential patch to check-cross-arch

Matteo Guglielmi Matteo.Guglielmi at dalco.ch
Thu Oct 10 12:05:59 CEST 2019


I've added debugging commands to show the problem:

# where is the ls command
if [ -f $target/bin/ls ]; then
    _ls=$target/bin/ls
elif [ -f $target/usr/bin/ls ]; then
    _ls=$target/usr/bin/ls
else
    echo "Cannot find ls command in $target"
    exit 3
fi


echo $_ls
ls -liah $_ls
file $_ls                       <<<==== causing the original error
file -L $_ls
_ls1=$target$(realpath $_ls)
echo $_ls1
ls -liah $_ls1
file $_ls1
_ls1=$target$(realpath -m $_ls)
echo $_ls1
ls -liah $_ls1
file $_ls1
_ls1=$target$(readlink -m $_ls)
echo $_ls1
ls -liah $_ls1
file $_ls1


# OUTPUT #


ftar: extracting /var/lib/fai/config/basefiles/OSUSE150S.tar to /target/
/target/bin/ls
6291548 lrwxrwxrwx 1 root root 11 Apr  9  2018 /target/bin/ls -> /usr/bin/ls
/target/bin/ls: symbolic link to /usr/bin/ls
/target/bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=a65f86cd6394e8f583c14d786d13b3bcbe051b87, stripped
/target/usr/bin/ls
4723631 -rwxr-xr-x 1 root root 132K Apr  9  2018 /target/usr/bin/ls
/target/usr/bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=2068163fab939170477770bed268bc34c81a5828, stripped
/target/usr/bin/ls
4723631 -rwxr-xr-x 1 root root 132K Apr  9  2018 /target/usr/bin/ls
/target/usr/bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=2068163fab939170477770bed268bc34c81a5828, stripped
/target/usr/bin/ls
4723631 -rwxr-xr-x 1 root root 132K Apr  9  2018 /target/usr/bin/ls
/target/usr/bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=2068163fab939170477770bed268bc34c81a5828, stripped



please note the different "BuildID[sha1]" value for the "right" ls binary.




This the correct patch:



info=$(file $target$(readlink -m $_ls))


or


info=$(file $target$(realpath -m $_ls))



where the '-m' option is needed to preserve

the symlink (print it out!) in case it's

completely broken relative to the nfsroot...

we never know... it's a safety feature.

________________________________
From: linux-fai <linux-fai-bounces at uni-koeln.de> on behalf of Matteo Guglielmi <Matteo.Guglielmi at dalco.ch>
Sent: Thursday, October 10, 2019 11:11:38 AM
To: fully automatic installation for Linux
Subject: Re: potential patch to check-cross-arch

Actually I'm not sure if your patch is correct

because despite the fact that it does not cause

a crash.



In fact,


given the fact that on suse systems:


/bin/ls


is a symlink to:


/usr/bin/ls


what happens is that:


$_ls


whose absolute path is:


/srv/fai/nfsroot/target/bin/ls


will now be a symlink to:


/srv/fai/nfsroot/usr/bin/ls


instead of:


/srv/fai/nfsroot/target/usr/bin/ls



... I hope it's clear.




So,




the correct patch should be mine:



info=$(file $(readlink -m $_ls))


because, relative to the nfsroot we have:




_ls=/target/bin/ls



_ls=$(readlink -m $_ls)



echo $_ls



/target/usr/bin/ls






________________________________
From: linux-fai <linux-fai-bounces at uni-koeln.de> on behalf of Matteo Guglielmi <Matteo.Guglielmi at dalco.ch>
Sent: Thursday, October 10, 2019 8:40:33 AM
To: fully automatic installation for Linux
Subject: Re: potential patch to check-cross-arch

openSUSE Leap 15.0/15.1

SLES/SLED 15.0/15.1


yes,


both patches do work:


info=$(file -L $_ls)


info=$(file $(readlink -m $_ls))



your patch is better.

________________________________
From: linux-fai <linux-fai-bounces at uni-koeln.de> on behalf of Thomas Lange <lange at informatik.uni-koeln.de>
Sent: Wednesday, October 9, 2019 6:39:41 PM
To: fully automatic installation for Linux
Subject: Re: potential patch to check-cross-arch

>>>>> On Wed, 9 Oct 2019 15:40:02 +0000, Matteo Guglielmi <Matteo.Guglielmi at dalco.ch> said:

    > This script:
    > /srv/fai/nfsroot/usr/lib/fai/check-cross-arch

    > fails (line 36: info=$(file $_ls)) on openSUSE
    > and Suse Linux Enterprise systems because:
Which openSUSE version are you using?
Does file -L help?

--
regards Thomas


More information about the linux-fai mailing list