summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-12-15 08:19:56 +1100
committerMaxime Coste <mawww@kakoune.org>2017-12-15 08:19:56 +1100
commitd8dc7d7f3941fdd02adc5b9a91ef89665eeca1d9 (patch)
treebd3c1c58dff3870660951cec981ec3c7f1674b59 /src
parentcafecda230c974a50ee200c5047fa76a096d1474 (diff)
Go back to getpwuid call to get user name from user id
Unfortunately, reading /etc/passwd is not enough.
Diffstat (limited to 'src')
-rw-r--r--src/remote.cc16
1 files changed, 0 insertions, 16 deletions
diff --git a/src/remote.cc b/src/remote.cc
index 0539c026..12313d83 100644
--- a/src/remote.cc
+++ b/src/remote.cc
@@ -530,23 +530,7 @@ void RemoteUI::exit(int status)
String get_user_name(int uid)
{
-#if defined(__APPLE__)
return getpwuid(uid)->pw_name;
-#else // Do not use getpwuid to avoid dependency on dynamic glibc
- struct invalid_index : runtime_error
- {
- invalid_index(size_t i) : runtime_error{format("invalid index '{}'", i)} {}
- };
-
- MappedFile passwd{"/etc/passwd"};
- for (auto entry : (StringView)passwd | split<StringView>('\n'))
- {
- auto name_and_id = entry | split<StringView>(':') | elements<invalid_index, 0, 2>();
- if (str_to_int(name_and_id[1]) == uid)
- return name_and_id[0].str();
- }
- throw runtime_error(format("Cannot find user name for uid '{}'", uid));
-#endif
}
static sockaddr_un session_addr(StringView session)