[Python-checkins] CVS: python/dist/src/Lib tempfile.py,1.20,1.21

Guido van Rossum python-dev@python.org
2000年4月24日 09:28:05 -0400 (EDT)


Update of /projects/cvsroot/python/dist/src/Lib
In directory eric:/projects/python/develop/guido/src/Lib
Modified Files:
	tempfile.py 
Log Message:
Security patch for Unix by Chris McDonough.
This uses the same precautions when trying to find a temporary
directory as when the actual tempfile is created (using O_CREAT and
O_EXCL). On non-posix platforms, nothing is changed.
Index: tempfile.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/tempfile.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** tempfile.py	2000年02月04日 15:28:41	1.20
--- tempfile.py	2000年04月24日 13:28:02	1.21
***************
*** 43,53 ****
 for dir in attempdirs:
 try:
! filename = os.path.join(dir, testfile)
! fp = open(filename, 'w')
! fp.write('blat')
! fp.close()
! os.unlink(filename)
! tempdir = dir
! break
 except IOError:
 pass
--- 43,67 ----
 for dir in attempdirs:
 try:
! filename = os.path.join(dir, testfile)
! if os.name == 'posix':
! try:
! fd = os.open(filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0700)
! except OSError:
! pass
! else:
! fp = os.fdopen(fd, 'w')
! fp.write('blat')
! fp.close()
! os.unlink(filename)
! del fp, fd
! tempdir = dir
! break
! else:
! fp = open(filename, 'w')
! fp.write('blat')
! fp.close()
! os.unlink(filename)
! tempdir = dir
! break
 except IOError:
 pass

AltStyle によって変換されたページ (->オリジナル) /