]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Only do st_uid check in have_cache() if we're root
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 22 Feb 2024 09:11:24 +0000 (10:11 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 22 Feb 2024 12:31:21 +0000 (13:31 +0100)
If we're not root then the check doesn't make any sense so skip it.

mkosi/__init__.py

index 505d01b722e919b66c19716622ec399c2bda95dc..2522b64d1baadacca650226dcd00278c7dc53e4f 100644 (file)
@@ -2637,7 +2637,7 @@ def have_cache(config: Config) -> bool:
     # namespace and we'll think the cache is owned by root. However, if we're running as root and the cache was
     # generated by an unprivileged build, the cache will not be owned by root and we should not use it.
     for p in (final, build):
-        if p.exists() and p.stat().st_uid != 0:
+        if p.exists() and os.getuid() == 0 and p.stat().st_uid != 0:
             return False
 
     return True