Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: From: Mitch Davis To: cygwin AT cygwin DOT com Cc: Mitch Davis , mjd AT alphalink DOT com DOT au Subject: 1.3.10: SendMessage(WM_COPYDATA) in a Win32 program fails within Cygwin Date: Thu, 30 May 2002 02:50:41 +1000 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C20730.F88DE58E" ------_=_NextPart_000_01C20730.F88DE58E Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C20730.F88DE58E" ------_=_NextPart_001_01C20730.F88DE58E Content-Type: text/plain; charset="iso-8859-1" Hello, Thank you for Cygwin - Cygwin rocks! I would like to use plink (a command-line SSH program from the "PuTTY" suite) to connect my W2K PC to a Linux host, using the ssh v2 protocol, and RSA keys, via the "pageant" key agent. I would also like to be able to invoke plink (a conventional "console" Win32 app) both from a W2K cmd.exe window, and from a bash window. My problem is, plink works under cmd.exe, but doesn't work under bash. It also doesn't work if I invoke cmd.exe inside bash, then invoke plink from the cmd.exe. By "doesn't work", I mean plink is unable to fetch any keys from "pageant", the SSH key agent. I got the source for putty (go Open Source!) and compiled it using Microsoft Visual Studio 6. I have found where in plink the problem is happening: http://cvs.tartarus.org/putty/pageantc.c?rev=1.5 Look for SendMessage(hwnd, WM_COPYDATA, (WPARAM) NULL, (LPARAM) & cds). This returns 1 (success) when run under cmd.exe, and 0 when run under bash, or cmd.exe under bash. (If SendMessage returns 0, the keys can't be fetched and authentication with keys fails. Version: I am using PuTTY compiled from source checked out using CVS at around May 29 14:10 GMT. The compiler is Visual C++ 6.0. Exactly the same problem happens with the binaries distributed on the PuTTY web site. The version of cygwin on my computer is no more than one day old. The cygwin1.dll is version 1.3.10. The OS is Windows 2000 Professional, Version 5.0.2195 Service Pack 2 Build 2195. The server is running OpenSSH v3.1p1 from very new binary RPMs supplied by Red Hat. The OS is Red Hat 7.2. SSH is configured to use winbind via PAM so users can log in with their Windows username. The winbind part is working fine. Protocols: I have to use a profile because we can only use ssh v2 protocol, and plink has no -2 switch to force v2. The profile works perfectly using putty.exe (the GUI ssh), with and without the agent running. Here's what I get when I run plink from cmd.exe: M:\src\putty>.\pageant "e:\mjd\identity" M:\src\putty>.\plink -v server date Looking up host "server" Connecting to 192.168.1.16 port 22 Server version: SSH-1.99-OpenSSH_3.1p1 We claim version: SSH-2.0-PuTTY-Local: May 30 2002 00:51:02 Using SSH protocol version 2 Doing Diffie-Hellman group exchange Doing Diffie-Hellman key exchange Host key fingerprint is: ssh-rsa 1024 24:4e:e9:2b:6b:3b:76:6c:c2:b2:4d:26:07:fb:48:47 Using username "mitch davis". Pageant is running. Requesting keys. agent_query: hwnd=0040010A agent_query: mapname=PageantRequest00000510 agent_query: filemap=000001D4 agent_query: id=1 do_ssh2_authconn: r=00811BF0 responselen=480 Pageant has 1 SSH2 keys Trying Pageant key #0 Authenticating with public key "mitch davis AT eng02 DOT extel DOT com DOT au" from agent agent_query: hwnd=0040010A agent_query: mapname=PageantRequest00000510 agent_query: filemap=000001D4 agent_query: id=1 Sending Pageant's response Access granted Opened channel for session Requesting OpenSSH-style agent forwarding Agent forwarding enabled Started a shell/command Server sent command exit status 0 Thu May 30 01:52:20 EST 2002 M:\src\putty> (In other words, exactly what I expect) Here's what I get when I run plink from cygwin bash: mjd AT eng02 [m:/src/putty] ./plink -v server date Looking up host "server" Connecting to 192.168.1.16 port 22 Server version: SSH-1.99-OpenSSH_3.1p1 We claim version: SSH-2.0-PuTTY-Local: May 30 2002 00:51:02 Using SSH protocol version 2 Doing Diffie-Hellman group exchange Doing Diffie-Hellman key exchange Host key fingerprint is: ssh-rsa 1024 24:4e:e9:2b:6b:3b:76:6c:c2:b2:4d:26:07:fb:48:47 Using username "mitch davis". Pageant is running. Requesting keys. agent_query: hwnd=0040010A agent_query: mapname=PageantRequest000005f8 agent_query: filemap=000002A0 agent_query: id=0 do_ssh2_authconn: r=00000000 responselen=0 mitch davis AT cvssrv's password: _ (In other words, id==0, the key can't be retrieved, and ssh.c falls back to a password. Things I've not tried: Trying to reproduce this on another computer. (Should I?) Downgrading Cygwin. (An earlier version chopped my Windows username ("Mitch Davis") and fed it to plink in two pieces; of course, plink couldn't work) My questions: - Do you know what the problem might be? - Do you know what might be causing SendMessage to fail? (I'm not a Windows programmer). - Can you suggest or provide a test program that could be used to isolate or further test the problem? (Is the one at the end of pageantc.c a good one to try?) Your help would be greatly appreciated. I have also sent this question to the PuTTY maintainer, to see if he can see the problem from his end. Many thanks, Mitch. --- mailto:mitch DOT davis AT extel DOT com DOT au ---------------------------------------------------------------------------- ------------------------ The information contained in this message and any attachments is confidential and intended for the named recipient(s). If you have received this message in error, please contact sender by return e-mail and destroy the message and any attachments. Any opinions or undertakings expressed in this message are those of the individual sender except where the sender expressly and with authority states them to be the opinions of Extel. ---------------------------------------------------------------------------- ------------------------ ------_=_NextPart_001_01C20730.F88DE58E Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 1.3.10: SendMessage(WM_COPYDATA) in a Win32 program fails within = Cygwin

Hello,

Thank you for Cygwin - Cygwin rocks!

I would like to use plink (a command-line
SSH program from the "PuTTY" suite) = to
connect my W2K PC to a Linux host, using the
ssh v2 protocol, and RSA keys, via the
"pageant" key agent.

I would also like to be able to invoke plink = (a
conventional "console" Win32 app) both = from a
W2K cmd.exe window, and from a bash window.

My problem is, plink works under cmd.exe, but = doesn't
work under bash.  It also doesn't work if I = invoke
cmd.exe inside bash, then invoke plink from the = cmd.exe.
By "doesn't work", I mean plink is unable = to fetch any
keys from "pageant", the SSH key = agent.

I got the source for putty (go Open Source!) and = compiled it
using Microsoft Visual Studio 6.  I have found = where in
plink the problem is happening:

  http://cvs.tartarus.org/putty/pageantc.c?rev=3D1.5=

Look for SendMessage(hwnd, WM_COPYDATA, (WPARAM) = NULL, (LPARAM) & cds).
This returns 1 (success) when run under cmd.exe, and = 0
when run under bash, or cmd.exe under bash.  = (If SendMessage
returns 0, the keys can't be fetched and = authentication with
keys fails.

Version:

  I am using PuTTY compiled from source = checked
  out using CVS at around May 29 14:10 = GMT.
  The compiler is Visual C++ 6.0.  Exactly = the same
  problem happens with the binaries distributed = on
  the PuTTY web site.

  The version of cygwin on my computer is no = more
  than one day old.  The cygwin1.dll is = version
  1.3.10.

  The OS is Windows 2000 Professional, = Version
  5.0.2195 Service Pack 2 Build 2195.

  The server is running OpenSSH v3.1p1 = from
  very new binary RPMs supplied by Red = Hat.
  The OS is Red Hat 7.2.  SSH is = configured to
  use winbind via PAM so users can log in with = their
  Windows username.  The winbind part is = working
  fine.

Protocols:

  I have to use a profile because we can only = use
  ssh v2 protocol, and plink has no -2 switch = to force v2.

  The profile works perfectly using = putty.exe
  (the GUI ssh), with and without the agent = running.

Here's what I get when I run plink from cmd.exe:

M:\src\putty>.\pageant = "e:\mjd\identity"
<then I authenticate>
M:\src\putty>.\plink -v server date
Looking up host "server"
Connecting to 192.168.1.16 port 22
Server version: SSH-1.99-OpenSSH_3.1p1
We claim version: SSH-2.0-PuTTY-Local: May 30 2002 = 00:51:02
Using SSH protocol version 2
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange
Host key fingerprint is:
ssh-rsa 1024 = 24:4e:e9:2b:6b:3b:76:6c:c2:b2:4d:26:07:fb:48:47
Using username "mitch davis".
Pageant is running. Requesting keys.
agent_query: hwnd=3D0040010A
agent_query: mapname=3DPageantRequest00000510
agent_query: filemap=3D000001D4
agent_query: id=3D1
do_ssh2_authconn: r=3D00811BF0 = responselen=3D480
Pageant has 1 SSH2 keys
Trying Pageant key #0
Authenticating with public key "mitch = davis AT eng02 DOT extel DOT com DOT au" from agent
agent_query: hwnd=3D0040010A
agent_query: mapname=3DPageantRequest00000510
agent_query: filemap=3D000001D4
agent_query: id=3D1
Sending Pageant's response
Access granted
Opened channel for session
Requesting OpenSSH-style agent forwarding
Agent forwarding enabled
Started a shell/command
Server sent command exit status 0
Thu May 30 01:52:20 EST 2002

M:\src\putty>

(In other words, exactly what I expect)

Here's what I get when I run plink from cygwin = bash:

mjd AT eng02 [m:/src/putty] ./plink -v server = date
Looking up host "server"
Connecting to 192.168.1.16 port 22
Server version: SSH-1.99-OpenSSH_3.1p1
We claim version: SSH-2.0-PuTTY-Local: May 30 2002 = 00:51:02
Using SSH protocol version 2
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange
Host key fingerprint is:
ssh-rsa 1024 = 24:4e:e9:2b:6b:3b:76:6c:c2:b2:4d:26:07:fb:48:47
Using username "mitch davis".
Pageant is running. Requesting keys.
agent_query: hwnd=3D0040010A
agent_query: mapname=3DPageantRequest000005f8
agent_query: filemap=3D000002A0
agent_query: id=3D0
do_ssh2_authconn: r=3D00000000 = responselen=3D0
mitch davis AT cvssrv's password: _

(In other words, id=3D=3D0, the key can't be
retrieved, and ssh.c falls back to a = password.

Things I've not tried:

  Trying to reproduce this on another = computer.
  (Should I?)

  Downgrading Cygwin.  (An earlier = version
  chopped my Windows username ("Mitch = Davis")
  and fed it to plink in two pieces; of = course,
  plink couldn't work)

My questions:

 - Do you know what the problem might be?
 - Do you know what might be causing = SendMessage to
   fail?  (I'm not a Windows = programmer).
 - Can you suggest or provide a test program = that
   could be used to isolate or further = test the
   problem?  (Is the one at the end = of pageantc.c
   a good one to try?)

Your help would be greatly appreciated.  I = have
also sent this question to the PuTTY = maintainer,
to see if he can see the problem from his = end.

Many thanks,

Mitch.
---
mailto:mitch DOT davis AT extel DOT com DOT au=

---------------------------------------------------------------= -------------------------------------
The information contained in this message and any = attachments is
confidential and intended for the named = recipient(s). If you have received
this message in error, please contact sender by = return e-mail and
destroy the message and any attachments.
Any opinions or undertakings expressed in this = message are those of the
individual sender except where the sender expressly = and with authority
states them to be the opinions of Extel.
---------------------------------------------------------------= -------------------------------------
   =20

  ------_=_NextPart_001_01C20730.F88DE58E-- ------_=_NextPart_000_01C20730.F88DE58E Content-Type: text/plain; name="env-under-cmd.txt" Content-Disposition: attachment; filename="env-under-cmd.txt" ALLUSERSPROFILE=C:\Documents and Settings\All Users APPDATA=C:\Documents and Settings\mitch davis\Application Data BUILD_SCRIPT_GREEN=c:\green BUILD_SCRIPT_TEMP=e:\temp BUILD_SCRIPT_VSS=E:\Program Files\Common\VSS\win32 CommonProgramFiles=C:\Program Files\Common Files COMPUTERNAME=ENG02 ComSpec=C:\WINNT\system32\cmd.exe CVS_RSH=e:\Program Files\Putty\plink.exe CYGWIN=ntsec tty GHS_LMHOST=@simulator HOME=e:\mjd HOMEDRIVE=C: HOMEPATH=\ LOGNAME=Importer LOGONSERVER=\\SERVER2 NUMBER_OF_PROCESSORS=1 OS=Windows_NT Os2LibPath=C:\WINNT\system32\os2\dll; Path=C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;e:\cygwin\bin;g:\vc98\bin;g:\common\msdev98\bin PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH PROCESSOR_ARCHITECTURE=x86 PROCESSOR_IDENTIFIER=x86 Family 6 Model 6 Stepping 2, AuthenticAMD PROCESSOR_LEVEL=6 PROCESSOR_REVISION=0602 ProgramFiles=C:\Program Files PROMPT=$P$G SystemDrive=C: SystemRoot=C:\WINNT TEMP=e:\temp TMP=c:\TEMP TRACE_SCRIPT_EXIT=vc++ USERDOMAIN=EXTEL.COM.AU USERNAME=Mitch Davis USERPROFILE=C:\Documents and Settings\mitch davis windir=C:\WINNT ------_=_NextPart_000_01C20730.F88DE58E Content-Type: text/plain; name="env-under-bash.txt" Content-Disposition: attachment; filename="env-under-bash.txt" ALLUSERSPROFILE='C:\Documents and Settings\All Users' APPDATA='C:\Documents and Settings\mitch davis\Application Data' BASH=/usr/bin/bash BASH_VERSINFO=([0]="2" [1]="05a" [2]="0" [3]="3" [4]="release" [5]="i686-pc-cygwin") BASH_VERSION='2.05a.0(3)-release' BUILD_SCRIPT_GREEN='c:\green' BUILD_SCRIPT_TEMP='e:\temp' BUILD_SCRIPT_VSS='E:\Program Files\Common\VSS\win32' COLUMNS=80 COMMONPROGRAMFILES='C:\Program Files\Common Files' COMPUTERNAME=ENG02 COMSPEC='C:\WINNT\system32\cmd.exe' CVS_RSH='e:\Program Files\Putty\plink.exe' CYGWIN='ntsec tty' DIRSTACK=() EUID=500 GHS_LMHOST=@simulator GROUPS=() HISTFILE=/mjd/.bash_history HISTFILESIZE=500 HISTSIZE=500 HOME=/mjd HOMEDRIVE=C: HOMEPATH='\' HOSTNAME=ENG02 HOSTTYPE=i686 IFS=$' \t\n' LINES=25 LOGNAME=Importer LOGONSERVER='\\SERVER2' MACHTYPE=i686-pc-cygwin MAILCHECK=60 MAKE_MODE=unix MANPATH=:/usr/ssl/man NUMBER_OF_PROCESSORS=1 OLDPWD=/cygdrive/e/mjd OPTERR=1 OPTIND=1 OS=Windows_NT OS2LIBPATH='C:\WINNT\system32\os2\dll;' OSTYPE=cygwin PATH=.:/mjd/bin:/bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT PATHEXT='.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH' PIPESTATUS=([0]="0") PPID=1 PROCESSOR_ARCHITECTURE=x86 PROCESSOR_IDENTIFIER='x86 Family 6 Model 6 Stepping 2, AuthenticAMD' PROCESSOR_LEVEL=6 PROCESSOR_REVISION=0602 PROGRAMFILES='C:\Program Files' PS1='mjd AT eng02 [\w] ' PS2='> ' PS4='+ ' PWD=/mjd SHELL=/bin/bash SHELLOPTS=braceexpand:hashall:histexpand:monitor:history:interactive-comments:emacs SHLVL=1 SYSTEMDRIVE=C: SYSTEMROOT='C:\WINNT' TEMP=/cygdrive/e/temp TERM=cygwin TMP=/cygdrive/c/TEMP TRACE_SCRIPT_EXIT=vc++ UID=500 USER=Administrator USERDOMAIN=EXTEL.COM.AU USERNAME='Mitch Davis' USERPROFILE='C:\Documents and Settings\mitch davis' WINDIR='C:\WINNT' _=pwd i=/etc/profile.d/openssl.sh ------_=_NextPart_000_01C20730.F88DE58E Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ------_=_NextPart_000_01C20730.F88DE58E--