zl程序教程

您现在的位置是:首页 >  其他

当前栏目

TPM零知识学习五 —— tpm2-abrmd源码安装

安装源码学习 知识 TPM
2023-09-14 09:09:19 时间

tpm2-abrmd包的的源码安装方法参考:

tpm2-abrmd/INSTALL.md at master · tpm2-software/tpm2-abrmd · GitHub

TPM模拟器和TPM2-TSS安装_jianming21的博客-CSDN博客_tpm2-tss

可信平台模块TPM(Trusted Platform Module)介绍及tpm-tools安装使用_jinhuazhe2013的博客-CSDN博客_tpm模块

0. 简介

tpm2-abrmd是一个守护进程,其应在操作系统启动过程中启动。使用TPM,守护程序和客户端之间的通信是通过DBus和Unix管道的组合完成的。DBus用于发现,会话管理以及“取消”,“ setLocality”和“ getPollHandles” API调用(大多数尚未实现)。管道用于分别在客户端和服务器之间发送和接收TPM命令和响应。
守护程序在dbus上拥有com.intel.tss2.Tabrmd名称。可以将其配置为连接到系统或会话总线。配置名称选择将是一个方便的功能,但这是将来的工作。

1. 源码下载

运行以下命令下载源码:

$ git clone https://github.com/tpm2-software/tpm2-abrmd.git

下载完成后,源码内容如下所示:

$ ls
bootstrap     CODE_OF_CONDUCT.md  CONTRIBUTING.md  dist  INSTALL.md  m4           Makefile.am  README.md   scripts      selinux  test
CHANGELOG.md  configure.ac        coverity         doc   LICENSE     MAINTAINERS  man          RELEASE.md  SECURITY.md  src

$ ls -l
总用量 148
-rwxrwxr-x 1 ph ph   419 12月  2 15:41 bootstrap
-rw-rw-r-- 1 ph ph 11891 12月  2 15:41 CHANGELOG.md
-rw-rw-r-- 1 ph ph  5492 12月  2 15:41 CODE_OF_CONDUCT.md
-rw-rw-r-- 1 ph ph  9296 12月  2 15:41 configure.ac
-rw-rw-r-- 1 ph ph  2360 12月  2 15:41 CONTRIBUTING.md
drwxrwxr-x 2 ph ph  4096 12月  2 15:41 coverity
drwxrwxr-x 2 ph ph  4096 12月  2 15:41 dist
drwxrwxr-x 2 ph ph  4096 12月  2 15:41 doc
-rw-rw-r-- 1 ph ph 17642 12月  2 15:41 INSTALL.md
-rw-rw-r-- 1 ph ph  1236 12月  2 15:41 LICENSE
drwxrwxr-x 2 ph ph  4096 12月  2 15:41 m4
-rw-rw-r-- 1 ph ph    79 12月  2 15:41 MAINTAINERS
-rw-rw-r-- 1 ph ph 21343 12月  2 15:41 Makefile.am
drwxrwxr-x 2 ph ph  4096 12月  2 15:41 man
-rw-rw-r-- 1 ph ph  4806 12月  2 15:41 README.md
-rw-rw-r-- 1 ph ph  5696 12月  2 15:41 RELEASE.md
drwxrwxr-x 2 ph ph  4096 12月  2 15:41 scripts
-rw-rw-r-- 1 ph ph  1605 12月  2 15:41 SECURITY.md
drwxrwxr-x 2 ph ph  4096 12月  2 15:41 selinux
drwxrwxr-x 3 ph ph  4096 12月  2 15:41 src
drwxrwxr-x 3 ph ph  4096 12月  2 15:41 test
$ tree ./
./
├── bootstrap
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── configure.ac
├── CONTRIBUTING.md
├── coverity
│   └── coverity-model.c
├── dist
│   ├── com.intel.tss2.Tabrmd.service
│   ├── tpm2-abrmd.conf
│   ├── tpm2-abrmd.preset.in
│   ├── tpm2-abrmd.service.in
│   └── tss2-tcti-tabrmd.pc.in
├── doc
│   ├── coding_standard_c.md
│   └── reference-counting.txt
├── INSTALL.md
├── LICENSE
├── m4
│   └── flags.m4
├── MAINTAINERS
├── Makefile.am
├── man
│   ├── colophon.in
│   ├── tpm2-abrmd.8.in
│   ├── tss2-tcti-tabrmd.7.in
│   └── Tss2_Tcti_Tabrmd_Init.3.in
├── README.md
├── RELEASE.md
├── scripts
│   ├── int-test-funcs.sh
│   ├── int-test-setup.sh
│   └── unit-count.sh
├── SECURITY.md
├── selinux
│   ├── tabrmd.fc
│   ├── tabrmd.if
│   └── tabrmd.te
├── src
│   ├── command-attrs.c
│   ├── command-attrs.h
│   ├── command-source.c
│   ├── command-source.h
│   ├── connection.c
│   ├── connection.h
│   ├── connection-manager.c
│   ├── connection-manager.h
│   ├── control-message.c
│   ├── control-message.h
│   ├── handle-map.c
│   ├── handle-map-entry.c
│   ├── handle-map-entry.h
│   ├── handle-map.h
│   ├── include
│   │   └── tss2-tcti-tabrmd.h
│   ├── ipc-frontend.c
│   ├── ipc-frontend-dbus.c
│   ├── ipc-frontend-dbus.h
│   ├── ipc-frontend.h
│   ├── logging.c
│   ├── logging.h
│   ├── message-queue.c
│   ├── message-queue.h
│   ├── random.c
│   ├── random.h
│   ├── resource-manager.c
│   ├── resource-manager.h
│   ├── resource-manager-session.c
│   ├── resource-manager-session.h
│   ├── response-sink.c
│   ├── response-sink.h
│   ├── session-entry.c
│   ├── session-entry.h
│   ├── session-entry-state-enum.c
│   ├── session-entry-state-enum.h
│   ├── session-list.c
│   ├── session-list.h
│   ├── sink-interface.c
│   ├── sink-interface.h
│   ├── source-interface.c
│   ├── source-interface.h
│   ├── tabrmd.c
│   ├── tabrmd-defaults.h
│   ├── tabrmd-error.c
│   ├── tabrmd.h
│   ├── tabrmd-init.c
│   ├── tabrmd-init.h
│   ├── tabrmd-options.c
│   ├── tabrmd-options.h
│   ├── tabrmd.xml
│   ├── tcti.c
│   ├── tcti.h
│   ├── tcti-tabrmd.c
│   ├── tcti-tabrmd.map
│   ├── tcti-tabrmd-priv.h
│   ├── thread.c
│   ├── thread.h
│   ├── tpm2.c
│   ├── tpm2-command.c
│   ├── tpm2-command.h
│   ├── tpm2.h
│   ├── tpm2-header.c
│   ├── tpm2-header.h
│   ├── tpm2-response.c
│   ├── tpm2-response.h
│   ├── util.c
│   └── util.h
└── test
    ├── command-attrs_unit.c
    ├── command-source_unit.c
    ├── connection-manager_unit.c
    ├── connection_unit.c
    ├── handle-map-entry_unit.c
    ├── handle-map_unit.c
    ├── integration
    │   ├── auth-session-max.int.c
    │   ├── auth-session-start-flush.int.c
    │   ├── auth-session-start-save.int.c
    │   ├── auth-session-start-save-load.int.c
    │   ├── common.c
    │   ├── common.h
    │   ├── context-util.c
    │   ├── context-util.h
    │   ├── get-capability-handles-transient.int.c
    │   ├── get-capability-with-session.int.c
    │   ├── hash-sequence.int.c
    │   ├── main.c
    │   ├── manage-transient-keys.int.c
    │   ├── max-transient-upperbound.int.c
    │   ├── not-enough-handles-for-command.int.c
    │   ├── password-authorization.int.c
    │   ├── session-gap.int.c
    │   ├── session-load-from-closed-connection.int.c
    │   ├── session-load-from-closed-connections-lru.int.c
    │   ├── session-load-from-open-connection.int.c
    │   ├── start-auth-session.int.c
    │   ├── tcti-cancel.int.c
    │   ├── tcti-connections-max.int.c
    │   ├── tcti-connect-multiple.int.c
    │   ├── tcti-double-finalize.int.c
    │   ├── tcti-set-locality.int.c
    │   ├── test.h
    │   ├── test-options.c
    │   ├── test-options.h
    │   ├── tpm2-command-flush-no-handle.int.c
    │   ├── tpm2-struct-init.h
    │   └── util-buf-max-upper-bound.int.c
    ├── ipc-frontend-dbus_unit.c
    ├── ipc-frontend_unit.c
    ├── logging_unit.c
    ├── message-queue_unit.c
    ├── mock-funcs.c
    ├── mock-funcs.h
    ├── mock-io-stream.c
    ├── mock-io-stream.h
    ├── random_unit.c
    ├── resource-manager_unit.c
    ├── response-sink_unit.c
    ├── session-entry_unit.c
    ├── session-list_unit.c
    ├── tabrmd-init_unit.c
    ├── tabrmd-options_unit.c
    ├── tab_unit.c
    ├── tcti-factory_unit.c
    ├── tcti-mock.c
    ├── tcti-mock.h
    ├── tcti-tabrmd-receive_unit.c
    ├── tcti_unit.c
    ├── test-skeleton_unit.c
    ├── thread_unit.c
    ├── tpm2-command_unit.c
    ├── tpm2-response_unit.c
    ├── tpm2_unit.c
    ├── tss2-tcti-tabrmd_unit.c
    └── util_unit.c

11 directories, 164 files

2. 安装依赖

构建并安装tpm2-abrmd需要以下依赖:

  • GNU Autoconf
  • GNU Autoconf archive
  • GNU Automake
  • GNU Libtool
  • C compiler
  • C Library Development Libraries and Header Files (for pthreads headers)
  • pkg-config
  • glib and gio 2.0 libraries and development files
  • libtss2-sys, libtss2-mu and TCTI libraries from https://github.com/tpm2-software/tpm2-tss
  • dbus

注意:不同的GNU/Linux发布的包glib-2.0不同,因此可能需要额外的包。tabrmd需要从glib-2.0中获得GObject和GIO D-Bus的支持,因此要确保你的发布版中有此特性,无论是何种包。

构建和运行测试套件时需要的包:

  • cmocka unit test framework
  • swtpm or tpm_server TPM2 simulator
  • Alternately, run the test suite on a real TPM hardware, with a safety attention described below.

大多数依赖的包在构建tpm2-tss的时候已经安装了,下边列出尚未安装的包。

  • dbus安装
$ sudo apt install dbus-x11 
[sudo] ph 的密码: 
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成                 
dbus-x11 已经是最新版 (1.12.20-2ubuntu4.1)。
dbus-x11 已设置为手动安装。
下列软件包是自动安装的并且现在不需要了:
  golang-1.18-go golang-1.18-src golang-src libflashrom1 libftdi1-2
使用'sudo apt autoremove'来卸载它(它们)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 10 个软件包未被升级。
$ sudo apt install libdbus-1-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成                 
下列软件包是自动安装的并且现在不需要了:
  golang-1.18-go golang-1.18-src golang-src libflashrom1 libftdi1-2
使用'sudo apt autoremove'来卸载它(它们)。
下列【新】软件包将被安装:
  libdbus-1-dev
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 10 个软件包未被升级。
需要下载 188 kB 的归档。
解压缩后会消耗 1,000 kB 的额外空间。
获取:1 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libdbus-1-dev amd64 1.12.20-2ubuntu4.1 [188 kB]
已下载 188 kB,耗时 2秒 (82.5 kB/s)    
正在选中未选择的软件包 libdbus-1-dev:amd64。
(正在读取数据库 ... 系统当前共安装有 259427 个文件和目录。)
准备解压 .../libdbus-1-dev_1.12.20-2ubuntu4.1_amd64.deb  ...
正在解压 libdbus-1-dev:amd64 (1.12.20-2ubuntu4.1) ...
正在设置 libdbus-1-dev:amd64 (1.12.20-2ubuntu4.1) ...
正在处理用于 sgml-base (1.30) 的触发器 ...
  • glib
$ sudo apt install libglib2.0-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成                 
下列软件包是自动安装的并且现在不需要了:
  golang-1.18-go golang-1.18-src golang-src libflashrom1 libftdi1-2
使用'sudo apt autoremove'来卸载它(它们)。
将会同时安装下列软件:
  libblkid-dev libffi-dev libglib2.0-0 libglib2.0-bin libglib2.0-dev-bin libmount-dev libpcre16-3 libpcre2-dev libpcre2-posix3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libselinux1-dev libsepol-dev
建议安装:
  libgirepository1.0-dev libglib2.0-doc libxml2-utils
下列【新】软件包将被安装:
  libblkid-dev libffi-dev libglib2.0-dev libglib2.0-dev-bin libmount-dev libpcre16-3 libpcre2-dev libpcre2-posix3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libselinux1-dev libsepol-dev
下列软件包将被升级:
  libglib2.0-0 libglib2.0-bin
升级了 2 个软件包,新安装了 13 个软件包,要卸载 0 个软件包,有 8 个软件包未被升级。
需要下载 5,844 kB 的归档。
解压缩后会消耗 21.2 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libglib2.0-bin amd64 2.72.4-0ubuntu1 [80.9 kB]
获取:2 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libglib2.0-0 amd64 2.72.4-0ubuntu1 [1,461 kB]
获取:3 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 libffi-dev amd64 3.4.2-4 [63.7 kB]
获取:4 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libglib2.0-dev-bin amd64 2.72.4-0ubuntu1 [117 kB]
获取:5 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 libblkid-dev amd64 2.37.2-4ubuntu3 [185 kB]
获取:6 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 libsepol-dev amd64 3.3-1build1 [378 kB]
获取:7 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpcre2-posix3 amd64 10.39-3ubuntu0.1 [6,130 B]
获取:8 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpcre2-dev amd64 10.39-3ubuntu0.1 [730 kB]
获取:9 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 libselinux1-dev amd64 3.3-1build2 [158 kB]
获取:10 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 libmount-dev amd64 2.37.2-4ubuntu3 [14.5 kB]
获取:11 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpcre16-3 amd64 2:8.39-13ubuntu0.22.04.1 [164 kB]
获取:12 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpcre32-3 amd64 2:8.39-13ubuntu0.22.04.1 [155 kB]
获取:13 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpcrecpp0v5 amd64 2:8.39-13ubuntu0.22.04.1 [16.5 kB]
获取:14 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpcre3-dev amd64 2:8.39-13ubuntu0.22.04.1 [579 kB]
获取:15 http://cn.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libglib2.0-dev amd64 2.72.4-0ubuntu1 [1,735 kB]
已下载 5,844 kB,耗时 6秒 (1,021 kB/s)     
(正在读取数据库 ... 系统当前共安装有 259466 个文件和目录。)
准备解压 .../00-libglib2.0-bin_2.72.4-0ubuntu1_amd64.deb  ...
正在解压 libglib2.0-bin (2.72.4-0ubuntu1) 并覆盖 (2.72.1-1) ...
准备解压 .../01-libglib2.0-0_2.72.4-0ubuntu1_amd64.deb  ...
正在解压 libglib2.0-0:amd64 (2.72.4-0ubuntu1) 并覆盖 (2.72.1-1) ...
正在选中未选择的软件包 libffi-dev:amd64。
准备解压 .../02-libffi-dev_3.4.2-4_amd64.deb  ...
正在解压 libffi-dev:amd64 (3.4.2-4) ...
正在选中未选择的软件包 libglib2.0-dev-bin。
准备解压 .../03-libglib2.0-dev-bin_2.72.4-0ubuntu1_amd64.deb  ...
正在解压 libglib2.0-dev-bin (2.72.4-0ubuntu1) ...
正在选中未选择的软件包 libblkid-dev:amd64。
准备解压 .../04-libblkid-dev_2.37.2-4ubuntu3_amd64.deb  ...
正在解压 libblkid-dev:amd64 (2.37.2-4ubuntu3) ...
正在选中未选择的软件包 libsepol-dev:amd64。
准备解压 .../05-libsepol-dev_3.3-1build1_amd64.deb  ...
正在解压 libsepol-dev:amd64 (3.3-1build1) ...
正在选中未选择的软件包 libpcre2-posix3:amd64。
准备解压 .../06-libpcre2-posix3_10.39-3ubuntu0.1_amd64.deb  ...
正在解压 libpcre2-posix3:amd64 (10.39-3ubuntu0.1) ...
正在选中未选择的软件包 libpcre2-dev:amd64。
准备解压 .../07-libpcre2-dev_10.39-3ubuntu0.1_amd64.deb  ...
正在解压 libpcre2-dev:amd64 (10.39-3ubuntu0.1) ...
正在选中未选择的软件包 libselinux1-dev:amd64。
准备解压 .../08-libselinux1-dev_3.3-1build2_amd64.deb  ...
正在解压 libselinux1-dev:amd64 (3.3-1build2) ...
正在选中未选择的软件包 libmount-dev:amd64。
准备解压 .../09-libmount-dev_2.37.2-4ubuntu3_amd64.deb  ...
正在解压 libmount-dev:amd64 (2.37.2-4ubuntu3) ...
正在选中未选择的软件包 libpcre16-3:amd64。
准备解压 .../10-libpcre16-3_2%3a8.39-13ubuntu0.22.04.1_amd64.deb  ...
正在解压 libpcre16-3:amd64 (2:8.39-13ubuntu0.22.04.1) ...
正在选中未选择的软件包 libpcre32-3:amd64。
准备解压 .../11-libpcre32-3_2%3a8.39-13ubuntu0.22.04.1_amd64.deb  ...
正在解压 libpcre32-3:amd64 (2:8.39-13ubuntu0.22.04.1) ...
正在选中未选择的软件包 libpcrecpp0v5:amd64。
准备解压 .../12-libpcrecpp0v5_2%3a8.39-13ubuntu0.22.04.1_amd64.deb  ...
正在解压 libpcrecpp0v5:amd64 (2:8.39-13ubuntu0.22.04.1) ...
正在选中未选择的软件包 libpcre3-dev:amd64。
准备解压 .../13-libpcre3-dev_2%3a8.39-13ubuntu0.22.04.1_amd64.deb  ...
正在解压 libpcre3-dev:amd64 (2:8.39-13ubuntu0.22.04.1) ...
正在选中未选择的软件包 libglib2.0-dev:amd64。
准备解压 .../14-libglib2.0-dev_2.72.4-0ubuntu1_amd64.deb  ...
正在解压 libglib2.0-dev:amd64 (2.72.4-0ubuntu1) ...
正在设置 libpcrecpp0v5:amd64 (2:8.39-13ubuntu0.22.04.1) ...
正在设置 libblkid-dev:amd64 (2.37.2-4ubuntu3) ...
正在设置 libpcre16-3:amd64 (2:8.39-13ubuntu0.22.04.1) ...
正在设置 libglib2.0-0:amd64 (2.72.4-0ubuntu1) ...
正在设置 libglib2.0-bin (2.72.4-0ubuntu1) ...
正在设置 libffi-dev:amd64 (3.4.2-4) ...
正在设置 libpcre32-3:amd64 (2:8.39-13ubuntu0.22.04.1) ...
正在设置 libsepol-dev:amd64 (3.3-1build1) ...
正在设置 libpcre2-posix3:amd64 (10.39-3ubuntu0.1) ...
正在设置 libglib2.0-dev-bin (2.72.4-0ubuntu1) ...
正在设置 libpcre2-dev:amd64 (10.39-3ubuntu0.1) ...
正在设置 libselinux1-dev:amd64 (3.3-1build2) ...
正在设置 libpcre3-dev:amd64 (2:8.39-13ubuntu0.22.04.1) ...
正在设置 libmount-dev:amd64 (2.37.2-4ubuntu3) ...
正在设置 libglib2.0-dev:amd64 (2.72.4-0ubuntu1) ...
正在处理用于 libc-bin (2.35-0ubuntu3.1) 的触发器 ...
正在处理用于 man-db (2.10.2-1) 的触发器 ...
正在处理用于 install-info (6.8-4build1) 的触发器 ...

 tpm2-abrmd必须使用tss或者root用户才能运行。

3. 源码构建

  • 引导构建

在配置tpm2-abrmd前,首先要运行引导(自举)脚本,此脚本产生源文件列表,并且创建配置脚本。如果从发布版源码tar包构建,此步骤可以忽略。

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ ./bootstrap 
aclocal: installing 'm4/ax_ac_append_to_file.m4' from '/usr/share/aclocal/ax_ac_append_to_file.m4'
aclocal: installing 'm4/ax_ac_print_to_file.m4' from '/usr/share/aclocal/ax_ac_print_to_file.m4'
aclocal: installing 'm4/ax_add_am_macro_static.m4' from '/usr/share/aclocal/ax_add_am_macro_static.m4'
aclocal: installing 'm4/ax_add_fortify_source.m4' from '/usr/share/aclocal/ax_add_fortify_source.m4'
aclocal: installing 'm4/ax_am_macros_static.m4' from '/usr/share/aclocal/ax_am_macros_static.m4'
aclocal: installing 'm4/ax_check_compile_flag.m4' from '/usr/share/aclocal/ax_check_compile_flag.m4'
aclocal: installing 'm4/ax_check_enable_debug.m4' from '/usr/share/aclocal/ax_check_enable_debug.m4'
aclocal: installing 'm4/ax_check_gnu_make.m4' from '/usr/share/aclocal/ax_check_gnu_make.m4'
aclocal: installing 'm4/ax_check_link_flag.m4' from '/usr/share/aclocal/ax_check_link_flag.m4'
aclocal: installing 'm4/ax_code_coverage.m4' from '/usr/share/aclocal/ax_code_coverage.m4'
aclocal: installing 'm4/ax_file_escapes.m4' from '/usr/share/aclocal/ax_file_escapes.m4'
aclocal: installing 'm4/ax_is_release.m4' from '/usr/share/aclocal/ax_is_release.m4'
aclocal: installing 'm4/ax_normalize_path.m4' from '/usr/share/aclocal/ax_normalize_path.m4'
aclocal: installing 'm4/ax_pthread.m4' from '/usr/share/aclocal/ax_pthread.m4'
aclocal: installing 'm4/ax_recursive_eval.m4' from '/usr/share/aclocal/ax_recursive_eval.m4'
aclocal: installing 'm4/libtool.m4' from '/usr/share/aclocal/libtool.m4'
aclocal: installing 'm4/ltoptions.m4' from '/usr/share/aclocal/ltoptions.m4'
aclocal: installing 'm4/ltsugar.m4' from '/usr/share/aclocal/ltsugar.m4'
aclocal: installing 'm4/ltversion.m4' from '/usr/share/aclocal/ltversion.m4'
aclocal: installing 'm4/lt~obsolete.m4' from '/usr/share/aclocal/lt~obsolete.m4'
aclocal: installing 'm4/pkg.m4' from '/usr/share/aclocal/pkg.m4'
libtoolize: putting auxiliary files in '.'.
libtoolize: linking file './ltmain.sh'
configure.ac:10: installing './compile'
configure.ac:13: installing './config.guess'
configure.ac:13: installing './config.sub'
configure.ac:15: installing './install-sh'
configure.ac:15: installing './missing'
aminclude_static.am:126: warning: .PHONY was already defined in condition TRUE, which includes condition AUTOCONF_CODE_COVERAGE_2019_01_06 ...
Makefile.am:176:   'aminclude_static.am' included from here
Makefile.am:6: ... '.PHONY' previously defined here
Makefile.am:183: warning: AM_DISTCHECK_CONFIGURE_FLAGS multiply defined in condition AUTOCONF_CODE_COVERAGE_2019_01_06 and CODE_COVERAGE_ENABLED ...
aminclude_static.am:100: ... 'AM_DISTCHECK_CONFIGURE_FLAGS' previously defined here
Makefile.am:176:   'aminclude_static.am' included from here
Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'
  • 配置构建

先运行带--help选项的configure脚本来查看所有支持的选项。如下所示:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ ./configure --help
`configure' configures tpm2-abrmd 3.0.0-rc0 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/tpm2-abrmd]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-debug=[yes/info/profile/no]
                          compile with debugging
  --enable-shared[=PKGS]  build shared libraries [default=yes]
  --enable-static[=PKGS]  build static libraries [default=yes]
  --enable-fast-install[=PKGS]
                          optimize for fast installation [default=yes]
  --disable-libtool-lock  avoid locking (might break parallel builds)
  --enable-dependency-tracking
                          do not reject slow dependency extractors
  --disable-dependency-tracking
                          speeds up one-time build
  --enable-silent-rules   less verbose build output (undo: "make V=1")
  --disable-silent-rules  verbose build output (undo: "make V=0")
  --enable-unit           build cmocka unit tests
  --enable-code-coverage  Whether to enable code coverage support
  --disable-dlclose       Some versions of libc cause a sigsegv on exit, this
                          disables the dlclose and works around that bug
  --enable-test-hwtpm     enable the integration test on a real tpm hardware
  --enable-integration    build and execute integration tests
  --disable-defaultflags  Disable default preprocessor, compiler, and linker
                          flags.
  --enable-asan           Configure an ASAN enabled build.

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                          both]
  --with-aix-soname=aix|svr4|both
                          shared library versioning (aka "SONAME") variant to
                          provide on AIX, [default=aix].
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
  --with-sysroot[=DIR]    Search for dependent libraries within DIR (or the
                          compiler's sysroot if not specified).
  --with-pkgconfigdir     pkg-config installation directory
                          ['${libdir}/pkgconfig']
  --with-gcov=GCOV        use given GCOV for coverage (GCOV=gcov).
  --with-systemdsystemunitdir=DIR
                          Directory for systemd service files
  --with-systemdpresetdir=DIR
                          Directory for systemd preset files
  --with-systemdpresetdisable
                          Configure systemd preset to 'disable', default is
                          'enable'
  --with-dbuspolicydir=DIR
                          D-Bus policy directory
  --with-sepolicy=[/usr/share/selinux/devel/include]
                          build SELinux policy module
  --with-python-sys-prefix
                          use Python's sys.prefix and sys.exec_prefix values
  --with-python_prefix    override the default PYTHON_PREFIX
  --with-python_exec_prefix
                          override the default PYTHON_EXEC_PREFIX

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  LT_SYS_LIBRARY_PATH
              User-defined run-time library search path.
  CPP         C preprocessor
  PKG_CONFIG  path to pkg-config utility
  PKG_CONFIG_PATH
              directories to add to pkg-config's search path
  PKG_CONFIG_LIBDIR
              path overriding pkg-config's built-in search path
  CMOCKA_CFLAGS
              C compiler flags for CMOCKA, overriding pkg-config
  CMOCKA_LIBS linker flags for CMOCKA, overriding pkg-config
  GIO_CFLAGS  C compiler flags for GIO, overriding pkg-config
  GIO_LIBS    linker flags for GIO, overriding pkg-config
  GLIB_CFLAGS C compiler flags for GLIB, overriding pkg-config
  GLIB_LIBS   linker flags for GLIB, overriding pkg-config
  GOBJECT_CFLAGS
              C compiler flags for GOBJECT, overriding pkg-config
  GOBJECT_LIBS
              linker flags for GOBJECT, overriding pkg-config
  TSS2_SYS_CFLAGS
              C compiler flags for TSS2_SYS, overriding pkg-config
  TSS2_SYS_LIBS
              linker flags for TSS2_SYS, overriding pkg-config
  TSS2_MU_CFLAGS
              C compiler flags for TSS2_MU, overriding pkg-config
  TSS2_MU_LIBS
              linker flags for TSS2_MU, overriding pkg-config
  TSS2_TCTILDR_CFLAGS
              C compiler flags for TSS2_TCTILDR, overriding pkg-config
  TSS2_TCTILDR_LIBS
              linker flags for TSS2_TCTILDR, overriding pkg-config
  TSS2_RC_CFLAGS
              C compiler flags for TSS2_RC, overriding pkg-config
  TSS2_RC_LIBS
              linker flags for TSS2_RC, overriding pkg-config
  GDBUS_CODEGEN
              The gdbus-codegen executable.
  PYTHON      the Python interpreter

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to <https://github.com/tpm2-software/tpm2-abrmd/issues>.
tpm2-abrmd home page: <https://github.com/tpm2-software/tpm2-abrmd>.

在构建tpm2-abrmd之前,必须进行配置。最为简单的情况是不带任何选项运行configure脚本,如下:

$ ./configure

但是这里我们并不采用不带任何选项的最简命令,而是带有以下选项执行配置:

$ ./configure --with-dbuspolicydir=/etc/dbus-1/system.d --with-systemdsystemunitdir=/lib/systemd/system

--with-dbuspolicydir=/etc/dbus-1/system.d选项可以将tpm2-abrmd声明到系统总线上,允许tss账户声明该策略。
–with-systemdsystemunitdir=/lib/systemd/system将tpm2-abrmd添加进系统引导。

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ ./configure --with-dbuspolicydir=/etc/dbus-1/system.d  --with-systemdsystemunitdir=/lib/systemd/system
checking whether to enable debugging... info
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether ln -s works... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... no
checking for mawk... mawk
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking whether make supports nested variables... yes
checking dependency style of gcc... gcc3
checking whether make supports nested variables... (cached) yes
checking how to run the C preprocessor... gcc -E
checking whether gcc is Clang... no
checking whether pthreads work with "-pthread" and "-lpthread"... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for library containing dlopen... none required
checking for gio-unix-2.0... yes
checking for glib-2.0... yes
checking for gobject-2.0... yes
checking for tss2-sys >= 2.4.0... yes
checking for tss2-mu... yes
checking for tss2-tctildr... yes
checking for tss2-rc... yes
checking for gdbus-codegen... gdbus-codegen
checking whether to build with code coverage support... no
checking whether C compiler accepts -Wall... yes
checking whether C compiler accepts -Wextra... yes
checking whether C compiler accepts -Werror... yes
checking whether C compiler accepts -std=gnu99... yes
checking whether C compiler accepts -Wformat... yes
checking whether C compiler accepts -Wformat-security... yes
checking whether C compiler accepts -Wno-missing-braces... yes
checking whether C compiler accepts -fdata-sections... yes
checking whether C compiler accepts -ffunction-sections... yes
checking whether the linker accepts -fstack-protector-all... yes
checking whether C compiler accepts -fpic... yes
checking whether C compiler accepts -fPIC... yes
checking whether C compiler accepts -Wstrict-overflow=5... yes
checking whether the linker accepts -Wl,--gc-sections... yes
checking whether the linker accepts -Wl,--no-undefined... yes
checking whether the linker accepts -Wl,-z,noexecstack... yes
checking whether the linker accepts -Wl,-z,now... yes
checking whether the linker accepts -Wl,-z,relro... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating dist/tss2-tcti-tabrmd.pc
config.status: creating dist/tpm2-abrmd.service
config.status: creating dist/tpm2-abrmd.preset
config.status: executing libtool commands
config.status: executing depfiles commands
  • 编译

运行make进行编译,如下所示:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ make
  GEN      src/tabrmd-generated.h
make  all-am
make[1]: 进入目录“/home/ph/dingdao/TPM/abrmd/tpm2-abrmd”
  CC       src/tabrmd.o
  CC       src/libutil_la-tpm2.lo
  CC       src/libutil_la-command-attrs.lo
  CC       src/libutil_la-command-source.lo
  CC       src/libutil_la-connection.lo
  CC       src/libutil_la-connection-manager.lo
  CC       src/libutil_la-control-message.lo
  CC       src/libutil_la-handle-map-entry.lo
  CC       src/libutil_la-handle-map.lo
  CC       src/libutil_la-ipc-frontend.lo
  CC       src/libutil_la-ipc-frontend-dbus.lo
  CC       src/libutil_la-logging.lo
  CC       src/libutil_la-message-queue.lo
  CC       src/libutil_la-random.lo
  CC       src/libutil_la-resource-manager-session.lo
  CC       src/libutil_la-resource-manager.lo
  CC       src/libutil_la-response-sink.lo
  CC       src/libutil_la-session-entry-state-enum.lo
  CC       src/libutil_la-session-entry.lo
  CC       src/libutil_la-session-list.lo
  CC       src/libutil_la-sink-interface.lo
  CC       src/libutil_la-source-interface.lo
  CC       src/libutil_la-tabrmd-error.lo
  CC       src/libutil_la-tabrmd-generated.lo
  CC       src/libutil_la-tabrmd-init.lo
  CC       src/libutil_la-tabrmd-options.lo
  CC       src/libutil_la-tcti.lo
  CC       src/libutil_la-thread.lo
  CC       src/libutil_la-tpm2-command.lo
  CC       src/libutil_la-tpm2-header.lo
  CC       src/libutil_la-tpm2-response.lo
  CC       src/libutil_la-util.lo
  CCLD     src/libutil.la
  CCLD     src/tpm2-abrmd
  CC       src/tcti-tabrmd.lo
  CCLD     src/libtss2-tcti-tabrmd.la
  GEN      man/man3/Tss2_Tcti_Tabrmd_Init.3
  GEN      man/man3/Tss2_Tcti_Tabrmd_Init.3
  GEN      man/man7/tss2-tcti-tabrmd.7
  GEN      man/man7/tss2-tcti-tabrmd.7
  GEN      man/man8/tpm2-abrmd.8
  GEN      man/man8/tpm2-abrmd.8
make[1]: 离开目录“/home/ph/dingdao/TPM/abrmd/tpm2-abrmd”
  • 安装

运行带DESTDIR的make install命令,安装到指定路径, 如下所示:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ make install DESTDIR=/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output
make  install-am
make[1]: 进入目录“/home/ph/dingdao/TPM/abrmd/tpm2-abrmd”
make[2]: 进入目录“/home/ph/dingdao/TPM/abrmd/tpm2-abrmd”
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib'
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   src/libtss2-tcti-tabrmd.la '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib'
libtool: install: /usr/bin/install -c src/.libs/libtss2-tcti-tabrmd.so.0.0.0 /home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib/libtss2-tcti-tabrmd.so.0.0.0
libtool: install: (cd /home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib && { ln -s -f libtss2-tcti-tabrmd.so.0.0.0 libtss2-tcti-tabrmd.so.0 || { rm -f libtss2-tcti-tabrmd.so.0 && ln -s libtss2-tcti-tabrmd.so.0.0.0 libtss2-tcti-tabrmd.so.0; }; })
libtool: install: (cd /home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib && { ln -s -f libtss2-tcti-tabrmd.so.0.0.0 libtss2-tcti-tabrmd.so || { rm -f libtss2-tcti-tabrmd.so && ln -s libtss2-tcti-tabrmd.so.0.0.0 libtss2-tcti-tabrmd.so; }; })
libtool: install: /usr/bin/install -c src/.libs/libtss2-tcti-tabrmd.lai /home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib/libtss2-tcti-tabrmd.la
libtool: install: /usr/bin/install -c src/.libs/libtss2-tcti-tabrmd.a /home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib/libtss2-tcti-tabrmd.a
libtool: install: chmod 644 /home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib/libtss2-tcti-tabrmd.a
libtool: install: ranlib /home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib/libtss2-tcti-tabrmd.a
libtool: warning: remember to run 'libtool --finish /usr/local/lib'
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/sbin'
  /bin/sh ./libtool   --mode=install /usr/bin/install -c src/tpm2-abrmd '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/sbin'
libtool: install: /usr/bin/install -c src/tpm2-abrmd /home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/sbin/tpm2-abrmd
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/etc/dbus-1/system.d'
 /usr/bin/install -c -m 644 dist/tpm2-abrmd.conf '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/etc/dbus-1/system.d'
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/share/dbus-1/system-services'
 /usr/bin/install -c -m 644 dist/com.intel.tss2.Tabrmd.service '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/share/dbus-1/system-services'
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/include/tss2'
 /usr/bin/install -c -m 644 ./src/include/tss2-tcti-tabrmd.h '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/include/tss2'
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/share/man/man3'
 /usr/bin/install -c -m 644 man/man3/Tss2_Tcti_Tabrmd_Init.3 '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/share/man/man3'
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/share/man/man7'
 /usr/bin/install -c -m 644 man/man7/tss2-tcti-tabrmd.7 '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/share/man/man7'
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/share/man/man8'
 /usr/bin/install -c -m 644 man/man8/tpm2-abrmd.8 '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/share/man/man8'
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 dist/tss2-tcti-tabrmd.pc '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib/pkgconfig'
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib/systemd/system-preset'
 /usr/bin/install -c -m 644 dist/tpm2-abrmd.preset '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/usr/local/lib/systemd/system-preset'
 /usr/bin/mkdir -p '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/lib/systemd/system'
 /usr/bin/install -c -m 644 dist/tpm2-abrmd.service '/home/ph/dingdao/TPM/abrmd/tpm2-abrmd/output/lib/systemd/system'
make[2]: 离开目录“/home/ph/dingdao/TPM/abrmd/tpm2-abrmd”
make[1]: 离开目录“/home/ph/dingdao/TPM/abrmd/tpm2-abrmd”

output目录下的内容如下:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ tree ./output
./output
├── etc
│   └── dbus-1
│       └── system.d
│           └── tpm2-abrmd.conf
├── lib
│   └── systemd
│       └── system
│           └── tpm2-abrmd.service
└── usr
    └── local
        ├── include
        │   └── tss2
        │       └── tss2-tcti-tabrmd.h
        ├── lib
        │   ├── libtss2-tcti-tabrmd.a
        │   ├── libtss2-tcti-tabrmd.la
        │   ├── libtss2-tcti-tabrmd.so -> libtss2-tcti-tabrmd.so.0.0.0
        │   ├── libtss2-tcti-tabrmd.so.0 -> libtss2-tcti-tabrmd.so.0.0.0
        │   ├── libtss2-tcti-tabrmd.so.0.0.0
        │   ├── pkgconfig
        │   │   └── tss2-tcti-tabrmd.pc
        │   └── systemd
        │       └── system-preset
        │           └── tpm2-abrmd.preset
        ├── sbin
        │   └── tpm2-abrmd
        └── share
            ├── dbus-1
            │   └── system-services
            │       └── com.intel.tss2.Tabrmd.service
            └── man
                ├── man3
                │   └── Tss2_Tcti_Tabrmd_Init.3
                ├── man7
                │   └── tss2-tcti-tabrmd.7
                └── man8
                    └── tpm2-abrmd.8

22 directories, 15 files

如果不指定目录,即不带参数的make install命令,则过程和结果如下:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ sudo make install
[sudo] ph 的密码: 
make  install-am
make[1]: 进入目录“/home/ph/dingdao/TPM/abrmd/tpm2-abrmd”
make[2]: 进入目录“/home/ph/dingdao/TPM/abrmd/tpm2-abrmd”
 /usr/bin/mkdir -p '/usr/local/lib'
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   src/libtss2-tcti-tabrmd.la '/usr/local/lib'
libtool: install: /usr/bin/install -c src/.libs/libtss2-tcti-tabrmd.so.0.0.0 /usr/local/lib/libtss2-tcti-tabrmd.so.0.0.0
libtool: install: (cd /usr/local/lib && { ln -s -f libtss2-tcti-tabrmd.so.0.0.0 libtss2-tcti-tabrmd.so.0 || { rm -f libtss2-tcti-tabrmd.so.0 && ln -s libtss2-tcti-tabrmd.so.0.0.0 libtss2-tcti-tabrmd.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libtss2-tcti-tabrmd.so.0.0.0 libtss2-tcti-tabrmd.so || { rm -f libtss2-tcti-tabrmd.so && ln -s libtss2-tcti-tabrmd.so.0.0.0 libtss2-tcti-tabrmd.so; }; })
libtool: install: /usr/bin/install -c src/.libs/libtss2-tcti-tabrmd.lai /usr/local/lib/libtss2-tcti-tabrmd.la
libtool: install: /usr/bin/install -c src/.libs/libtss2-tcti-tabrmd.a /usr/local/lib/libtss2-tcti-tabrmd.a
libtool: install: chmod 644 /usr/local/lib/libtss2-tcti-tabrmd.a
libtool: install: ranlib /usr/local/lib/libtss2-tcti-tabrmd.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /usr/bin/mkdir -p '/usr/local/sbin'
  /bin/sh ./libtool   --mode=install /usr/bin/install -c src/tpm2-abrmd '/usr/local/sbin'
libtool: install: /usr/bin/install -c src/tpm2-abrmd /usr/local/sbin/tpm2-abrmd
 /usr/bin/mkdir -p '/etc/dbus-1/system.d'
 /usr/bin/install -c -m 644 dist/tpm2-abrmd.conf '/etc/dbus-1/system.d'
 /usr/bin/mkdir -p '/usr/local/share/dbus-1/system-services'
 /usr/bin/install -c -m 644 dist/com.intel.tss2.Tabrmd.service '/usr/local/share/dbus-1/system-services'
 /usr/bin/mkdir -p '/usr/local/include/tss2'
 /usr/bin/install -c -m 644 ./src/include/tss2-tcti-tabrmd.h '/usr/local/include/tss2'
 /usr/bin/mkdir -p '/usr/local/share/man/man3'
 /usr/bin/install -c -m 644 man/man3/Tss2_Tcti_Tabrmd_Init.3 '/usr/local/share/man/man3'
 /usr/bin/mkdir -p '/usr/local/share/man/man7'
 /usr/bin/install -c -m 644 man/man7/tss2-tcti-tabrmd.7 '/usr/local/share/man/man7'
 /usr/bin/mkdir -p '/usr/local/share/man/man8'
 /usr/bin/install -c -m 644 man/man8/tpm2-abrmd.8 '/usr/local/share/man/man8'
 /usr/bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 dist/tss2-tcti-tabrmd.pc '/usr/local/lib/pkgconfig'
 /usr/bin/mkdir -p '/usr/local/lib/systemd/system-preset'
 /usr/bin/install -c -m 644 dist/tpm2-abrmd.preset '/usr/local/lib/systemd/system-preset'
 /usr/bin/mkdir -p '/lib/systemd/system'
 /usr/bin/install -c -m 644 dist/tpm2-abrmd.service '/lib/systemd/system'
make[2]: 离开目录“/home/ph/dingdao/TPM/abrmd/tpm2-abrmd”
make[1]: 离开目录“/home/ph/dingdao/TPM/abrmd/tpm2-abrmd”
  • 安装后操作

在安装编译的软件和配置后,所有带有新配置的组件(Systemd and D-Bus)必须被提示重新加载其配置。这可以通过重启系统实现,但这并不必需。

更好的做法是每个组件被手动配置。以下详细描述各个过程。

  • 添加tpm2-abrmd进入系统服务
sudo cp /usr/local/share/dbus-1/system-services/com.intel.tss2.Tabrmd.service /usr/share/dbus-1/system-services/
  • 重启D-Bus
$ sudo pkill -HUP dbus-daemon
ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ sudo pkill -HUP dbus-daemon
[sudo] ph 的密码: 
ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ 
  • Systemd重新加载配置
$ sudo systemctl daemon-reload
  • 启动服务
$ sudo systemctl start tpm2-abrmd.service
$ sudo systemctl start tpm2-abrmd.service
Job for tpm2-abrmd.service failed because a timeout was exceeded.
See "systemctl status tpm2-abrmd.service" and "journalctl -xeu tpm2-abrmd.service" for details.

 出现了问题,启动服务超时。如何解决?按照以下方法:

  • 修改tpm2-abrmd.service服务配置

修改服务配置文件/lib/systemd/system/tpm2-abrmd.service。原始内容如下:

[Unit]
Description=TPM2 Access Broker and Resource Management Daemon
# These settings are needed when using the device TCTI. If the
# TCP mssim is used then the settings should be commented out.
After=dev-tpm0.device
Requires=dev-tpm0.device

[Service]
Type=dbus
BusName=com.intel.tss2.Tabrmd
ExecStart=/usr/local/sbin/tpm2-abrmd
User=tss

[Install]
WantedBy=multi-user.target

在启动服务时加载tss动态库并将服务启动到本地2321端口。将文件中“ExecStart=/usr/local/sbin/tpm2-abrmd”修改为“ExecStart=/usr/local/sbin/tpm2-abrmd --tcti=“libtss2-tcti-mssim.so.0:host=127.0.0.1,port=2321””。修改后文件内容如下:

[Unit]
Description=TPM2 Access Broker and Resource Management Daemon
# These settings are needed when using the device TCTI. If the
# TCP mssim is used then the settings should be commented out.
After=dev-tpm0.device
Requires=dev-tpm0.device

[Service]
Type=dbus
BusName=com.intel.tss2.Tabrmd
ExecStart=/usr/local/sbin/tpm2-abrmd --tcti="libtss2-tci-mssim.so.0:host=127.0.0.1,port=2321"
User=tss

[Install]
WantedBy=multi-user.target

修改后保存退出。重新执行前述步骤,如下所示:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ sudo systemctl daemon-reload 

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ sudo systemctl start tpm2-abrmd.service
Job for tpm2-abrmd.service failed because the control process exited with error code.
See "systemctl status tpm2-abrmd.service" and "journalctl -xeu tpm2-abrmd.service" for details.

依然有问题。使用以下命令查看问题细节:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ sudo systemctl status tpm2-abrmd.service
× tpm2-abrmd.service - TPM2 Access Broker and Resource Management Daemon
     Loaded: loaded (/lib/systemd/system/tpm2-abrmd.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2022-12-02 20:50:55 CST; 2min 30s ago
    Process: 270902 ExecStart=/usr/local/sbin/tpm2-abrmd --tcti=libtss2-tci-mssim.so.0:host=127.0.0.1,port=2321 (code=exited, status=74)
   Main PID: 270902 (code=exited, status=74)
        CPU: 5ms

12月 02 20:50:55 ph-ThinkBook-14-G2-ITL systemd[1]: Starting TPM2 Access Broker and Resource Management Daemon...
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL tpm2-abrmd[270902]: ERROR:tcti:src/tss2-tcti/tctildr.c:430:Tss2_TctiLdr_Initialize_Ex() Failed to instantiate TCTI
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL tpm2-abrmd[270902]: init_thread_func: failed to create TCTI with conf "libtss2-tci-mssim.so.0:host=127.0.0.1,port=2321", got RC: 0xa0015
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL tpm2-abrmd[270902]: g_bus_unown_name: assertion 'owner_id > 0' failed
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL systemd[1]: tpm2-abrmd.service: Main process exited, code=exited, status=74/IOERR
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL systemd[1]: tpm2-abrmd.service: Failed with result 'exit-code'.
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL systemd[1]: Failed to start TPM2 Access Broker and Resource Management Daemon.
ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ journalctl -xeu tpm2-abrmd.service
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ tpm2-abrmd.service 单元已失败。
░░ 
░░ 结果为“failed”。
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL systemd[1]: Starting TPM2 Access Broker and Resource Management Daemon...
░░ Subject: tpm2-abrmd.service 单元已开始启动
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ tpm2-abrmd.service 单元已开始启动。
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL tpm2-abrmd[270902]: ERROR:tcti:src/tss2-tcti/tctildr.c:430:Tss2_TctiLdr_Initialize_Ex() Failed to instantiate TCTI
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL tpm2-abrmd[270902]: init_thread_func: failed to create TCTI with conf "libtss2-tci-mssim.so.0:host=127.0.0.1,port=2321", got RC: 0xa0015
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL tpm2-abrmd[270902]: g_bus_unown_name: assertion 'owner_id > 0' failed
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL systemd[1]: tpm2-abrmd.service: Main process exited, code=exited, status=74/IOERR
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStart= process belonging to unit tpm2-abrmd.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 74.
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL systemd[1]: tpm2-abrmd.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit tpm2-abrmd.service has entered the 'failed' state with result 'exit-code'.
12月 02 20:50:55 ph-ThinkBook-14-G2-ITL systemd[1]: Failed to start TPM2 Access Broker and Resource Management Daemon.
░░ Subject: tpm2-abrmd.service 单元已失败
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ tpm2-abrmd.service 单元已失败。
░░ 
░░ 结果为“failed”。

这个问题最终查到是由于之前笔者通过snap安装过了tpm2-toolbox,tpm2-abrmd已经启动了的原因。如下所示:

$ ps -ef | grep tpm
root         120       2  0 16:06 ?        00:00:00 [tpm_dev_wq]
root        1036       1  0 16:07 ?        00:00:00 /snap/tpm2-toolbox/1493/sbin/tpm_server
root        1038       1  0 16:07 ?        00:00:00 /bin/sh /snap/tpm2-toolbox/1493/bin/tpm2-abrmd-start.sh
root        1682    1038  0 16:07 ?        00:00:00 sh -c /snap/tpm2-toolbox/1493/usr/sbin/tpm2-abrmd --allow-root --tcti=mssim:host=localhost,port=2321
root        1683    1682  0 16:07 ?        00:00:00 /snap/tpm2-toolbox/1493/usr/sbin/tpm2-abrmd --allow-root --tcti=mssim:host=localhost,port=2321
ph          5225    5197  0 16:17 pts/0    00:00:00 grep --color=auto tpm

解决方法是卸载之前安装的tpm2-toolbox,如下所示:

$ sudo snap remove tpm2-toolbox 
停止 snap "tpm2-toolbox" 服务                                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:network 从 snapd:network 断开                                                                                                                                                              将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:home 从 snapd:home 断开                                                                                                                                                                    将 tpm2-toolbox:network-bind 从 snapd:network-bind 断开                                                                                                                                                    将 tpm2-toolbox:network-bind 从 snapd:network-bind 断开                                                                                                                                                    将 tpm2-toolbox:network-bind 从 snapd:network-bind 断开                                                                                                                                                    将 tpm2-toolbox:network-bind 从 snapd:network-bind 断开                                                                                                                                                    将 tpm2-toolbox:network-bind 从 snapd:network-bind 断开                                                                                                                                                    移除 snap "tpm2-toolbox" 的别名                                                                                                                                                                            已删除 tpm2-toolbox
$ ps -ef | grep tpm
root         120       2  0 16:06 ?        00:00:00 [tpm_dev_wq]
ph          9302    5197  0 16:58 pts/0    00:00:00 grep --color=auto tpm

可以看到,之前安装的tpm2相关服务已经停止了。

问题解决之后,继续之前的工作。这次把之前做服务的文件/lib/systemd/system/tpm2-abrmd.service先暂时剪切或者重命名,不做成服务了,直接使用命令来测。

运行时需要带上--allow-root选项,否则会出现以下提示:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ sudo /usr/local/sbin/tpm2-abrmd --tcti="libtss2-tcti-mssim.so.0:host=127.0.0.1,port=2321"
[sudo] ph 的密码: 
Refusing to run as root. Pass --allow-root if you know what you are doing.

带--allow-root选项后,分为两种情况:

  • 使用tpm模拟器

使用tpm模拟器的情况下,需要带上--tcti选项。如下所示:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ sudo /usr/local/sbin/tpm2-abrmd --allow-root --tcti="libtss2-tcti-mssim.so.0:host=127.0.0.1,port=2321"
WARNING:tcti:src/util/io.c:262:socket_connect() Failed to connect to host 127.0.0.1, port 2321: errno 111: Connection refused 
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:169:tcti_from_file() Could not initialize TCTI file: libtss2-tcti-mssim.so.0 
ERROR:tcti:src/tss2-tcti/tctildr.c:430:Tss2_TctiLdr_Initialize_Ex() Failed to instantiate TCTI 

** (tpm2-abrmd:6709): CRITICAL **: 14:39:36.570: init_thread_func: failed to create TCTI with conf "libtss2-tcti-mssim.so.0:host=127.0.0.1,port=2321", got RC: 0xa000a

(tpm2-abrmd:6709): GLib-GIO-CRITICAL **: 14:39:36.570: g_bus_unown_name: assertion 'owner_id > 0' failed

或者

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ sudo /usr/local/sbin/tpm2-abrmd --allow-root --tcti=mssim
WARNING:tcti:src/util/io.c:262:socket_connect() Failed to connect to host 127.0.0.1, port 2321: errno 111: Connection refused 
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:169:tcti_from_file() Could not initialize TCTI file: mssim 
ERROR:tcti:src/tss2-tcti/tctildr.c:430:Tss2_TctiLdr_Initialize_Ex() Failed to instantiate TCTI 

** (tpm2-abrmd:6816): CRITICAL **: 14:48:14.604: init_thread_func: failed to create TCTI with conf "mssim", got RC: 0xa000a

(tpm2-abrmd:6816): GLib-GIO-CRITICAL **: 14:48:14.605: g_bus_unown_name: assertion 'owner_id > 0' failed

libtrss2-tcti-mssim库相关路径如下所示:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ sudo find / -name "libtss2-tcti-mssim.so*"
/home/ph/dingdao/TPM/tss/tpm2-tss/output/usr/local/lib/libtss2-tcti-mssim.so.0.0.0
/home/ph/dingdao/TPM/tss/tpm2-tss/output/usr/local/lib/libtss2-tcti-mssim.so
/home/ph/dingdao/TPM/tss/tpm2-tss/output/usr/local/lib/libtss2-tcti-mssim.so.0
/home/ph/dingdao/TPM/tss/tpm2-tss/src/tss2-tcti/.libs/libtss2-tcti-mssim.so.0.0.0T
/home/ph/dingdao/TPM/tss/tpm2-tss/src/tss2-tcti/.libs/libtss2-tcti-mssim.so.0.0.0
/home/ph/dingdao/TPM/tss/tpm2-tss/src/tss2-tcti/.libs/libtss2-tcti-mssim.so
/home/ph/dingdao/TPM/tss/tpm2-tss/src/tss2-tcti/.libs/libtss2-tcti-mssim.so.0
/usr/local/lib/libtss2-tcti-mssim.so.0.0.0
/usr/local/lib/libtss2-tcti-mssim.so
/usr/local/lib/libtss2-tcti-mssim.so.0
/usr/lib/x86_64-linux-gnu/libtss2-tcti-mssim.so.0.0.0
/usr/lib/x86_64-linux-gnu/libtss2-tcti-mssim.so.0
find: ‘/run/user/1000/doc’: 权限不够

可见,tpm2-abrmd、tpm2-tss与tpm-server三者相关联。

  • 不使用tpm模拟器,直接操作真机

不使用tpm模拟器的情况下,只带--allow-root参数即可,不用带--tcti参数。如下所示:

ph@ph-ThinkBook-14-G2-ITL:~/dingdao/TPM/abrmd/tpm2-abrmd$ sudo /usr/local/sbin/tpm2-abrmd --allow-root