Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f362d10

Browse filesBrowse files
committed
Fixed 'Inappropriate ioctl for device' problem on posix systems
1 parent 6e86f8a commit f362d10
Copy full SHA for f362d10

1 file changed

+14-7Lines changed: 14 additions & 7 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/util.py‎

Copy file name to clipboardExpand all lines: git/util.py
+14-7Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
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

145147
def 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

155162
def is_git_dir(d):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.