File tree Expand file tree Collapse file tree
Open diff view settings
Expand file tree Collapse file tree
Open diff view settings
Original file line number Diff line number Diff line change 2020 SlidingWindowMapManager ,
2121 SlidingWindowMapBuffer
2222 )
23-
23+ # Import the user database on unix based systems
24+ if os .name == "posix" :
25+ import pwd
2426
2527
2628__all__ = ( "stream_copy" , "join_path" , "to_native_path_windows" , "to_native_path_linux" ,
@@ -144,12 +146,17 @@ def __getslice__(self, start, end):
144146
145147def get_user_id ():
146148 """:return: string identifying the currently active system user as name@node
147- :note: user can be set with the 'USER' environment variable, usually set on windows"""
148- ukn = 'UNKNOWN'
149- username = os .environ .get ('USER' , os .environ .get ('USERNAME' , ukn ))
150- if username == ukn and hasattr (os , 'getlogin' ):
151- username = os .getlogin ()
152- # END get username from login
149+ :note: user can be set with the 'USER' environment variable, usually set on windows
150+ :note: on unix based systems you can use the password database
151+ to get the login name of the effective process user"""
152+ if os .name == "posix" :
153+ username = pwd .getpwuid (os .geteuid ()).pw_name
154+ else :
155+ ukn = 'UNKNOWN'
156+ username = os .environ .get ('USER' , os .environ .get ('USERNAME' , ukn ))
157+ if username == ukn and hasattr (os , 'getlogin' ):
158+ username = os .getlogin ()
159+ # END get username from login
153160 return "%s@%s" % (username , platform .node ())
154161
155162def is_git_dir (d ):
You can’t perform that action at this time.
0 commit comments