MCPcopy Create free account
hub / github.com/apache/impala / GetEffectiveShortUser

Function GetEffectiveShortUser

be/src/util/auth-util.cc:51–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51Status GetEffectiveShortUser(const TSessionState& session, std::string* short_name) {
52 const string& effective_user = GetEffectiveUser(session);
53 if (IsKerberosEnabled() && (effective_user.find('@') != std::string::npos)) {
54 // Regex to match kerberos names, based on org.apache.hadoop.security.KerberosName.
55 static const std::regex kerberos_name("([^/@]*)(/([^/@]*))*@([^/@]*)");
56 std::smatch groups;
57 if (std::regex_match(effective_user, groups, kerberos_name)) {
58 DCHECK_GE(groups.size(), 2);
59 // The first group contains the name.
60 if (!groups[1].str().empty()) {
61 *short_name = groups[1].str();
62 return Status::OK();
63 }
64 }
65 stringstream ss;
66 ss << "Could not parse Kerberos name " << effective_user;
67 return Status::Expected(ss.str());
68 } else {
69 *short_name = effective_user;
70 }
71 return Status::OK();
72}
73
74const string& GetEffectiveUser(const ImpalaServer::SessionState& session) {
75 return session.do_as_user.empty() ? session.connected_user : session.do_as_user;

Callers 5

CanAdmitQuotaMethod · 0.85
SubmitForAdmissionMethod · 0.85
TryDequeueMethod · 0.85
assertEffectiveShortUserFunction · 0.85
TESTFunction · 0.85

Calls 6

IsKerberosEnabledFunction · 0.85
OKFunction · 0.85
findMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
strMethod · 0.45

Tested by 2

assertEffectiveShortUserFunction · 0.68
TESTFunction · 0.68