Skip to content
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
4 changes: 3 additions & 1 deletion docs/updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ repository and every Aurora update in it. The setting is a dnf5 repository overr
locally. Once Fedora's dnf5 has `auto_import_local_keys`, which the override already sets, the metadata
check can come back. The image imports the key into its rpm database (`config.sh` checks it), so the
first Aurora install does not ask either, and the image build checks every Aurora package against it
(`package_gpgcheck` in the KIWI repository).
(`package_gpgcheck` in the KIWI repository). The build checks Fedora's packages the same way, against
the KIWI description's Fedora key (`distribution-gpg-keys`, the same key as `fedora-gpg-keys`), and
`configure.py` refuses an upstream repository that has no key.

Fedora Asahi Remix sets `allow_vendor_change=False`. Images built before `aurora-release` 44-7 have no
policies, so their first `dnf upgrade` brings the policies (`aurora-release` and `aurora-repos` carry no
Expand Down
11 changes: 9 additions & 2 deletions images/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ def prepare(source, destination, profile, repository_url, key, fingerprint, lock
parent.set("kernelcmdline", " ".join(arguments))
if parent.tag == "systemdisk":
parent.set("name", "aurora")
if parent.tag == "repository":
# KIWI writes gpgcheck=0 into a repository's file unless asked,
# which overrides rpm-check-signatures. Its <signing> keys are
# in the image rpm database before the first package.
if parent.find("source/signing") is None:
raise ValueError(f"upstream repository {parent.get('alias')} has no signing key; "
"review the integration")
parent.set("package_gpgcheck", "true")
for node in list(parent):
if node.tag == "package" and node.get("name") in REPLACED:
parent.remove(node)
Expand Down Expand Up @@ -188,8 +196,7 @@ def prepare(source, destination, profile, repository_url, key, fingerprint, lock
# KIWI resolves description-local signing keys before the root filesystem exists.
(destination / key_name).write_bytes(key_bytes)
repository = ET.Element("image")
# KIWI turns off the package check of a repository unless asked; the key
# is in the image's rpm database before the first package.
# Package signatures are checked as for the Fedora repositories above.
node = ET.SubElement(repository, "repository", {
"type": "rpm-md", "alias": "aurora", "sourcetype": "baseurl", "priority": "1",
"package_gpgcheck": "true",
Expand Down
28 changes: 28 additions & 0 deletions images/test_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def setUpClass(cls):
f'<packages type="image" profiles="{profile}"><namedCollection name="input-methods"/>'
'</packages></image>')
(cls.source / "repositories/asahi.xml").write_text("<image/>")
(cls.source / "repositories/core.xml").write_text("<image>" + "".join(
f'<repository type="rpm-md" alias="{alias}" sourcetype="metalink">'
f'<source path="https://mirrors.fedoraproject.org/metalink?repo={repo}&amp;arch=$basearch">'
'<signing key="file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-$releasever-primary"/>'
'</source></repository>'
for alias, repo in (("fedora", "fedora-$releasever"), ("updates", "updates-released-f$releasever")))
+ "</image>")
(cls.source / "root/etc").mkdir()
(cls.source / "root/etc/fstab.script").write_text(
"#!/bin/sh\n"
Expand Down Expand Up @@ -236,6 +243,27 @@ def test_image_trusts_the_aurora_signing_key(self):
"rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-aurora",
f"rpmkeys --list {self.fingerprint}"])

def test_image_build_checks_fedora_package_signatures(self):
out = self.root / "fedora-signatures"
self.prepare(out)
repositories = {node.get("alias"): node for path in (out / "repositories").glob("*.xml")
for node in ET.parse(path).getroot().iter("repository")}
self.assertEqual(set(repositories), {"fedora", "updates", "aurora"})
for alias, node in repositories.items():
with self.subTest(alias=alias):
self.assertEqual(node.get("package_gpgcheck"), "true")
self.assertIsNotNone(node.find("source/signing"))
self.assertEqual(repositories["fedora"].find("source/signing").get("key"),
"file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-$releasever-primary")

def unsigned(source):
path = source / "repositories/core.xml"
path.write_text(re.sub(r"<signing [^>]*/>", "", path.read_text(), count=1))

source, lock = self.variant("upstream-unsigned", unsigned)
with self.assertRaisesRegex(ValueError, "fedora has no signing key"):
self.prepare(self.root / "rejected-unsigned", source=source, lock=lock)

def test_requires_the_aurora_repos_repository_file(self):
changed = self.root / "changed.repo"
changed.write_text("[aurora]\nname=Aurora\nmetalink=https://packages.example.org/metalink\n")
Expand Down