apt-news.service reporting errors after ubuntu-pro-client install
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ubuntu-advantage-tools (Ubuntu) |
Fix Released
|
High
|
Andreas Hasenack | ||
Xenial |
Fix Released
|
High
|
Andreas Hasenack | ||
Bionic |
Fix Released
|
High
|
Andreas Hasenack | ||
Focal |
Fix Released
|
High
|
Andreas Hasenack | ||
Jammy |
Fix Released
|
High
|
Andreas Hasenack | ||
Mantic |
Fix Released
|
High
|
Andreas Hasenack | ||
Noble |
Fix Released
|
High
|
Andreas Hasenack |
Bug Description
[ Impact ]
src:ubuntu-
Turns out, however, that apparmor can be enabled on a system, but without the apparmor package installed. When this package is not installed, no profiles are loaded. Crucially, the ubuntu_pro_apt_news profile, used by apt-news.service, is not loaded.
This situation is different than "apparmor is disabled", and systemd will try to launch apt-news confined by ubuntu_
apt-news.service is called as an apt update hook, but its failure does not fail apt, since it's guarded[3] by "|| true", i.e., failures in the hook are ignored. The only impact is that apt news won't be fetched.
[ Test Plan ]
The test plan will be in two parts. One to confirm the apt-news service won't fail to start if the apparmor profile is not available (it's what triggered this bug). The second part is to confirm that in the "good case", with apparmor available on the system, the confinement is still applied.
a) To reproduce the problem, launch an ubuntu lxd container, or a VM, and:
# install ubuntu-
sudo apt update && sudo apt install ubuntu-
# verify it's version 31 or higher:
$ dpkg -l ubuntu-
ii ubuntu-
# remove (not purge) apparmor:
sudo apt remove apparmor -y
# reboot
sudo reboot
# start apt-news.service, and verify it fails:
$ sudo systemctl start apt-news.service
Job for apt-news.service failed because the control process exited with error code.
See "systemctl status apt-news.service" and "journalctl -xeu apt-news.service" for details.
# The log will show it's because it couldn't confine the service with the ubuntu_pro_apt_news profile:
$ systemctl status apt-news.service
× apt-news.service - Update APT News
Loaded: loaded (/lib/systemd/
Active: failed (Result: exit-code) since Mon 2024-03-18 20:35:41 UTC; 35s ago
Process: 263 ExecStart=
Main PID: 263 (code=exited, status=
CPU: 7ms
Mar 18 20:35:41 j systemd[1]: Starting Update APT News...
Mar 18 20:35:41 j systemd[263]: apt-news.service: Failed to prepare AppArmor profile change to ubuntu_
Mar 18 20:35:41 j systemd[263]: apt-news.service: Failed at step APPARMOR spawning /usr/bin/python3: No such file or directory
Mar 18 20:35:41 j systemd[1]: apt-news.service: Main process exited, code=exited, status=231/APPARMOR
Mar 18 20:35:41 j systemd[1]: apt-news.service: Failed with result 'exit-code'.
Mar 18 20:35:41 j systemd[1]: Failed to start Update APT News.
With the fixed package, the service will not fail to start.
b) Continuing from the test plan above, now we will confirm that if apparmor is installed, that the apt-news service is run confined.
* Install apparmor back again and reboot:
$ sudo apt install apparmor -y
$ sudo reboot
* Confirm the apt-news profile is loaded and in enforce mode:
$ sudo grep ubuntu_pro_apt_news /sys/kernel/
ubuntu_pro_apt_news (enforce)
* start apt-news, and confirm it doesn't fail:
$ sudo systemctl start apt-news.service ; echo $?
0
To really confirm that the profile is being applied, and not just ignored, we have to hack the service unit file. Replace ExecStart with a sleep command in /lib/systemd/
[Service]
Type=oneshot
ExecStart=
Then run:
$ sudo systemctl daemon-reload
Start the service again in one terminal (it will hang):
$ sudo systemctl start apt-news.service
In another terminal, list the process and its confinement status:
$ ps auxwZ|grep time\\.sleep
ubuntu_pro_apt_news (enforce) root 553 0.0 0.0 17224 8576 ? Ss 13:54 0:00 /usr/bin/python3 -c import time;time.
The first column will show the apparmor profile being enforced on the process.
[ Where problems could occur ]
Note that most ubuntu packages use apparmor in an opportunistic way. If there is a profile, and its name matches the executable's path, then it will be applied. Otherwise, the executable runs unconfined. With the change in this SRU, that's essentially what we doing with apt-news.service.
The fix is essentially ignoring errors when loading the specified apparmor profile, leaving the service unconfined in the case of an error like this, which is exactly how it was prior to the version 31 update. If the profile is loaded in the kernel, it will be applied as designed.
Since we are now ignoring errors, here are some scenarios where things could go wrong:
a) the user decided they don't like apparmor, and removed the apparmor package. That's the scenario that triggered this bug. In that case, it's a decision the user made, and apt-news.service will run unconfined.
b) the user made a change to the installed apparmor profile in /etc/apparmor.
The error will only be noticed when that profile is loaded into the kernel. Then we have the following possible outcomes:
b1) The user, right after making the change, invokes apparmor_parser to actually apply them and load the modified profile into the kernel. The tool will flag the error, and not load the changed profile. The previous profile will remain loaded, and apt-news will remain confined by it.
b2) The user forgets to run apparmor_parser, and eventually reboots. Upon reboot, that profile specifically will fail to load (all the others will load), and when apt-news is started, there will be no ubuntu_pro_apt_news profile to attach to. With this new "-" flag, that will not be an error, and the service will run unconfined.
b3) Instead of rebooting or running apparmor_parser, the user invokes "systemctl restart apparmor". From my testing, that will also flag the syntax error, and not unload the already-loaded profile, so this is similar to (b1).
b4) We (Ubuntu) might make a mistake in the profile, and introduce a syntax error that will make it fail to load. To guard against that, the package build runs a syntax check on the generated profile. But it's still possible it would pass that check, but fail to load in the actual kernel that is running on the system.
[ Other Info ]
Upstream issue:
https:/
Fixed via:
https:/
1. https:/
2. https:/
3. https:/
[ Original Description ]
After ubuntu-pro-client was installed the following errors are being logged.
Mar 14 09:00:11 edmonton systemd[1]: Starting Update APT News...
Mar 14 09:00:11 edmonton systemd[2927302]: apt-news.service: Failed to prepare AppArmor profile chang
e to ubuntu_
Mar 14 09:00:11 edmonton systemd[2927302]: apt-news.service: Failed at step APPARMOR spawning /usr/bi
n/python3: No such file or directory
The updates that started the problem:
Start-Date: 2024-03-13 22:00:22
Commandline: apt-get -y -o Dpkg::Options:
Install: ubuntu-
Upgrade: ubuntu-
End-Date: 2024-03-13 22:00:28
This is happening on all servers where this update is installed.
ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: ubuntu-pro-client 31.2~22.04
ProcVersionSign
Uname: Linux 5.15.0-91-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckR
Date: Thu Mar 14 10:02:35 2024
ProcEnviron:
TERM=xterm-
PATH=(custom, no user)
LANG=en_US.UTF-8
SHELL=/bin/bash
RebootRequiredPkgs: Error: path contained symlinks.
SourcePackage: ubuntu-
UpgradeStatus: No upgrade log present (probably fresh install)
apparmor_logs.txt:
cloud-id.txt-error: Invalid command specified 'cloud-id'.
livepatch-
uaclient.conf:
contract_url: https:/
log_level: debug
Related branches
- Renan Rodrigo (community): Approve
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 44 lines (+14/-2)3 files modifieddebian/changelog (+12/-0)
systemd/apt-news.service (+1/-1)
uaclient/version.py (+1/-1)
- Renan Rodrigo (community): Approve
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 44 lines (+14/-2)3 files modifieddebian/changelog (+12/-0)
systemd/apt-news.service (+1/-1)
uaclient/version.py (+1/-1)
- Renan Rodrigo (community): Approve
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 44 lines (+14/-2)3 files modifieddebian/changelog (+12/-0)
systemd/apt-news.service (+1/-1)
uaclient/version.py (+1/-1)
- Renan Rodrigo (community): Approve
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 44 lines (+14/-2)3 files modifieddebian/changelog (+12/-0)
systemd/apt-news.service (+1/-1)
uaclient/version.py (+1/-1)
- Renan Rodrigo (community): Approve
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 44 lines (+14/-2)3 files modifieddebian/changelog (+12/-0)
systemd/apt-news.service (+1/-1)
uaclient/version.py (+1/-1)
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 44 lines (+14/-2)3 files modifieddebian/changelog (+12/-0)
systemd/apt-news.service (+1/-1)
uaclient/version.py (+1/-1)
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 44 lines (+14/-2)3 files modifieddebian/changelog (+12/-0)
systemd/apt-news.service (+1/-1)
uaclient/version.py (+1/-1)
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 44 lines (+14/-2)3 files modifieddebian/changelog (+12/-0)
systemd/apt-news.service (+1/-1)
uaclient/version.py (+1/-1)
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 44 lines (+14/-2)3 files modifieddebian/changelog (+12/-0)
systemd/apt-news.service (+1/-1)
uaclient/version.py (+1/-1)
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 44 lines (+14/-2)3 files modifieddebian/changelog (+12/-0)
systemd/apt-news.service (+1/-1)
uaclient/version.py (+1/-1)
- Bryce Harrington (community): Approve
- Canonical Server Reporter: Pending requested
-
Diff: 27 lines (+7/-1)2 files modifieddebian/changelog (+6/-0)
systemd/apt-news.service (+1/-1)
information type: | Private → Public |
tags: | removed: need-amd64-retrace |
Changed in ubuntu-advantage-tools (Ubuntu): | |
status: | New → Incomplete |
Changed in ubuntu-advantage-tools (Ubuntu): | |
status: | Incomplete → Triaged |
importance: | Undecided → High |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in ubuntu-advantage-tools (Ubuntu Mantic): | |
status: | New → Triaged |
Changed in ubuntu-advantage-tools (Ubuntu Jammy): | |
status: | New → Triaged |
Changed in ubuntu-advantage-tools (Ubuntu Focal): | |
status: | New → Triaged |
Changed in ubuntu-advantage-tools (Ubuntu Bionic): | |
status: | New → Triaged |
Changed in ubuntu-advantage-tools (Ubuntu Xenial): | |
status: | New → Triaged |
importance: | Undecided → High |
Changed in ubuntu-advantage-tools (Ubuntu Bionic): | |
importance: | Undecided → High |
Changed in ubuntu-advantage-tools (Ubuntu Focal): | |
importance: | Undecided → High |
Changed in ubuntu-advantage-tools (Ubuntu Jammy): | |
importance: | Undecided → High |
Changed in ubuntu-advantage-tools (Ubuntu Mantic): | |
importance: | Undecided → High |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in ubuntu-advantage-tools (Ubuntu Jammy): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in ubuntu-advantage-tools (Ubuntu Focal): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in ubuntu-advantage-tools (Ubuntu Bionic): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in ubuntu-advantage-tools (Ubuntu Xenial): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
tags: | added: regression-update |
description: | updated |
description: | updated |
Changed in ubuntu-advantage-tools (Ubuntu Noble): | |
status: | Triaged → In Progress |
description: | updated |
description: | updated |
description: | updated |
Hi Erik,
please show the output of the following commands:
a) systemctl cat apt-news.service
b) ls -la /etc/apparmor. d/ubuntu*
c) sudo aa-status
d) dpkg -l ubuntu- advantage- tools ubuntu-pro-client ubuntu- pro-client- l10n
e) python3 --version
f) sudo apparmor_parser -r -W -T /etc/apparmor. d/ubuntu_ pro_apt_ news