[tor-commits] [stem/master] Making lsof cwd checks account for permissions
atagar at torproject.org
atagar at torproject.org
Thu Jan 12 18:13:56 UTC 2012
commit 479a620ee8d3351e07d1bc86bec3f1107c04cc69
Author: Damian Johnson <atagar at torproject.org>
Date: Thu Jan 12 09:17:20 2012 -0800
Making lsof cwd checks account for permissions
With the anti-debugger tor change the /proc/<pid>/cwd symlink becomes only
readable by root. This causes lsof queries for a process' cwd to return the
proc path with a message saying that permission is denied, and the sys tools
misparsed that as meaning that the cwd _was_ the proc path.
---
stem/util/system.py | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/stem/util/system.py b/stem/util/system.py
index 8eced97..f58f698 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -451,7 +451,13 @@ def get_cwd(pid):
results = call(GET_CWD_LSOF % pid)
if results and len(results) == 2 and results[1].startswith("n/"):
- return results[1][1:].strip()
+ lsof_result = results[1][1:].strip()
+
+ # If we lack read permissions for the cwd then it returns...
+ # p2683
+ # n/proc/2683/cwd (readlink: Permission denied)
+
+ if not " " in lsof_result: return lsof_result
else:
log.debug("%s we got unexpected output from lsof: %s" % (logging_prefix, results))
More information about the tor-commits
mailing list