[PATCH]: scp could hang in Cygwin

Corinna Vinschen vinschen at redhat.com
Wed Apr 4 19:34:58 EST 2001


On Mon, Apr 02, 2001 at 09:58:29PM +0200, Corinna Vinschen wrote:
> Hi,
> 
> attached is a patch which solves the following problem:
> 
> Sometimes scp could hang in Cygwin when used as remote end using
> the -t option. This is due to a binmode/textmode problem which
> could be raised by the login shell which is used by the user and
> it's setting of textmode on stdin. The patch solves that problem
> by explicitly setting binmode on stdin.
> 
> Besides solving the hanging problem, the patch results in a way
> faster copy process.

Ok, I had to review that patch. Unfortunately, sftp-server
is affected by the same problem.

I have attached a new patch which includes the change to scp
and additionally patches sftp-server to deal with that situation.

Thanks,
Corinna

Index: scp.c
===================================================================
RCS file: /cvs/openssh_cvs/scp.c,v
retrieving revision 1.66
diff -u -p -r1.66 scp.c
--- scp.c	2001/03/29 00:43:54	1.66
+++ scp.c	2001/04/04 09:30:52
@@ -291,6 +291,9 @@ main(argc, argv)
 		case 't':	/* "to" */
 			iamremote = 1;
 			tflag = 1;
+#ifdef HAVE_CYGWIN
+			setmode (0, O_BINARY);
+#endif
 			break;
 		default:
 			usage();
Index: sftp-server.c
===================================================================
RCS file: /cvs/openssh_cvs/sftp-server.c,v
retrieving revision 1.28
diff -u -p -r1.28 sftp-server.c
--- sftp-server.c	2001/03/15 00:09:16	1.28
+++ sftp-server.c	2001/04/04 09:30:52
@@ -1043,6 +1043,11 @@ main(int ac, char **av)
 	in = dup(STDIN_FILENO);
 	out = dup(STDOUT_FILENO);
 
+#ifdef HAVE_CYGWIN
+	setmode (in, O_BINARY);
+	setmode (out, O_BINARY);
+#endif
+
 	max = 0;
 	if (in > max)
 		max = in;
Index: openbsd-compat/bsd-cygwin_util.c
===================================================================
RCS file: /cvs/openssh_cvs/openbsd-compat/bsd-cygwin_util.c,v
retrieving revision 1.3
diff -u -p -r1.3 bsd-cygwin_util.c
--- openbsd-compat/bsd-cygwin_util.c	2001/02/18 01:30:56	1.3
+++ openbsd-compat/bsd-cygwin_util.c	2001/04/04 09:30:52
@@ -20,7 +20,6 @@ RCSID("$Id: bsd-cygwin_util.c,v 1.3 2001
 #ifdef HAVE_CYGWIN
 
 #include <fcntl.h>
-#include <io.h>
 #include <stdlib.h>
 #include <sys/vfs.h>
 #include <windows.h>
Index: openbsd-compat/bsd-cygwin_util.h
===================================================================
RCS file: /cvs/openssh_cvs/openbsd-compat/bsd-cygwin_util.h,v
retrieving revision 1.3
diff -u -p -r1.3 bsd-cygwin_util.h
--- openbsd-compat/bsd-cygwin_util.h	2001/02/18 01:30:56	1.3
+++ openbsd-compat/bsd-cygwin_util.h	2001/04/04 09:30:52
@@ -20,6 +20,8 @@
 
 #ifdef HAVE_CYGWIN
 
+#include <io.h>
+
 int binary_open(const char *filename, int flags, ...);
 int binary_pipe(int fd[2]);
 int check_nt_auth(int pwd_authenticated, uid_t uid);



More information about the openssh-unix-dev mailing list