tahoe-lafs/src/allmydata/util
Brian Warner d27a57cb49 Avoid Popen() of executables that don't exist
The stdlib 'subprocess' module in python-2.7.4 through 2.7.7 suffers
from http://bugs.python.org/issue18851 which causes unrelated file
descriptors to be closed when `subprocess.call()` fails the `exec()`,
such as when the executable being invoked does not actually exist. There
appears to be some randomness involved. This was fixed in python-2.7.8.

Tahoe's iputil.py uses subprocess.call on many different "ifconfig"-type
executables, most of which don't exist on any given platform (added in
git commit 8e31d66cd0). This results in a lot of file-descriptor
closing, which (at least during unit tests) tends to clobber important
things like Tub TCP sockets. This seems to be the root cause behind
ticket:2121, in which normal code tries to close already-closed sockets,
crashing the unit tests. Since different platforms have different
ifconfigs, some platforms will experience more failed execs than others,
so this bug could easily behave differently on linux vs freebsd, as well
as working normally on python-2.7.8 or 2.7.4.

This patch inserts a guard to make sure that os.path.isfile() is true
before allowing Popen.call() to try executing the target. This ought to
be enough to avoid the bug. It changes both iputil.py and
allmydata.__init__ (which uses Popen for calling "lsb_release"), which
are all the places where 'subprocess' is used outside of unit tests.

Other potential fixes: use the 'subprocess32' module from PyPI (which is
a bug-free backport of the Python3 stdlib subprocess module, but would
introduce a new dependency), or require python >= 2.7.8 (but this would
rule out development/deployment on the current OS-X 10.9 release, which
ships with 2.7.5, as well as other distributions like Ubuntu 14.04 LTS).

I believe this closes ticket:2121, and given the apparent relationship
between 2121 and 2023, I think it also closes ticket:2023 (although
since 2023 doesn't have copies of the failing log files, it's hard to
tell). I'm hoping that this will tide us over until 1.11 is released, at
which point we can execute on the plan to remove iputil.py entirely by
changing the way that nodes learn their externally-facing IP address.
2014-09-12 13:01:56 -07:00
..
__init__.py
abbreviate.py Make abbreviate_space able to output in exabytes. refs #1812 2012-12-27 20:08:27 +00:00
assertutil.py Change relative imports to absolute 2010-02-26 01:14:33 -07:00
base32.py Change relative imports to absolute 2010-02-26 01:14:33 -07:00
base62.py remove interpreter shbang lines from non-executables 2011-10-14 10:23:01 -07:00
cachedir.py
consumer.py setup: ignore _darcs in the "test-clean" test and make the "clean" step remove all .egg's in the root dir 2009-12-06 10:48:35 -08:00
deferredutil.py util: deferredutil: undo my recent patch to use our own implementation of gatherResults 2009-01-07 11:00:05 -07:00
dictutil.py dictutil.DictOfSets: remove .union() method, it was misleading 2012-05-16 16:55:09 -07:00
encodingutil.py Only quote newline characters where necessary. fixes #1484 2013-03-07 16:22:47 +00:00
fake_inotify.py Drop-upload frontend, rerecorded for 1.9 beta (and correcting a minor mistake). Includes some fixes for Windows but not the Windows inotify implementation. fixes #1429 2011-08-08 16:40:49 -07:00
fileutil.py Revert [603f5eba32] which was applied unintentionally. 2014-05-05 22:09:33 +01:00
happinessutil.py util/happinessutil.py: suppress a warning from check-miscaptures. (It is not a bug because the capturing function is only used by a 'map' in the same iteration.) refs #1556 2011-10-08 22:21:06 -07:00
hashutil.py Use bigger random one-time keys in timing_safe_compare. fixes #2165 2014-02-24 20:43:23 +00:00
humanreadable.py doc: licensing cleanups 2009-09-20 10:16:31 -07:00
idlib.py
iputil.py Avoid Popen() of executables that don't exist 2014-09-12 13:01:56 -07:00
keyutil.py 'tahoe admin generate-keypair/derive-pubkey': add Ed25519 keypair commands 2012-03-13 18:24:32 -07:00
limiter.py switch all foolscap imports to use foolscap.api or foolscap.logging 2009-05-21 17:38:23 -07:00
log.py Change relative imports to absolute 2010-02-26 01:14:33 -07:00
mathutil.py hush pyflakes-0.4.0 warnings: remove trivial unused variables. For #900. 2010-01-14 14:15:29 -08:00
netstring.py directories: keep track of your position as you decode netstring after netstring from an input buffer instead of copying the trailing part 2009-07-04 19:51:09 -07:00
nummedobj.py Change relative imports to absolute 2010-02-26 01:14:33 -07:00
observer.py util/observer.py: add EventStreamObserver 2010-08-04 00:26:12 -07:00
pipeline.py PipelineError: fix str() on python2.4 . Closes #842. 2009-11-24 13:25:12 -08:00
pkgresutil.py
pollmixin.py tests: raise the timeout on pollmixin from 100s to 1000s -- it looks like it may have triggered too eagerly on Zandr's 266 MHz armel 2009-07-08 21:47:29 -07:00
repeatable_random.py Change relative imports to absolute 2010-02-26 01:14:33 -07:00
rrefutil.py Fix introweb display for mixed V1/V2 clients. Closes #1721. 2012-04-23 18:30:53 -04:00
sibpath.py
spans.py util/spans.py: __nonzero__ cannot return a long either. for #1154 2010-08-05 11:55:07 -07:00
statistics.py setup: fix error in licensing declaration from Shawn Willden, as noted by the FSF compliance division 2010-03-09 08:37:36 -08:00
time_format.py trivial: remove obsolete comment text 2009-07-20 06:08:43 -07:00
verlib.py setup.py: get version from git or darcs 2011-12-04 20:40:01 -08:00