Merge pull request #109 from warner/2023-caution
Avoid Popen() of executables that don't exist
This commit is contained in:
commit
d91170a7ac
|
@ -106,6 +106,7 @@ def get_linux_distro():
|
||||||
if _distname and _version:
|
if _distname and _version:
|
||||||
return (_distname, _version)
|
return (_distname, _version)
|
||||||
|
|
||||||
|
if os.path.isfile("/usr/bin/lsb_release") or os.path.isfile("/bin/lsb_release"):
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(["lsb_release", "--all"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(["lsb_release", "--all"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
rc = p.wait()
|
rc = p.wait()
|
||||||
|
|
|
@ -130,6 +130,7 @@ class ListAddresses(testutil.SignalMixin, unittest.TestCase):
|
||||||
e.errno = errno.ENOENT
|
e.errno = errno.ENOENT
|
||||||
raise e
|
raise e
|
||||||
self.patch(subprocess, 'Popen', call_Popen)
|
self.patch(subprocess, 'Popen', call_Popen)
|
||||||
|
self.patch(os.path, 'isfile', lambda x: True)
|
||||||
|
|
||||||
def call_get_local_ip_for(target):
|
def call_get_local_ip_for(target):
|
||||||
if target in ("localhost", "127.0.0.1"):
|
if target in ("localhost", "127.0.0.1"):
|
||||||
|
|
|
@ -190,6 +190,8 @@ def _synchronously_find_addresses_via_config():
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _query(path, args, regex):
|
def _query(path, args, regex):
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
return []
|
||||||
env = {'LANG': 'en_US.UTF-8'}
|
env = {'LANG': 'en_US.UTF-8'}
|
||||||
TRIES = 5
|
TRIES = 5
|
||||||
for trial in xrange(TRIES):
|
for trial in xrange(TRIES):
|
||||||
|
|
Loading…
Reference in New Issue