You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
smartcardauth/usr/share/initramfs-tools/hooks/cryptlukssc

135 lines
3.0 KiB

#!/bin/sh
set -e
PREREQ="cryptroot"
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
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}
fi
done
# 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
ARCHDIR=$(uname -i)
if [ "$ARCHDIR" = "unknown" ]; then
ARCHDIR=$(uname -m)
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
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
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
cp -LRp /usr/lib/pcsc ${DESTDIR}/usr/lib/
if [ -e /etc/reader.conf.d ]
then
cp -L -Rp /etc/reader.conf.d ${DESTDIR}/etc/
else
cp -L /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/
# 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
# Install other required utilities
copy_exec /bin/grep /bin
copy_exec /bin/mv /bin
copy_exec /bin/cat /bin
copy_exec /bin/sleep /bin
copy_exec /usr/bin/opensc-explorer /bin
copy_exec /usr/bin/openssl /bin
copy_exec /usr/bin/perl /bin
copy_exec /bin/rm /bin
copy_exec /usr/bin/xxd /bin
copy_exec /usr/bin/killall /bin
copy_exec /bin/sed /bin
copy_exec /usr/bin/tr /bin
copy_exec /bin/bash /bin
# Main scripts
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.5 ]
then
cp -L /lib/*${ARCHDIR}*/libncursesw.so.5 ${DESTDIR}/lib
else
cp -L /lib/libncursesw.so.5 ${DESTDIR}/lib
fi
# LUKS keys
if [ -e /etc/trinity/luks/card ]
then
cp -LRp /etc/trinity/luks/card ${DESTDIR}/tde_luks_keys
else
mkdir -p ${DESTDIR}/tde_luks_keys
fi
exit 0