#810741 gsasl: produces unhelpful error message on Kerberos failure

Package:
gsasl
Source:
gsasl
Description:
GNU SASL command line utility
Submitter:
Michael Gold
Date:
2020-11-25 21:27:04 UTC
Severity:
normal
#810741#5
Date:
2016-01-11 20:10:00 UTC
From:
To:
As I noted in Debian bug #810727, I need to use the proper hostname to
connect to my SMTP server; otherwise Kerberos authentication will fail.
But this wasn't easy to figure out, as the message returned by msmtp is
kind of useless (it seems to just print whatever text is returned by GNU
SASL):
	msmtp: GNU SASL: GSSAPI error in client while negotiating security
	context in gss_init_sec_context() in SASL library.  This is most
	likely due insufficient credentials or malicious interactions.

This makes it seem like I used a bad password or the SMTP server didn't
like the ticket.  In fact, the Kerberos server didn't recognise the
hostname, and according to a Wireshark dump returned a perfectly clear
error message:
	krb-error
		pvno: 5
		msg-type: krb-error (30)
		stime: 2016-01-11 16:08:01 (UTC)
		susec: 299239
		error-code: eRR-S-PRINCIPAL-UNKNOWN (7)
		realm: EXAMPLE.COM
		sname
			name-type: kRB5-NT-SRV-HST (3)
			name-string: 2 items
				KerberosString: smtp
				KerberosString: smtp-server.EXAMPLE.COM

I suggest a message like the following, based on the libkrb5 text:
	"Server not found in Kerberos database:
	 smtp/smtp-server.example.com@EXAMPLE.COM"

- Michael

#810741#10
Date:
2020-11-25 21:01:33 UTC
From:
To:
Hi,

First read https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810741 for
context if you forgot about this report.

I agree the messages is unhelpful, but I don't know how to improve it.
Libgsasl uses Kerberos via GSS-API, so I can't access or see the libkrb5
error codes -- maybe someone knows of a way to read out useful error
messages via GSS-API?  Some experimentation is probably needed.  So help
wanted to improve this.

/Simon