Bug#681350: libconvert-asn1-perl: "use strict" breaks smbldap-tools

Salvatore Bonaccorso carnil at debian.org
Fri Jul 13 05:11:55 UTC 2012


Hi Saulo

I'm Cc'in the bugreport on smbldap-tools, but I think these two should
be merged and only assigned to smbldap-tools.

On Thu, Jul 12, 2012 at 09:51:54PM -0300, Saulo Soares de Toledo wrote:
> 2012/7/12 Salvatore Bonaccorso <carnil at debian.org>
> 
> > Could you give more information on which problems you see with
> > smbldap-tools? Should the bugreport reassigned to smbldap-tools?
> >
> 
> I've opened the bug report 680939 <680939 at bugs.debian.org> to smbldap-tools.
> "Smbldap-tools is a set of perl scripts designed to manage user and
> groupaccounts stored in an LDAP directory." (website description)
> 
> Some scripts of the package simple do not works with use sctrict enabled.
> The Debian version is 0.9.7, but 0.9.8 (latest from developers) do not
> works too. The error returned with smbldap-userlist is:
> 
> Can't use string ("['username','uidNumber','uid']") as an ARRAY ref while
> "strict refs" in use at /usr/share/perl5/Convert/ASN1/_encode.pm line 269.
> 
> Smbldap-tools is needed while using Samba + LDAP. I sent an email do
> smbldap-tools developers about the problem and will update here when I get
> some more information about.

I did not yet dig into it in detail, but this seems a a wrong use in
smbldap-userlist.pl. I see there, that first the $attrs is 'assembled'
as a string in "['username','uidNumber','uid'" . "]" (line 198). Then
it passes to a Net::LDAP object:

----cut---------cut---------cut---------cut---------cut---------cut-----
my  $mesg = $ldap_master->search ( base   => $base,
                                   scope => $config{scope},
                                   filter => $filter,
                   attrs => "$attrs"
                   );
----cut---------cut---------cut---------cut---------cut---------cut-----

In documentation of Net::LDAP you find the details to the search
options. In particular you see:

----cut---------cut---------cut---------cut---------cut---------cut-----
=item attrs =E<gt> [ ATTR, ... ]

A list of attributes to be returned for each entry that matches the
search filter.

If not specified, then the server will return the attributes that are
specified as accessible by default given your bind credentials.

Certain additional attributes such as "createTimestamp" and other
operational attributes may also be available for the asking:

  $mesg = $ldap->search( ... ,
                         attrs => ['createTimestamp']
                       );

To retrieve the default attributes and additional ones, use '*'.

  $mesg = $ldap->search( ... ,
                         attrs => ['*', 'createTimestamp']
                       );

To retrieve no attributes (the server only returns the DNs of matching
entries), use '1.1':

  $mesg = $ldap->search( ... ,
                         attrs => ['1.1']
                       );
----cut---------cut---------cut---------cut---------cut---------cut-----


So smbldap-userlist.pl. passes a string, where is should be a list.

Btw, you can reproduce the error message easily by:

----cut---------cut---------cut---------cut---------cut---------cut-----
#!/usr/bin/perl

use strict 'refs';

my $attrs = "[ 'foo', 'bar', ]";

push @{$attrs}, 'foobar';

use Data::Dumper 'Dumper';
warn Dumper [$attrs];
----cut---------cut---------cut---------cut---------cut---------cut-----

You see, here if you remove the "use strict 'refs'" again, it does not
throw out the "Can't use string ("[ 'foo', 'bar', ]") as an ARRAY ref
while "strict refs" in use at testcase_broken.pl line 7.".

Correctly it would be:

----cut---------cut---------cut---------cut---------cut---------cut-----
#!/usr/bin/perl

use strict 'refs';

my $attrs = [ 'foo', 'bar', ];

push @{$attrs}, 'foobar';

use Data::Dumper 'Dumper';
warn Dumper [$attrs];
----cut---------cut---------cut---------cut---------cut---------cut-----

Conclusion: I'm more convinced that is a real bug in smbldap-tools and
we surely should not remove the "use strict;" from
libconvert-asn1-perl.

Regards,
Salvatore
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-perl-maintainers/attachments/20120713/f2917d6e/attachment-0001.pgp>


More information about the pkg-perl-maintainers mailing list