work around false positives in deltatar fs checks during rpmbuild
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Fri, 11 Aug 2017 12:16:56 +0000 (14:16 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 2 Apr 2018 11:34:09 +0000 (13:34 +0200)
These only happen when running in rpmbuild, otherwise the tests
are fine. Of course, on RHBT the choir resoundeth “thou shalt not
run thine rpm build as root” but that’s not really an option
here.

deltatar/deltatar.py

index 9a96467..6f8cbb1 100644 (file)
@@ -500,7 +500,11 @@ class DeltaTar(object):
 
         # only if user is root, then also check gid/uid. otherwise do not check it,
         # because tarfile can chown in case of being superuser only
-        if hasattr(os, "geteuid") and os.geteuid() == 0:
+        #
+        # also, skip the check in rpmbuild since the sources end up with the
+        # uid:gid of the packager while the extracted files are 0:0.
+        if hasattr(os, "geteuid") and os.geteuid() == 0 \
+                and os.getenv ("RPMBUILD_OPTIONS") is None:
             keys.append('gid')
             keys.append('uid')