diff options
author | Andreas Schneider <asn@samba.org> | 2017-03-08 11:56:30 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2017-03-10 11:37:21 +0100 |
commit | f0c4fcace586197d5c170f6a9dcc175df23e3802 (patch) | |
tree | ebbab297575e3906e773e56c2ce3e4e299fc9482 /lib/krb5_wrap | |
parent | 65228925ab3c4da4ae299f77cae219fc7d37cc68 (diff) | |
download | samba-f0c4fcace586197d5c170f6a9dcc175df23e3802.tar.gz |
krb5_wrap: pass client_realm to smb_krb5_get_realm_from_hostname()
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/krb5_wrap')
-rw-r--r-- | lib/krb5_wrap/krb5_samba.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c index 92af8c60979..c2d0d7263cb 100644 --- a/lib/krb5_wrap/krb5_samba.c +++ b/lib/krb5_wrap/krb5_samba.c @@ -2688,7 +2688,8 @@ static char *smb_krb5_get_default_realm_from_ccache(TALLOC_CTX *mem_ctx) ************************************************************************/ static char *smb_krb5_get_realm_from_hostname(TALLOC_CTX *mem_ctx, - const char *hostname) + const char *hostname, + const char *client_realm) { #if defined(HAVE_KRB5_REALM_TYPE) /* Heimdal. */ @@ -2719,6 +2720,9 @@ 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]); + if (realm == NULL) { + goto out; + } } else { const char *p = NULL; @@ -2731,9 +2735,16 @@ static char *smb_krb5_get_realm_from_hostname(TALLOC_CTX *mem_ctx, p = strchr_m(hostname, '.'); if (p != NULL && p[1] != '\0') { realm = talloc_strdup_upper(mem_ctx, p + 1); + if (realm == NULL) { + goto out; + } } } + if (realm == NULL) { + realm = talloc_strdup(mem_ctx, client_realm); + } + out: if (ctx) { @@ -2776,7 +2787,8 @@ char *smb_krb5_get_principal_from_service_hostname(TALLOC_CTX *mem_ctx, if (host) { /* DNS name. */ realm = smb_krb5_get_realm_from_hostname(talloc_tos(), - remote_name); + remote_name, + default_realm); } else { /* NetBIOS name - use our realm. */ realm = smb_krb5_get_default_realm_from_ccache(talloc_tos()); |