[tor-commits] [arm/master] Using stem's function for getting tor's user

atagar at torproject.org atagar at torproject.org
Sat Jun 1 01:06:18 UTC 2013


commit 4556f896532aeb41a516431457ceeb18d9d700a8
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri May 31 08:43:07 2013 -0700

    Using stem's function for getting tor's user
    
    Dropping our code for getting the user tor is running as in favor of stem's
    method.
---
 src/util/torTools.py |   23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/src/util/torTools.py b/src/util/torTools.py
index 410afd3..353ad25 100644
--- a/src/util/torTools.py
+++ b/src/util/torTools.py
@@ -1239,28 +1239,7 @@ class Controller:
             result = line[2:].split()
             break
       elif key == "user":
-        # provides the empty string if the query fails
-        queriedUser = self.getInfo("process/user", None)
-        
-        if queriedUser != None and queriedUser != "":
-          result = queriedUser
-        else:
-          myPid = self.controller.get_pid(None)
-          
-          if myPid:
-            # if proc contents are available then fetch the pid from there and
-            # convert it to the username
-            if proc.is_available():
-              try:
-                myUid = proc.get_uid(myPid)
-                if myUid and myUid.isdigit():
-                  result = pwd.getpwuid(int(myUid)).pw_name
-              except: pass
-            
-            # fall back to querying via ps
-            if not result:
-              psResults = system.call("ps -o user %s" % myPid)
-              if psResults and len(psResults) >= 2: result = psResults[1].strip()
+        result = self.controller.get_user(None)
       elif key == "fdLimit":
         # provides -1 if the query fails
         queriedLimit = self.getInfo("process/descriptor-limit", None)





More information about the tor-commits mailing list