summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2016-11-29 03:54:50 +0000
committerDamien Miller <djm@mindrot.org>2016-11-29 16:51:27 +1100
commitb0899ee26a6630883c0f2350098b6a35e647f512 (patch)
tree9869e87c60d4458dfc1776542c5f5c7c5ad81464 /sshd.c
parent54d022026aae4f53fa74cc636e4a032d9689b64d (diff)
upstream commit
Factor out code to disconnect from controlling terminal into its own function. ok djm@ Upstream-ID: 39fd9e8ebd7222615a837312face5cc7ae962885
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/sshd.c b/sshd.c
index 816611c93..d7e812000 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.476 2016/09/28 16:33:07 djm Exp $ */ 1/* $OpenBSD: sshd.c,v 1.477 2016/11/29 03:54:50 dtucker 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
@@ -123,10 +123,6 @@
123#include "version.h" 123#include "version.h"
124#include "ssherr.h" 124#include "ssherr.h"
125 125
126#ifndef O_NOCTTY
127#define O_NOCTTY 0
128#endif
129
130/* Re-exec fds */ 126/* Re-exec fds */
131#define REEXEC_DEVCRYPTO_RESERVED_FD (STDERR_FILENO + 1) 127#define REEXEC_DEVCRYPTO_RESERVED_FD (STDERR_FILENO + 1)
132#define REEXEC_STARTUP_PIPE_FD (STDERR_FILENO + 2) 128#define REEXEC_STARTUP_PIPE_FD (STDERR_FILENO + 2)
@@ -1807,20 +1803,11 @@ main(int ac, char **av)
1807 * exits. 1803 * exits.
1808 */ 1804 */
1809 if (!(debug_flag || inetd_flag || no_daemon_flag)) { 1805 if (!(debug_flag || inetd_flag || no_daemon_flag)) {
1810#ifdef TIOCNOTTY 1806
1811 int fd;
1812#endif /* TIOCNOTTY */
1813 if (daemon(0, 0) < 0) 1807 if (daemon(0, 0) < 0)
1814 fatal("daemon() failed: %.200s", strerror(errno)); 1808 fatal("daemon() failed: %.200s", strerror(errno));
1815 1809
1816 /* Disconnect from the controlling tty. */ 1810 disconnect_controlling_tty();
1817#ifdef TIOCNOTTY
1818 fd = open(_PATH_TTY, O_RDWR | O_NOCTTY);
1819 if (fd >= 0) {
1820 (void) ioctl(fd, TIOCNOTTY, NULL);
1821 close(fd);
1822 }
1823#endif /* TIOCNOTTY */
1824 } 1811 }
1825 /* Reinitialize the log (because of the fork above). */ 1812 /* Reinitialize the log (because of the fork above). */
1826 log_init(__progname, options.log_level, options.log_facility, log_stderr); 1813 log_init(__progname, options.log_level, options.log_facility, log_stderr);