krb5_wrap: Make smb_krb5_get_realm_from_hostname() public
authorAndreas Schneider <asn@samba.org>
Wed, 8 Mar 2017 10:56:30 +0000 (11:56 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 10 Mar 2017 10:37:21 +0000 (11:37 +0100)
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>
lib/krb5_wrap/krb5_samba.c
lib/krb5_wrap/krb5_samba.h

index c2d0d7263cb3fdf67977e6b6c4b50546e1becf32..0bce8509ccaa57f3ee512a69195ba6422933ffa6 100644 (file)
@@ -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. */
index 71e81ea26e170e5635d5481329d9f96274d882ae..accae449a0eea68f15886fb7187edfcf4bd53c1b 100644 (file)
@@ -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,