If remote host name is to long to fit into utmp try to remove domain
part if it does match our local domain. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@92 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -847,9 +847,7 @@ doit(who)
|
|||||||
if (hp == NULL && registerd_host_only) {
|
if (hp == NULL && registerd_host_only) {
|
||||||
fatal(net, "Couldn't resolve your address into a host name.\r\n\
|
fatal(net, "Couldn't resolve your address into a host name.\r\n\
|
||||||
Please contact your net administrator");
|
Please contact your net administrator");
|
||||||
} else if (hp &&
|
} else if (hp) {
|
||||||
(strlen(hp->h_name) <= (unsigned int)((utmp_len < 0) ? -utmp_len
|
|
||||||
: utmp_len))) {
|
|
||||||
host = hp->h_name;
|
host = hp->h_name;
|
||||||
} else {
|
} else {
|
||||||
host = inet_ntoa(who->sin_addr);
|
host = inet_ntoa(who->sin_addr);
|
||||||
@@ -865,6 +863,27 @@ doit(who)
|
|||||||
(void) gethostname(host_name, sizeof (host_name));
|
(void) gethostname(host_name, sizeof (host_name));
|
||||||
hostname = host_name;
|
hostname = host_name;
|
||||||
|
|
||||||
|
#define abs(x) ((x < 0) ? (-x) : x)
|
||||||
|
|
||||||
|
#define TRIM_HOSTNAME
|
||||||
|
#ifdef TRIM_HOSTNAME
|
||||||
|
/* Only trim if too long (and possible) */
|
||||||
|
if (strlen(remote_host_name) > abs(utmp_len)) {
|
||||||
|
char *domain = strchr(host_name, '.');
|
||||||
|
char *p = strchr(remote_host_name, '.');
|
||||||
|
if (domain && p && (strcmp(p, domain) == 0))
|
||||||
|
*p = 0; /* remove domain part */
|
||||||
|
}
|
||||||
|
#endif /* TRIM_HOSTNAME */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If hostname still doesn't fit utmp, use ipaddr.
|
||||||
|
*/
|
||||||
|
if (strlen(remote_host_name) > abs(utmp_len))
|
||||||
|
strncpy(remote_host_name,
|
||||||
|
inet_ntoa(who->sin_addr),
|
||||||
|
sizeof(remote_host_name)-1);
|
||||||
|
|
||||||
#if defined(AUTHENTICATION) || defined(ENCRYPTION)
|
#if defined(AUTHENTICATION) || defined(ENCRYPTION)
|
||||||
auth_encrypt_init(hostname, host, "TELNETD", 1);
|
auth_encrypt_init(hostname, host, "TELNETD", 1);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user