Hello Guys, I''m was starring my screen for many hours before send this. This is a problem related to Capistrano Pageant interface witch rely on DL interfaces to communicate. The thing is this mechanism sometimes works, sometimes fail by unknown reasons and sometimes segfault. Tried different versions of Ruby from 1.8.5-p114 to 1.8.6-p114 with same results. The code in charge of this is located now in GitHub: http://github.com/jamis/net-ssh/tree/cdcb65ac9ed69be4ecaeed54326b927c99e2075e/lib/net/ssh/authentication/pageant.rb When it fails? When you try to send two messages to the target window at the same time, which is basically the way to communicate with Pageant. This happens when you try to connect and authenticate to two or more servers at the same time. I tried sending a SMTO_BLOCK in SendMessageTimeout, all without success. Looks like there is a corruption of data before that, but that is making my eyes bleed. Even using Winspector to look at the messages and failed. Do you think that migration from DL to Windows-PR will help me pinpoint the bug? The code is not mine, but I''ll love to fix this since it''s annoying (sometimes works, sometimes it doesn''t). Thanks in advance for pointer and suggestions how to tackle this problem. Regards, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Thursday, June 26, 2008 5:02 AM > To: Development and ideas for win32utils projects > Subject: [Win32utils-devel] Replace DL with Windows-PR > > Hello Guys, > > I''m was starring my screen for many hours before send this. > This is a problem related to Capistrano Pageant interface > witch rely on DL interfaces to communicate. > > The thing is this mechanism sometimes works, sometimes fail > by unknown reasons and sometimes segfault. > > Tried different versions of Ruby from 1.8.5-p114 to > 1.8.6-p114 with same results. > > The code in charge of this is located now in GitHub: > > http://github.com/jamis/net-ssh/tree/cdcb65ac9ed69be4ecaeed543 > 26b927c99e2075e/lib/net/ssh/authentication/pageant.rb > > When it fails? > When you try to send two messages to the target window at the > same time, which is basically the way to communicate with Pageant. > This happens when you try to connect and authenticate to two > or more servers at the same time. > > I tried sending a SMTO_BLOCK in SendMessageTimeout, all > without success. > > Looks like there is a corruption of data before that, but > that is making my eyes bleed. Even using Winspector to look > at the messages and failed. > > Do you think that migration from DL to Windows-PR will help > me pinpoint the bug? The code is not mine, but I''ll love to > fix this since it''s annoying (sometimes works, sometimes it doesn''t). > > Thanks in advance for pointer and suggestions how to tackle > this problem.Well, there''s only one way to find out. :) You could save yourself some effort by using win32-mmap, too. The only function I noticed that you''ll have to define yourself is SendMessageTimeout. You can find FindWindow in the Windows::Window module. Note that I think I''m going to reorganize that for 0.9.0 so that it''s under the Windows::Windowing:: namespace, because it seems like a better way to organize the windowing related functions, e.g. Messages, Windows, Timers, etc. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
Replying to myself...> You can find FindWindow in the Windows::Window module. Note > that I think I''m going to reorganize that for 0.9.0 so that > it''s under the > Windows::Windowing:: namespace, because it seems like a > better way to organize the windowing related functions, e.g. > Messages, Windows, Timers, etc.Upon further review I better leave Windows::Window where it is, since it looks like at least one other major project (Watir) is using it. I''ll put the rest of the Windowing related functions under "Windows::Window::", though. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Thursday, June 26, 2008 5:02 AM > To: Development and ideas for win32utils projects > Subject: [Win32utils-devel] Replace DL with Windows-PR > > Hello Guys, > > I''m was starring my screen for many hours before send this. > This is a problem related to Capistrano Pageant interface > witch rely on DL interfaces to communicate. > > The thing is this mechanism sometimes works, sometimes fail > by unknown reasons and sometimes segfault. > > Tried different versions of Ruby from 1.8.5-p114 to > 1.8.6-p114 with same results. > > The code in charge of this is located now in GitHub: > > http://github.com/jamis/net-ssh/tree/cdcb65ac9ed69be4ecaeed543 > 26b927c99e2075e/lib/net/ssh/authentication/pageant.rb<snip> After looking this over I don''t understand this portion: # Start code snippet ptr = Win.mapViewOfFile(filemap, Win::FILE_MAP_WRITE, 0, 0, AGENT_MAX_MSGLEN) if ptr.nil? || ptr.null? raise Net::SSH::Exception, "Mapping of file failed" end ptr[0] = query # HUH? cds = [AGENT_COPYDATA_ID, mapname.size + 1, mapname]. pack("LLp").to_ptr succ = Win.sendMessageTimeout(@win, Win::WM_COPYDATA, Win::NULL, cds, Win::SMTO_NORMAL, 5000, id) if succ > 0 retlen = 4 + ptr.to_s(4).unpack("N")[0] res = ptr.to_s(retlen) end return res # End code snippet MapViewOfFile returns an address, not a pointer, unless this has something to do with DL. Even if it does return a pointer (ok, fine, unpack it), I don''t understand why you are assigning ''query'' to ptr[0]. Something tells me you don''t want to change the address of the mapped view, but perhaps I don''t understand something. Anyway, here''s an attempt at using win32-mmap + windows-pr. Note that the portion at the end is undefined since I''m not sure what you''re trying to do exactly: # UNTESTED! require ''win32/mmap'' require ''windows/thread'' require ''windows/window'' require ''windows/window/message'' module Net module SSH module Authentication module Pageant AGENT_MAX_MSGLEN = 8192 AGENT_COPYDATA_ID = 0x804e50ba class Socket include Windows::Thread include Windows::Window include Windows::Window::Message private_class_method :new def self.open(location=nil) new end def initialize @win = FindWindow("Pageant", "Pageant") if @win == 0 raise Net::SSH::Exception, "pageant process not running" end @res = nil @pos = 0 end def send(data, *args) @res = send_query(data) @pos = 0 end def send_query(query) mapname = "PageantRequest%08x\000" % GetCurrentThreadId() filemap = Win32::MMap.new( :name => mapname, :size => AGENT_MAX_MSGLEN ) result = [0].pack(''L''0 cds = [AGENT_COPYDATA_ID, mapname.size + 1, mapname].pack("LLp") succ = SendMessageTimeout( @win, WM_COPYDATA, nil, cds, SMTO_NORMAL, 5000, result ) if succ > 0 # Do something # res = ??? end return res ensure filemap.close end end end end end end The Windows::Window::Message module you''ll have to grab from the windows-pr cvs repo. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
On Fri, Jun 27, 2008 at 3:19 AM, Berger, Daniel <Daniel.Berger at qwest.com> wrote:> > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Luis Lavena >> Sent: Thursday, June 26, 2008 5:02 AM >> To: Development and ideas for win32utils projects >> Subject: [Win32utils-devel] Replace DL with Windows-PR >> >> Hello Guys, >> >> I''m was starring my screen for many hours before send this. >> This is a problem related to Capistrano Pageant interface >> witch rely on DL interfaces to communicate. >> >> The thing is this mechanism sometimes works, sometimes fail >> by unknown reasons and sometimes segfault. >> >> Tried different versions of Ruby from 1.8.5-p114 to >> 1.8.6-p114 with same results. >> >> The code in charge of this is located now in GitHub: >> >> http://github.com/jamis/net-ssh/tree/cdcb65ac9ed69be4ecaeed543 >> 26b927c99e2075e/lib/net/ssh/authentication/pageant.rb > > <snip> > > After looking this over I don''t understand this portion: > > # Start code snippet > ptr = Win.mapViewOfFile(filemap, Win::FILE_MAP_WRITE, 0, 0, > AGENT_MAX_MSGLEN) > > if ptr.nil? || ptr.null? > raise Net::SSH::Exception, "Mapping of file failed" > end > > ptr[0] = query # HUH? > > cds = [AGENT_COPYDATA_ID, mapname.size + 1, mapname]. pack("LLp").to_ptr > succ = Win.sendMessageTimeout(@win, Win::WM_COPYDATA, Win::NULL, cds, > Win::SMTO_NORMAL, 5000, id) > > if succ > 0 > retlen = 4 + ptr.to_s(4).unpack("N")[0] > res = ptr.to_s(retlen) > end > > return res > # End code snippet > > MapViewOfFile returns an address, not a pointer, unless this has > something to do with DL. > > Even if it does return a pointer (ok, fine, unpack it), I don''t > understand why you are assigning ''query'' to ptr[0]. Something tells me > you don''t want to change the address of the mapped view, but perhaps I > don''t understand something. >me neither, been looking for code examples on internet (that communicate with Pageant) without success, I want fix this since is randomly crashing, whcih could be related to what you described here.> Anyway, here''s an attempt at using win32-mmap + windows-pr. Note that > the portion at the end is undefined since I''m not sure what you''re > trying to do exactly: > > # UNTESTED! > require ''win32/mmap'' > require ''windows/thread'' > require ''windows/window'' > require ''windows/window/message'' > > module Net > module SSH > module Authentication > module Pageant > > AGENT_MAX_MSGLEN = 8192 > AGENT_COPYDATA_ID = 0x804e50ba > > class Socket > include Windows::Thread > include Windows::Window > include Windows::Window::Message > > private_class_method :new > > def self.open(location=nil) > new > end > > def initialize > @win = FindWindow("Pageant", "Pageant") > > if @win == 0 > raise Net::SSH::Exception, "pageant process not > running" > end > > @res = nil > @pos = 0 > end > > def send(data, *args) > @res = send_query(data) > @pos = 0 > end > > def send_query(query) > mapname = "PageantRequest%08x\000" % > GetCurrentThreadId() > > filemap = Win32::MMap.new( > :name => mapname, > :size => AGENT_MAX_MSGLEN > ) > > result = [0].pack(''L''0 > > cds = [AGENT_COPYDATA_ID, mapname.size + 1, > mapname].pack("LLp") > > succ = SendMessageTimeout( > @win, > WM_COPYDATA, > nil, > cds, > SMTO_NORMAL, > 5000, > result > ) > > if succ > 0 > # Do something > # res = ??? > end > > return res > ensure > filemap.close > end > end > end > end > end > end > > The Windows::Window::Message module you''ll have to grab from the > windows-pr cvs repo. > > Regards, >Thank you Daniel, I''ll give it a whirl later today. Regards, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams
On Fri, Jun 27, 2008 at 3:19 AM, Berger, Daniel <Daniel.Berger at qwest.com> wrote:>... > > The Windows::Window::Message module you''ll have to grab from the > windows-pr cvs repo. >Btw, just wondering, no planned upgrade to svn? It seems that Sapphire is using it also, just wanted to know your position about that.> Regards, >Regards and thank you for your time, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Friday, June 27, 2008 2:25 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Replace DL with Windows-PR > > On Fri, Jun 27, 2008 at 3:19 AM, Berger, Daniel > <Daniel.Berger at qwest.com> wrote: > >... > > > > The Windows::Window::Message module you''ll have to grab from the > > windows-pr cvs repo. > > > > Btw, just wondering, no planned upgrade to svn? It seems that > Sapphire is using it also, just wanted to know your position > about that.Nope, no plans. For small libraries like ours I see no real advantage to switching to SVN. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
On Fri, Jun 27, 2008 at 3:42 PM, Berger, Daniel <Daniel.Berger at qwest.com> wrote:> > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Luis Lavena >> Sent: Friday, June 27, 2008 2:25 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Replace DL with Windows-PR >> >> On Fri, Jun 27, 2008 at 3:19 AM, Berger, Daniel >> <Daniel.Berger at qwest.com> wrote: >> >... >> > >> > The Windows::Window::Message module you''ll have to grab from the >> > windows-pr cvs repo. >> > >> >> Btw, just wondering, no planned upgrade to svn? It seems that >> Sapphire is using it also, just wanted to know your position >> about that. > > Nope, no plans. For small libraries like ours I see no real advantage to > switching to SVN. >Then I''ll need to install CVS, last time I had it installed was in 2003 I think :-P> Regards, >Thank you again for your time Daniel, will check this tonight! -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams