mirror of
https://github.com/sheumann/telnetd.git
synced 2024-06-08 03:29:28 +00:00
sync with usr.bin/telnet/commands.c 1.21 -> 1.22. pierre.dampure@alveley.org
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@62773 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
This commit is contained in:
parent
5137153b86
commit
79d0212f03
|
@ -2468,7 +2468,19 @@ tn(argc, argv)
|
||||||
hints.ai_family = family;
|
hints.ai_family = family;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
error = getaddrinfo(hostname, portp, &hints, &res);
|
error = getaddrinfo(hostname, portp, &hints, &res);
|
||||||
if (error == 0) {
|
if (error) {
|
||||||
|
hints.ai_flags = AI_CANONNAME;
|
||||||
|
error = getaddrinfo(hostname, portp, &hints, &res);
|
||||||
|
}
|
||||||
|
if (error != 0) {
|
||||||
|
fprintf(stderr, "%s: %s\n", hostname, gai_strerror(error));
|
||||||
|
if (error == EAI_SYSTEM)
|
||||||
|
fprintf(stderr, "%s: %s\n", hostname, strerror(errno));
|
||||||
|
setuid(getuid());
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (hints.ai_flags == AI_NUMERICHOST) {
|
||||||
|
/* hostname has numeric */
|
||||||
int gni_err = 1;
|
int gni_err = 1;
|
||||||
|
|
||||||
if (doaddrlookup)
|
if (doaddrlookup)
|
||||||
|
@ -2476,19 +2488,11 @@ tn(argc, argv)
|
||||||
_hostname, sizeof(_hostname) - 1, NULL, 0,
|
_hostname, sizeof(_hostname) - 1, NULL, 0,
|
||||||
NI_NAMEREQD);
|
NI_NAMEREQD);
|
||||||
if (gni_err != 0)
|
if (gni_err != 0)
|
||||||
(void) strncpy(_hostname, hostp, sizeof(_hostname) - 1);
|
(void) strncpy(_hostname, hostp, sizeof(_hostname) - 1);
|
||||||
_hostname[sizeof(_hostname)-1] = '\0';
|
_hostname[sizeof(_hostname)-1] = '\0';
|
||||||
hostname = _hostname;
|
hostname = _hostname;
|
||||||
} else if (error == EAI_NONAME) {
|
} else {
|
||||||
hints.ai_flags = AI_CANONNAME;
|
/* hostname has FQDN */
|
||||||
error = getaddrinfo(hostname, portp, &hints, &res);
|
|
||||||
if (error != 0) {
|
|
||||||
fprintf(stderr, "%s: %s\n", hostname, gai_strerror(error));
|
|
||||||
if (error == EAI_SYSTEM)
|
|
||||||
fprintf(stderr, "%s: %s\n", hostname, strerror(errno));
|
|
||||||
setuid(getuid());
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (srcroute != 0)
|
if (srcroute != 0)
|
||||||
(void) strncpy(_hostname, hostname, sizeof(_hostname) - 1);
|
(void) strncpy(_hostname, hostname, sizeof(_hostname) - 1);
|
||||||
else if (res->ai_canonname != NULL)
|
else if (res->ai_canonname != NULL)
|
||||||
|
@ -2497,12 +2501,6 @@ tn(argc, argv)
|
||||||
(void) strncpy(_hostname, hostp, sizeof(_hostname) - 1);
|
(void) strncpy(_hostname, hostp, sizeof(_hostname) - 1);
|
||||||
_hostname[sizeof(_hostname)-1] = '\0';
|
_hostname[sizeof(_hostname)-1] = '\0';
|
||||||
hostname = _hostname;
|
hostname = _hostname;
|
||||||
} else if (error != 0) {
|
|
||||||
fprintf(stderr, "%s: %s\n", hostname, gai_strerror(error));
|
|
||||||
if (error == EAI_SYSTEM)
|
|
||||||
fprintf(stderr, "%s: %s\n", hostname, strerror(errno));
|
|
||||||
setuid(getuid());
|
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
res0 = res;
|
res0 = res;
|
||||||
af_again:
|
af_again:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user