diff options
-rw-r--r-- | sshd.c | 19 | ||||
-rw-r--r-- | sshpty.c | 16 | ||||
-rw-r--r-- | sshpty.h | 3 |
3 files changed, 20 insertions, 18 deletions
@@ -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); |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshpty.c,v 1.30 2015/07/30 23:09:15 djm Exp $ */ | 1 | /* $OpenBSD: sshpty.c,v 1.31 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 |
@@ -238,3 +238,17 @@ pty_setowner(struct passwd *pw, const char *tty) | |||
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | |||
242 | /* Disconnect from the controlling tty. */ | ||
243 | void | ||
244 | disconnect_controlling_tty(void) | ||
245 | { | ||
246 | #ifdef TIOCNOTTY | ||
247 | int fd; | ||
248 | |||
249 | if ((fd = open(_PATH_TTY, O_RDWR | O_NOCTTY)) >= 0) { | ||
250 | (void) ioctl(fd, TIOCNOTTY, NULL); | ||
251 | close(fd); | ||
252 | } | ||
253 | #endif /* TIOCNOTTY */ | ||
254 | } | ||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshpty.h,v 1.12 2010/01/09 05:04:24 djm Exp $ */ | 1 | /* $OpenBSD: sshpty.h,v 1.13 2016/11/29 03:54:50 dtucker Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -25,3 +25,4 @@ void pty_release(const char *); | |||
25 | void pty_make_controlling_tty(int *, const char *); | 25 | void pty_make_controlling_tty(int *, const char *); |
26 | void pty_change_window_size(int, u_int, u_int, u_int, u_int); | 26 | void pty_change_window_size(int, u_int, u_int, u_int, u_int); |
27 | void pty_setowner(struct passwd *, const char *); | 27 | void pty_setowner(struct passwd *, const char *); |
28 | void disconnect_controlling_tty(void); | ||