[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Don't convert every proc uid to ints



commit d6c7996c4905756ff12e13ac01ac61f5b39368f6
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Sep 24 10:53:57 2017 -0700

    Don't convert every proc uid to ints
    
    The uid is only used for a simple comparison. Might as well convert what we're
    looking for to an str rather than every entry to an int.
---
 stem/util/proc.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/stem/util/proc.py b/stem/util/proc.py
index 59681160..85f728a2 100644
--- a/stem/util/proc.py
+++ b/stem/util/proc.py
@@ -369,7 +369,7 @@ def connections(pid = None, user = None):
       raise IOError("This requires python's pwd module, which is unavailable on Windows.")
 
     inodes = _inodes_for_sockets(pid) if pid else set()
-    process_uid = pwd.getpwnam(user).pw_uid if user else None
+    process_uid = str(pwd.getpwnam(user).pw_uid) if user else None
 
     for proc_file_path in ('/proc/net/tcp', '/proc/net/tcp6', '/proc/net/udp', '/proc/net/udp6'):
       if proc_file_path.endswith('6') and not os.path.exists(proc_file_path):
@@ -387,7 +387,7 @@ def connections(pid = None, user = None):
 
             if inodes and inode not in inodes:
               continue
-            elif process_uid and int(uid) != process_uid:
+            elif process_uid and uid != process_uid:
               continue
             elif protocol == 'tcp' and status != b'01':
               continue  # skip tcp connections that aren't yet established

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits