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
This commit is contained in:
djm@openbsd.org authored and Damien Miller committed 2026-09-15 16:47:18 +10:00
1 parent 02cf3c2bd6
commit a7f490e1e3
2 files changed
+18 -19

No files matched your search

+17
View File
@@ -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)
{
+1 -19
View File
@@ -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 <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -39,10 +39,6 @@
# include <pty.h>
#endif
#ifndef O_NOCTTY
#define O_NOCTTY 0
#endif
#ifdef __APPLE__
# include <AvailabilityMacros.h>
# 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 */
}