aboutsummaryrefslogtreecommitdiffstats
path: root/archivemail.py
diff options
context:
space:
mode:
authorNikolaus Schulz <microschulz@web.de>2006-10-27 03:23:16 +0000
committerNikolaus Schulz <microschulz@web.de>2006-10-27 03:23:16 +0000
commit5eb4cf3cf6bde4ef8d44247055f3fd98f22d878d (patch)
treeca66f726ef9349913f047114f8213a25708a0d33 /archivemail.py
parente491da3a113ed15e5966a78b4461613b56c4b582 (diff)
downloadarchivemail-5eb4cf3cf6bde4ef8d44247055f3fd98f22d878d.tar.gz
archivemail-5eb4cf3cf6bde4ef8d44247055f3fd98f22d878d.tar.bz2
archivemail-5eb4cf3cf6bde4ef8d44247055f3fd98f22d878d.zip
Replaced all tempfile.mktemp() calls with mkstemp()/mkdtemp().
Should just serve as a last security fallback, since we operate in a safe temporary directory and everything should be okay anyway, but that may be less obvious. :-)
Diffstat (limited to 'archivemail.py')
-rwxr-xr-xarchivemail.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/archivemail.py b/archivemail.py
index 26dc331..8d25e43 100755
--- a/archivemail.py
+++ b/archivemail.py
@@ -461,7 +461,7 @@ class RetainMbox(Mbox):
"""
assert(final_name)
- temp_name = tempfile.mktemp("retain")
+ temp_name = tempfile.mkstemp("retain")[1]
self.mbox_file = open(temp_name, "w")
self.mbox_file_name = temp_name
_stale.retain = temp_name
@@ -533,7 +533,7 @@ class ArchiveMbox(Mbox):
unexpected_error("""There is already a file named '%s'!
Have you been previously compressing this archive? You probably should
uncompress it manually, and try running me again.""" % compressed_archive)
- temp_name = tempfile.mktemp("archive")
+ temp_name = tempfile.mkstemp("archive")[1]
if os.path.isfile(final_name):
vprint("file already exists that is named: %s" % final_name)
shutil.copy2(final_name, temp_name)
@@ -550,7 +550,7 @@ uncompress it manually, and try running me again.""" % compressed_archive)
Have you been reading this archive? You probably should re-compress it
manually, and try running me again.""" % final_name)
- temp_name = tempfile.mktemp("archive.gz")
+ temp_name = tempfile.mkstemp("archive.gz")[1]
if os.path.isfile(compressed_filename):
vprint("file already exists that is named: %s" % \
compressed_filename)
@@ -1071,9 +1071,8 @@ def archive(mailbox_name):
# create a temporary directory for us to work in securely
old_temp_dir = tempfile.tempdir
tempfile.tempdir = None
- new_temp_dir = tempfile.mktemp('archivemail')
+ new_temp_dir = tempfile.mkdtemp('archivemail')
assert(new_temp_dir)
- os.mkdir(new_temp_dir)
_stale.temp_dir = new_temp_dir
tempfile.tempdir = new_temp_dir
vprint("set tempfile directory to '%s'" % new_temp_dir)