summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2001-05-03 00:26:47 +0000
committergreen <green@FreeBSD.org>2001-05-03 00:26:47 +0000
commit6d6d6e45eef23a17436127fff2be44601092a312 (patch)
tree5ee130f185e131debec7a568084b82575a6c6b18 /crypto
parent21fd43ad54cdca636a431a0af1953fccbbdb15f0 (diff)
downloadFreeBSD-src-6d6d6e45eef23a17436127fff2be44601092a312.zip
FreeBSD-src-6d6d6e45eef23a17436127fff2be44601092a312.tar.gz
Backout completely canonical lookup modifications.
Diffstat (limited to 'crypto')
-rw-r--r--crypto/openssh/ssh.c18
-rw-r--r--crypto/openssh/ssh.h2
-rw-r--r--crypto/openssh/sshconnect.c19
3 files changed, 24 insertions, 15 deletions
diff --git a/crypto/openssh/ssh.c b/crypto/openssh/ssh.c
index c859056..7acb513 100644
--- a/crypto/openssh/ssh.c
+++ b/crypto/openssh/ssh.c
@@ -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,
diff --git a/crypto/openssh/ssh.h b/crypto/openssh/ssh.h
index 82ed914..b7ecde7 100644
--- a/crypto/openssh/ssh.h
+++ b/crypto/openssh/ssh.h
@@ -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);
diff --git a/crypto/openssh/sshconnect.c b/crypto/openssh/sshconnect.c
index 364a7c9..21ee0e6 100644
--- a/crypto/openssh/sshconnect.c
+++ b/crypto/openssh/sshconnect.c
@@ -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);
OpenPOWER on IntegriCloud