summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2007-03-26 04:17:26 +0000
committerAlec Warner <antarus@gentoo.org>2007-03-26 04:17:26 +0000
commit4c7ce189aba715f1e2e4d33e6ef212b9a03a1463 (patch)
tree67a5e3d278703757748622055b8f997e28debba8
parentc8dd054674e594790d08033b10b384df68c0e5a7 (diff)
downloadportage-4c7ce189aba715f1e2e4d33e6ef212b9a03a1463.tar.gz
portage-4c7ce189aba715f1e2e4d33e6ef212b9a03a1463.tar.bz2
portage-4c7ce189aba715f1e2e4d33e6ef212b9a03a1463.zip
Fix insecure tempfile usage
svn path=/main/trunk/; revision=6286
-rw-r--r--pym/portage/tests/env/config/test_PackageKeywordsFile.py8
-rw-r--r--pym/portage/tests/env/config/test_PackageMaskFile.py2
-rw-r--r--pym/portage/tests/env/config/test_PackageUseFile.py7
3 files changed, 11 insertions, 6 deletions
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):