1/* $OpenBSD: sshd.c,v 1.465 2016/02/15 09:47:49 dtucker Exp $ */ 2/* 3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 5 * All rights reserved 6 * This program is the ssh daemon. It listens for connections from clients, 7 * and performs authentication, executes use commands or shell, and forwards 8 * information to/from the application to the user client over an encrypted --- 29 unchanged lines hidden (view full) --- 38 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 39 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 40 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 41 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 42 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 */ 44 45#include "includes.h" |
46__RCSID("$FreeBSD: head/crypto/openssh/sshd.c 302182 2016-06-24 23:22:42Z gjb $"); |
47 48#include <sys/types.h> 49#include <sys/ioctl.h> 50#include <sys/mman.h> 51#include <sys/socket.h> 52#ifdef HAVE_SYS_STAT_H 53# include <sys/stat.h> 54#endif --- 75 unchanged lines hidden (view full) --- 130#include "monitor.h" 131#ifdef GSSAPI 132#include "ssh-gss.h" 133#endif 134#include "monitor_wrap.h" 135#include "ssh-sandbox.h" 136#include "version.h" 137#include "ssherr.h" |
138 139#ifdef LIBWRAP 140#include <tcpd.h> 141#include <syslog.h> 142int allow_severity; 143int deny_severity; 144#endif /* LIBWRAP */ 145 --- 237 unchanged lines hidden (view full) --- 383 * Try to kill any processes that we have spawned, E.g. authorized 384 * keys command helpers. 385 */ 386 if (getpgid(0) == getpid()) { 387 signal(SIGTERM, SIG_IGN); 388 kill(0, SIGTERM); 389 } 390 |
391 /* Log error and exit. */ 392 sigdie("Timeout before authentication for %s", get_remote_ipaddr()); 393} 394 395/* 396 * Signal handler for the key regeneration alarm. Note that this 397 * alarm only occurs in the daemon waiting for connections, and it does not 398 * do anything with the private key or random state before forking. --- 245 unchanged lines hidden (view full) --- 644 if ((RAND_bytes((u_char *)rnd, 1)) != 1) 645 fatal("%s: RAND_bytes failed", __func__); 646#endif 647 explicit_bzero(rnd, sizeof(rnd)); 648 649 /* Demote the private keys to public keys. */ 650 demote_sensitive_data(); 651 |
652 /* Demote the child */ 653 if (getuid() == 0 || geteuid() == 0) { 654 /* Change our root directory */ 655 if (chroot(_PATH_PRIVSEP_CHROOT_DIR) == -1) 656 fatal("chroot(\"%s\"): %s", _PATH_PRIVSEP_CHROOT_DIR, 657 strerror(errno)); 658 if (chdir("/") == -1) 659 fatal("chdir(\"/\"): %s", strerror(errno)); --- 607 unchanged lines hidden (view full) --- 1267 for (i = 0; i < num_listen_socks; i++) 1268 if (listen_socks[i] > maxfd) 1269 maxfd = listen_socks[i]; 1270 /* pipes connected to unauthenticated childs */ 1271 startup_pipes = xcalloc(options.max_startups, sizeof(int)); 1272 for (i = 0; i < options.max_startups; i++) 1273 startup_pipes[i] = -1; 1274 |
1275 /* 1276 * Stay listening for connections until the system crashes or 1277 * the daemon is killed with a signal. 1278 */ 1279 for (;;) { 1280 if (received_sighup) 1281 sighup_restart(); 1282 free(fdset); --- 1418 unchanged lines hidden --- |