|
20 | 20 | SlidingWindowMapManager, |
21 | 21 | SlidingWindowMapBuffer |
22 | 22 | ) |
23 | | - |
| 23 | +# Import the user database on unix based systems |
| 24 | +ifos.name=="posix": |
| 25 | +importpwd |
24 | 26 |
|
25 | 27 |
|
26 | 28 | __all__= ("stream_copy","join_path","to_native_path_windows","to_native_path_linux", |
@@ -144,12 +146,17 @@ def __getslice__(self, start, end): |
144 | 146 |
|
145 | 147 | defget_user_id(): |
146 | 148 | """: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 | | -ifusername==uknandhasattr(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 | +ifos.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 | +ifusername==uknandhasattr(os,'getlogin'): |
| 158 | +username=os.getlogin() |
| 159 | +# END get username from login |
153 | 160 | return"%s@%s"% (username,platform.node()) |
154 | 161 |
|
155 | 162 | defis_git_dir(d): |
|