[PATCH] Fix minor breakage on Cygwin: auth-passwd.c andsession.c
Darren Tucker
dtucker at zip.com.au
Wed Aug 13 00:11:18 EST 2003
Markus Friedl wrote:
> On Tue, Aug 12, 2003 at 03:17:57PM +0200, Corinna Vinschen wrote:
> > tcsendbreak(s->ttyfd, 0);
[snip]
> i really don't want to sleep.
Yeah, you'll hang all the sessions.
> there reason we sleep in the original code is
> that the draft specifies the duration of the
> break, if we just use tcsendbreak() then we
> ignore the specified duration, so no additional sleep
> is necessary.
The treatment of tcsendbreak withh a duration != 0 is "implementation
defined" which appears to mean "amazingly inconsistent".
> on the otherhand, i don't see a need for the break length,
> this should be tcsendbreak()'s job.
Agreed. I vote for ignoring the duration and using tcsendbreak everywhere
including OpenBSD.
--
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
-------------- next part --------------
Index: configure.ac
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/configure.ac,v
retrieving revision 1.138
diff -u -p -r1.138 configure.ac
--- configure.ac 2 Aug 2003 12:24:49 -0000 1.138
+++ configure.ac 12 Aug 2003 13:51:41 -0000
@@ -695,8 +695,8 @@ AC_CHECK_FUNCS(\
setdtablesize setegid setenv seteuid setgroups setlogin setpcred \
setproctitle setregid setresgid setresuid setreuid setrlimit \
setsid setvbuf sigaction sigvec snprintf socketpair strerror \
- strlcat strlcpy strmode strnvis sysconf tcgetpgrp truncate utimes \
- vhangup vsnprintf waitpid \
+ strlcat strlcpy strmode strnvis sysconf tcgetpgrp tcsendbreak \
+ truncate utimes vhangup vsnprintf waitpid \
)
AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP))
Index: session.c
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/session.c,v
retrieving revision 1.244
diff -u -p -r1.244 session.c
--- session.c 7 Aug 2003 06:28:16 -0000 1.244
+++ session.c 12 Aug 2003 13:55:45 -0000
@@ -1696,20 +1696,11 @@ session_break_req(Session *s)
break_length = packet_get_int();
packet_check_eom();
-#if defined(TIOCSBRK) && defined(TIOCCBRK)
if (s->ttyfd == -1)
return 0;
- /* we will sleep from 500ms to 3000ms */
- break_length = MIN(break_length, 3000);
- break_length = MAX(break_length, 500);
- ioctl(s->ttyfd, TIOCSBRK, NULL);
- /* should we care about EINTR? */
- usleep(break_length * 1000);
- ioctl(s->ttyfd, TIOCCBRK, NULL);
- return 1;
-#else
+ if (tcsendbreak(s->ttyfd, 0) == 0)
+ return 1;
return 0;
-#endif
}
static int
Index: openbsd-compat/bsd-misc.c
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/openbsd-compat/bsd-misc.c,v
retrieving revision 1.16
diff -u -p -r1.16 bsd-misc.c
--- openbsd-compat/bsd-misc.c 2 Aug 2003 14:36:16 -0000 1.16
+++ openbsd-compat/bsd-misc.c 12 Aug 2003 13:50:21 -0000
@@ -180,3 +180,17 @@ tcgetpgrp(int fd)
}
#endif /* HAVE_TCGETPGRP */
+#ifndef HAVE_TCSENDBREAK
+int
+tcsendbreak(int fd, int duration)
+{
+# if defined(TIOCSBRK) && defined(TIOCCBRK)
+ if (ioctl(fd, TIOCSBRK, NULL) == -1)
+ return -1;
+ usleep(500 * 1000);
+ return ioctl(fd, TIOCCBRK, NULL);
+# else
+ return -1;
+# endif
+}
+#endif /* HAVE_TCSENDBREAK */
Index: openbsd-compat/bsd-misc.h
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/openbsd-compat/bsd-misc.h,v
retrieving revision 1.9
diff -u -p -r1.9 bsd-misc.h
--- openbsd-compat/bsd-misc.h 2 Aug 2003 13:31:42 -0000 1.9
+++ openbsd-compat/bsd-misc.h 12 Aug 2003 13:55:25 -0000
@@ -91,6 +91,10 @@ int nanosleep(const struct timespec *, s
#ifndef HAVE_TCGETPGRP
pid_t tcgetpgrp(int);
-#endif /* HAVE_TCGETPGRP */
+#endif
+
+#ifndef HAVE_TCSENDBREAK
+int tcsendbreak(int, int);
+#endif
#endif /* _BSD_MISC_H */
More information about the openssh-unix-dev
mailing list