[Python-checkins] r50619 - in python/trunk: Lib/ctypes/util.py Misc/NEWS
thomas.heller
python-checkins at python.org
Thu Jul 13 19:01:17 CEST 2006
Author: thomas.heller
Date: Thu Jul 13 19:01:14 2006
New Revision: 50619
Modified:
python/trunk/Lib/ctypes/util.py
python/trunk/Misc/NEWS
Log:
Fix #1521375. When running with root priviledges, 'gcc -o /dev/null'
did overwrite /dev/null. Use a temporary file instead of /dev/null.
Modified: python/trunk/Lib/ctypes/util.py
==============================================================================
--- python/trunk/Lib/ctypes/util.py (original)
+++ python/trunk/Lib/ctypes/util.py Thu Jul 13 19:01:14 2006
@@ -47,10 +47,13 @@
def _findLib_gcc(name):
expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name
+ fdout, ccout = tempfile.mkstemp()
+ os.close(fdout)
cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \
- '$CC -Wl,-t -o /dev/null 2>&1 -l' + name
+ '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name
try:
fdout, outfile = tempfile.mkstemp()
+ os.close(fdout)
fd = os.popen(cmd)
trace = fd.read()
err = fd.close()
@@ -60,6 +63,11 @@
except OSError, e:
if e.errno != errno.ENOENT:
raise
+ try:
+ os.unlink(ccout)
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
res = re.search(expr, trace)
if not res:
return None
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Thu Jul 13 19:01:14 2006
@@ -25,6 +25,10 @@
Extension Modules
-----------------
+- Bug #1521375: The code in ctypes.util.find_library was
+ run with root priviledges, it could overwrite or delete
+ /dev/null in certain cases; this is now fixed.
+
- Bug #1467450: On Mac OS X 10.3, RTLD_GLOBAL is now used as the
default mode for loading shared libraries in ctypes.
More information about the Python-checkins
mailing list