From a7f490e1e3d758df1ccd42a70f2ca47d7a09fe89 Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Tue, 15 Sep 2026 06:30:58 +0000 Subject: [PATCH] upstream: disconnect_controlling_tty() is the only thing from sshpty.c used in sshd, and sshd is the only thing that calls this function. Move it into sshd.c and we no longer need to compile sshd against sshpty.c Part of bz3996 from Colin Watson OpenBSD-Commit-ID: cbfb0ecba5c63852d33e930d01f00586ce15ad1d --- sshd.c | 17 +++++++++++++++++ sshpty.c | 20 +------------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/sshd.c b/sshd.c index 10c0da3b3..f264cf7e6 100644 --- a/sshd.c +++ b/sshd.c @@ -1272,6 +1272,23 @@ prepare_proctitle(int ac, char **av) return ret; } +/* Disconnect from the controlling tty. */ +void +disconnect_controlling_tty(void) +{ +#ifdef TIOCNOTTY +# ifndef O_NOCTTY +# define O_NOCTTY 0 +# endif + int fd; + + if ((fd = open(_PATH_TTY, O_RDWR | O_NOCTTY)) >= 0) { + (void) ioctl(fd, TIOCNOTTY, NULL); + close(fd); + } +#endif /* TIOCNOTTY */ +} + static void print_config(struct connection_info *connection_info) { diff --git a/sshpty.c b/sshpty.c index b3e1e2466..f8102604c 100644 --- a/sshpty.c +++ b/sshpty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshpty.c,v 1.35 2026/02/11 17:05:32 dtucker Exp $ */ +/* $OpenBSD: sshpty.c,v 1.36 2026/09/15 06:30:58 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -39,10 +39,6 @@ # include #endif -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - #ifdef __APPLE__ # include # if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) @@ -212,17 +208,3 @@ pty_setowner(struct passwd *pw, const char *tty) } } } - -/* Disconnect from the controlling tty. */ -void -disconnect_controlling_tty(void) -{ -#ifdef TIOCNOTTY - int fd; - - if ((fd = open(_PATH_TTY, O_RDWR | O_NOCTTY)) >= 0) { - (void) ioctl(fd, TIOCNOTTY, NULL); - close(fd); - } -#endif /* TIOCNOTTY */ -}