Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix domain name length for host machine #43

Merged
merged 3 commits into from
Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion auth/kerberos/src/krb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// renew the ticket 1 hrs before the expiration
#define RENEW_TICKET_HOURS 1
#define SECONDS_IN_HOUR 3600
// Active Directory uses NetBIOS computer names that do not exceed 15 characters.
// https://learn.microsoft.com/en-us/troubleshoot/windows-server/identity/naming-conventions-for-computer-domain-site-ou
#define HOST_NAME_LENGTH_LIMIT 15

static const std::string install_path_for_decode_exe =
"/usr/sbin/credentials_fetcher_utf16_private.exe";
Expand Down Expand Up @@ -105,11 +108,21 @@ static std::pair<int, std::string> get_machine_principal( std::string domain_nam
return result;
}

std::string host_name = hostname_result.second;

// truncate the hostname to the host name size limit defined by microsoft
if(host_name.length() > HOST_NAME_LENGTH_LIMIT){
cf_logger.logger( LOG_ERR, "WARNING: %s:%d hostname exceeds 15 characters,
"this can cause problems in getting kerberos tickets, please reduce hostname length",
__func__, __LINE__ );
host_name = host_name.substr(0,HOST_NAME_LENGTH_LIMIT);
}

/**
* Machine principal is of the format EC2AMAZ-Q5VJZQ$@CONTOSO.COM'
*/
result.first = 0;
result.second = hostname_result.second + "$@" + realm_name_result.second;
result.second = host_name + "$@" + realm_name_result.second;

return result;
}
Expand Down
4 changes: 2 additions & 2 deletions package/credentials-fetcher.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Source0: https://github.com/aws/credentials-fetcher/archive/refs/tags/%{v

BuildRequires: cmake3 make chrpath openldap-clients grpc-devel gcc-c++ glib2-devel boost-devel
BuildRequires: openssl-devel zlib-devel protobuf-devel re2-devel krb5-devel systemd-devel
BuildRequires: systemd-rpm-macros dotnet grpc-plugins
BuildRequires: systemd-rpm-macros dotnet-sdk-6.0 grpc-plugins

Requires: bind-utils openldap openldap-clients awscli
Requires: bind-utils openldap openldap-clients awscli dotnet-runtime-6.0

# No one likes you i686
ExcludeArch: i686 armv7hl ppc64le
Expand Down