@ -18,22 +18,32 @@ esac
. /usr/share/initramfs-tools/hook-functions
# Hooks for loading smartcard reading software into the initramfs
# Install directories needed by smartcard reading daemon, command, and
# key-script
for dir in etc/opensc usr/lib var/run tmp ; do
if [ ! -d ${DESTDIR}/${dir} ] ;
then
mkdir -p ${DESTDIR}/${dir}
# Additional function for copying plugin (library) from multiarch directory.
# Based on copy_exec.
copy_plugin() {
local src target x
src="${1}"
if [ ${src} = "${src#/}" ]; then
for x in /${ARCHDIR} /lib /usr/${ARCHDIR} /usr/lib; do
if [ -e $x/$src ]; then
src=$(echo $x/$src)
break
fi
done
fi
target="${2:-$src}"
# Install pcscd daemon, drivers, conf file, and include libgcc as well since
# pcscd utilizes pthread_cancel
mkdir -p ${DESTDIR}/lib
copy_exec /usr/sbin/pcscd /sbin
copy_exec "${src}" "${target}" || return $(($? - 1))
}
# Determine multiarch directory
ARCHDIR=$(ldd $SHELL | grep libc\.so |\
sed -e "s|^.*=> \(.*\)/[^/]*$|\1|" -e "s|^/usr||" -e "s|^/||")
if [ -z "$ARCHDIR" ] && [ -n "$HOSTTYPE" ] && [ -n "$OSTYPE" ]; then
ARCHDIR=$HOSTTYPE-$OSTYPE
fi
if [ -z "$ARCHDIR" ]; then
ARCHDIR=$(uname -i)
if [ "$ARCHDIR" = "unknown" ]; then
ARCHDIR=$(uname -m)
@ -44,71 +54,51 @@ fi
if [ "$ARCHDIR" = "ppc64el" ]; then
ARCHDIR="powerpc64"
fi
if [ -e /lib/*${ARCHDIR}*/libgcc_s.so.1 ]
then
cp -L /lib/*${ARCHDIR}*/libgcc_s.so.1 ${DESTDIR}/lib
else
cp -L /lib/libgcc_s.so.1 ${DESTDIR}/lib
ARCHDIR="*${ARCHDIR}*"
fi
if [ -e /lib/*${ARCHDIR}*/libpcsclite.so.1 ]
then
cp -L /lib/*${ARCHDIR}*/libpcsclite.so.1 ${DESTDIR}/lib
elif [ -e /usr/lib/*${ARCHDIR}*/libpcsclite.so.1 ]
then
cp -L /usr/lib/*${ARCHDIR}*/libpcsclite.so.1 ${DESTDIR}/lib
else
cp -L /lib/libpcsclite.so.1 ${DESTDIR}/lib
fi
# Hooks for loading smartcard reading software into the initramfs
if [ -e /lib/*${ARCHDIR}*/libudev.so.1 ]
then
cp -L /lib/*${ARCHDIR}*/libudev.so.1 ${DESTDIR}/lib
elif [ -e /usr/lib/*${ARCHDIR}*/libudev.so.1 ]
# Install directories needed by smartcard reading daemon, command, and
# key-script
for dir in etc/opensc lib usr/lib var/run tmp ; do
if [ ! -d ${DESTDIR}/${dir} ] ;
then
cp -L /usr/lib/*${ARCHDIR}*/libudev.so.1 ${DESTDIR}/lib
else
cp -L /lib/libudev.so.1 ${DESTDIR}/lib
mkdir -p ${DESTDIR}/${dir}
fi
done
if [ -e /usr/lib/*${ARCHDIR}*/libusb-1.0.so.0 ]
then
cp -L /usr/lib/*${ARCHDIR}*/libusb-1.0.so.0 ${DESTDIR}/usr/lib
elif [ -e /lib/*${ARCHDIR}*/libusb-1.0.so.0 ]
then
cp -L /lib/*${ARCHDIR}*/libusb-1.0.so.0 ${DESTDIR}/usr/lib
elif [ -e /usr/lib/libusb-1.0.so.0 ]
then
cp -L /usr/lib/libusb-1.0.so.0 ${DESTDIR}/usr/lib
else
echo "Unable to locate libusb-1.0"
exit 1
fi
# Install pcscd daemon, drivers, conf file
copy_exec /usr/sbin/pcscd /sbin
cp -LRp /usr/lib/pcsc ${DESTDIR}/usr/lib/
copy_plugin libpcsclite.so.1
if [ -e /etc/reader.conf.d ]
then
cp -L -Rp /etc/reader.conf.d ${DESTDIR}/etc/
find /usr/lib/pcsc ! -type d |
while read PSCS_FILE; do
if [ ! -x ${PSCS_FILE} ] && [ ${PSCS_FILE} = ${PSCS_FILE%.so} ]; then
[ -d ${DESTDIR}${PSCS_FILE%/*} ] || \
mkdir -p ${DESTDIR}${PSCS_FILE%/*}
cp -pL $PSCS_FILE ${DESTDIR}${PSCS_FILE%/*}
else
cp -L /etc/reader.conf ${DESTDIR}/etc/
copy_exec $PSCS_FILE
fi
done
if [ -d /etc/reader.conf.d ]; then
cp -pLR /etc/reader.conf.d ${DESTDIR}/etc/
fi
if [ -e /etc/reader.conf ]; then
cp -pL /etc/reader.conf ${DESTDIR}/etc/
fi
# Install opensc commands and conf file
copy_exec /usr/bin/opensc-tool /bin/
copy_exec /usr/bin/pkcs15-crypt /bin/
copy_exec /usr/bin/pkcs15-tool /bin/
cp -L /etc/opensc/opensc.conf ${DESTDIR}/etc/opensc/
cp -p L /etc/opensc/opensc.conf ${DESTDIR}/etc/opensc/
# Install opensc interface library
if [ -e /usr/lib/*${ARCHDIR}*/opensc-pkcs11.so ]
then
cp -L /usr/lib/*${ARCHDIR}*/opensc-pkcs11.so ${DESTDIR}/usr/lib
elif [ -e /usr/lib/opensc-pkcs11.so ]
then
cp -L /usr/lib/opensc-pkcs11.so ${DESTDIR}/usr/lib
fi
copy_plugin opensc-pkcs11.so
# Install other required utilities
copy_exec /bin/grep /bin
@ -130,14 +120,7 @@ copy_exec /usr/bin/cryptosmartcard.sh /bin
copy_exec /usr/bin/cardpincheck /bin
# Libraries
# cp -L /usr/lib/libltdl.so* ${DESTDIR}/usr/lib
# cp -L /lib/libncurses.so.5 ${DESTDIR}/lib
if [ -e /lib/*${ARCHDIR}*/libncursesw.so.[0-9] ]
then
cp -L /lib/*${ARCHDIR}*/libncursesw.so.[0-9] ${DESTDIR}/lib
else
cp -L /lib/libncursesw.so.[0-9] ${DESTDIR}/lib
fi
copy_plugin libncursesw.so.[0-9]
# LUKS keys
if [ -e /etc/trinity/luks/card ]