summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--canohost.c27
-rw-r--r--serverloop.c36
3 files changed, 53 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index e4f703fe2..cefc3e0b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -90,6 +90,9 @@
90 - jmc@cvs.openbsd.org 2005/10/31 19:55:25 90 - jmc@cvs.openbsd.org 2005/10/31 19:55:25
91 [ssh-keygen.1] 91 [ssh-keygen.1]
92 grammar; 92 grammar;
93 - dtucker@cvs.openbsd.org 2005/11/03 13:38:29
94 [canohost.c]
95 Cache reverse lookups with and without DNS separately; ok markus@
93 96
9420051102 9720051102
95 - (dtucker) [openbsd-compat/bsd-misc.c] Bug #1108: fix broken strdup(). 98 - (dtucker) [openbsd-compat/bsd-misc.c] Bug #1108: fix broken strdup().
@@ -3223,4 +3226,4 @@
3223 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 3226 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
3224 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 3227 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
3225 3228
3226$Id: ChangeLog,v 1.3949 2005/11/05 04:16:27 djm Exp $ 3229$Id: ChangeLog,v 1.3950 2005/11/05 04:16:52 djm Exp $
diff --git a/canohost.c b/canohost.c
index 66867c10b..bd7f830de 100644
--- a/canohost.c
+++ b/canohost.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: canohost.c,v 1.46 2005/10/30 08:29:29 dtucker Exp $"); 15RCSID("$OpenBSD: canohost.c,v 1.47 2005/11/03 13:38:29 dtucker Exp $");
16 16
17#include "packet.h" 17#include "packet.h"
18#include "xmalloc.h" 18#include "xmalloc.h"
@@ -198,26 +198,27 @@ ipv64_normalise_mapped(struct sockaddr_storage *addr, socklen_t *len)
198const char * 198const char *
199get_canonical_hostname(int use_dns) 199get_canonical_hostname(int use_dns)
200{ 200{
201 char *host;
201 static char *canonical_host_name = NULL; 202 static char *canonical_host_name = NULL;
202 static int use_dns_done = 0; 203 static char *remote_ip = NULL;
203 204
204 /* Check if we have previously retrieved name with same option. */ 205 /* Check if we have previously retrieved name with same option. */
205 if (canonical_host_name != NULL) { 206 if (use_dns && canonical_host_name != NULL)
206 if (use_dns_done != use_dns) 207 return canonical_host_name;
207 xfree(canonical_host_name); 208 if (!use_dns && remote_ip != NULL)
208 else 209 return remote_ip;
209 return canonical_host_name;
210 }
211 210
212 /* Get the real hostname if socket; otherwise return UNKNOWN. */ 211 /* Get the real hostname if socket; otherwise return UNKNOWN. */
213 if (packet_connection_is_on_socket()) 212 if (packet_connection_is_on_socket())
214 canonical_host_name = get_remote_hostname( 213 host = get_remote_hostname(packet_get_connection_in(), use_dns);
215 packet_get_connection_in(), use_dns);
216 else 214 else
217 canonical_host_name = xstrdup("UNKNOWN"); 215 host = "UNKNOWN";
218 216
219 use_dns_done = use_dns; 217 if (use_dns)
220 return canonical_host_name; 218 canonical_host_name = host;
219 else
220 remote_ip = host;
221 return host;
221} 222}
222 223
223/* 224/*
diff --git a/serverloop.c b/serverloop.c
index 208f7e1e9..03376bacf 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: serverloop.c,v 1.120 2005/10/30 08:52:17 djm Exp $"); 38RCSID("$OpenBSD: serverloop.c,v 1.121 2005/10/31 11:48:29 djm Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "packet.h" 41#include "packet.h"
@@ -61,6 +61,7 @@ extern ServerOptions options;
61/* XXX */ 61/* XXX */
62extern Kex *xxx_kex; 62extern Kex *xxx_kex;
63extern Authctxt *the_authctxt; 63extern Authctxt *the_authctxt;
64extern int use_privsep;
64 65
65static Buffer stdin_buffer; /* Buffer for stdin data. */ 66static Buffer stdin_buffer; /* Buffer for stdin data. */
66static Buffer stdout_buffer; /* Buffer for stdout data. */ 67static Buffer stdout_buffer; /* Buffer for stdout data. */
@@ -90,6 +91,9 @@ static int client_alive_timeouts = 0;
90 91
91static volatile sig_atomic_t child_terminated = 0; /* The child has terminated. */ 92static volatile sig_atomic_t child_terminated = 0; /* The child has terminated. */
92 93
94/* Cleanup on signals (!use_privsep case only) */
95static volatile sig_atomic_t received_sigterm = 0;
96
93/* prototypes */ 97/* prototypes */
94static void server_init_dispatch(void); 98static void server_init_dispatch(void);
95 99
@@ -151,6 +155,12 @@ sigchld_handler(int sig)
151 errno = save_errno; 155 errno = save_errno;
152} 156}
153 157
158static void
159sigterm_handler(int sig)
160{
161 received_sigterm = sig;
162}
163
154/* 164/*
155 * Make packets from buffered stderr data, and buffer it for sending 165 * Make packets from buffered stderr data, and buffer it for sending
156 * to the client. 166 * to the client.
@@ -502,6 +512,12 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
502 child_terminated = 0; 512 child_terminated = 0;
503 mysignal(SIGCHLD, sigchld_handler); 513 mysignal(SIGCHLD, sigchld_handler);
504 514
515 if (!use_privsep) {
516 signal(SIGTERM, sigterm_handler);
517 signal(SIGINT, sigterm_handler);
518 signal(SIGQUIT, sigterm_handler);
519 }
520
505 /* Initialize our global variables. */ 521 /* Initialize our global variables. */
506 fdin = fdin_arg; 522 fdin = fdin_arg;
507 fdout = fdout_arg; 523 fdout = fdout_arg;
@@ -629,6 +645,12 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
629 wait_until_can_do_something(&readset, &writeset, &max_fd, 645 wait_until_can_do_something(&readset, &writeset, &max_fd,
630 &nalloc, max_time_milliseconds); 646 &nalloc, max_time_milliseconds);
631 647
648 if (received_sigterm) {
649 logit("Exiting on signal %d", received_sigterm);
650 /* Clean up sessions, utmp, etc. */
651 cleanup_exit(255);
652 }
653
632 /* Process any channel events. */ 654 /* Process any channel events. */
633 channel_after_select(readset, writeset); 655 channel_after_select(readset, writeset);
634 656
@@ -749,6 +771,12 @@ server_loop2(Authctxt *authctxt)
749 connection_in = packet_get_connection_in(); 771 connection_in = packet_get_connection_in();
750 connection_out = packet_get_connection_out(); 772 connection_out = packet_get_connection_out();
751 773
774 if (!use_privsep) {
775 signal(SIGTERM, sigterm_handler);
776 signal(SIGINT, sigterm_handler);
777 signal(SIGQUIT, sigterm_handler);
778 }
779
752 notify_setup(); 780 notify_setup();
753 781
754 max_fd = MAX(connection_in, connection_out); 782 max_fd = MAX(connection_in, connection_out);
@@ -766,6 +794,12 @@ server_loop2(Authctxt *authctxt)
766 wait_until_can_do_something(&readset, &writeset, &max_fd, 794 wait_until_can_do_something(&readset, &writeset, &max_fd,
767 &nalloc, 0); 795 &nalloc, 0);
768 796
797 if (received_sigterm) {
798 logit("Exiting on signal %d", received_sigterm);
799 /* Clean up sessions, utmp, etc. */
800 cleanup_exit(255);
801 }
802
769 collect_children(); 803 collect_children();
770 if (!rekeying) { 804 if (!rekeying) {
771 channel_after_select(readset, writeset); 805 channel_after_select(readset, writeset);