mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Fix #1521375. When running with root priviledges, 'gcc -o /dev/null'
did overwrite /dev/null. Use a temporary file instead of /dev/null.
This commit is contained in:
parent
b4dc2ef5da
commit
2bdf29ec28
2 changed files with 13 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue