Skip to content

Commit 3e23989

Browse files
authored
mock: backport upstream change for disabling ca-trust copying (#13706)
1 parent 0a14c4e commit 3e23989

2 files changed

Lines changed: 94 additions & 2 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
From f40ef246bcaa479eed39bbe1657c9952bb431211 Mon Sep 17 00:00:00 2001
2+
From: reuben olinsky <reubeno@users.noreply.github.com>
3+
Date: Mon, 28 Apr 2025 09:49:16 -0700
4+
Subject: [PATCH] fix: disable copying ca-trust dirs with Azure Linux 3
5+
6+
Makes ca-trust dir copying in copy_certs() a configurable behavior
7+
via new config option 'ssl_copied_ca_trust_dirs'. Disables this option
8+
in Azure Linux 3 configurations to avoid clashes between files copied
9+
from the host and a symlink installed by the ca-certificates-shared
10+
package in that distro.
11+
12+
Fixes #1572
13+
---
14+
mock/docs/site-defaults.cfg | 11 +++++++++++
15+
mock/py/mockbuild/config.py | 5 +++++
16+
mock/py/mockbuild/package_manager.py | 10 ++++++----
17+
releng/release-notes-next/azure-linux-ca-trust.bugfix | 5 +++++
18+
19+
diff --git a/mock/docs/site-defaults.cfg b/mock/docs/site-defaults.cfg
20+
index 61d890f20..622eae3a8 100644
21+
--- a/mock/docs/site-defaults.cfg
22+
+++ b/mock/docs/site-defaults.cfg
23+
@@ -661,6 +661,17 @@
24+
# if 0 is set, then no time limit is used
25+
# config_opts['opstimeout'] = 0
26+
27+
+# Copy host's ca-trust directories into the specified locations inside the
28+
+# chroot. Each item in the list is a pair of (host, chroot) paths for the
29+
+# directories to be copied, since some hosts and some destination chroots
30+
+# may use different paths. The directories are copied recursively.
31+
+#config_opts['ssl_copied_ca_trust_dirs'] = None
32+
+# Example:
33+
+#config_opts['ssl_copied_ca_trust_dirs'] = [
34+
+# ('/etc/pki/ca-trust', '/etc/pki/ca-trust'),
35+
+# ('/usr/share/pki/ca-trust-source', '/usr/share/pki/ca-trust-source')
36+
+#]
37+
+
38+
# Copy host's SSL certificate bundle ('/etc/pki/tls/certs/ca-bundle.crt') into
39+
# specified location inside chroot. This usually isn't needed because we copy
40+
# the whole /etc/pki/ca-trust/extracted directory recursively by default, and
41+
diff --git a/mock/py/mockbuild/config.py b/mock/py/mockbuild/config.py
42+
index d69a11d36..f6c11fc9c 100644
43+
--- a/mock/py/mockbuild/config.py
44+
+++ b/mock/py/mockbuild/config.py
45+
@@ -136,6 +136,11 @@ def setup_default_config_opts():
46+
47+
config_opts['ssl_ca_bundle_path'] = None
48+
49+
+ config_opts['ssl_copied_ca_trust_dirs'] = [
50+
+ ('/etc/pki/ca-trust', '/etc/pki/ca-trust'),
51+
+ ('/usr/share/pki/ca-trust-source', '/usr/share/pki/ca-trust-source')
52+
+ ]
53+
+
54+
config_opts['ssl_extra_certs'] = None
55+
56+
# (global) plugins and plugin configs.
57+
diff --git a/mock/py/mockbuild/package_manager.py b/mock/py/mockbuild/package_manager.py
58+
index f88b3e6a5..8a8848079 100644
59+
--- a/mock/py/mockbuild/package_manager.py
60+
+++ b/mock/py/mockbuild/package_manager.py
61+
@@ -398,10 +398,12 @@ def copy_gpg_keys(self):
62+
63+
@traceLog()
64+
def copy_certs(self):
65+
- cert_paths = ["/etc/pki/ca-trust", "/usr/share/pki/ca-trust-source"]
66+
- for cert_path in cert_paths:
67+
- pki_dir = self.buildroot.make_chroot_path(cert_path)
68+
- file_util.update_tree(pki_dir, cert_path)
69+
+ copied_ca_cert_paths = self.config['ssl_copied_ca_trust_dirs']
70+
+ if copied_ca_cert_paths:
71+
+ for host_path, root_path in copied_ca_cert_paths:
72+
+ self.buildroot.root_log.debug('copying CA trust dir into chroot: %s => %s', host_path, root_path)
73+
+ dest_dir = self.buildroot.make_chroot_path(root_path)
74+
+ file_util.update_tree(dest_dir, host_path)
75+
76+
bundle_path = self.config['ssl_ca_bundle_path']
77+
if bundle_path:
78+
diff --git a/releng/release-notes-next/azure-linux-ca-trust.bugfix b/releng/release-notes-next/azure-linux-ca-trust.bugfix
79+
new file mode 100644
80+
index 000000000..3937d3ca1
81+
--- /dev/null
82+
+++ b/releng/release-notes-next/azure-linux-ca-trust.bugfix
83+
@@ -0,0 +1,5 @@
84+
+Disables copying /etc/pki/ca-trust and /usr/share/pki/ca-trust-source on
85+
+Azure Linux 3.0 via a new config options ('ssl_copied_ca_trust_dirs').
86+
+This avoids file ownership conflicts with a symlink installed by the
87+
+ca-certificates-shared packages on that distro. Behavior should be unchanged
88+
+for other configurations.

SPECS/mock/mock.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
Summary: Builds packages inside chroots
1111
Name: mock
1212
Version: 5.6
13-
Release: 1%{?dist}
13+
Release: 2%{?dist}
1414
Vendor: Microsoft Corporation
1515
Distribution: Azure Linux
1616
License: GPL-2.0-or-later
1717
Source: https://github.com/rpm-software-management/mock/archive/refs/tags/%{name}-%{version}-1.tar.gz#/%{name}-%{version}.tar.gz
18+
Patch0: disable-copying-ca-trust-dirs.patch
1819
URL: https://github.com/rpm-software-management/mock/
1920
BuildArch: noarch
2021
Requires: tar
@@ -152,7 +153,7 @@ Requires(pre): shadow-utils
152153
Filesystem layout and group for Mock.
153154

154155
%prep
155-
%setup -q -n mock-%{name}-%{version}-1/%{name}
156+
%autosetup -p2 -n mock-%{name}-%{version}-1/%{name}
156157
for file in py/mock.py py/mock-parse-buildlog.py; do
157158
sed -i 1"s|#!/usr/bin/python3 |#!%{__python} |" $file
158159
done
@@ -298,6 +299,9 @@ pylint-3 py/mockbuild/ py/*.py py/mockbuild/plugins/* || :
298299
%dir %{_datadir}/cheat
299300

300301
%changelog
302+
* Wed May 07 2025 Reuben Olinsky <reubeno@microsoft.com> - 5.6-2
303+
- Backport change allowing disabling ca-trust file copying.
304+
301305
* Wed Aug 28 2024 Reuben Olinsky <reubeno@microsoft.com> - 5.6-1
302306
- Sync with Fedora 41 version of spec.
303307

0 commit comments

Comments
 (0)