swtpm_setup cannot be run as user (AppArmor profile)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
swtpm (Ubuntu) |
Fix Released
|
Undecided
|
Lena Voytek | ||
Jammy |
Fix Released
|
Undecided
|
Lena Voytek | ||
Kinetic |
Fix Released
|
Undecided
|
Lena Voytek |
Bug Description
[Impact]
When running the swtpm_setup or swtpm-create-
Could not find @DATAROOTDIR@
This is due to the patch 0001-Install-
The fix for this issue should be backported to Jammy and Kinetic to allow users to easily setup certs with swtpm scripts.
This is fixed by changing the reference to swtpm-localca to the correct location in the swtpm-create-
[Test Plan]
$ lxc launch ubuntu:{kinetic, jammy} --vm test-swtpm
$ lxc exec test-swtpm bash
# apt update && apt dist-upgrade -y
# apt install swtpm swtpm-tools -y
# su ubuntu
$ cd
$ /usr/share/
$ swtpm_setup --tpm2 --tpmstate . --overwrite --create-ek-cert
> Before the fix, this will result in
...
Could not find @DATAROOTDIR@
...
> After it will provide a success message such as:
...
Successfully created RSA 2048 EK with handle 0x81010001.
...
[Where problems could occur]
If problems were to occur, they would be related to swtpm-create-
[Other Info]
This is not an issue in lunar and later as scripts and paths were updated in 0.7.x.
[Original Description]
It looks like the AppArmor profile that Ubuntu added to swtpm 0.6.3 (before it was contributed to the upstream project; https:/
In particular, the following doesn't work for me:
$ swtpm_setup --tpm2 --tpmstate . --overwrite --create-ek-cert
Starting vTPM manufacturing as stefanb:stefanb @ Mon 17 Apr 2023 05:12:05 PM EDT
swtpm process terminated unexpectedly.
Could not start the TPM 2.
An error occurred. Authoring the TPM state failed.
Ending vTPM manufacturing @ Mon 17 Apr 2023 05:12:05 PM EDT
Also, once I copied the AppArmor profile from this project over onto the 22.04 machine I ran into this issue here:
$ swtpm_setup --tpm2 --tpmstate . --overwrite --create-ek-cert
Starting vTPM manufacturing as stefanb:stefanb @ Mon 17 Apr 2023 05:14:04 PM EDT
TPM is listening on Unix socket.
Successfully created RSA 2048 EK with handle 0x81010001.
Could not find @DATAROOTDIR@
An error occurred. Authoring the TPM state failed.
Ending vTPM manufacturing @ Mon 17 Apr 2023 05:14:04 PM EDT
[ The script requiring @DATAROOTDIR@ has been rewritten in more recent version of swtpm. ]
This has been previously reported here https:/
Related branches
- git-ubuntu bot: Approve
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 53 lines (+31/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/create-user-config-files-use-correct-swtpm-localca.patch (+23/-0)
debian/patches/series (+1/-0)
- git-ubuntu bot: Approve
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 72 lines (+39/-0) (has conflicts)3 files modifieddebian/changelog (+15/-0)
debian/patches/create-user-config-files-use-correct-swtpm-localca.patch (+23/-0)
debian/patches/series (+1/-0)
Changed in swtpm (Ubuntu): | |
assignee: | nobody → Lena Voytek (lvoytek) |
description: | updated |
Confirmed this is an issue for kinetic and jammy-proposed
$ lxc launch ubuntu:jammy --vm test-swtpm
$ lxc exec test-swtpm bash
# cat <<EOF >/etc/apt/ sources. list.d/ ubuntu- $(lsb_release -cs)-proposed.list archive. ubuntu. com/ubuntu/ $(lsb_release -cs)-proposed restricted main multiverse universe
# Enable Ubuntu proposed archive
deb http://
EOF
# apt update && apt dist-upgrade -y
# apt install swtpm swtpm-tools -y
# su ubuntu
$ cd swtpm/swtpm- create- user-config- files --overwrite .config/ swtpm_setup. conf. .config/ swtpm-localca. conf. .config/ swtpm-localca. options.
$ /usr/share/
Environment variable XDG_CONFIG_HOME is not set. Using ${HOME}/.config.
Writing /home/ubuntu/
Writing /home/ubuntu/
Writing /home/ubuntu/
$ swtpm_setup --tpm2 --tpmstate . --overwrite --create-ek-cert /swtpm/ swtpm-localca in PATH.
Starting vTPM manufacturing as ubuntu:ubuntu @ Tue 25 Apr 2023 04:15:36 PM UTC
TPM is listening on Unix socket.
Successfully created RSA 2048 EK with handle 0x81010001.
Could not find @DATAROOTDIR@
An error occurred. Authoring the TPM state failed.
Ending vTPM manufacturing @ Tue 25 Apr 2023 04:15:36 PM UTC
$ lxc launch ubuntu:kinetic --vm test-swtpm
$ lxc exec test-swtpm bash
# apt update && apt dist-upgrade -y
# apt install swtpm swtpm-tools -y
# su ubuntu
$ cd swtpm/swtpm- create- user-config- files --overwrite .config/ swtpm_setup. conf. .config/ swtpm-localca. conf. .config/ swtpm-localca. options.
$ /usr/share/
Environment variable XDG_CONFIG_HOME is not set. Using ${HOME}/.config.
Writing /home/ubuntu/
Writing /home/ubuntu/
Writing /home/ubuntu/
$ swtpm_setup --tpm2 --tpmstate . --overwrite --create-ek-cert /swtpm/ swtpm-localca in PATH.
Starting vTPM manufacturing as ubuntu:ubuntu @ Tue 25 Apr 2023 04:07:27 PM UTC
TPM is listening on Unix socket.
Successfully created RSA 2048 EK with handle 0x81010001.
Could not find @DATAROOTDIR@
An error occurred. Authoring the TPM state failed.
Ending vTPM manufacturing @ Tue 25 Apr 2023 04:07:28 PM UTC
Lunar, however, is working properly:
$ lxc launch ubuntu:lunar --vm test-swtpm
$ lxc exec test-swtpm bash
# apt update && apt dist-upgrade -y
# apt install swtpm swtpm-tools -y
# su ubuntu
$ cd swtpm/swtpm- create- user-config- files --overwrite .config/ swtpm_setup. conf. .config/ swtpm-localca. conf. .config/ swtpm-localca. options.
$ /usr/share/
Environment variable XDG_CONFIG_HOME is not set. Using ${HOME}/.config.
Writing /home/ubuntu/
Writing /home/ubuntu/
Writing /home/ubuntu/
$ swtpm_setup --tpm2 --tpmstate . --overwrite --create-ek-cert swtpm_localca --type ek --ek c3c156cd0c219f0 97b180d7884f591 1c428f7b1e8ccbd 829b28c317302a2 8e35edddbc334e0 7c0b87c771243ab 7e4794ffd6f5e45 a7e69d3f2182ff5 0956b1eb6bd90f9 47401a392f940b2 a6fd0cb1223d25d 476ac24f94490a0 177885b7bc481d1 facddf880e2c1c3 6f9712d1ae3988d fe6637170c79f53 ec8e57c4eb60280 058ed032c7c802d dd6d2186d4a53b0 4c45ef47ef7a669 1d263410810cae8 1cf236491cf5405 9a250268402e30b 8590b8f98d7dbd1 fa58b978c0d62d0 310b8212a8104a3 eb2731d551265eb 414be3f33319c24 59deed673204f5f 6e2e7bc3ef494ac 8f3bc2e63439661 f57...
Starting vTPM manufacturing as ubuntu:ubuntu @ Tue 25 Apr 2023 04:29:45 PM UTC
TPM is listening on Unix socket.
Successfully created RSA 2048 EK with handle 0x81010001.
Invoking /usr/bin/