Similar to #74, TOTP is not displayed when using systemd initramfs, i.e. following mkinitcpio.conf
hooks on Arch:
HOOKS=(… systemd tpm2-totp …)
I tried writing a small systemd unit file and accompanying installation hook, but no luck.
I checked that all the files are present in the initramfs with lsinitcpio
and tried to trace unit execution with systemd-analyze plot
.
The unit always gets started way too late in the boot process, long after systemd-ask-password-console.service
.
Also, tpm2-totp
seemed to fail on first invocation during initramfs stage with:
tpm2-totp[…]: failed to allocate dbus proxy object: Could not connect: No such file or directory
Could this be a side effect of having tpm2-abrmd
installed? I saw that it uses dbus and usr/lib/libtss2-tcti-tabrmd.so
got included in the initramfs.
On a side note - I haven't researched how to stop the service after the initrd.target
. Right now it keeps lingering in the booted system until stopped manually.
Thanks for writing awesome tpm2 tools ;)
For reference, the systemd unit (commented out parameters are from exploring possible permutations):
tpm2-totp.service
[Unit]
Description=Display attestation using tpm2-totp
#Requires=dev-tpm0.device
#After=dev-tpm0.device
Before=systemd-ask-password-console.service
DefaultDependencies=no
[Service]
Type=exec
#ExecStart=/usr/bin/show-tpm2-totp
ExecStart=/usr/lib/tpm2-totp/show-tpm2-totp
#StandardOutput=kmsg+console
StandardOutput=tty
#[Install]
#WantedBy=sysinit.target
#WantedBy=initrd.target
… and a small install hook:
sd-tpm2-totp
#!/bin/bash
build() {
add_systemd_unit "tpm2-totp.service"
}
NOTE: The unit has to be installed in /usr/lib/systemd/system
, not /etc/systemd/system
, otherwise the add_systemd_unit
function fails silently during mkinitcpio
and the unit doesn't get included in the initramfs.