Backout completely canonical lookup modifications.
This commit is contained in:
parent
31255c78c7
commit
1f5ce8f412
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=76226
@ -567,6 +567,22 @@ main(int ac, char **av)
|
||||
if (options.hostname != NULL)
|
||||
host = options.hostname;
|
||||
|
||||
/* Find canonic host name. */
|
||||
if (strchr(host, '.') == 0) {
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *ai = NULL;
|
||||
int errgai;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = IPv4or6;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
errgai = getaddrinfo(host, NULL, &hints, &ai);
|
||||
if (errgai == 0) {
|
||||
if (ai->ai_canonname != NULL)
|
||||
host = xstrdup(ai->ai_canonname);
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
}
|
||||
/* Disable rhosts authentication if not running as root. */
|
||||
if (original_effective_uid != 0 || !options.use_privileged_port) {
|
||||
options.rhosts_authentication = 0;
|
||||
@ -598,7 +614,7 @@ main(int ac, char **av)
|
||||
* if rhosts_{rsa_}authentication is enabled.
|
||||
*/
|
||||
|
||||
ok = ssh_connect(&host, &hostaddr, options.port,
|
||||
ok = ssh_connect(host, &hostaddr, options.port,
|
||||
options.connection_attempts,
|
||||
!options.rhosts_authentication &&
|
||||
!options.rhosts_rsa_authentication,
|
||||
|
@ -285,7 +285,7 @@ void record_logout(pid_t pid, const char *ttyname);
|
||||
* packet_set_connection for the connection.
|
||||
*/
|
||||
int
|
||||
ssh_connect(char **host, struct sockaddr_storage * hostaddr,
|
||||
ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
|
||||
u_short port, int connection_attempts,
|
||||
int anonymous, uid_t original_real_uid,
|
||||
const char *proxy_command);
|
||||
|
@ -173,7 +173,6 @@ ssh_create_socket(uid_t original_real_uid, int privileged, int family)
|
||||
|
||||
/*
|
||||
* Opens a TCP/IP connection to the remote server on the given host.
|
||||
* The canonical host name used to connect will be returned in *host.
|
||||
* The address of the remote host will be returned in hostaddr.
|
||||
* If port is 0, the default port will be used. If anonymous is zero,
|
||||
* a privileged port will be allocated to make the connection.
|
||||
@ -184,7 +183,7 @@ ssh_create_socket(uid_t original_real_uid, int privileged, int family)
|
||||
* the daemon.
|
||||
*/
|
||||
int
|
||||
ssh_connect(char **host, struct sockaddr_storage * hostaddr,
|
||||
ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
|
||||
u_short port, int connection_attempts,
|
||||
int anonymous, uid_t original_real_uid,
|
||||
const char *proxy_command)
|
||||
@ -209,17 +208,16 @@ ssh_connect(char **host, struct sockaddr_storage * hostaddr,
|
||||
}
|
||||
/* If a proxy command is given, connect using it. */
|
||||
if (proxy_command != NULL)
|
||||
return ssh_proxy_connect(*host, port, original_real_uid, proxy_command);
|
||||
return ssh_proxy_connect(host, port, original_real_uid, proxy_command);
|
||||
|
||||
/* No proxy command. */
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = IPv4or6;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
snprintf(strport, sizeof strport, "%d", port);
|
||||
if ((gaierr = getaddrinfo(*host, strport, &hints, &aitop)) != 0)
|
||||
fatal("%s: %.100s: %s", __progname, *host,
|
||||
if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
|
||||
fatal("%s: %.100s: %s", __progname, host,
|
||||
gai_strerror(gaierr));
|
||||
|
||||
/*
|
||||
@ -243,7 +241,7 @@ ssh_connect(char **host, struct sockaddr_storage * hostaddr,
|
||||
continue;
|
||||
}
|
||||
debug("Connecting to %.200s [%.100s] port %s.",
|
||||
ai->ai_canonname, ntop, strport);
|
||||
host, ntop, strport);
|
||||
|
||||
/* Create a socket for connecting. */
|
||||
sock = ssh_create_socket(original_real_uid,
|
||||
@ -275,13 +273,8 @@ ssh_connect(char **host, struct sockaddr_storage * hostaddr,
|
||||
close(sock);
|
||||
}
|
||||
}
|
||||
if (ai) {
|
||||
#if 0
|
||||
if (ai->ai_canonname != NULL)
|
||||
*host = xstrdup(ai->ai_canonname);
|
||||
#endif
|
||||
if (ai)
|
||||
break; /* Successful connection. */
|
||||
}
|
||||
|
||||
/* Sleep a moment before retrying. */
|
||||
sleep(1);
|
||||
|
Loading…
Reference in New Issue
Block a user