Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add os-release ID_LIKE to features #598

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions qubes/ext/core_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ async def qubes_features_request(self, vm, event, untrusted_features):
# entry point already validates values for safe characters
vm.features["os-distribution"] = \
untrusted_features["os-distribution"]
if "os-distribution-like" in untrusted_features \
and untrusted_features["os-distribution-like"]:
# entry point already validates values for safe characters
vm.features["os-distribution-like"] = \
untrusted_features["os-distribution-like"]
if "os-version" in untrusted_features \
and untrusted_features["os-version"]:
# no letters in versions please
Expand Down
7 changes: 7 additions & 0 deletions qubes/tests/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,13 @@ def test_031_distro_meta_ubuntu(self):
untrusted_features={
'os': 'Linux',
'os-distribution': 'ubuntu',
'os-distribution-like': 'debian',
'os-version': '22.04',
'os-eol': '2027-06-01',
}))
self.assertListEqual(self.vm.mock_calls, [
('features.__setitem__', ('os-distribution', 'ubuntu'), {}),
('features.__setitem__', ('os-distribution-like', 'debian'), {}),
('features.__setitem__', ('os-version', '22.04'), {}),
('features.__setitem__', ('os-eol', '2027-06-01'), {}),
('features.get', ('qrexec', False), {}),
Expand All @@ -285,11 +287,13 @@ def test_032_distro_meta_invalid(self):
untrusted_features={
'os': 'Linux',
'os-distribution': 'ubuntu',
'os-distribution-like': 'debian',
'os-version': '123aaa',
'os-eol': '20270601',
}))
self.assertListEqual(self.vm.mock_calls, [
('features.__setitem__', ('os-distribution', 'ubuntu'), {}),
('features.__setitem__', ('os-distribution-like', 'debian'), {}),
('log.warning', unittest.mock.ANY, {}),
('log.warning', unittest.mock.ANY, {}),
('features.get', ('qrexec', False), {}),
Expand All @@ -303,11 +307,13 @@ def test_033_distro_meta_invalid2(self):
untrusted_features={
'os': 'Linux',
'os-distribution': 'ubuntu',
'os-distribution-like': 'debian',
'os-version': 'a123',
'os-eol': '2027-06-40',
}))
self.assertListEqual(self.vm.mock_calls, [
('features.__setitem__', ('os-distribution', 'ubuntu'), {}),
('features.__setitem__', ('os-distribution-like', 'debian'), {}),
('log.warning', unittest.mock.ANY, {}),
('log.warning', unittest.mock.ANY, {}),
('features.get', ('qrexec', False), {}),
Expand All @@ -321,6 +327,7 @@ def test_034_distro_meta_empty(self):
untrusted_features={
'os': '',
'os-distribution': '',
'os-distribution-like': '',
'os-version': '',
'os-eol': '',
}))
Expand Down
4 changes: 4 additions & 0 deletions qubes/tests/integ/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,12 @@ def test_010_os_metadata(self):
self.assertIsNotNone(tpl.features.get('os-eol'))
elif self.template.startswith('whonix-'):
self.assertEqual(tpl.features.get('os-distribution'), 'whonix')
self.assertEqual(tpl.features.get('os-distribution-like'), 'debian')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test failed for (both) Whonix templates, the bot will post details when the run completes. I do see in the log it sent some info to dom0 after installing updates:

Jun 10 08:27:55 dom0 qrexec-policy-daemon[19866]: qrexec: qubes.FeaturesRequest+: whonix-workstation-17 -> @adminvm: allowed to dom0

Copy link
Contributor Author

@ben-grande ben-grande Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on the other PR QubesOS/qubes-core-agent-linux#504

    elif [ -f /usr/share/whonix/marker ]; then
        distro="whonix"
        distro_like="debian"

Because Whonix does not set /etc/os-release to the norm of using ID_LIKE=, the value will just be reported correctly after the other PR is merged. Is my assumption correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also assume that Whonix reposted an empty value for os-distribution-like as Whonix does not set ID_LIKE=. It will just work after the other PR is merged unless tests could be made upon the other PR branch also instead of the main branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test did run with the other PR included too...

Copy link
Contributor Author

@ben-grande ben-grande Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I do not understand the issue yet, I read the OpenQA output. Last commit only fixes the version gathering for Whonix and Kicksecure which where inverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the issue was with the version gathering, I inverted Whonix and Kicksecure information and with set -e, it was exiting on the first error:

+ [ -f /usr/share/kicksecure/marker ]
+ [ -f /usr/share/whonix/marker ]
+ distro=whonix
+ distro_like=debian
+ cat /etc/kicksecure_version
cat: /etc/kicksecure_version: No such file or directory
+ version=
zsh: exit 1     sudo sh -x ./10-qubes-core-agent-features.sh

Last commit QubesOS/qubes-core-agent-linux@c33b577 fixes this issue. Comparison.

version = self.template.split('-')[2]
self.assertEqual(tpl.features.get('os-version'), version)
elif self.template.startswith('kali-core'):
self.assertEqual(tpl.features.get('os-distribution'), 'kali')
self.assertEqual(tpl.features.get('os-distribution-like'), 'debian')

@unittest.skipUnless(
spawn.find_executable('xdotool'), "xdotool not installed")
Expand Down