summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2006-07-13 17:01:14 (GMT)
committerThomas Heller <theller@ctypes.org>2006-07-13 17:01:14 (GMT)
commit2bdf29ec28fa5f5284d57672d63fdd8402030a92 (patch)
tree05006ea2f41f79983b27ecce946b29c1436a3a7b /Lib/ctypes
parentb4dc2ef5dacf833327f0db4b9acf8761e1f7b21b (diff)
downloadcpython-2bdf29ec28fa5f5284d57672d63fdd8402030a92.zip
cpython-2bdf29ec28fa5f5284d57672d63fdd8402030a92.tar.gz
cpython-2bdf29ec28fa5f5284d57672d63fdd8402030a92.tar.bz2
Fix #1521375. When running with root priviledges, 'gcc -o /dev/null'
did overwrite /dev/null. Use a temporary file instead of /dev/null.
Diffstat (limited to 'Lib/ctypes')
-rw-r--r--Lib/ctypes/util.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index d4e314a..2ee2968 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -47,10 +47,13 @@ elif os.name == "posix":
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 @@ elif os.name == "posix":
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