This would discard the realm the client specified.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
service,
KRB5_NT_SRV_HST,
out);
+ if (ret == 0) {
+ const char *in_realm = krb5_principal_get_realm(context,
+ p);
+ const char *out_realm = krb5_principal_get_realm(context,
+ *out);
+
+ /*
+ * Avoid loss of information, check for the "referral
+ * realm" and set back what was specified.
+ */
+ if (out_realm != NULL && out_realm[0] == '\0') {
+ ret = krb5_principal_set_realm(context, *out, in_realm);
+ }
+ }
+
} else {
ret = krb5_copy_principal(context, p, out);
}