File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change 1313import tempfile
1414import platform
1515
16+ # Import the user database on unix based systems
17+ if os .name == "posix" :
18+ import pwd
19+
1620from gitdb .util import (
1721 make_sha ,
1822 LockedFD ,
@@ -113,12 +117,17 @@ def assure_directory_exists(path, is_file=False):
113117
114118def get_user_id ():
115119 """:return: string identifying the currently active system user as name@node
116- :note: user can be set with the 'USER' environment variable, usually set on windows"""
117- ukn = 'UNKNOWN'
118- username = os .environ .get ('USER' , os .environ .get ('USERNAME' , ukn ))
119- if username == ukn and hasattr (os , 'getlogin' ):
120- username = os .getlogin ()
121- # END get username from login
120+ :note: user can be set with the 'USER' environment variable, usually set on windows
121+ :note: on unix based systems you can use the password database
122+ to get the login name of the effective process user"""
123+ if os .name == "posix" :
124+ username = pwd .getpwuid (os .geteuid ()).pw_name
125+ else :
126+ ukn = 'UNKNOWN'
127+ username = os .environ .get ('USER' , os .environ .get ('USERNAME' , ukn ))
128+ if username == ukn and hasattr (os , 'getlogin' ):
129+ username = os .getlogin ()
130+ # END get username from login
122131 return "%s@%s" % (username , platform .node ())
123132
124133#} END utilities
You can’t perform that action at this time.
0 commit comments