mirror of
https://github.com/opnsense/src.git
synced 2026-06-04 22:32:43 -04:00
Canonicize the host name before looking it up in the host file.
Sponsored by: DARPA, NAI Labs
This commit is contained in:
parent
5b400a39b8
commit
bf2e2524a2
1 changed files with 19 additions and 1 deletions
|
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: ssh.c,v 1.179 2002/06/12 01:09:52 markus Exp $");
|
RCSID("$OpenBSD: ssh.c,v 1.179 2002/06/12 01:09:52 markus Exp $");
|
||||||
|
RCSID("$FreeBSD$");
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
|
@ -242,7 +243,7 @@ main(int ac, char **av)
|
||||||
/* Get user data. */
|
/* Get user data. */
|
||||||
pw = getpwuid(original_real_uid);
|
pw = getpwuid(original_real_uid);
|
||||||
if (!pw) {
|
if (!pw) {
|
||||||
log("You don't exist, go away!");
|
log("unknown user %d", original_real_uid);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
/* Take a copy of the returned structure. */
|
/* Take a copy of the returned structure. */
|
||||||
|
|
@ -600,6 +601,23 @@ again:
|
||||||
if (options.hostname != NULL)
|
if (options.hostname != NULL)
|
||||||
host = options.hostname;
|
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. */
|
/* Disable rhosts authentication if not running as root. */
|
||||||
#ifdef HAVE_CYGWIN
|
#ifdef HAVE_CYGWIN
|
||||||
/* Ignore uid if running under Windows */
|
/* Ignore uid if running under Windows */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue