| 447 | } |
| 448 | |
| 449 | Status GetConfiguredPrincipal(const string& in_principal, string* out_principal) { |
| 450 | *out_principal = in_principal; |
| 451 | static const auto& kHostToken = "_HOST"; |
| 452 | if (in_principal.find(kHostToken) != string::npos) { |
| 453 | string hostname; |
| 454 | // Try to fill in either the FQDN or hostname. |
| 455 | if (!GetFQDN(&hostname).ok()) { |
| 456 | RETURN_NOT_OK(GetHostname(&hostname)); |
| 457 | } |
| 458 | // Hosts in principal names are canonicalized to lower-case. |
| 459 | std::transform(hostname.begin(), hostname.end(), hostname.begin(), tolower); |
| 460 | GlobalReplaceSubstring(kHostToken, hostname, out_principal); |
| 461 | } |
| 462 | return Status::OK(); |
| 463 | } |
| 464 | |
| 465 | optional<string> GetLoggedInPrincipalFromKeytab() { |
| 466 | if (!g_kinit_ctx) { |
no test coverage detected