]> andersk Git - openssh.git/commitdiff
- dtucker@cvs.openbsd.org 2005/11/03 13:38:29
authordjm <djm>
Sat, 5 Nov 2005 04:16:52 +0000 (04:16 +0000)
committerdjm <djm>
Sat, 5 Nov 2005 04:16:52 +0000 (04:16 +0000)
     [canohost.c]
     Cache reverse lookups with and without DNS separately; ok markus@

ChangeLog
canohost.c
serverloop.c

index b798593b0c3d81a32eff9125d6c23793b8673951..d1a8fc375e54f933854c81ed53aaa3194a75e0ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -90,6 +90,9 @@
    - jmc@cvs.openbsd.org 2005/10/31 19:55:25
      [ssh-keygen.1]
      grammar;
+   - dtucker@cvs.openbsd.org 2005/11/03 13:38:29
+     [canohost.c]
+     Cache reverse lookups with and without DNS separately; ok markus@
 
 20051102
  - (dtucker) [openbsd-compat/bsd-misc.c] Bug #1108: fix broken strdup().
index 66867c10bf33d703441ce3c3a97969da1bacb7e3..bd7f830dea4590f97071f5b9473303279740c4b2 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #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 "xmalloc.h"
@@ -198,26 +198,27 @@ ipv64_normalise_mapped(struct sockaddr_storage *addr, socklen_t *len)
 const char *
 get_canonical_hostname(int use_dns)
 {
+       char *host;
        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. */
-       if (canonical_host_name != NULL) {
-               if (use_dns_done != use_dns)
-                       xfree(canonical_host_name);
-               else
-                       return canonical_host_name;
-       }
+       if (use_dns && canonical_host_name != NULL)
+               return canonical_host_name;
+       if (!use_dns && remote_ip != NULL)
+               return remote_ip;
 
        /* Get the real hostname if socket; otherwise return UNKNOWN. */
        if (packet_connection_is_on_socket())
-               canonical_host_name = get_remote_hostname(
-                   packet_get_connection_in(), use_dns);
+               host = get_remote_hostname(packet_get_connection_in(), use_dns);
        else
-               canonical_host_name = xstrdup("UNKNOWN");
+               host = "UNKNOWN";
 
-       use_dns_done = use_dns;
-       return canonical_host_name;
+       if (use_dns)
+               canonical_host_name = host;
+       else
+               remote_ip = host;
+       return host;
 }
 
 /*
index 208f7e1e9a48f42a6acef94a20d78d49c58ab4b1..03376bacf5df99e817f32c8fd1290be449fef328 100644 (file)
@@ -35,7 +35,7 @@
  */
 
 #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 "packet.h"
@@ -61,6 +61,7 @@ extern ServerOptions options;
 /* XXX */
 extern Kex *xxx_kex;
 extern Authctxt *the_authctxt;
+extern int use_privsep;
 
 static Buffer stdin_buffer;    /* Buffer for stdin 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. */
 
+/* Cleanup on signals (!use_privsep case only) */
+static volatile sig_atomic_t received_sigterm = 0;
+
 /* prototypes */
 static void server_init_dispatch(void);
 
@@ -151,6 +155,12 @@ sigchld_handler(int sig)
        errno = save_errno;
 }
 
+static void
+sigterm_handler(int sig)
+{
+       received_sigterm = sig;
+}
+
 /*
  * Make packets from buffered stderr data, and buffer it for sending
  * to the client.
@@ -502,6 +512,12 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
        child_terminated = 0;
        mysignal(SIGCHLD, sigchld_handler);
 
+       if (!use_privsep) {
+               signal(SIGTERM, sigterm_handler);
+               signal(SIGINT, sigterm_handler);
+               signal(SIGQUIT, sigterm_handler);
+       }
+
        /* Initialize our global variables. */
        fdin = fdin_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,
                    &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. */
                channel_after_select(readset, writeset);
 
@@ -749,6 +771,12 @@ server_loop2(Authctxt *authctxt)
        connection_in = packet_get_connection_in();
        connection_out = packet_get_connection_out();
 
+       if (!use_privsep) {
+               signal(SIGTERM, sigterm_handler);
+               signal(SIGINT, sigterm_handler);
+               signal(SIGQUIT, sigterm_handler);
+       }
+
        notify_setup();
 
        max_fd = MAX(connection_in, connection_out);
@@ -766,6 +794,12 @@ server_loop2(Authctxt *authctxt)
                wait_until_can_do_something(&readset, &writeset, &max_fd,
                    &nalloc, 0);
 
+               if (received_sigterm) {
+                       logit("Exiting on signal %d", received_sigterm);
+                       /* Clean up sessions, utmp, etc. */
+                       cleanup_exit(255);
+               }
+
                collect_children();
                if (!rekeying) {
                        channel_after_select(readset, writeset);
This page took 0.047026 seconds and 5 git commands to generate.