summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2011-09-06 14:56:29 +0100
committerColin Watson <cjwatson@debian.org>2011-09-06 14:56:29 +0100
commit978e62d6f14c60747bddef2cc72d66a9c8b83b54 (patch)
tree89400a44e42d84937deba7864e4964d6c7734da5 /sshd.c
parent87c685b8c6a49814fd782288097b3093f975aa72 (diff)
parent3a7e89697ca363de0f64e0d5704c57219294e41c (diff)
* New upstream release (http://www.openssh.org/txt/release-5.9).
- Introduce sandboxing of the pre-auth privsep child using an optional sshd_config(5) "UsePrivilegeSeparation=sandbox" mode that enables mandatory restrictions on the syscalls the privsep child can perform. - Add new SHA256-based HMAC transport integrity modes from http://www.ietf.org/id/draft-dbider-sha2-mac-for-ssh-02.txt. - The pre-authentication sshd(8) privilege separation slave process now logs via a socket shared with the master process, avoiding the need to maintain /dev/log inside the chroot (closes: #75043, #429243, #599240). - ssh(1) now warns when a server refuses X11 forwarding (closes: #504757). - sshd_config(5)'s AuthorizedKeysFile now accepts multiple paths, separated by whitespace (closes: #76312). The authorized_keys2 fallback is deprecated but documented (closes: #560156). - ssh(1) and sshd(8): set IPv6 traffic class from IPQoS, as well as IPv4 ToS/DSCP (closes: #498297). - ssh-add(1) now accepts keys piped from standard input. E.g. "ssh-add - < /path/to/key" (closes: #229124). - Clean up lost-passphrase text in ssh-keygen(1) (closes: #444691). - Say "required" rather than "recommended" in unprotected-private-key warning (LP: #663455).
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/sshd.c b/sshd.c
index 67a2f9d6b..9b32cb458 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.381 2011/01/11 06:13:10 djm Exp $ */ 1/* $OpenBSD: sshd.c,v 1.385 2011/06/23 09:34:13 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -118,6 +118,7 @@
118#endif 118#endif
119#include "monitor_wrap.h" 119#include "monitor_wrap.h"
120#include "roaming.h" 120#include "roaming.h"
121#include "ssh-sandbox.h"
121#include "version.h" 122#include "version.h"
122 123
123#ifdef USE_SECURITY_SESSION_API 124#ifdef USE_SECURITY_SESSION_API
@@ -629,42 +630,62 @@ privsep_preauth(Authctxt *authctxt)
629{ 630{
630 int status; 631 int status;
631 pid_t pid; 632 pid_t pid;
633 struct ssh_sandbox *box = NULL;
632 634
633 /* Set up unprivileged child process to deal with network data */ 635 /* Set up unprivileged child process to deal with network data */
634 pmonitor = monitor_init(); 636 pmonitor = monitor_init();
635 /* Store a pointer to the kex for later rekeying */ 637 /* Store a pointer to the kex for later rekeying */
636 pmonitor->m_pkex = &xxx_kex; 638 pmonitor->m_pkex = &xxx_kex;
637 639
640 if (use_privsep == PRIVSEP_SANDBOX)
641 box = ssh_sandbox_init();
638 pid = fork(); 642 pid = fork();
639 if (pid == -1) { 643 if (pid == -1) {
640 fatal("fork of unprivileged child failed"); 644 fatal("fork of unprivileged child failed");
641 } else if (pid != 0) { 645 } else if (pid != 0) {
642 debug2("Network child is on pid %ld", (long)pid); 646 debug2("Network child is on pid %ld", (long)pid);
643 647
644 close(pmonitor->m_recvfd); 648 if (box != NULL)
649 ssh_sandbox_parent_preauth(box, pid);
645 pmonitor->m_pid = pid; 650 pmonitor->m_pid = pid;
646 monitor_child_preauth(authctxt, pmonitor); 651 monitor_child_preauth(authctxt, pmonitor);
647 close(pmonitor->m_sendfd);
648 652
649 /* Sync memory */ 653 /* Sync memory */
650 monitor_sync(pmonitor); 654 monitor_sync(pmonitor);
651 655
652 /* Wait for the child's exit status */ 656 /* Wait for the child's exit status */
653 while (waitpid(pid, &status, 0) < 0) 657 while (waitpid(pid, &status, 0) < 0) {
654 if (errno != EINTR) 658 if (errno != EINTR)
655 break; 659 fatal("%s: waitpid: %s", __func__,
656 return (1); 660 strerror(errno));
661 }
662 if (WIFEXITED(status)) {
663 if (WEXITSTATUS(status) != 0)
664 fatal("%s: preauth child exited with status %d",
665 __func__, WEXITSTATUS(status));
666 } else if (WIFSIGNALED(status))
667 fatal("%s: preauth child terminated by signal %d",
668 __func__, WTERMSIG(status));
669 if (box != NULL)
670 ssh_sandbox_parent_finish(box);
671 return 1;
657 } else { 672 } else {
658 /* child */ 673 /* child */
659
660 close(pmonitor->m_sendfd); 674 close(pmonitor->m_sendfd);
675 close(pmonitor->m_log_recvfd);
676
677 /* Arrange for logging to be sent to the monitor */
678 set_log_handler(mm_log_handler, pmonitor);
661 679
662 /* Demote the child */ 680 /* Demote the child */
663 if (getuid() == 0 || geteuid() == 0) 681 if (getuid() == 0 || geteuid() == 0)
664 privsep_preauth_child(); 682 privsep_preauth_child();
665 setproctitle("%s", "[net]"); 683 setproctitle("%s", "[net]");
684 if (box != NULL)
685 ssh_sandbox_child(box);
686
687 return 0;
666 } 688 }
667 return (0);
668} 689}
669 690
670static void 691static void
@@ -690,7 +711,6 @@ privsep_postauth(Authctxt *authctxt)
690 fatal("fork of unprivileged child failed"); 711 fatal("fork of unprivileged child failed");
691 else if (pmonitor->m_pid != 0) { 712 else if (pmonitor->m_pid != 0) {
692 verbose("User child is on pid %ld", (long)pmonitor->m_pid); 713 verbose("User child is on pid %ld", (long)pmonitor->m_pid);
693 close(pmonitor->m_recvfd);
694 buffer_clear(&loginmsg); 714 buffer_clear(&loginmsg);
695 monitor_child_postauth(pmonitor); 715 monitor_child_postauth(pmonitor);
696 716
@@ -698,7 +718,10 @@ privsep_postauth(Authctxt *authctxt)
698 exit(0); 718 exit(0);
699 } 719 }
700 720
721 /* child */
722
701 close(pmonitor->m_sendfd); 723 close(pmonitor->m_sendfd);
724 pmonitor->m_sendfd = -1;
702 725
703 /* Demote the private keys to public keys. */ 726 /* Demote the private keys to public keys. */
704 demote_sensitive_data(); 727 demote_sensitive_data();
@@ -1120,7 +1143,7 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
1120 (int) received_sigterm); 1143 (int) received_sigterm);
1121 close_listen_socks(); 1144 close_listen_socks();
1122 unlink(options.pid_file); 1145 unlink(options.pid_file);
1123 exit(255); 1146 exit(received_sigterm == SIGTERM ? 0 : 255);
1124 } 1147 }
1125 if (key_used && key_do_regen) { 1148 if (key_used && key_do_regen) {
1126 generate_ephemeral_server_key(); 1149 generate_ephemeral_server_key();
@@ -1311,7 +1334,6 @@ main(int ac, char **av)
1311 (void)set_auth_parameters(ac, av); 1334 (void)set_auth_parameters(ac, av);
1312#endif 1335#endif
1313 __progname = ssh_get_progname(av[0]); 1336 __progname = ssh_get_progname(av[0]);
1314 init_rng();
1315 1337
1316 /* Save argv. Duplicate so setproctitle emulation doesn't clobber it */ 1338 /* Save argv. Duplicate so setproctitle emulation doesn't clobber it */
1317 saved_argc = ac; 1339 saved_argc = ac;