summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2017-03-08 10:48:52 +0100
committerAndreas Schneider <asn@cryptomilk.org>2017-03-10 11:37:21 +0100
commit65228925ab3c4da4ae299f77cae219fc7d37cc68 (patch)
tree4e0d3cb3bd2c1b858a42cff63ad54c490b52e655 /lib
parent946f9dd1170be63b91e31ce825ea123f3c07329b (diff)
downloadsamba-65228925ab3c4da4ae299f77cae219fc7d37cc68.tar.gz
krb5_wrap: Try to guess the correct realm from the service hostname
If we do not get a realm mapping from the krb5.conf or from the Kerberos library try to guess it from the service hostname. The guessing of the realm from the service hostname is already implemented in Heimdal. This makes the behavior of smb_krb5_get_realm_from_hostname() consistent with both MIT and Heimdal. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12554 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Andreas Schneider <asn@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/krb5_wrap/krb5_samba.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c
index 780a7a4adf5..92af8c60979 100644
--- a/lib/krb5_wrap/krb5_samba.c
+++ b/lib/krb5_wrap/krb5_samba.c
@@ -2719,6 +2719,19 @@ static char *smb_krb5_get_realm_from_hostname(TALLOC_CTX *mem_ctx,
realm_list[0] != NULL &&
realm_list[0][0] != '\0') {
realm = talloc_strdup(mem_ctx, realm_list[0]);
+ } else {
+ const char *p = NULL;
+
+ /*
+ * "dc6.samba2003.example.com"
+ * returns a realm of "SAMBA2003.EXAMPLE.COM"
+ *
+ * "dc6." returns realm as NULL
+ */
+ p = strchr_m(hostname, '.');
+ if (p != NULL && p[1] != '\0') {
+ realm = talloc_strdup_upper(mem_ctx, p + 1);
+ }
}
out: