Skip to content

Commit

Permalink
Merge pull request #43 from aws/hostname_limit
Browse files Browse the repository at this point in the history
Handle domain name length for host machine
  • Loading branch information
saikiranakula-amzn authored Mar 25, 2023
2 parents 528b111 + 8bc5903 commit d030c13
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
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

0 comments on commit d030c13

Please sign in to comment.