Re: [Ssh-sftp-perl-users] Net::SSH2 on perl 5.6
Brought to you by:
dbrobins
From: hugues <Hug...@af...> - 2006-02-06 19:26:23
|
>>>>> "David" =3D=3D David Robins <dbr...@cp...> writes: David> On Friday February 3, 2006 00:51, hugues wrote: >> I just wanted to know if there were some fundamental reason why your >> module actually requires perl 5.8 or if there might be some hope to >> make it run under perl 5.6 too ? David> Nothing particular, just the convenience of not having to jump t= hrough hoops=20 David> and include cruft for compatibility. David> However, I am aware there are a lot of perl 5.6 installations ou= t there (the=20 David> last place I worked still used it; they brought in a contractor = to help with=20 David> upgrading to 5.8 but I don't think they actually did upgrade), a= nd I'm=20 David> willing to make Net::SSH2 work with 5.6, especially if met halfw= ay by someone=20 David> such as yourself helping with testing/changes. >> I've been trying just the obvious things, i.e removing all 'use 5.00= 8' >> in Makefile.PL and all the .pm files, and adding a typemap entry for >> 'const char *' as it is defined in the default one for perl5.8 but n= ot >> for perl5.6. >>=20 >> With that mods, i managed to compile the stuff, but got stuck there:= =20 >>=20 >> root-w2# prove -v -b t/Net-SSH2.t=20=20 David> ... >> ok 8 - API date yyyymmddhhmm=20 >> event is not of type AVPtr at blib/lib/Net/SSH2.pm line 396.=20 David> I searched and found something that looks relevant: David> http://www.mail-archive.com/pe...@pe.../msg00982.html David> Looks like 5.6 doesn't like "AV *" in an XS signature and requir= es it be typed=20 David> as an SV * and then checked/cast (a typemap entry might work the= re too; it=20 David> would be nice if the entries added can be 5.6-only (to keep the = 5.8 path=20 David> cleaner), which will probably require two typemap files). Hi David, I've started investigating as promised, and locally modified the prototype for the net_ss__poll() function in the SSH2.xs file as advised in http://www.mail-archive.com/pe...@pe.../msg00982.html (well hopefully ;-) Here are the diffs: --- SSH2.xs.orig Wed Nov 30 04:54:08 2005 +++ SSH2.xs Mon Feb 6 20:00:57 2006 @@ -964,20 +964,23 @@ RETVAL =20 void -net_ss__poll(SSH2* ss, int timeout, AV* event) +net_ss__poll(SSH2* ss, int timeout, SV* event) PREINIT: LIBSSH2_POLLFD* pollfd; int i, count, changed; CODE: + if (! (SvRV(event) && SvTYPE(SvRV(event)) =3D=3D SVt_PVAV)) + croak("%s::poll: reference to an array expected", class); + AV* av_event =3D (AV *) SvRV(event); clear_error(ss); - count =3D av_len(event) + 1; + count =3D av_len(av_event) + 1; debug("%s::poll: timeout =3D %d, array[%d]\n", class, timeout, count); if (!(pollfd =3D malloc(sizeof(LIBSSH2_POLLFD) * count))) { set_error(ss, 0, "out of memory allocating pollfd structures"); XSRETURN_EMPTY; } for (i =3D 0; i < count; ++i) { - SV* sv =3D *av_fetch(event, i, 0/*lval*/), ** handle, ** events; + SV* sv =3D *av_fetch(av_event, i, 0/*lval*/), ** handle, ** events; HV* hv; =20 if (!SvROK(sv) || SvTYPE(SvRV(sv)) !=3D SVt_PVHV) @@ -1027,7 +1030,7 @@ XSRETURN_EMPTY; =20 for (i =3D 0; i < count; ++i) { - HV* hv =3D (HV*)SvRV(*av_fetch(event, i, 0/*lval*/)); + HV* hv =3D (HV*)SvRV(*av_fetch(av_event, i, 0/*lval*/)); hv_store(hv, "revents", 7, newSViv(pollfd[i].revents), 0/*hash*/); debug("- [%d] revents %d\n", i, pollfd[i].revents); } With this change, the module now compile and apparently passes the same tests as in perl5.8. =20 I've also checked that the changes still pass on my perl5.7. I've been stuck though at connect() time when running the t/Net-SSH2.t test file. It seems to me that there might be a typo here as the test is done via: ok($ssh2->connect($host), "connect to $host"); but i beleive that: ok($ssh2->connect($host) =3D=3D 0, "connect to $host"); would be more appropriate, at least that's the impression i get when reading both the module code and the libssh2 API documentation that says:=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - Name libssh2_session_startup =E2=80=94 start ssh2 on a socket - Synopsis #include <libssh2.h> int libssh2_session_startup(LIBSSH2_SESSION *session, int socket); Description This function starts the SSH2 protocol on an existing socket, and associates it with session.=20 On success, 0 is returned. On error, one of the errorcodes below is returned indicating the specific error that occurred.=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D So i understand that $ssh2->connect() will return 0 when succeeding. Anyway when applying the following change, i can get the tests to proceed up to the authentication phase (i will stop here for today): --- t/Net-SSH2.t.orig Wed Nov 30 04:30:52 2005 +++ t/Net-SSH2.t Mon Feb 6 20:16:14 2006 @@ -54,7 +54,7 @@ } SKIP: { # SKIP-server skip '- no server daemon available', 61 unless $host; -ok($ssh2->connect($host), "connect to $host"); +ok($ssh2->connect($host) =3D=3D 0, "connect to $host"); =20 # (8) server methods for my $type(qw(kex hostkey crypt_cs crypt_sc mac_cs mac_sc comp_cs comp_s= c)) { Thanks again for your help. --=20 Hugues Lafarge || Email: Hug...@af... Agence France Presse || Phone: +33 1 40 41 77 15 4 rue de la bourse, 75002 Paris || Fax: +33 1 40 41 79 24 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- This e-mail, and any file transmitted with it, is confidential and intended solely for the use of the individual or entity to whom it is addressed. If you have received this email in error, please contact the sender and delete the email from your system. If you are not the named addressee you should not disseminate, distribute or copy this email. For more information on Agence France-Presse, please visit our web site at http://www.afp.com -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |