Skip Menu |

This queue is for tickets about the IO-Socket-SSL CPAN distribution.

Report information
The Basics
Id: 23419
Status: rejected
Priority: 0/
Queue: IO-Socket-SSL

People
Owner: Nobody in particular
Requestors: jschulz.cpan [...] bloonix.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.01
Fixed in: (no value)



Hi, I tests IO::Socket::SSL with Storable and received the following error: File is not a perl storable at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/fd_retrieve.al) line 346, at ./storable-socket- ssl line 61 my code: use strict; use warnings; package Server; use IO::Socket::SSL; use Storable qw(nstore_fd); use Data::Dumper; unless (-d "certs") { if (-d "../certs") { chdir ".."; } else { die "Please run this example from the IO::Socket::SSL distribution directory!\n"; } } sub run { my $socket = IO::Socket::SSL->new( Listen => 5, LocalAddr => 'localhost', LocalPort => 9000, Proto => 'tcp', Reuse => 1, SSL_verify_mode => 0x01, SSL_passwd_cb => sub {return "bluebell"}, ) or die "server: can't open socket over port 9000"; warn "server initialized\n"; while (my $client = $socket->accept()) { chomp (my $request = <$client>); next unless $request; warn "client request: $request\n"; my %hash = (a=>1,b=>2,c=>3); nstore_fd(\%hash, $client) or die $!; close($client); close($socket); } } package Client; use IO::Socket::SSL; use Storable qw(fd_retrieve); use Data::Dumper; sub run { my $socket = IO::Socket::SSL->new( PeerAddr => 'localhost', PeerPort => '9000', Proto => 'tcp', SSL_use_cert => 1, SSL_verify_mode => 0x01, SSL_passwd_cb => sub { return "opossum" } ) or die "client: can't connect to 127.0.0.1:9000"; warn "client connected to server\n"; print $socket "hash\n"; my $data = fd_retrieve($socket) or die $!; warn Dumper($data); close($socket); } 1; if (my $pid = fork) { run Server; waitpid($pid,0); } else { sleep 1; run Client; } end code If I run the same example with IO::Socket::INET I receive no error. #> perl -V Summary of my perl5 (revision 5 version 8 subversion 7) configuration: Platform: osname=linux, osvers=2.6.10, archname=i486-linux-gnu-thread-multi uname='linux rothera 2.6.10 #1 smp fri may 13 09:24:22 utc 2005 i686 gnulinux ' config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN - Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dprefix=/usr -Dprivlib=/ usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix=/usr - Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/ usr/local -Dsitelib=/usr/local/share/perl/5.8.7 -Dsitearch=/usr/local/ lib/perl/5.8.7 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/ man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/ man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs - Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.7 - Dd_dosuid -des' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS - DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include - D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN - fno-strict-aliasing -pipe -I/usr/local/include' ccversion='', gccversion='4.0.3 20051204 (prerelease) (Ubuntu 4.0.2- 5ubuntu2)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt perllibs=-ldl -lm -lpthread -lc -lcrypt libc=/lib/libc-2.3.5.so, so=so, useshrplib=true, libperl=libperl.so.5.8.7 gnulibc_version='2.3.5' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT Locally applied patches: SPRINTF0 - fixes for sprintf formatting issues - CVE-2005-3962 Built under linux Compiled at Dec 16 2005 07:48:39 @INC: /etc/perl /usr/local/lib/perl/5.8.7 /usr/local/share/perl/5.8.7 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl #> uname -a Linux acd-js 2.6.15-27-386 #1 PREEMPT Sat Sep 16 01:51:59 UTC 2006 i686 GNU/Linux Cheers, Jonny
Subject: IO::Socket::SSL and Storable
Hi, I tests IO::Socket::SSL with Storable and received the following error: File is not a perl storable at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/fd_retrieve.al) line 346, at ./storable-socket- ssl line 61 my code: use strict; use warnings; package Server; use IO::Socket::SSL; use Storable qw(nstore_fd); use Data::Dumper; unless (-d "certs") { if (-d "../certs") { chdir ".."; } else { die "Please run this example from the IO::Socket::SSL distribution directory!\n"; } } sub run { my $socket = IO::Socket::SSL->new( Listen => 5, LocalAddr => 'localhost', LocalPort => 9000, Proto => 'tcp', Reuse => 1, SSL_verify_mode => 0x01, SSL_passwd_cb => sub {return "bluebell"}, ) or die "server: can't open socket over port 9000"; warn "server initialized\n"; while (my $client = $socket->accept()) { chomp (my $request = <$client>); next unless $request; warn "client request: $request\n"; my %hash = (a=>1,b=>2,c=>3); nstore_fd(\%hash, $client) or die $!; close($client); close($socket); } } package Client; use IO::Socket::SSL; use Storable qw(fd_retrieve); use Data::Dumper; sub run { my $socket = IO::Socket::SSL->new( PeerAddr => 'localhost', PeerPort => '9000', Proto => 'tcp', SSL_use_cert => 1, SSL_verify_mode => 0x01, SSL_passwd_cb => sub { return "opossum" } ) or die "client: can't connect to 127.0.0.1:9000"; warn "client connected to server\n"; print $socket "hash\n"; my $data = fd_retrieve($socket) or die $!; warn Dumper($data); close($socket); } 1; if (my $pid = fork) { run Server; waitpid($pid,0); } else { sleep 1; run Client; } end code If I run the same example with IO::Socket::INET I receive no error. #> perl -V Summary of my perl5 (revision 5 version 8 subversion 7) configuration: Platform: osname=linux, osvers=2.6.10, archname=i486-linux-gnu-thread-multi uname='linux rothera 2.6.10 #1 smp fri may 13 09:24:22 utc 2005 i686 gnulinux ' config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN - Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dprefix=/usr -Dprivlib=/ usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix=/usr - Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/ usr/local -Dsitelib=/usr/local/share/perl/5.8.7 -Dsitearch=/usr/local/ lib/perl/5.8.7 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/ man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/ man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs - Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.7 - Dd_dosuid -des' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS - DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include - D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN - fno-strict-aliasing -pipe -I/usr/local/include' ccversion='', gccversion='4.0.3 20051204 (prerelease) (Ubuntu 4.0.2- 5ubuntu2)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt perllibs=-ldl -lm -lpthread -lc -lcrypt libc=/lib/libc-2.3.5.so, so=so, useshrplib=true, libperl=libperl.so.5.8.7 gnulibc_version='2.3.5' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT Locally applied patches: SPRINTF0 - fixes for sprintf formatting issues - CVE-2005-3962 Built under linux Compiled at Dec 16 2005 07:48:39 @INC: /etc/perl /usr/local/lib/perl/5.8.7 /usr/local/share/perl/5.8.7 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl #> uname -a Linux acd-js 2.6.15-27-386 #1 PREEMPT Sat Sep 16 01:51:59 UTC 2006 i686 GNU/Linux Cheers, Jonny
Sorry, double post! You can delete this report!
From: BLOONIX [...] cpan.org
Hello, I have further informations. Send: my %hash1 = ( a => 1 ); my %hash2 = ( 1, 2, 3, 4 ); my %hash3 = ( a => '1' ); my $dump1 = nfreeze \%hash1; my $dump2 = nfreeze \%hash2; my $dump3 = nfreeze \%hash3; print $client $dump1; print $client "\n"; print $client $dump2; print $client "\n"; print $client $dump3; Receive: my $dump1 = <$socket>; my $dump2 = <$socket>; my $dump3 = <$socket>; my $data1 = thaw($dump1); my $data2 = thaw($dump2); my $data3 = thaw($dump3); warn Dumper($data1); warn Dumper($data2); warn Dumper($data3); Output: $VAR1 = { 'a' => 1 }; $VAR1 = { '1' => 2, '3' => 4 }; $VAR1 = undef; The problem doesn't exists with IO::Socket::INET but with IO::Socket::SSL. What can this be? Also I tried it with nfreeze() and thaw() and got the same output (undef). Regards, Jonny
From: Steffen_Ullrich [...] genua.de
Storable uses the PerlIO layer to send and retrieve data, not the sysread/syswrite function. With ssl a read might fail because it needs to write and a write might fail because it needs to read (because the it needs to do SSL handshaking, e.g. transport data on the SSL layer, not on the application layer). I guess it needs one need to export the sysread/syswrite somehow to the PerlIO Layer, but I don't know yet how. Show quoted text
> > The problem doesn't exists with IO::Socket::INET but with > IO::Socket::SSL. What can this be? Also I tried it with nfreeze() and > thaw() and got the same output (undef).
The problem with the undef in your example is an error in the code. You do 'print $client3' w/o a newline afterwards, but you read with <$socket>, e.g expecting a line, which you don't get. With all the prints before you add a 'print "\n"'. But there is another flaw in your program. The output from nfreeze is binary, so it might contain "\n" already. Thus reading with <$socket> might give you only part of the packet. Me preferred method: write: my $packet = nfreeze( $data ); # freeze packet $packet = pack( "N/a*", $packet ); # add length of packet print $packet; read: die if 4 != read( $socket, my $buf,4 ); # read length my $len = unpack( "N",$buf ); # extract length die if $len != read( $socket, $buf,$len); # read data my $data = thaw( $buf ); # thaw packet This is not much harder then fd_retrieve etc, but you have more control about error handling and this is the only method which works if you need multiple read/writes (e.g if the socket is non-blocking) Show quoted text
> > Regards, > Jonny
From: BLOONIX [...] cpan.org
Hallo Steffen, danke fuer deine zuegige Antwort. Show quoted text
> The problem with the undef in your example is an error in the code. > You do 'print $client3' w/o a newline afterwards, but you read with > <$socket>, e.g expecting a line, which you don't get. > With all the prints before you add a 'print "\n"'.
Das Problem besteht auch mit einen print $client3 "\n"; my %hash1 = ( a => 1 ); my %hash2 = ( 1, 2, 3, 4 ); my %hash3 = ( a => '1' ); Wenn ich %hash1 = ( a => '1' ); zuweise, dann klappt es einfach nicht. Der einzige Unterschied hier sind die Hochkomma '1'. Strings werden also auch nicht Uebertragen, da sie ebenfalls gequotet werden muessen. Diese Phenomaen ist recht seltsam. Gruss, Jonny
From: Steffen_Ullrich [...] genua.de
das Problem ist, das du mit <$socket> liest. Damit liest du bis zum Zeilenende, genauer gesagt bis 0x0a ("\n"). Wenn du mal anschaust, wie { a => '1' } gefreezed wird im Gegensatz zu { a => 1 }: perl -MStorable -e ' print Storable::nfreeze({ a => q[1] })' | od -x 0000000 0705 0003 0000 0a01 3101 0000 0100 0061 0000017 vs. perl -MStorable -e ' print Storable::nfreeze({ a => q1 })' | od -x 0000000 0705 0003 0000 0a01 7102 0031 0000 6101 0000020 dann fällt auf, das bei der ersten Variante ein 0x0a, d.h newline im gefreezten auftaucht, bei der zweiten aber nicht. D.h. dein <$socket> liest nur die ersten paar bytes, bis zum ersten 0x0a. der Output von Storable::nfreeze ist binary, d.h. du kannst ihn nicht sicher mit <> einlesen, sondern musst stattdessen die Länge vorab wissen und dann mit read( $fd,$buf,$len) die Daten einlesen. Siehe das Beispiel vom letzten Mal, wie man ein Paket erzeugt, was als Prefix die Länge hat und wie man mit dem ersten read dann die Länge und mit dem zweiten read dann die Daten einliest Show quoted text
> Das Problem besteht auch mit einen print $client3 "\n"; > > my %hash1 = ( a => 1 ); > my %hash2 = ( 1, 2, 3, 4 ); > my %hash3 = ( a => '1' ); > > Wenn ich %hash1 = ( a => '1' ); zuweise, dann klappt es einfach nicht. > Der einzige Unterschied hier sind die Hochkomma '1'. Strings werden > also auch nicht Uebertragen, da sie ebenfalls gequotet werden muessen. > Diese Phenomaen ist recht seltsam. > > Gruss, > Jonny >
I don't expect me to fix this in the near future. At least added info in manual page and BUGS file about the problem and how to work around it.
will probably never work unless Storable behaves differently