From db64d46820234956bd41e8f350ba970b62b46093 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Sun, 4 Feb 2024 22:22:30 +0100 Subject: [PATCH] Only change home files ownership for --rebuild mode Changing ownership of the entire $HOME directory tree is sometimes an expensive task and a no-op anyway because there's typically no reason for files with the wrong ownership to appear. Let's stop doing it to make the subsequent mock --chroot calls faster and more predictable. In other words, if users want to shoot themselves in the foot and give the files in '/builddir' away (e.g., using "privileged" --chroot calls), Mock will no longer fix the ownership problems. We only continue to fix the permissions for the --rebuild mode, which shouldn't be expensive (because there are pre-build cleanups) and seems important enough to risk changing. Suggested by @kdudka in #1257. --- mock/py/mockbuild/buildroot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mock/py/mockbuild/buildroot.py b/mock/py/mockbuild/buildroot.py index d34e9983b..fa331f66b 100644 --- a/mock/py/mockbuild/buildroot.py +++ b/mock/py/mockbuild/buildroot.py @@ -348,7 +348,8 @@ def _init(self, prebuild): # Change owner of homdir tree if the root of it not owned # by the current user - self.chown_home_dir() + if prebuild: + self.chown_home_dir() # mark the buildroot as initialized file_util.touch(self.make_chroot_path('.initialized'))