mirror of
git://anongit.mindrot.org/openssh.git
synced 2025-02-18 06:46:55 +00:00
- dtucker@cvs.openbsd.org 2005/11/03 13:38:29
[canohost.c] Cache reverse lookups with and without DNS separately; ok markus@
This commit is contained in:
parent
83d0d39d0e
commit
24ecf61261
@ -90,6 +90,9 @@
|
|||||||
- jmc@cvs.openbsd.org 2005/10/31 19:55:25
|
- jmc@cvs.openbsd.org 2005/10/31 19:55:25
|
||||||
[ssh-keygen.1]
|
[ssh-keygen.1]
|
||||||
grammar;
|
grammar;
|
||||||
|
- dtucker@cvs.openbsd.org 2005/11/03 13:38:29
|
||||||
|
[canohost.c]
|
||||||
|
Cache reverse lookups with and without DNS separately; ok markus@
|
||||||
|
|
||||||
20051102
|
20051102
|
||||||
- (dtucker) [openbsd-compat/bsd-misc.c] Bug #1108: fix broken strdup().
|
- (dtucker) [openbsd-compat/bsd-misc.c] Bug #1108: fix broken strdup().
|
||||||
@ -3223,4 +3226,4 @@
|
|||||||
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
||||||
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.3949 2005/11/05 04:16:27 djm Exp $
|
$Id: ChangeLog,v 1.3950 2005/11/05 04:16:52 djm Exp $
|
||||||
|
27
canohost.c
27
canohost.c
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: canohost.c,v 1.46 2005/10/30 08:29:29 dtucker Exp $");
|
RCSID("$OpenBSD: canohost.c,v 1.47 2005/11/03 13:38:29 dtucker Exp $");
|
||||||
|
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
@ -198,26 +198,27 @@ ipv64_normalise_mapped(struct sockaddr_storage *addr, socklen_t *len)
|
|||||||
const char *
|
const char *
|
||||||
get_canonical_hostname(int use_dns)
|
get_canonical_hostname(int use_dns)
|
||||||
{
|
{
|
||||||
|
char *host;
|
||||||
static char *canonical_host_name = NULL;
|
static char *canonical_host_name = NULL;
|
||||||
static int use_dns_done = 0;
|
static char *remote_ip = NULL;
|
||||||
|
|
||||||
/* Check if we have previously retrieved name with same option. */
|
/* Check if we have previously retrieved name with same option. */
|
||||||
if (canonical_host_name != NULL) {
|
if (use_dns && canonical_host_name != NULL)
|
||||||
if (use_dns_done != use_dns)
|
return canonical_host_name;
|
||||||
xfree(canonical_host_name);
|
if (!use_dns && remote_ip != NULL)
|
||||||
else
|
return remote_ip;
|
||||||
return canonical_host_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the real hostname if socket; otherwise return UNKNOWN. */
|
/* Get the real hostname if socket; otherwise return UNKNOWN. */
|
||||||
if (packet_connection_is_on_socket())
|
if (packet_connection_is_on_socket())
|
||||||
canonical_host_name = get_remote_hostname(
|
host = get_remote_hostname(packet_get_connection_in(), use_dns);
|
||||||
packet_get_connection_in(), use_dns);
|
|
||||||
else
|
else
|
||||||
canonical_host_name = xstrdup("UNKNOWN");
|
host = "UNKNOWN";
|
||||||
|
|
||||||
use_dns_done = use_dns;
|
if (use_dns)
|
||||||
return canonical_host_name;
|
canonical_host_name = host;
|
||||||
|
else
|
||||||
|
remote_ip = host;
|
||||||
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
36
serverloop.c
36
serverloop.c
@ -35,7 +35,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: serverloop.c,v 1.120 2005/10/30 08:52:17 djm Exp $");
|
RCSID("$OpenBSD: serverloop.c,v 1.121 2005/10/31 11:48:29 djm Exp $");
|
||||||
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
@ -61,6 +61,7 @@ extern ServerOptions options;
|
|||||||
/* XXX */
|
/* XXX */
|
||||||
extern Kex *xxx_kex;
|
extern Kex *xxx_kex;
|
||||||
extern Authctxt *the_authctxt;
|
extern Authctxt *the_authctxt;
|
||||||
|
extern int use_privsep;
|
||||||
|
|
||||||
static Buffer stdin_buffer; /* Buffer for stdin data. */
|
static Buffer stdin_buffer; /* Buffer for stdin data. */
|
||||||
static Buffer stdout_buffer; /* Buffer for stdout data. */
|
static Buffer stdout_buffer; /* Buffer for stdout data. */
|
||||||
@ -90,6 +91,9 @@ static int client_alive_timeouts = 0;
|
|||||||
|
|
||||||
static volatile sig_atomic_t child_terminated = 0; /* The child has terminated. */
|
static volatile sig_atomic_t child_terminated = 0; /* The child has terminated. */
|
||||||
|
|
||||||
|
/* Cleanup on signals (!use_privsep case only) */
|
||||||
|
static volatile sig_atomic_t received_sigterm = 0;
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
static void server_init_dispatch(void);
|
static void server_init_dispatch(void);
|
||||||
|
|
||||||
@ -151,6 +155,12 @@ sigchld_handler(int sig)
|
|||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sigterm_handler(int sig)
|
||||||
|
{
|
||||||
|
received_sigterm = sig;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make packets from buffered stderr data, and buffer it for sending
|
* Make packets from buffered stderr data, and buffer it for sending
|
||||||
* to the client.
|
* to the client.
|
||||||
@ -502,6 +512,12 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
|
|||||||
child_terminated = 0;
|
child_terminated = 0;
|
||||||
mysignal(SIGCHLD, sigchld_handler);
|
mysignal(SIGCHLD, sigchld_handler);
|
||||||
|
|
||||||
|
if (!use_privsep) {
|
||||||
|
signal(SIGTERM, sigterm_handler);
|
||||||
|
signal(SIGINT, sigterm_handler);
|
||||||
|
signal(SIGQUIT, sigterm_handler);
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize our global variables. */
|
/* Initialize our global variables. */
|
||||||
fdin = fdin_arg;
|
fdin = fdin_arg;
|
||||||
fdout = fdout_arg;
|
fdout = fdout_arg;
|
||||||
@ -629,6 +645,12 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
|
|||||||
wait_until_can_do_something(&readset, &writeset, &max_fd,
|
wait_until_can_do_something(&readset, &writeset, &max_fd,
|
||||||
&nalloc, max_time_milliseconds);
|
&nalloc, max_time_milliseconds);
|
||||||
|
|
||||||
|
if (received_sigterm) {
|
||||||
|
logit("Exiting on signal %d", received_sigterm);
|
||||||
|
/* Clean up sessions, utmp, etc. */
|
||||||
|
cleanup_exit(255);
|
||||||
|
}
|
||||||
|
|
||||||
/* Process any channel events. */
|
/* Process any channel events. */
|
||||||
channel_after_select(readset, writeset);
|
channel_after_select(readset, writeset);
|
||||||
|
|
||||||
@ -749,6 +771,12 @@ server_loop2(Authctxt *authctxt)
|
|||||||
connection_in = packet_get_connection_in();
|
connection_in = packet_get_connection_in();
|
||||||
connection_out = packet_get_connection_out();
|
connection_out = packet_get_connection_out();
|
||||||
|
|
||||||
|
if (!use_privsep) {
|
||||||
|
signal(SIGTERM, sigterm_handler);
|
||||||
|
signal(SIGINT, sigterm_handler);
|
||||||
|
signal(SIGQUIT, sigterm_handler);
|
||||||
|
}
|
||||||
|
|
||||||
notify_setup();
|
notify_setup();
|
||||||
|
|
||||||
max_fd = MAX(connection_in, connection_out);
|
max_fd = MAX(connection_in, connection_out);
|
||||||
@ -766,6 +794,12 @@ server_loop2(Authctxt *authctxt)
|
|||||||
wait_until_can_do_something(&readset, &writeset, &max_fd,
|
wait_until_can_do_something(&readset, &writeset, &max_fd,
|
||||||
&nalloc, 0);
|
&nalloc, 0);
|
||||||
|
|
||||||
|
if (received_sigterm) {
|
||||||
|
logit("Exiting on signal %d", received_sigterm);
|
||||||
|
/* Clean up sessions, utmp, etc. */
|
||||||
|
cleanup_exit(255);
|
||||||
|
}
|
||||||
|
|
||||||
collect_children();
|
collect_children();
|
||||||
if (!rekeying) {
|
if (!rekeying) {
|
||||||
channel_after_select(readset, writeset);
|
channel_after_select(readset, writeset);
|
||||||
|
Loading…
Reference in New Issue
Block a user