MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getUserName

Function getUserName

src/Common/assertProcessUserMatchesDataOwner.cpp:20–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace
19{
20 std::string getUserName(uid_t user_id)
21 {
22 /// Try to convert user id into user name.
23 auto buffer_size = sysconf(_SC_GETPW_R_SIZE_MAX);
24 if (buffer_size <= 0)
25 buffer_size = 1024;
26 std::string buffer;
27 buffer.reserve(buffer_size);
28
29 struct passwd passwd_entry{};
30 struct passwd * result = nullptr;
31 const auto error = getpwuid_r(user_id, &passwd_entry, buffer.data(), buffer_size, &result);
32
33 if (error)
34 ErrnoException::throwWithErrno(
35 ErrorCodes::FAILED_TO_GETPWUID, error, "Failed to find user name for {}", std::to_string(user_id));
36 else if (result)
37 return result->pw_name;
38 return std::to_string(user_id);
39 }
40}
41
42void assertProcessUserMatchesDataOwner(const std::string & path, std::function<void(const PreformattedMessage &)> on_warning)

Callers 7

usedMethod · 0.85
usedPerNormalizedHashMethod · 0.85
usedForQueryMethod · 0.85
checkExceededMethod · 0.85
getRowPolicyFilterMethod · 0.85
checkAccessImplHelperMethod · 0.85

Calls 3

to_stringFunction · 0.50
reserveMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected