From: Andreas Schneider Date: Wed, 8 Mar 2017 10:56:30 +0000 (+0100) Subject: krb5_wrap: Make smb_krb5_get_realm_from_hostname() public X-Git-Tag: tdb-1.3.13~530 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=339a2ecb3f05d0c9e860a5dd59b8bdbc51d4ffa7;p=thirdparty%2Fsamba.git krb5_wrap: Make smb_krb5_get_realm_from_hostname() public BUG: https://bugzilla.samba.org/show_bug.cgi?id=12554 Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Andreas Schneider Signed-off-by: Stefan Metzmacher --- diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c index c2d0d7263cb..0bce8509cca 100644 --- a/lib/krb5_wrap/krb5_samba.c +++ b/lib/krb5_wrap/krb5_samba.c @@ -2683,13 +2683,27 @@ static char *smb_krb5_get_default_realm_from_ccache(TALLOC_CTX *mem_ctx) return realm; } -/************************************************************************ - Routine to get the realm from a given DNS name. -************************************************************************/ - -static char *smb_krb5_get_realm_from_hostname(TALLOC_CTX *mem_ctx, - const char *hostname, - const char *client_realm) +/** + * @brief Get the realm from the service hostname. + * + * This function will look for a domain realm mapping in the [domain_realm] + * section of the krb5.conf first and fallback to extract the realm from + * the provided service hostname. As a last resort it will return the + * provided client_realm. + * + * @param[in] mem_ctx The talloc context + * + * @param[in] hostname The service hostname + * + * @param[in] client_realm If we can not find a mapping, fall back to + * this realm. + * + * @return The realm to use for the service hostname, NULL if a fatal error + * occured. + */ +char *smb_krb5_get_realm_from_hostname(TALLOC_CTX *mem_ctx, + const char *hostname, + const char *client_realm) { #if defined(HAVE_KRB5_REALM_TYPE) /* Heimdal. */ diff --git a/lib/krb5_wrap/krb5_samba.h b/lib/krb5_wrap/krb5_samba.h index 71e81ea26e1..accae449a0e 100644 --- a/lib/krb5_wrap/krb5_samba.h +++ b/lib/krb5_wrap/krb5_samba.h @@ -314,6 +314,10 @@ krb5_error_code smb_krb5_principal_set_realm(krb5_context context, krb5_principal principal, const char *realm); +char *smb_krb5_get_realm_from_hostname(TALLOC_CTX *mem_ctx, + const char *hostname, + const char *client_realm); + char *smb_krb5_get_principal_from_service_hostname(TALLOC_CTX *mem_ctx, const char *service, const char *remote_name,