[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: windows xp and ssh setup

From: Glenn Davy <gdavy_at_tpg.com.au>
Date: 2005-02-17 12:00:46 CET

Thanks chris -
I've replaced the existing plink with thisone,
and at first glance this hasn't solved my problem,
But I'll review what I've done from scratch including
your plink on the weekend when the wolves aren't at
my heals.

In principle does what I've out lined look like it
Should work, having now included ryans username and password options?
Glenn

-----Original Message-----
From: Chris Hecker [mailto:checker@d6.com]
Sent: Wednesday, 16 February 2005 4:02 PM
To: Glenn Davy; 'Ryan Bloom'
Cc: users@subversion.tigris.org
Subject: RE: windows xp and ssh setup

The release plink is broken for use as a tunnel using stdin/stdout (like
svn uses it). I fixed it so it now works (it was prompting on stdout/stdin
instead of grabbing the console input/output handle directly). I was
having a ton of troubles with cygwin ssh lately as well, as I posted about
here a week ago...I think something either changed in the cygwin ssh
recently, or with the way svn interacts with the spawned program, or nobody
but me actually runs svn+ssh without ssh-agent or pageant. :) It seemed
easier to just fix plink than to mess with either the cygwin insanity or
svn.

I've put a diff below. It's against the 0.56 sources (the current stable
version). It's a very simple fix. Let me know if you need a binary.

Chris

diff -rwu 0.56orig/CONSOLE.C 0.56/CONSOLE.C
--- 0.56orig/CONSOLE.C 2004-04-27 14:31:58.000000000 -0700
+++ 0.56/CONSOLE.C 2005-02-12 02:12:44.359521600 -0800
@@ -6,6 +6,8 @@
  #include <stdio.h>
  #include <stdlib.h>
  #include <stdarg.h>
+#include <io.h>
+#include <fcntl.h>

  #include "putty.h"
  #include "storage.h"
@@ -15,6 +17,21 @@

  static void *console_logctx = NULL;

+void console_init( void )
+{
+ // open the console output directly and map stderr to it so all
+ // error output always goes to the screen, in case plink is being
+ // spawned by another app that redirects stdout and stderr
+ // (this should probably be a command line option)
+ HANDLE fake_stderr = CreateFile("CONOUT$",
+ GENERIC_READ|GENERIC_WRITE,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ 0,OPEN_EXISTING,0,0);
+ int ofh = _open_osfhandle((long)fake_stderr,_O_APPEND);
+ *stderr = *_fdopen(ofh,"a");
+ dup2(ofh,2);
+}
+
  /*
   * Clean up and exit.
   */
@@ -283,8 +300,23 @@
          if (maxlen > 0)
              str[0] = '\0';
      } else {
+ if(is_pw) {
+ // open the console directly in case stdin and stdout are
+ // redirected (for example, Subversion's svn.exe does this)
+ // (we need all these flags so the SetConsoleMode below will
+ // work)
+ hin = CreateFile("CONIN$",
+ GENERIC_READ|GENERIC_WRITE,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ 0,OPEN_EXISTING,0,0);
+ hout = CreateFile("CONOUT$",
+ GENERIC_READ|GENERIC_WRITE,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ 0,OPEN_EXISTING,0,0);
+ } else {
          hin = GetStdHandle(STD_INPUT_HANDLE);
          hout = GetStdHandle(STD_OUTPUT_HANDLE);
+ }
          if (hin == INVALID_HANDLE_VALUE || hout == INVALID_HANDLE_VALUE) {
              fprintf(stderr, "Cannot get standard input/output handles\n");
              cleanup_exit(1);
@@ -299,10 +331,25 @@
          SetConsoleMode(hin, newmode);

          WriteFile(hout, prompt, strlen(prompt), &i, NULL);
+ if(is_pw) {
+ // for some reason we need to "prime" the input buffer if
+ // multiple copies of plink are attached to this console
+ CONSOLE_SCREEN_BUFFER_INFO info;
+ INPUT_RECORD out;
+ GetConsoleScreenBufferInfo(hin,&info);
+ out.EventType = WINDOW_BUFFER_SIZE_EVENT;
+ out.Event.WindowBufferSizeEvent.dwSize = info.dwSize;
+ WriteConsoleInput(hin,&out,1,0);
+ }
          ReadFile(hin, str, maxlen - 1, &i, NULL);

          SetConsoleMode(hin, savemode);

+ if(is_pw) {
+ CloseHandle(hin);
+ CloseHandle(hout);
+ }
+
          if ((int) i > maxlen)
              i = maxlen - 1;
          else
diff -rwu 0.56orig/PLINK.C 0.56/PLINK.C
--- 0.56orig/PLINK.C 2004-10-24 15:29:02.000000000 -0700
+++ 0.56/PLINK.C 2005-02-11 22:38:40.821420800 -0800
@@ -280,6 +280,7 @@
      int errors;
      int use_subsystem = 0;

+ console_init();
      ssh_get_line = console_get_line;

      sklist = NULL;
diff -rwu 0.56orig/PUTTY.H 0.56/PUTTY.H
--- 0.56orig/PUTTY.H 2004-10-24 15:37:32.000000000 -0700
+++ 0.56/PUTTY.H 2005-02-11 22:38:21.443556800 -0800
@@ -825,6 +825,7 @@
   * windlg.c).
   */
  extern int console_batch_mode;
+void console_init( void );
  int console_get_line(const char *prompt, char *str, int maxlen, int
is_pw);
  void console_provide_logctx(void *logctx);
  int is_interactive(void);

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Feb 17 12:03:59 2005

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.