From: Alec Warner Date: Mon, 26 Mar 2007 04:17:26 +0000 (-0000) Subject: Fix insecure tempfile usage X-Git-Tag: v2.2_pre1~1537 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4c7ce189aba715f1e2e4d33e6ef212b9a03a1463;p=portage.git Fix insecure tempfile usage svn path=/main/trunk/; revision=6286 --- diff --git a/pym/portage/tests/env/config/test_PackageKeywordsFile.py b/pym/portage/tests/env/config/test_PackageKeywordsFile.py index f493b82dc..229d9dffe 100644 --- a/pym/portage/tests/env/config/test_PackageKeywordsFile.py +++ b/pym/portage/tests/env/config/test_PackageKeywordsFile.py @@ -5,10 +5,11 @@ from portage.tests import TestCase from portage.env.config import PackageKeywordsFile +from tempfile import mkstemp +import os class PackageKeywordsFileTestCase(TestCase): - fname = 'package.keywords' cpv = 'sys-apps/portage' keywords = ['~x86', 'amd64', '-mips'] @@ -28,8 +29,9 @@ class PackageKeywordsFileTestCase(TestCase): self.NukeFile() def BuildFile(self): - f = open(self.fname, 'wb') - f.write('%s %s\n' % (self.cpv, ' '.join(self.keywords))) + fd, self.fname = mkstemp() + f = os.fdopen(fd, 'w') + f.write("\n".join(self.atoms)) f.close() def NukeFile(self): diff --git a/pym/portage/tests/env/config/test_PackageMaskFile.py b/pym/portage/tests/env/config/test_PackageMaskFile.py index d97eeebe8..ad87d5a56 100644 --- a/pym/portage/tests/env/config/test_PackageMaskFile.py +++ b/pym/portage/tests/env/config/test_PackageMaskFile.py @@ -7,6 +7,7 @@ import os from portage.env.config import PackageMaskFile from portage.tests import TestCase +from tempfile import mkstemp class PackageMaskFileTestCase(TestCase): @@ -22,7 +23,6 @@ class PackageMaskFileTestCase(TestCase): self.NukeFile() def BuildFile(self): - from tempfile import mkstemp fd, self.fname = mkstemp() f = os.fdopen(fd, 'w') f.write("\n".join(self.atoms)) diff --git a/pym/portage/tests/env/config/test_PackageUseFile.py b/pym/portage/tests/env/config/test_PackageUseFile.py index 71ab526ff..d20ab4572 100644 --- a/pym/portage/tests/env/config/test_PackageUseFile.py +++ b/pym/portage/tests/env/config/test_PackageUseFile.py @@ -3,12 +3,14 @@ # Distributed under the terms of the GNU General Public License v2 # $Id: test_PackageUseFile.py 6182 2007-03-06 07:35:22Z antarus $ +import os from portage.tests import TestCase from portage.env.config import PackageUseFile +from tempfile import mkstemp + class PackageUseFileTestCase(TestCase): - fname = 'package.use' cpv = 'sys-apps/portage' useflags = ['cdrom', 'far', 'boo', 'flag', 'blat'] @@ -27,7 +29,8 @@ class PackageUseFileTestCase(TestCase): self.NukeFile() def BuildFile(self): - f = open(self.fname, 'wb') + fd, self.fname = mkstemp() + f = os.fdopen(self.fname, 'wb') f.write("%s %s" % (self.cpv, ' '.join(self.useflags))) def NukeFile(self):