From 830beb91cbb447a1da23132785a42d50922b8a9a Mon Sep 17 00:00:00 2001 From: Grant Orndorff Date: Fri, 1 Nov 2024 10:39:38 +0100 Subject: [PATCH] wsl: do not enable livepatch on wsl Fixes: #3156 --- features/livepatch.feature | 24 ++++++++++++++++++++++++ uaclient/entitlements/livepatch.py | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/features/livepatch.feature b/features/livepatch.feature index 8f69b64188..4a8cf64eb3 100644 --- a/features/livepatch.feature +++ b/features/livepatch.feature @@ -338,3 +338,27 @@ Feature: Livepatch | release | machine_type | | xenial | lxd-vm | | bionic | lxd-vm | + + Scenario Outline: Livepatch doesn't enable on wsl from a systemd service + Given a `` `` machine with ubuntu-advantage-tools installed + When I create the file `/lib/systemd/system/test.service` with the following + """ + [Unit] + Description=test + + [Service] + Type=oneshot + ExecStart=/usr/bin/pro attach + PrivateMounts=yes + """ + When I replace `` in `/lib/systemd/system/test.service` with token `contract_token` + When I run `systemctl start test.service` with sudo + Then I verify that running `canonical-livepatch` `with sudo` exits `1` + Then I will see the following on stderr + """ + sudo: canonical-livepatch: command not found + """ + + Examples: ubuntu release + | release | machine_type | + | jammy | wsl | diff --git a/uaclient/entitlements/livepatch.py b/uaclient/entitlements/livepatch.py index ed58d06d1f..18f1aee5af 100644 --- a/uaclient/entitlements/livepatch.py +++ b/uaclient/entitlements/livepatch.py @@ -72,7 +72,8 @@ def static_affordances(self) -> Tuple[StaticAffordance, ...]: messages.SERVICE_ERROR_INSTALL_ON_CONTAINER.format( title=self.title ), - lambda: system.is_container(), + lambda: system.is_container() + or system.get_virt_type() == "wsl", False, ), (