]> git.ipfire.org Git - pakfire.git/commitdiff
Convert all files in a source tarball to owner root.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Dec 2011 17:56:52 +0000 (18:56 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Dec 2011 17:56:52 +0000 (18:56 +0100)
Sometimes, when files had crappy owners, there has been
an issue in extrating the properly. To overcome that and
also to overcome that users can take benefit from weird
owners, we will change that to user root.

When extracting the source package, we may replace that
if we feel so.

python/pakfire/packages/packager.py

index 282696292d6ae0aaa338707f2a4ac182344175a4..d17f7d38d1e62eab85b27a41ceb7117b4257c9a4 100644 (file)
@@ -622,7 +622,17 @@ class SourcePackager(Packager):
                # Add all files in the package directory.
                for file in sorted(self.pkg.files):
                        arcname = os.path.relpath(file, self.pkg.path)
-                       datafile.add(file, arcname)
+
+                       # Get tarinfo from file that is to be added.
+                       tarinfo = datafile.gettarinfo(file, arcname)
+
+                       # Modify owner/group of the file. All source files belong
+                       # to root (at least in this package).
+                       tarinfo.uname = tarinfo.gname = "root"
+                       tarinfo.uid = tarinfo.gid = 0
+
+                       # Add file to tarball.
+                       datafile.addfile(tarinfo)
 
                datafile.close()