[openssh-commits] [openssh] 04/09: upstream commit

git+noreply at mindrot.org git+noreply at mindrot.org
Tue Nov 29 17:20:07 AEDT 2016


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit b0899ee26a6630883c0f2350098b6a35e647f512
Author: dtucker at openbsd.org <dtucker at openbsd.org>
Date:   Tue Nov 29 03:54:50 2016 +0000

    upstream commit
    
    Factor out code to disconnect from controlling terminal
    into its own function.  ok djm@
    
    Upstream-ID: 39fd9e8ebd7222615a837312face5cc7ae962885
---
 sshd.c   | 19 +++----------------
 sshpty.c | 16 +++++++++++++++-
 sshpty.h |  3 ++-
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/sshd.c b/sshd.c
index 816611c..d7e8120 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshd.c,v 1.476 2016/09/28 16:33:07 djm Exp $ */
+/* $OpenBSD: sshd.c,v 1.477 2016/11/29 03:54:50 dtucker Exp $ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -123,10 +123,6 @@
 #include "version.h"
 #include "ssherr.h"
 
-#ifndef O_NOCTTY
-#define O_NOCTTY	0
-#endif
-
 /* Re-exec fds */
 #define REEXEC_DEVCRYPTO_RESERVED_FD	(STDERR_FILENO + 1)
 #define REEXEC_STARTUP_PIPE_FD		(STDERR_FILENO + 2)
@@ -1807,20 +1803,11 @@ main(int ac, char **av)
 	 * exits.
 	 */
 	if (!(debug_flag || inetd_flag || no_daemon_flag)) {
-#ifdef TIOCNOTTY
-		int fd;
-#endif /* TIOCNOTTY */
+
 		if (daemon(0, 0) < 0)
 			fatal("daemon() failed: %.200s", strerror(errno));
 
-		/* Disconnect from the controlling tty. */
-#ifdef TIOCNOTTY
-		fd = open(_PATH_TTY, O_RDWR | O_NOCTTY);
-		if (fd >= 0) {
-			(void) ioctl(fd, TIOCNOTTY, NULL);
-			close(fd);
-		}
-#endif /* TIOCNOTTY */
+		disconnect_controlling_tty();
 	}
 	/* Reinitialize the log (because of the fork above). */
 	log_init(__progname, options.log_level, options.log_facility, log_stderr);
diff --git a/sshpty.c b/sshpty.c
index b8457d9..fe2fb5a 100644
--- a/sshpty.c
+++ b/sshpty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshpty.c,v 1.30 2015/07/30 23:09:15 djm Exp $ */
+/* $OpenBSD: sshpty.c,v 1.31 2016/11/29 03:54:50 dtucker Exp $ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -238,3 +238,17 @@ 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 */
+}
diff --git a/sshpty.h b/sshpty.h
index cfa3224..9ec7e9a 100644
--- a/sshpty.h
+++ b/sshpty.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshpty.h,v 1.12 2010/01/09 05:04:24 djm Exp $ */
+/* $OpenBSD: sshpty.h,v 1.13 2016/11/29 03:54:50 dtucker Exp $ */
 
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
@@ -25,3 +25,4 @@ void	 pty_release(const char *);
 void	 pty_make_controlling_tty(int *, const char *);
 void	 pty_change_window_size(int, u_int, u_int, u_int, u_int);
 void	 pty_setowner(struct passwd *, const char *);
+void	 disconnect_controlling_tty(void);

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list