diff options
| author | Damian Johnson <atagar@torproject.org> | 2014-12-07 11:48:30 -0800 |
|---|---|---|
| committer | Damian Johnson <atagar@torproject.org> | 2014-12-07 12:36:06 -0800 |
| commit | 500fd38a7d09e883257d84dd67bc7014f4f47085 (patch) | |
| tree | 5b21e9093e9152ce6cf9e01a35c1c03feee8b0ba | |
| parent | 4e2473d98c88399d1fd00e4c92ae215c092188b7 (diff) | |
Check for /proc read permissions when determining if it's available
On Gentoo proc permissions are locked down, causing our tests to fail...
======================================================================
ERROR: test_get_connections
----------------------------------------------------------------------
Traceback (most recent call last):
File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/test/integ/util/connection.py", line 27, in test_get_connections
connections = get_connections(resolver, process_pid = tor_pid)
File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/stem/util/connection.py", line 177, in get_connections
return [Connection(*conn) for conn in stem.util.proc.connections(process_pid)]
File "/var/tmp/portage/net-libs/stem-1.2.2_p20141208/work/stem-1.2.2_p20141208/stem/util/proc.py", line 404, in connections
raise exc
IOError: unable to read '/proc/net/tcp': [Errno 13] Permission denied: '/proc/net/tcp'
----------------------------------------------------------------------
I'm tempted to change our 'is proc available?' check, but the platform only
restricts /proc/net/*, so only doing this for connection resolution.
| -rw-r--r-- | stem/util/connection.py | 2 | ||||
| -rw-r--r-- | test/integ/util/proc.py | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/stem/util/connection.py b/stem/util/connection.py index f5ca3f4d..c94b6fe9 100644 --- a/stem/util/connection.py +++ b/stem/util/connection.py @@ -272,7 +272,7 @@ def system_resolvers(system = None): # proc resolution, by far, outperforms the others so defaults to this is able - if stem.util.proc.is_available(): + if stem.util.proc.is_available() and os.access('/proc/net/tcp', os.R_OK) and os.access('/proc/net/udp', os.R_OK): resolvers = [Resolver.PROC] + resolvers return resolvers diff --git a/test/integ/util/proc.py b/test/integ/util/proc.py index cad0114b..10479128 100644 --- a/test/integ/util/proc.py +++ b/test/integ/util/proc.py @@ -90,6 +90,9 @@ class TestProc(unittest.TestCase): elif not test.runner.get_runner().is_ptraceable(): test.runner.skip(self, '(DisableDebuggerAttachment is set)') return + elif not os.access('/proc/net/tcp', os.R_OK) or not os.access('/proc/net/udp', os.R_OK): + test.runner.skip(self, '(proc lacks read permissions)') + return # making a controller connection so that we have something to query for with runner.get_tor_socket(): |
