diff options
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/bin/cryptosmartcard.sh | 28 | ||||
-rwxr-xr-x | usr/share/initramfs-tools/hooks/cryptlukssc | 137 |
2 files changed, 87 insertions, 78 deletions
diff --git a/usr/bin/cryptosmartcard.sh b/usr/bin/cryptosmartcard.sh index c6cd7fc..25f8d6e 100755 --- a/usr/bin/cryptosmartcard.sh +++ b/usr/bin/cryptosmartcard.sh @@ -43,8 +43,34 @@ fi # Find plymouth PLYDIR=/bin/plymouth +# 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) + fi + if [ "$ARCHDIR" = "ppc64le" ]; then + ARCHDIR="powerpc64" + fi + if [ "$ARCHDIR" = "ppc64el" ]; then + ARCHDIR="powerpc64" + fi + ARCHDIR="*${ARCHDIR}*" +fi + # Set system PKCS library path -SYSTEM_PKCS_LIBRARY=/usr/lib/opensc-pkcs11.so +SYSTEM_PKCS_LIBRARY=opensc-pkcs11.so +for x in /${ARCHDIR} /lib /usr/${ARCHDIR} /usr/lib; do + if [ -e $x/$SYSTEM_PKCS_LIBRARY ]; then + SYSTEM_PKCS_LIBRARY=$(echo $x/$SYSTEM_PKCS_LIBRARY) + break + fi +done # print message to usplash or stderr # usage: msg <command> "message" [switch] diff --git a/usr/share/initramfs-tools/hooks/cryptlukssc b/usr/share/initramfs-tools/hooks/cryptlukssc index 6665c73..51aa730 100755 --- a/usr/share/initramfs-tools/hooks/cryptlukssc +++ b/usr/share/initramfs-tools/hooks/cryptlukssc @@ -18,97 +18,87 @@ esac . /usr/share/initramfs-tools/hook-functions +# 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}" + + 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) + fi + if [ "$ARCHDIR" = "ppc64le" ]; then + ARCHDIR="powerpc64" + fi + if [ "$ARCHDIR" = "ppc64el" ]; then + ARCHDIR="powerpc64" + fi + ARCHDIR="*${ARCHDIR}*" +fi + # 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 +for dir in etc/opensc lib 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 +# Install pcscd daemon, drivers, conf file copy_exec /usr/sbin/pcscd /sbin -ARCHDIR=$(uname -i) -if [ "$ARCHDIR" = "unknown" ]; then - ARCHDIR=$(uname -m) -fi -if [ "$ARCHDIR" = "ppc64le" ]; then - ARCHDIR="powerpc64" -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 -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 /lib/*${ARCHDIR}*/libudev.so.1 ] -then - cp -L /lib/*${ARCHDIR}*/libudev.so.1 ${DESTDIR}/lib -elif [ -e /usr/lib/*${ARCHDIR}*/libudev.so.1 ] -then - cp -L /usr/lib/*${ARCHDIR}*/libudev.so.1 ${DESTDIR}/lib -else - cp -L /lib/libudev.so.1 ${DESTDIR}/lib -fi +copy_plugin libpcsclite.so.1 + +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 + copy_exec $PSCS_FILE + 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 +if [ -d /etc/reader.conf.d ]; then + cp -pLR /etc/reader.conf.d ${DESTDIR}/etc/ 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/ +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 -pL /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 ] |