From 4168cfe85d2a99c4b0f3eeef889f3bef637cd5e2 Mon Sep 17 00:00:00 2001 From: Mats Erik Andersson Date: Fri, 17 Aug 2012 03:29:15 +0200 Subject: [PATCH] telnet: Activate principal naming. --- ChangeLog | 10 ++++++++++ libtelnet/shishi.c | 8 +++++++- telnet/commands.c | 14 +++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 356d739f..d25bdb49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2012-08-17 Mats Erik Andersson + + telnet: Selectable principal name. + + * libtelnet/shishi.c (krb5shishi_send): Add a prefix + `host/' to RemoteHostName only if a prefix is missing. + * telnet/commands.c (tn) [AUTHENTICATION || ENCRYPTION]: + Strip off any prefix from HOSTP before resolving address. + [IPV6]: Improve error message at failed resolution. + 2012-08-16 Mats Erik Andersson telnetd: Configurable principal name. diff --git a/libtelnet/shishi.c b/libtelnet/shishi.c index 1a21624e..0ffd6a98 100644 --- a/libtelnet/shishi.c +++ b/libtelnet/shishi.c @@ -173,7 +173,13 @@ krb5shishi_send (TN_Authenticator * ap) DEBUG (("telnet: Kerberos V5: shishi memory allocation failed\r\n")); return 0; } - sprintf (tmp, "host/%s", RemoteHostName); + + /* Check for Kerberos prefix in principal name. */ + if (strchr (RemoteHostName, '/')) + strcpy (tmp, RemoteHostName); + else + sprintf (tmp, "host/%s", RemoteHostName); + memset (&hint, 0, sizeof (hint)); hint.server = tmp; hint.client = UserNameRequested; diff --git a/telnet/commands.c b/telnet/commands.c index 6a1be367..b511e4ce 100644 --- a/telnet/commands.c +++ b/telnet/commands.c @@ -2555,6 +2555,18 @@ tn (int argc, char *argv[]) return 0; } +#if defined AUTHENTICATION || defined ENCRYPTION + { + /* Extract instance name of server, eliminating + * the Kerberos principal prefix. + */ + char *p = strchr (hostp, '/'); + + if (p) + hostp = ++p; + } +#endif /* AUTHENTICATION || ENCRYPTION */ + #ifdef IPV6 hints.ai_socktype = SOCK_STREAM; @@ -2568,7 +2580,7 @@ tn (int argc, char *argv[]) else errmsg = gai_strerror (err); - printf ("%s/%s: lookup failure: %s\n", hostp, portp, errmsg); + printf ("Server lookup failure: %s:%s, %s\n", hostp, portp, errmsg); return 0; }