我已使用 BIOS 启用了 TPM 2.0。
$ [ -c /dev/tpmrm0 ] && echo "TPM 2.0"
TPM 2.0
当我尝试安装时tpm-tools
,出现以下错误:
% sudo apt install tpm-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
tpm-tools is already the newest version (1.3.9.1-0.2ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up trousers (0.3.14+fixed1-1build1) ...
Job for trousers.service failed because the control process exited with error code.
See "systemctl status trousers.service" and "journalctl -xe" for details.
invoke-rc.d: initscript trousers, action "start" failed.
● trousers.service - LSB: starts tcsd
Loaded: loaded (/etc/init.d/trousers; generated)
Active: failed (Result: exit-code) since Wed 2021-02-10 03:59:26 AEST; 3ms ago
Docs: man:systemd-sysv-generator(8)
Process: 7414 ExecStart=/etc/init.d/trousers start (code=exited, status=30)
Feb 10 03:59:26 blueray-i5 systemd[1]: Starting LSB: starts tcsd...
Feb 10 03:59:26 blueray-i5 trousers[7414]: * Starting Trusted Computing daemon tcsd
Feb 10 03:59:26 blueray-i5 trousers[7414]: /etc/init.d/trousers: 32: [: /dev/tpm0: unexpected operator
Feb 10 03:59:26 blueray-i5 tcsd[7420]: TCSD TDDL[7420]: TrouSerS ioctl: (25) Inappropriate ioctl for device
Feb 10 03:59:26 blueray-i5 tcsd[7420]: TCSD TDDL[7420]: TrouSerS Falling back to Read/Write device support.
Feb 10 03:59:26 blueray-i5 tcsd[7420]: TCSD TCS[7420]: TrouSerS ERROR: TCS GetCapability failed with result = 0x1e
Feb 10 03:59:26 blueray-i5 trousers[7414]: ...fail!
Feb 10 03:59:26 blueray-i5 systemd[1]: trousers.service: Control process exited, code=exited, status=30/n/a
Feb 10 03:59:26 blueray-i5 systemd[1]: trousers.service: Failed with result 'exit-code'.
Feb 10 03:59:26 blueray-i5 systemd[1]: Failed to start LSB: starts tcsd.
dpkg: error processing package trousers (--configure):
installed trousers package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of tpm-tools:
tpm-tools depends on trousers; however:
Package trousers is not configured yet.
dpkg: error processing package tpm-tools (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
trousers
tpm-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)
于是,我尝试启动裤子服务。它给出了以下信息:
% systemctl start trousers.service
Job for trousers.service failed because the control process exited with error code.
See "systemctl status trousers.service" and "journalctl -xe" for details.
% systemctl status trousers.service
● trousers.service - LSB: starts tcsd
Loaded: loaded (/etc/init.d/trousers; generated)
Active: failed (Result: exit-code) since Wed 2021-02-10 04:04:56 AEST; 23s ago
Docs: man:systemd-sysv-generator(8)
Process: 9114 ExecStart=/etc/init.d/trousers start (code=exited, status=30)
Feb 10 04:04:56 blueray-i5 systemd[1]: Starting LSB: starts tcsd...
Feb 10 04:04:56 blueray-i5 trousers[9114]: * Starting Trusted Computing daemon tcsd
Feb 10 04:04:56 blueray-i5 trousers[9114]: /etc/init.d/trousers: 32: [: /dev/tpm0: unexpected operator
Feb 10 04:04:56 blueray-i5 tcsd[9120]: TCSD TDDL[9120]: TrouSerS ioctl: (25) Inappropriate ioctl for device
Feb 10 04:04:56 blueray-i5 tcsd[9120]: TCSD TDDL[9120]: TrouSerS Falling back to Read/Write device support.
Feb 10 04:04:56 blueray-i5 tcsd[9120]: TCSD TCS[9120]: TrouSerS ERROR: TCS GetCapability failed with result = 0x1e
Feb 10 04:04:56 blueray-i5 trousers[9114]: ...fail!
Feb 10 04:04:56 blueray-i5 systemd[1]: trousers.service: Control process exited, code=exited, status=30/n/a
Feb 10 04:04:56 blueray-i5 systemd[1]: trousers.service: Failed with result 'exit-code'.
Feb 10 04:04:56 blueray-i5 systemd[1]: Failed to start LSB: starts tcsd.
我能做些什么?
答案1
针对 OP 提出的评论这里,他们想要在其中获取代码这里并将其重写为更简洁的形式。
我在这里重复代码,以防它从外部站点消失:
if [ ! -e /dev/tpmrm ]
then
log_warning_msg "device driver not loaded, skipping."
exit 0
fi
for tpm_dev in /dev/tpmrm; do
TPM_OWNER=$(stat -c %U $tpm_dev)
if [ "x$TPM_OWNER" != "xtss" ]
then
log_warning_msg "TPM device owner for $tpm_dev is not 'tss', this can cause problems."
fi
done
if [ ! -e /dev/tpm0 ]
then
log_warning_msg "device driver not loaded, skipping."
exit 0
fi
for tpm_dev in /dev/tpm0; do
TPM_OWNER=$(stat -c %U $tpm_dev)
if [ "x$TPM_OWNER" != "xtss" ]
then
log_warning_msg "TPM device owner for $tpm_dev is not 'tss', this can cause problems."
fi
done
整理出格式并将其重写为单个循环:
for tpm_dev in /dev/tpmrm /dev/tpm0; do
if [ ! -e "$tpm_dev" ]; then
log_warning_msg "device driver not loaded, skipping."
continue
fi
TPM_OWNER=$(stat -c %U "$tpm_dev")
if [ "$TPM_OWNER" != "tss" ]; then
log_warning_msg "TPM device owner for $tpm_dev is not 'tss', this can cause problems."
fi
done
目前尚不清楚exit 0
如果设备文件不存在,是否仍应执行包含的原始脚本。我选择使用continue
跳到下一个设备路径(因为消息说“跳过”)。
我唯一改变的其他事情是在第二次测试中删除了过时的安全防护x
,并且添加了一组缺失的双引号。
或者,没有continue
:
for tpm_dev in /dev/tpmrm /dev/tpm0; do
if [ -e "$tpm_dev" ]; then
TPM_OWNER=$(stat -c %U "$tpm_dev")
if [ "$TPM_OWNER" != "tss" ]; then
log_warning_msg "TPM device owner for $tpm_dev is not 'tss', this can cause problems."
fi
else
log_warning_msg "device driver not loaded, skipping."
fi
done
答案2
答案3
if [ ! -e /dev/tpmrm ]
then
log_warning_msg "device driver not loaded, skipping."
exit 0
fi
for tpm_dev in /dev/tpmrm; do
TPM_OWNER=$(stat -c %U $tpm_dev)
if [ "x$TPM_OWNER" != "xtss" ]
then
log_warning_msg "TPM device owner for $tpm_dev is not 'tss', this can cause problems."
fi
done