Skip to content

Commit

Permalink
feat(pcsc): introducing the pcsc module
Browse files Browse the repository at this point in the history
  • Loading branch information
johannbg committed Feb 8, 2022
1 parent d03fb67 commit dcaff88
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
62 changes: 62 additions & 0 deletions modules.d/91pcsc/module-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later

# Prerequisite check(s) for module.
check() {

# If the binary(s) requirements are not fulfilled the module can't be installed.
require_binaries pcscd || return 1

# Return 255 to only include the module, if another module requires it.
return 255

}

# Module dependency requirements.
depends() {

# This module has external dependency on other module(s).
echo systemd-udevd
# Return 0 to include the dependent module(s) in the initramfs.
return 0

}

# Install the required file(s) and directories for the module in the initramfs.
install() {
inst_simple "$moddir/pcscd.service" "${systemdsystemunitdir}"/pcscd.service
inst_simple "$moddir/pcscd.socket" "${systemdsystemunitdir}"/pcscd.socket

inst_multiple -o \
pcscd

# Enable systemd type unit(s)
for i in \
pcscd.service \
pcscd.socket; do
$SYSTEMCTL -q --root "$initdir" enable "$i"
done

# Install library file(s)
_arch=${DRACUT_ARCH:-$(uname -m)}
inst_libdir_file \
{"tls/$_arch/",tls/,"$_arch/",}"libopensc.so.*" \
{"tls/$_arch/",tls/,"$_arch/",}"libsmm-local.so.*" \
{"tls/$_arch/",tls/,"$_arch/",}"opensc-pkcs11.so" \
{"tls/$_arch/",tls/,"$_arch/",}"onepin-opensc-pkcs11.so" \
{"tls/$_arch/",tls/,"$_arch/",}"pkcs11/opensc-pkcs11.so" \
{"tls/$_arch/",tls/,"$_arch/",}"pkcs11/onepin-opensc-pkcs11.so" \
{"tls/$_arch/",tls/,"$_arch/",}"pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist" \
{"tls/$_arch/",tls/,"$_arch/",}"pcsc/drivers/ifd-ccid.bundle/Contents/Linux/libccid.so" \
{"tls/$_arch/",tls/,"$_arch/",}"pcsc/drivers/serial/libccidtwin.so" \
{"tls/$_arch/",tls/,"$_arch/",}"libpcsclite.so.*"

# Install the hosts local user configurations if enabled.
if [[ $hostonly ]]; then
inst_multiple -H -o \
/etc/opensc.conf \
"/etc/reader.conf.d/*"
fi

}
13 changes: 13 additions & 0 deletions modules.d/91pcsc/pcscd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
DefaultDependencies=no
Description=PC/SC Smart Card Daemon (Dracut)
Documentation=man:pcscd(8)
Requires=pcscd.socket

[Service]
ExecStart=/usr/sbin/pcscd --foreground --auto-exit
ExecReload=/usr/sbin/pcscd --hotplug

[Install]
Also=pcscd.socket
WantedBy=cryptsetup-pre.target
11 changes: 11 additions & 0 deletions modules.d/91pcsc/pcscd.socket
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
DefaultDependencies=no
Description=PC/SC Smart Card Daemon Activation Socket (Dracut)
Documentation=man:pcscd(8)

[Socket]
ListenStream=/run/pcscd/pcscd.comm
SocketMode=0666

[Install]
WantedBy=cryptsetup-pre.target sockets.target
1 change: 1 addition & 0 deletions pkgbuild/dracut.spec
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{dracutlibdir}/modules.d/91crypt-gpg
%{dracutlibdir}/modules.d/91crypt-loop
%{dracutlibdir}/modules.d/91fido2
%{dracutlibdir}/modules.d/91pcsc
%{dracutlibdir}/modules.d/91pkcs11
%{dracutlibdir}/modules.d/91tpm2-tss
%{dracutlibdir}/modules.d/95debug
Expand Down

0 comments on commit dcaff88

Please sign in to comment.