From: Daan De Meyer Date: Tue, 23 Jul 2024 20:59:22 +0000 (+0200) Subject: Drop uid/gid from cache manifest X-Git-Tag: v24~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36dea6cbfba7db647c7cdf4a5600c5aa5524cf60;p=thirdparty%2Fmkosi.git Drop uid/gid from cache manifest 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. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index a987a6c6a..36a9b470c 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -3332,6 +3332,9 @@ def reuse_cache(context: Context) -> bool: 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, diff --git a/mkosi/config.py b/mkosi/config.py index 193f95702..ff21cc111 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -1363,8 +1363,6 @@ class Args: j = cls._load_json(s) return dataclasses.replace(cls.default(), **j) -CACHE_UID = os.getuid() -CACHE_GID = os.getgid() PACKAGE_GLOBS = ( "*.rpm", @@ -1657,8 +1655,6 @@ class Config: def cache_manifest(self) -> dict[str, Any]: return { - "uid": CACHE_UID, - "gid": CACHE_GID, "distribution": self.distribution, "release": self.release, "mirror": self.mirror,