- Merge fixes from Debian patch from Phil Hands <phil@hands.com>
- Allow setting of PAM service name through CFLAGS (SSHD_PAM_SERVICE)
- Use vhangup to clean up Linux ttys
- Force posix getopt processing on GNU libc systems
diff --git a/pty.c b/pty.c
index c6af6f4..21ddab5 100644
--- a/pty.c
+++ b/pty.c
@@ -14,7 +14,7 @@
*/
#include "includes.h"
-RCSID("$Id: pty.c,v 1.18 2000/04/16 01:18:44 damien Exp $");
+RCSID("$Id: pty.c,v 1.19 2000/04/20 13:12:59 damien Exp $");
#ifdef HAVE_UTIL_H
# include <util.h>
@@ -201,6 +201,9 @@
pty_make_controlling_tty(int *ttyfd, const char *ttyname)
{
int fd;
+#ifdef HAVE_VHANGUP
+ void *old;
+#endif /* HAVE_VHANGUP */
/* First disconnect from the old controlling tty. */
#ifdef TIOCNOTTY
@@ -232,12 +235,22 @@
*/
ioctl(*ttyfd, TIOCSCTTY, NULL);
#endif /* TIOCSCTTY */
+#ifdef HAVE_VHANGUP
+ old = signal(SIGHUP, SIG_IGN);
+ vhangup();
+ signal(SIGHUP, old);
+#endif /* HAVE_VHANGUP */
fd = open(ttyname, O_RDWR);
- if (fd < 0)
+ if (fd < 0) {
error("%.100s: %.100s", ttyname, strerror(errno));
- else
+ } else {
+#ifdef HAVE_VHANGUP
+ close(*ttyfd);
+ *ttyfd = fd;
+#else /* HAVE_VHANGUP */
close(fd);
-
+#endif /* HAVE_VHANGUP */
+ }
/* Verify that we now have a controlling tty. */
fd = open("/dev/tty", O_WRONLY);
if (fd < 0)