This does not work as we call have_cache() to determine whether
we need to clean the tools tree or not and when running as root to
boot after building an image the UID/GID will differ and the tools
tree will incorrectly be considered out of date.
Let's move the UID/GID check out of have_cache() and into reuse_cache()
instead. reuse_cache() always runs after we've already potentially
unshared the user namespace and become root, so checking the owner of
the cache directory against the current UID should be a valid check
there.
final, build, _ = cache_tree_paths(context.config)
+ if final.stat().st_uid != os.getuid():
+ return False
+
with complete_step("Copying cached trees"):
copy_tree(
final, context.root,
j = cls._load_json(s)
return dataclasses.replace(cls.default(), **j)
-CACHE_UID = os.getuid()
-CACHE_GID = os.getgid()
PACKAGE_GLOBS = (
"*.rpm",
def cache_manifest(self) -> dict[str, Any]:
return {
- "uid": CACHE_UID,
- "gid": CACHE_GID,
"distribution": self.distribution,
"release": self.release,
"mirror": self.mirror,