Skip Menu |

This queue is for tickets about the perl-ldap CPAN distribution.

Report information
The Basics
Id: 77458
Status: resolved
Priority: 0/
Queue: perl-ldap

People
Owner: Nobody in particular
Requestors: quanah.gibsonmount [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.44
Fixed in: 0.45



Subject: Make IPv6 usage more sane
For some bizarre reason, Net::LDAP requires a flag to enable IPv6. Since IO::Socket::INET6 supports both IPv4 and IPv6, this seems rather odd. I would instead suggest doing what every other perl module I use does -- Test if IO::Socket::INET6 is available to load. If it is, then use it. If not, don't. Then there is no need for an obnoxious flag that requires writing special code or rewriting every script ever written using Net::LDAP just for IPv6 support. For example, from IO::Socket::SSL; if ( ! eval { require Socket6; Socket6->import( 'inet_pton' ); require IO::Socket::INET6; @ISA = qw(IO::Socket::INET6); $can_ipv6 = 1; }) { @ISA = qw(IO::Socket::INET); } I.e., see if we can do IPv6 or not.
On Sat May 26 20:09:13 2012, MISHIKAL wrote: Show quoted text
> For example, from IO::Socket::SSL; > > if ( ! eval { > require Socket6; > Socket6->import( 'inet_pton' ); > require IO::Socket::INET6; > @ISA = qw(IO::Socket::INET6); > $can_ipv6 = 1; > }) { > @ISA = qw(IO::Socket::INET); > }
As a side note, even if you don't use INET6 with net-ldap via the flag, any SSL (startTLS, Ldaps) connections done with net-ldap will, because of this very code block in IO::Socket::SSL. So you may as well use it if it is available, because it is going to look really odd to not have Net::LDAP fail when IO::Socket::SSL does if there's an IPv6 hostname->IP issue. --Quanah
Hi
Please try https://github.com/marschap/perl- ldap/commit/eedd42a7be87fb63546d4edb27d64cccfd021882 and report feedback Peter (written again in case the text of the other reply got lost)
On Mon May 28 11:23:15 2012, marschap wrote: Show quoted text
> Please try > https://github.com/marschap/perl- > ldap/commit/eedd42a7be87fb63546d4edb27d64cccfd021882 > and report feedback > > Peter > (written again in case the text of the other reply got lost)
Hi Peter, I will get this tested this week or next. I have to re-setup my IPv6 lab. ;)
On Wed May 30 18:23:57 2012, MISHIKAL wrote: Your version fails for me because the value assigned to $can_ipv6 is not preserved. I modified the code to clearly note the state of $can_ipv6: my $can_ipv6 = 0; # try to load IO::Socket::INET6 and note if we were successful BEGIN { $can_ipv6 = 1 if (eval { require IO::Socket::INET6; }); print "BEGIN CAN_IPV6 is : $can_ipv6\n"; } print "CAN_IPV6 is : $can_ipv6\n"; zimbra@zqa-395-ipv6:~$ zmldappasswd -b sillypass BEGIN CAN_IPV6 is : 1 CAN_IPV6 is : 0 This is because BEGIN is executed *before* the code line setting it to zero. Changing the code block like this fixes the problem: my $can_ipv6; BEGIN { $can_ipv6 = 1 if (eval { require IO::Socket::INET6; }); print "BEGIN CAN_IPV6 is : $can_ipv6\n"; } my $can_ipv6; BEGIN { if (eval { require IO::Socket::INET6; }) { $can_ipv6 = 1; } else { $can_ipv6 = 1; } print "BEGIN CAN_IPV6 is : $can_ipv6\n"; } print "CAN_IPV6 is : $can_ipv6\n"; zimbra@zqa-395-ipv6:~$ zmldappasswd -b sillypass BEGIN CAN_IPV6 is : 1 CAN_IPV6 is : 1 Updating local config and LDAP
On Thu May 31 15:38:39 2012, MISHIKAL wrote: Show quoted text
> Changing the code block like this fixes the problem:
Whoops, had part of a bad paste in there. This code block works: my $can_ipv6; BEGIN { if (eval { require IO::Socket::INET6; }) { $can_ipv6 = 1; } else { $can_ipv6 = 1; } }
On Thu May 31 15:39:55 2012, MISHIKAL wrote:
Grrr, somehow only the first line gets submitted ... On Thu May 31 15:39:55 2012, MISHIKAL wrote: Show quoted text
> This code block works: > my $can_ipv6; > BEGIN { > if (eval { require IO::Socket::INET6; }) { > $can_ipv6 = 1; > } else { > $can_ipv6 = 1; > } > }
It may, but it dies not fulfil the intention, as it sets the value to 1 in both branches of the if. IMHO the solution similar to IO::Socket::SSL should do: my $can_ipv6; BEGIN { $can_ipv6 = 1 if (eval { require IO::Socket::INET6; }); } It leverages the fact that Perl variables get initialized to undef, and undef is treated as 0 in boolean contects. All if-tests in Net::LDAP.pm use boolean context, hence it should work. Please test again, and use the following line to print the results: print "CAN_IPV6 is : ".($can_ipv6 ? 1 : 0)."\n"; Thanks in advance
Subject: Re: [rt.cpan.org #77458] Make IPv6 usage more sane
Date: Fri, 1 Jun 2012 10:22:51 -0500
To: bug-perl-ldap [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
On Jun 1, 2012, at 08:27 , Peter Marschall via RT wrote: Show quoted text
> Queue: perl-ldap > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=77458 > > > Grrr, somehow only the first line gets submitted ... > On Thu May 31 15:39:55 2012, MISHIKAL wrote:
>> This code block works: >> my $can_ipv6; >> BEGIN { >> if (eval { require IO::Socket::INET6; }) { >> $can_ipv6 = 1; >> } else { >> $can_ipv6 = 1; >> } >> }
> It may, but it dies not fulfil the intention, as it sets the value to 1 in both > branches of the if. > > IMHO the solution similar to IO::Socket::SSL should do: > my $can_ipv6; > BEGIN { > $can_ipv6 = 1 > if (eval { require IO::Socket::INET6; }); > } > > It leverages the fact that Perl variables get initialized to undef, and undef is > treated as 0 in boolean contects.
Right. and the my $can_ipv6 = 0; causes a problem because it is run after after the BEGIN block. It also depends on an undocumented implementation detail of my that it has no runtime effect. Why not just use constant CAN_IPV6 => eval { require IO::Socket::INET6 } ? 1 : 0; and create a compile time constant. Graham.
On Fri Jun 01 09:27:37 2012, marschap wrote: Show quoted text
> It may, but it dies not fulfil the intention, as it sets the value to > 1 in both > branches of the if.
Holy cut and paste errors. :/ It was 1/0 in my code. sigh. ;)
On Fri Jun 01 11:23:09 2012, gbarr@pobox.com wrote: Show quoted text
> use constant CAN_IPV6 => eval { require IO::Socket::INET6 } ? 1 : 0; > > and create a compile time constant.
That sounds reasonable to me.
Fixed in perl-ldap 0.45. (please use perl-ldap 0.46 as 0.45 has a different bug)