aboutsummaryrefslogtreecommitdiff
path: root/crypto/openssh/sshd.c
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2006-03-22 20:41:37 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2006-03-22 20:41:37 +0000
commitb74df5b26fa43e05a034a6ce662dcf286a1ffdd9 (patch)
treefb276a713da5dc24fdafffe04d15c0de14e138e2 /crypto/openssh/sshd.c
parent4f87d658747b4e9afbd29979d608b4f4514eacce (diff)
downloadsrc-b74df5b26fa43e05a034a6ce662dcf286a1ffdd9.tar.gz
src-b74df5b26fa43e05a034a6ce662dcf286a1ffdd9.zip
Merge conflicts.
Notes
Notes: svn path=/head/; revision=157019
Diffstat (limited to 'crypto/openssh/sshd.c')
-rw-r--r--crypto/openssh/sshd.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/crypto/openssh/sshd.c b/crypto/openssh/sshd.c
index 7e5e386bdb4e..9ab5e95713fd 100644
--- a/crypto/openssh/sshd.c
+++ b/crypto/openssh/sshd.c
@@ -42,7 +42,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.312 2005/07/25 11:59:40 markus Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.318 2005/12/24 02:27:41 djm Exp $");
RCSID("$FreeBSD$");
#include <openssl/dh.h>
@@ -641,16 +641,8 @@ privsep_postauth(Authctxt *authctxt)
if (authctxt->pw->pw_uid == 0 || options.use_login) {
#endif
/* File descriptor passing is broken or root login */
- monitor_apply_keystate(pmonitor);
use_privsep = 0;
- return;
- }
-
- /* Authentication complete */
- alarm(0);
- if (startup_pipe != -1) {
- close(startup_pipe);
- startup_pipe = -1;
+ goto skip;
}
/* New socket pair */
@@ -677,6 +669,7 @@ privsep_postauth(Authctxt *authctxt)
/* Drop privileges */
do_setusercontext(authctxt->pw);
+ skip:
/* It is safe now to apply the key state */
monitor_apply_keystate(pmonitor);
@@ -808,6 +801,7 @@ send_rexec_state(int fd, Buffer *conf)
* bignum iqmp "
* bignum p "
* bignum q "
+ * string rngseed (only if OpenSSL is not self-seeded)
*/
buffer_init(&m);
buffer_put_cstring(&m, buffer_ptr(conf));
@@ -824,6 +818,10 @@ send_rexec_state(int fd, Buffer *conf)
} else
buffer_put_int(&m, 0);
+#ifndef OPENSSL_PRNG_ONLY
+ rexec_send_rng_seed(&m);
+#endif
+
if (ssh_msg_send(fd, 0, &m) == -1)
fatal("%s: ssh_msg_send failed", __func__);
@@ -866,6 +864,11 @@ recv_rexec_state(int fd, Buffer *conf)
rsa_generate_additional_parameters(
sensitive_data.server_key->rsa);
}
+
+#ifndef OPENSSL_PRNG_ONLY
+ rexec_recv_rng_seed(&m);
+#endif
+
buffer_free(&m);
debug3("%s: done", __func__);
@@ -922,6 +925,9 @@ main(int ac, char **av)
if (geteuid() == 0 && setgroups(0, NULL) == -1)
debug("setgroups(): %.200s", strerror(errno));
+ /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
+ sanitise_stdfd();
+
/* Initialize configuration options to their default values. */
initialize_server_options(&options);
@@ -1059,8 +1065,6 @@ main(int ac, char **av)
drop_cray_privs();
#endif
- seed_rng();
-
sensitive_data.server_key = NULL;
sensitive_data.ssh1_host_key = NULL;
sensitive_data.have_ssh1_key = 0;
@@ -1079,6 +1083,8 @@ main(int ac, char **av)
if (!rexec_flag)
buffer_free(&cfg);
+ seed_rng();
+
/* Fill in default values for those options not explicitly set. */
fill_default_server_options(&options);
@@ -1669,7 +1675,12 @@ main(int ac, char **av)
debug("get_remote_port failed");
cleanup_exit(255);
}
- remote_ip = get_remote_ipaddr();
+
+ /*
+ * We use get_canonical_hostname with usedns = 0 instead of
+ * get_remote_ipaddr here so IP options will be checked.
+ */
+ remote_ip = get_canonical_hostname(0);
#ifdef SSH_AUDIT_EVENTS
audit_connection_from(remote_ip, remote_port);
@@ -1695,10 +1706,10 @@ main(int ac, char **av)
verbose("Connection from %.500s port %d", remote_ip, remote_port);
/*
- * We don\'t want to listen forever unless the other side
+ * We don't want to listen forever unless the other side
* successfully authenticates itself. So we set up an alarm which is
* cleared after successful authentication. A limit of zero
- * indicates no limit. Note that we don\'t set the alarm in debugging
+ * indicates no limit. Note that we don't set the alarm in debugging
* mode; it is just annoying to have the server exit just when you
* are about to discover the bug.
*/
@@ -1745,6 +1756,17 @@ main(int ac, char **av)
}
authenticated:
+ /*
+ * Cancel the alarm we set to limit the time taken for
+ * authentication.
+ */
+ alarm(0);
+ signal(SIGALRM, SIG_DFL);
+ if (startup_pipe != -1) {
+ close(startup_pipe);
+ startup_pipe = -1;
+ }
+
#ifdef SSH_AUDIT_EVENTS
audit_event(SSH_AUTH_SUCCESS);
#endif