summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--acconfig.h6
-rw-r--r--configure.ac58
-rw-r--r--sshd.c8
4 files changed, 60 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 18a975ad3..5b4ff341b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
120030510 120030510
2 - (dtucker) Bug #318: Create ssh_prng_cmds.out during "make" rather than 2 - (dtucker) Bug #318: Create ssh_prng_cmds.out during "make" rather than
3 "make install". Patch by roth@feep.net. 3 "make install". Patch by roth@feep.net.
4 - (dtucker) Bug #536: Test for and work around openpty/controlling tty
5 problem on Linux (fixes "could not set controlling tty" errors).
4 6
520030504 720030504
6 - (dtucker) Bug #497: Move #include of bsd-cygwin_util.h to openbsd-compat.h. 8 - (dtucker) Bug #497: Move #include of bsd-cygwin_util.h to openbsd-compat.h.
@@ -1374,4 +1376,4 @@
1374 save auth method before monitor_reset_key_state(); bugzilla bug #284; 1376 save auth method before monitor_reset_key_state(); bugzilla bug #284;
1375 ok provos@ 1377 ok provos@
1376 1378
1377$Id: ChangeLog,v 1.2671 2003/05/10 06:48:23 dtucker Exp $ 1379$Id: ChangeLog,v 1.2672 2003/05/10 07:05:46 dtucker Exp $
diff --git a/acconfig.h b/acconfig.h
index 6164ecc8d..0a4706425 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -1,4 +1,4 @@
1/* $Id: acconfig.h,v 1.150 2003/05/02 10:48:21 dtucker Exp $ */ 1/* $Id: acconfig.h,v 1.151 2003/05/10 07:05:46 dtucker Exp $ */
2 2
3#ifndef _CONFIG_H 3#ifndef _CONFIG_H
4#define _CONFIG_H 4#define _CONFIG_H
@@ -374,8 +374,8 @@
374/* Some systems put this outside of libc */ 374/* Some systems put this outside of libc */
375#undef HAVE_NANOSLEEP 375#undef HAVE_NANOSLEEP
376 376
377/* Pushing STREAMS modules incorrectly acquires a controlling TTY */ 377/* Define if sshd somehow reacquires a controlling TTY after setsid() */
378#undef STREAMS_PUSH_ACQUIRES_CTTY 378#undef SSHD_ACQUIRES_CTTY
379 379
380/* Define if cmsg_type is not passed correctly */ 380/* Define if cmsg_type is not passed correctly */
381#undef BROKEN_CMSG_TYPE 381#undef BROKEN_CMSG_TYPE
diff --git a/configure.ac b/configure.ac
index d6726eaab..dee852854 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.115 2003/05/02 10:48:21 dtucker Exp $ 1# $Id: configure.ac,v 1.116 2003/05/10 07:05:46 dtucker Exp $
2 2
3AC_INIT 3AC_INIT
4AC_CONFIG_SRCDIR([ssh.c]) 4AC_CONFIG_SRCDIR([ssh.c])
@@ -188,15 +188,56 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
188 AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV) 188 AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV)
189 AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0') 189 AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0')
190 inet6_default_4in6=yes 190 inet6_default_4in6=yes
191 AC_MSG_CHECKING(for broken cmsg_type) 191 # openpty can be in libutil, needed for controlling tty test
192 AC_SEARCH_LIBS(openpty, util)
193 # make sure that openpty does not reacquire controlling terminal
194 AC_MSG_CHECKING(if openpty correctly handles controlling tty)
195 AC_TRY_RUN(
196 [
197#include <stdio.h>
198#include <sys/fcntl.h>
199#include <sys/types.h>
200#include <sys/wait.h>
201
202int
203main()
204{
205 pid_t pid;
206 int fd, ptyfd, ttyfd, status;
207
208 pid = fork();
209 if (pid < 0) { /* failed */
210 exit(1);
211 } else if (pid > 0) { /* parent */
212 waitpid(pid, &status, 0);
213 if (WIFEXITED(status))
214 exit(WEXITSTATUS(status));
215 else
216 exit(2);
217 } else { /* child */
218 close(0); close(1); close(2);
219 setsid();
220 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
221 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
222 if (fd >= 0)
223 exit(3); /* Acquired ctty: broken */
224 else
225 exit(0); /* Did not acquire ctty: OK */
226 }
227}
228 ],
229 [
230 AC_MSG_RESULT(yes)
231 ],
232 [
233 AC_MSG_RESULT(no)
234 AC_DEFINE(SSHD_ACQUIRES_CTTY)
235 ]
236 )
192 case `uname -r` in 237 case `uname -r` in
193 2.0.*) 238 1.*|2.0.*)
194 AC_MSG_RESULT(yes)
195 AC_DEFINE(BROKEN_CMSG_TYPE) 239 AC_DEFINE(BROKEN_CMSG_TYPE)
196 ;; 240 ;;
197 *)
198 AC_MSG_RESULT(no)
199 ;;
200 esac 241 esac
201 ;; 242 ;;
202mips-sony-bsd|mips-sony-newsos4) 243mips-sony-bsd|mips-sony-newsos4)
@@ -230,7 +271,8 @@ mips-sony-bsd|mips-sony-newsos4)
230 AC_DEFINE(LOGIN_NEEDS_UTMPX) 271 AC_DEFINE(LOGIN_NEEDS_UTMPX)
231 AC_DEFINE(LOGIN_NEEDS_TERM) 272 AC_DEFINE(LOGIN_NEEDS_TERM)
232 AC_DEFINE(PAM_TTY_KLUDGE) 273 AC_DEFINE(PAM_TTY_KLUDGE)
233 AC_DEFINE(STREAMS_PUSH_ACQUIRES_CTTY) 274 # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
275 AC_DEFINE(SSHD_ACQUIRES_CTTY)
234 # hardwire lastlog location (can't detect it on some versions) 276 # hardwire lastlog location (can't detect it on some versions)
235 conf_lastlog_location="/var/adm/lastlog" 277 conf_lastlog_location="/var/adm/lastlog"
236 AC_MSG_CHECKING(for obsolete utmp and wtmp in solaris2.x) 278 AC_MSG_CHECKING(for obsolete utmp and wtmp in solaris2.x)
diff --git a/sshd.c b/sshd.c
index 62b4f45f4..63070ac23 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1400,11 +1400,11 @@ main(int ac, char **av)
1400 * setlogin() affects the entire process group. We don't 1400 * setlogin() affects the entire process group. We don't
1401 * want the child to be able to affect the parent. 1401 * want the child to be able to affect the parent.
1402 */ 1402 */
1403#if !defined(STREAMS_PUSH_ACQUIRES_CTTY) 1403#if !defined(SSHD_ACQUIRES_CTTY)
1404 /* 1404 /*
1405 * If setsid is called on Solaris, sshd will acquire the controlling 1405 * If setsid is called, on some platforms sshd will later acquire a
1406 * terminal while pushing STREAMS modules. This will prevent the 1406 * controlling terminal which will result in "could not set
1407 * shell from acquiring it later. 1407 * controlling tty" errors.
1408 */ 1408 */
1409 if (!debug_flag && !inetd_flag && setsid() < 0) 1409 if (!debug_flag && !inetd_flag && setsid() < 0)
1410 error("setsid: %.100s", strerror(errno)); 1410 error("setsid: %.100s", strerror(errno));